Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

Commit

Permalink
Add a minor optimization, don't bother bootstrapping Puppet if it's a…
Browse files Browse the repository at this point in the history
…lready in our PATH
  • Loading branch information
R. Tyler Croy committed Aug 25, 2012
1 parent edcc292 commit 2edecb4
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lib/blimpy/livery/puppet.rb
Expand Up @@ -11,24 +11,35 @@ def initialize(*args)
@module_path = './modules'
@manifest_path = 'manifests/site.pp'
@options = '--verbose'
@puppet_exists = false
end

def script
'puppet.sh'
end

def preflight(box)
# If we find Puppet in our default path, we don't really need to send
# the bootstrap script again
@puppet_exists = box.ssh_into('which puppet > /dev/null')
unless @puppet_exists
super(box)
end
end

def flight(box)
# This should get our puppet.sh bootstrap script run
super(box)
unless @puppet_exists
# This should get our puppet.sh bootstrap script run
super(box)
end

# At this point we should be safe to actually invoke Puppet
command = "puppet apply --modulepath=#{module_path} #{options} #{manifest_path}"

if use_sudo?(box)
box.ssh_into("sudo #{command}")
else
box.ssh_into(command)
end
run_sudo = ''
run_sudo = 'sudo' if use_sudo?(box)

box.ssh_into("cd #{dir_name} && #{run_sudo} #{command}")
end

def postflight(box)
Expand Down

0 comments on commit 2edecb4

Please sign in to comment.