This repository has been archived by the owner on Mar 8, 2018. It is now read-only.
/
puppet.rb
64 lines (51 loc) · 1.54 KB
/
puppet.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require 'blimpy/livery/base'
require 'blimpy/livery/cwd'
module Blimpy
module Livery
class Puppet < CWD
attr_accessor :module_path, :manifest_path, :options
def initialize(*args)
super
@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)
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}"
run_sudo = ''
run_sudo = 'sudo' if use_sudo?(box)
box.ssh_into("cd #{dir_name} && #{run_sudo} #{command}")
end
def postflight(box)
end
def bootstrap_script
File.expand_path(File.dirname(__FILE__) + "/../../../scripts/#{script}")
end
def self.configure(&block)
if block.nil?
raise Blimpy::InvalidLiveryException, "Puppet livery must be given a block in order to configure itself"
end
instance = self.new
yield instance
instance
end
end
end
end