Class: Skewer::Puppet
- Inherits:
-
Object
- Object
- Skewer::Puppet
- Defined in:
- lib/puppet.rb
Overview
responsible for executing puppet
Class Method Summary collapse
Instance Method Summary collapse
- #arguments ⇒ Object
- #bundle ⇒ Object
- #command_string(username, options) ⇒ Object
- #run(node, options) ⇒ Object
Class Method Details
.run(node, options) ⇒ Object
48 49 50 51 |
# File 'lib/puppet.rb', line 48 def self.run(node, ) this = self.new this.run(node, ) end |
Instance Method Details
#arguments ⇒ Object
7 8 9 10 11 12 |
# File 'lib/puppet.rb', line 7 def arguments [ "--modulepath modules", "--vardir /var/lib/puppet" ].join(' ') end |
#bundle ⇒ Object
14 15 16 |
# File 'lib/puppet.rb', line 14 def bundle "/var/lib/gems/1.8/bin/bundle" end |
#command_string(username, options) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/puppet.rb', line 18 def command_string(username, ) @command_line = "cd infrastructure" if username == 'root' @command_line << " &&" else @command_line << " && sudo" end @command_line << " #{self.bundle} exec" @command_line << " puppet apply" @command_line << " manifests/site.pp" @command_line << " --color false" @command_line << " #{arguments}" if [:noop] @command_line << " --noop" end @command_line end |
#run(node, options) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/puppet.rb', line 36 def run(node, ) command = command_string(node.username, ) result = node.ssh(command)[0] if result.status != 0 Skewer.logger.debug result.stdout raise PuppetRuntimeError, "Puppet failed" else Skewer.logger.debug "Puppet run succeeded" end result end |