vagrant-pe_build 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/Gemfile +2 -0
  2. data/README.markdown +10 -10
  3. data/lib/pe_build.rb +15 -7
  4. data/lib/pe_build/archive.rb +112 -0
  5. data/lib/pe_build/archive_collection.rb +43 -0
  6. data/lib/pe_build/command.rb +48 -11
  7. data/lib/pe_build/command/copy.rb +38 -0
  8. data/lib/pe_build/command/download.rb +34 -3
  9. data/lib/pe_build/command/list.rb +16 -4
  10. data/lib/pe_build/config/global.rb +69 -0
  11. data/lib/pe_build/config/pe_bootstrap.rb +110 -0
  12. data/lib/pe_build/config_default.rb +16 -0
  13. data/lib/pe_build/idempotent.rb +16 -0
  14. data/lib/pe_build/plugin.rb +38 -0
  15. data/lib/pe_build/provisioner/pe_bootstrap.rb +202 -0
  16. data/lib/pe_build/transfer/file.rb +18 -0
  17. data/lib/pe_build/transfer/uri.rb +53 -0
  18. data/lib/pe_build/unpack/tar.rb +38 -0
  19. data/lib/pe_build/util/config.rb +29 -0
  20. data/lib/pe_build/version.rb +1 -1
  21. data/lib/{vagrant_init.rb → vagrant-pe_build.rb} +0 -0
  22. data/templates/answers/agent.txt.erb +1 -1
  23. data/templates/answers/master-existing-db.txt.erb +2 -2
  24. data/templates/answers/master.txt.erb +2 -2
  25. data/templates/locales/en.yml +7 -0
  26. data/{bootstrap/master/post/relocate_puppet.sh → templates/scripts/relocate_installation.sh} +0 -0
  27. data/vagrant-pe_build.gemspec +2 -1
  28. metadata +40 -17
  29. data/bootstrap/base/provision/install_puppet_enterprise.sh +0 -10
  30. data/lib/pe_build/action.rb +0 -20
  31. data/lib/pe_build/action/download.rb +0 -56
  32. data/lib/pe_build/action/unpackage.rb +0 -70
  33. data/lib/pe_build/config.rb +0 -35
  34. data/lib/pe_build/provisioners.rb +0 -9
  35. data/lib/pe_build/provisioners/puppet_enterprise.rb +0 -1
  36. data/lib/pe_build/provisioners/puppet_enterprise_bootstrap.rb +0 -171
