Class: Runpuppet::Config
- Inherits:
-
Object
- Object
- Runpuppet::Config
- Defined in:
- lib/runpuppet.rb
Class Method Summary collapse
- .command ⇒ Object
- .config ⇒ Object
- .default_branch ⇒ Object
- .extract_auth_from_url!(url) ⇒ Object
- .is_ec2? ⇒ Boolean
- .local_ip ⇒ Object
- .lock_file ⇒ Object
- .puppet_controller_auth ⇒ Object
- .puppet_controller_url ⇒ Object
Class Method Details
.command ⇒ Object
116 117 118 |
# File 'lib/runpuppet.rb', line 116 def self.command config['command'] || "cd /etc/puppet/repo && git fetch && git checkout -f origin/@@branch@@ && puppet -v --debug --logdest console --modulepath /etc/puppet/repo/modules /etc/puppet/repo/manifests/site.pp" end |
.config ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/runpuppet.rb', line 90 def self.config home = File.('~') ["#{home}/.runpuppet.yml", '/etc/runpuppet.yml'].each do |file| return YAML.load(File.read(file)) if File.exist?(file) end raise "No runpuppet.yml found in /etc or #{home}" end |
.default_branch ⇒ Object
120 121 122 |
# File 'lib/runpuppet.rb', line 120 def self.default_branch config['defaulf_branch'] || 'master' end |
.extract_auth_from_url!(url) ⇒ Object
106 107 108 109 110 |
# File 'lib/runpuppet.rb', line 106 def self.extract_auth_from_url!(url) url.sub!(%r{//(.*?):(.*?)@}, '//') auth = [$1, $2].compact auth.empty? ? nil : auth end |
.is_ec2? ⇒ Boolean
134 135 136 |
# File 'lib/runpuppet.rb', line 134 def self.is_ec2? %x(arp -n -i eth0) =~ /fe:ff:ff:ff:ff/ end |
.local_ip ⇒ Object
124 125 126 127 128 129 130 131 132 |
# File 'lib/runpuppet.rb', line 124 def self.local_ip if is_ec2? require 'facter' require 'facter/ec2' ip = Facter.value("ec2_public_ipv4") else %x(ifconfig)[/192.168.\d+.\d+/] || config['local_ip'] end end |
.lock_file ⇒ Object
112 113 114 |
# File 'lib/runpuppet.rb', line 112 def self.lock_file config['lock_file'] || '/tmp/runpuppet.lock' end |
.puppet_controller_auth ⇒ Object
102 103 104 |
# File 'lib/runpuppet.rb', line 102 def self.puppet_controller_auth extract_auth_from_url!(config['puppet_controller_url']) end |
.puppet_controller_url ⇒ Object
98 99 100 |
# File 'lib/runpuppet.rb', line 98 def self.puppet_controller_url config['puppet_controller_url'].sub(%r{/$},'') end |