Class: Runpuppet::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/runpuppet.rb

Class Method Summary collapse

Class Method Details

.commandObject



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

.configObject



90
91
92
93
94
95
96
# File 'lib/runpuppet.rb', line 90

def self.config
  home = File.expand_path('~')
  ["#{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_branchObject



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

Returns:

  • (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_ipObject



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_fileObject



112
113
114
# File 'lib/runpuppet.rb', line 112

def self.lock_file
  config['lock_file'] || '/tmp/runpuppet.lock'
end

.puppet_controller_authObject



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_urlObject



98
99
100
# File 'lib/runpuppet.rb', line 98

def self.puppet_controller_url
  config['puppet_controller_url'].sub(%r{/$},'')
end