@@ -1 +0,0 @@
1
- require 'pe_build/provisioners'
@@ -1,171 +0,0 @@
1
- require 'pe_build'
2
- require 'pe_build/provisioners'
3
- require 'vagrant'
4
- require 'fileutils'
5
- require 'erb'
6
-
7
- class PEBuild::Provisioners::PuppetEnterpriseBootstrap < Vagrant::Provisioners::Base
8
-
9
- class Config < Vagrant::Config::Base
10
- attr_writer :verbose, :master, :answers
11
-
12
- def role=(rolename)
13
- @role = (rolename.is_a?(Symbol)) ? rolename : rolename.intern
14
- end
15
-
16
- def role
17
- @role || :agent
18
- end
19
-
20
- def verbose
21
- @verbose || true
22
- end
23
-
24
- def master
25
- @master || 'master'
26
- end
27
-
28
- def answers
29
- # Either the path the user provided to the answers file under
30
- # the project answers dir, or see if one exists based on the role.
31
- @answers || "#{role}.txt"
32
- end
33
-
34
- def step
35
- @step || @step = {}
36
- end
37
-
38
- def add_step(name, script_path)
39
- name = (name.is_a?(Symbol)) ? name : name.intern
40
- step[name] = script_path
41
- end
42
-
43
- def validate(env, errors)
44
- errors.add("role must be one of [:master, :agent]") unless [:master, :agent].include? role
45
-
46
- step.keys.each do |key|
47
- errors.add("step name :#{key.to_s} is invalid, must be one of [:pre, :provision, :post]") unless [:pre, :provision, :post].include? key
48
- end
49
- end
50
- end
51
-
52
- def self.config_class
53
- Config
54
- end
55
-
56
- def initialize(*args)
57
- super
58
-
59
- load_variables
60
-
61
- @cache_path = File.join(@env[:root_path], '.pe_build')
62
- @answers_dir = File.join(@cache_path, 'answers')
63
- end
64
-
65
- def validate(app, env)
66
-
67
- end
68
-
69
- def prepare
70
- FileUtils.mkdir @cache_path unless File.directory? @cache_path
71
- @env[:action_runner].run(:prep_build, :unpack_directory => @cache_path)
72
- end
73
-
74
- def provision!
75
- # determine if bootstrapping is necessary
76
-
77
- prepare_answers_file
78
- configure_installer
79
-
80
- [:pre, :provision, :post].each do |stepname|
81
- [:base, config.role].each do |rolename|
82
- process_step rolename, stepname
83
- end
84
- end
85
- end
86
-
87
- private
88
-
89
- # I HATE THIS.
90
- def load_variables
91
- if @env[:box_name]
92
- @root = @env[:vm].pe_build.download_root
93
- @version = @env[:vm].pe_build.version
94
- @filename = @env[:vm].pe_build.version
95
- @suffix = @env[:vm].pe_build.suffix
96
- end
97
-
98
- @root ||= @env[:global_config].pe_build.download_root
99
- @version ||= @env[:global_config].pe_build.version
100
- @filename ||= @env[:global_config].pe_build.filename
101
- @suffix ||= @env[:global_config].pe_build.suffix
102
- end
103
-
104
- def prepare_answers_file
105
- @env[:ui].info "Creating answers file, node:#{@env[:vm].name}, role: #{config.role}"
106
- FileUtils.mkdir_p @answers_dir unless File.directory? @answers_dir
107
- dest = "#{@answers_dir}/#{@env[:vm].name}.txt"
108
-
109
- # answers dir is enforced
110
- user_answers = File.join(@env[:root_path],"answers/#{config.answers}")
111
- if File.exists?(user_answers)
112
- template = File.read(user_answers)
113
- else
114
- @env[:ui].info "Using default answers, no answers file available at #{user_answers}"
115
- template = File.read("#{PEBuild.source_root}/templates/answers/#{config.role}.txt.erb")
116
- end
117
-
118
- contents = ERB.new(template).result(binding)
119
-
120
- @env[:ui].info "Writing answers file to #{dest}"
121
- File.open(dest, "w") do |file|
122
- file.write contents
123
- end
124
- end
125
-
126
- def process_step(role, stepname)
127
-
128
- if role != :base && config.step[stepname]
129
- if File.file? config.step[stepname]
130
- script_list = [*config.step[stepname]]
131
- else
132
- script_list = []
133
- @env[:ui].warn "Cannot find defined step for #{role}/#{stepname.to_s} at \'#{config.step[stepname]}\'"
134
- end
135
- else
136
- # We do not have a user defined step for this role or we're processing the :base step
137
- script_dir = File.join(PEBuild.source_root, 'bootstrap', role.to_s, stepname.to_s)
138
- script_list = Dir.glob("#{script_dir}/*")
139
- end
140
-
141
- if script_list.empty?
142
- @env[:ui].info "No steps for #{role}/#{stepname}", :color => :cyan
143
- end
144
-
145
- script_list.each do |template_path|
146
- # A message to show which step's action is running
147
- @env[:ui].info "Running action for #{role}/#{stepname}"
148
- template = File.read(template_path)
149
- contents = ERB.new(template).result(binding)
150
-
151
- on_remote contents
152
- end
153
- end
154
-
155
- # Determine the proper invocation of the PE installer
156
- def configure_installer
157
- vm_base_dir = "/vagrant/.pe_build"
158
- installer = "#{vm_base_dir}/puppet-enterprise-#{@version}-#{@suffix}/puppet-enterprise-installer"
159
- answers = "#{vm_base_dir}/answers/#{@env[:vm].name}.txt"
160
- log_file = "/root/puppet-enterprise-installer-#{Time.now.strftime('%s')}.log"
161
-
162
- @installer_cmd = "#{installer} -a #{answers} -l #{log_file}"
163
- end
164
-
165
- def on_remote(cmd)
166
- env[:vm].channel.sudo(cmd) do |type, data|
167
- color = (type == :stdout) ? :green : :red
168
- @env[:ui].info(data.chomp, :color => color, :prefix => false)
169
- end
170
- end
171
- end