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
@@ -0,0 +1,38 @@
1
+ require 'archive/tar/minitar'
2
+ require 'zlib'
3
+
4
+ module PEBuild
5
+ module Unpack
6
+ class Tar
7
+
8
+ # @param src [String]
9
+ # @param dst [String]
10
+ def initialize(src, dst)
11
+ @src, @dst = src, dst
12
+ end
13
+
14
+ def unpack
15
+ ::Archive::Tar::Minitar.unpack(zip, @dst)
16
+ end
17
+
18
+ # @return [String] The base directory contained in the tar archive
19
+ def dirname
20
+ input = ::Archive::Tar::Minitar::Input.new(zip)
21
+
22
+ base = nil
23
+ input.each do |entry|
24
+ path = entry.name
25
+ base = path.split(File::SEPARATOR).first
26
+ end
27
+
28
+ base
29
+ end
30
+
31
+ private
32
+
33
+ def zip
34
+ Zlib::GzipReader.new(File.open(@src, 'rb'))
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,29 @@
1
+ module PEBuild
2
+ module Util
3
+ module Config
4
+
5
+ # Merge configuration classes together with the "local" object overwriting any
6
+ # values set in the "other" object. This uses the default merging in the Vagrant
7
+ # plugin config class. The builtin merge function is not straight forward however.
8
+ # It needs to be called on the object being overwritten. When using a subclass of
9
+ # a global config for a provisioner config, the builtin merge method cannot actually
10
+ # merge them in the direction that would be needed.
11
+ #
12
+ # This function assumes that the "local" object is of the same class or at the very
13
+ # least a subclass of "other".
14
+ #
15
+ # @param local [Vagrant::Plugin::V2::Config] Local configuration class to merge
16
+ # @param other [Vagrant::Plugin::V2::Config] Other configuration class to merge
17
+ # @return [Vagrant::Plugin::V2::Config] New object of the same class as Local that represents the merged result
18
+ #
19
+ def self.local_merge(local, other)
20
+ if other.class >= local.class
21
+ result = local.class.new
22
+
23
+ result = result.merge(other)
24
+ result = result.merge(local)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module PEBuild
2
- VERSION = '0.0.3'
2
+ VERSION = '0.1.0'
3
3
  end
File without changes
@@ -2,7 +2,7 @@ q_install=y
2
2
  q_puppet_cloud_install=n
3
3
  q_puppet_enterpriseconsole_install=n
4
4
  q_puppet_symlinks_install=y
5
- q_puppetagent_certname=<%= @env[:vm].name %>
5
+ q_puppetagent_certname=<%= @machine.name %>
6
6
  q_puppetagent_install=y
7
7
  q_puppetagent_server=<%= config.master %>
8
8
  q_puppetmaster_install=n
@@ -33,9 +33,9 @@ q_puppet_enterpriseconsole_smtp_user_auth=n
33
33
  q_puppet_enterpriseconsole_smtp_username=
34
34
 
35
35
  q_puppet_symlinks_install=y
36
- q_puppetagent_certname=<%= @env[:vm].name %>
36
+ q_puppetagent_certname=<%= @machine.name %>
37
37
  q_puppetagent_install=y
38
- q_puppetagent_server=<%= @env[:vm].name %>
38
+ q_puppetagent_server=<%= @machine.name %>
39
39
  q_puppetca_install=y
40
40
  q_puppetmaster_certname=master
41
41
  q_puppetmaster_dnsaltnames=master,puppet
@@ -27,9 +27,9 @@ q_puppet_enterpriseconsole_smtp_use_tls=n
27
27
  q_puppet_enterpriseconsole_smtp_user_auth=n
28
28
  q_puppet_enterpriseconsole_smtp_username=
29
29
 
30
- q_puppetagent_certname=<%= @env[:vm].name %>
30
+ q_puppetagent_certname=<%= @machine.name %>
31
31
  q_puppetagent_install=y
32
- q_puppetagent_server=<%= @env[:vm].name %>
32
+ q_puppetagent_server=<%= @machine.name %>
33
33
  q_puppetca_install=y
34
34
  q_puppetmaster_certname=master
35
35
  q_puppetmaster_dnsaltnames=master,puppet
@@ -0,0 +1,7 @@
1
+ en:
2
+ pebuild:
3
+ archive:
4
+ no_installer_source: |-
5
+ No installer source is available. Please provide a download_root
6
+ to retrieve the installer from or use 'vagrant pe-build' to provide
7
+ the installer...
@@ -13,7 +13,8 @@ Gem::Specification.new do |gem|
13
13
 
14
14
  gem.summary = "Vagrant provisioner for installing Puppet Enterprise"
15
15
 
16
- gem.add_dependency 'vagrant', '~> 1.0.0'
16
+ gem.add_dependency 'progressbar'
17
+ gem.add_dependency 'minitar'
17
18
 
18
19
  gem.files = %x{git ls-files -z}.split("\0")
19
20
  gem.require_path = 'lib'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-pe_build
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-20 00:00:00.000000000 Z
12
+ date: 2013-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: vagrant
15
+ name: progressbar
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.0
21
+ version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 1.0.0
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: minitar
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  description:
31
47
  email: adrien@somethingsinistral.net
32
48
  executables: []
@@ -36,8 +52,6 @@ files:
36
52
  - Gemfile
37
53
  - LICENSE
38
54
  - README.markdown
39
- - bootstrap/base/provision/install_puppet_enterprise.sh
40
- - bootstrap/master/post/relocate_puppet.sh
41
55
  - doc/answers/README.markdown
42
56
  - doc/answers/agent.txt
43
57
  - doc/answers/master-1.1.txt
@@ -45,21 +59,29 @@ files:
45
59
  - doc/answers/master-2.5.0.txt
46
60
  - doc/answers/master-db.txt
47
61
  - lib/pe_build.rb
48
- - lib/pe_build/action.rb
49
- - lib/pe_build/action/download.rb
50
- - lib/pe_build/action/unpackage.rb
62
+ - lib/pe_build/archive.rb
63
+ - lib/pe_build/archive_collection.rb
51
64
  - lib/pe_build/command.rb
65
+ - lib/pe_build/command/copy.rb
52
66
  - lib/pe_build/command/download.rb
53
67
  - lib/pe_build/command/list.rb
54
- - lib/pe_build/config.rb
55
- - lib/pe_build/provisioners.rb
56
- - lib/pe_build/provisioners/puppet_enterprise.rb
57
- - lib/pe_build/provisioners/puppet_enterprise_bootstrap.rb
68
+ - lib/pe_build/config/global.rb
69
+ - lib/pe_build/config/pe_bootstrap.rb
70
+ - lib/pe_build/config_default.rb
71
+ - lib/pe_build/idempotent.rb
72
+ - lib/pe_build/plugin.rb
73
+ - lib/pe_build/provisioner/pe_bootstrap.rb
74
+ - lib/pe_build/transfer/file.rb
75
+ - lib/pe_build/transfer/uri.rb
76
+ - lib/pe_build/unpack/tar.rb
77
+ - lib/pe_build/util/config.rb
58
78
  - lib/pe_build/version.rb
59
- - lib/vagrant_init.rb
79
+ - lib/vagrant-pe_build.rb
60
80
  - templates/answers/agent.txt.erb
61
81
  - templates/answers/master-existing-db.txt.erb
62
82
  - templates/answers/master.txt.erb
83
+ - templates/locales/en.yml
84
+ - templates/scripts/relocate_installation.sh
63
85
  - vagrant-pe_build.gemspec
64
86
  homepage: https://github.com/adrienthebo/vagrant-pe_build
65
87
  licenses: []
@@ -86,3 +108,4 @@ signing_key:
86
108
  specification_version: 3
87
109
  summary: Vagrant provisioner for installing Puppet Enterprise
88
110
  test_files: []
111
+ has_rdoc:
@@ -1,10 +0,0 @@
1
- if [ -f /opt/puppet/bin/puppet ]; then
2
- echo "Puppet Enterprise already present, version $(/opt/puppet/bin/puppet --version)"
3
- echo "Skipping installation."
4
- else
5
- <%= @installer_cmd %>
6
- echo
7
- echo
8
- echo " -- Notice: scheduling Puppet run in one minute to install mcollective"
9
- echo "/opt/puppet/bin/puppet agent --onetime --noop" | at next minute
10
- fi
@@ -1,20 +0,0 @@
1
- require 'vagrant'
2
- require 'vagrant/action/builder'
3
- require 'pe_build'
4
-
5
- module PEBuild::Action
6
- end
7
-
8
- require 'pe_build/action/download'
9
- require 'pe_build/action/unpackage'
10
-
11
- builder = Vagrant::Action::Builder.new do
12
- use PEBuild::Action::Download
13
- end
14
-
15
- Vagrant.actions.register :download_pe_build, builder
16
-
17
- Vagrant.actions.register(:prep_build, Vagrant::Action::Builder.new do
18
- use PEBuild::Action::Download
19
- use PEBuild::Action::Unpackage
20
- end)
@@ -1,56 +0,0 @@
1
- require 'pe_build'
2
- require 'pe_build/action'
3
- require 'vagrant'
4
- require 'fileutils'
5
-
6
- class PEBuild::Action::Download
7
- # Downloads a PE build to a temp directory
8
-
9
- def initialize(app, env)
10
- @app, @env = app, env
11
- load_variables
12
- end
13
-
14
- def call(env)
15
- @env = env
16
- perform_download
17
- @app.call(@env)
18
- end
19
-
20
- private
21
-
22
- # Determine system state and download a PE build accordingly.
23
- #
24
- # If we are applying actions within the context of a single box, then we
25
- # should try to prefer and box level configuration options first. If
26
- # anything is unset then we should fall back to the global settings.
27
- def load_variables
28
- if @env[:box_name]
29
- @root = @env[:vm].pe_build.download_root
30
- @version = @env[:vm].pe_build.version
31
- @filename = @env[:vm].pe_build.filename
32
- end
33
-
34
- @root ||= @env[:global_config].pe_build.download_root
35
- @version ||= @env[:global_config].pe_build.version
36
- @filename ||= @env[:global_config].pe_build.filename
37
-
38
- @archive_path = File.join(PEBuild.archive_directory, @filename)
39
- end
40
-
41
- # @return [String] The full URL to download, based on the config
42
- def url
43
- [@root, @version, @filename].join('/')
44
- end
45
-
46
- def perform_download
47
- if File.exist? @archive_path
48
- @env[:ui].info "#{@filename} cached, skipping download."
49
- else
50
- FileUtils.mkdir_p PEBuild.archive_directory unless File.directory? PEBuild.archive_directory
51
- cmd = %{curl -L -A "Vagrant/PEBuild (v#{PEBuild::VERSION})" -O #{url}}
52
- @env[:ui].info "Executing '#{cmd}'"
53
- Dir.chdir(PEBuild.archive_directory) { %x{#{cmd}} }
54
- end
55
- end
56
- end
@@ -1,70 +0,0 @@
1
- require 'vagrant'
2
- require 'pe_build/action'
3
- require 'fileutils'
4
-
5
- class PEBuild::Action::Unpackage
6
- def initialize(app, env)
7
- @app, @env = app, env
8
- load_variables
9
- end
10
-
11
- def call(env)
12
- @env = env
13
- @extracted_dir = File.join(@env[:unpack_directory], destination_directory)
14
- extract_build
15
- @app.call(@env)
16
- end
17
-
18
- private
19
-
20
- def load_variables
21
- if @env[:box_name]
22
- @root = @env[:vm].pe_build.download_root
23
- @version = @env[:vm].pe_build.version
24
- @filename = @env[:vm].pe_build.version
25
- end
26
-
27
- @root ||= @env[:global_config].pe_build.download_root
28
- @version ||= @env[:global_config].pe_build.version
29
- @filename ||= @env[:global_config].pe_build.filename
30
-
31
- @archive_path = File.join(PEBuild.archive_directory, @filename)
32
- end
33
-
34
- # Sadly, shelling out is more sane than trying to use the facilities
35
- # provided.
36
- def extract_build
37
- if File.directory? @extracted_dir
38
- @env[:ui].info "#{destination_directory} already present, skipping extraction."
39
- else
40
- cmd = %{tar xf #{@archive_path} -C #{@env[:unpack_directory]}}
41
- @env[:ui].info "Extracting #{@archive_path} to #{@env[:unpack_directory]}"
42
- %x{#{cmd}}
43
- end
44
- rescue => e
45
- # If anything goes wrong while extracting, nuke the extracted directory
46
- # as it could be incomplete. If we do this, then we can ensure that if
47
- # the extracted directory already exists then it will be in a good state.
48
- @env[:ui].info "Removing possibly damaged installer directory '#{@extracted_dir}'"
49
- FileUtils.rm_r @extracted_dir
50
- end
51
-
52
- # Determine the name of the top level directory by peeking into the tarball
53
- def destination_directory
54
- raise Errno::ENOENT, "No such file \"#{@archive_path}\"" unless File.file? @archive_path
55
-
56
- firstline = nil
57
- dir = nil
58
- dir_regex = %r[^(.*?)/]
59
- IO.popen(%{tar -tf #{@archive_path}}) { |out| firstline = out.gets }
60
-
61
- if firstline.nil? or firstline.empty?
62
- raise "Could not get a directory listing from the installer tarfile #{File.basename @archive_path}"
63
- elsif (match = firstline.match dir_regex)
64
- dir = match[1]
65
- else
66
- raise "Could not determine the base directory name from #{firstline} - doesn't match #{dir_regex.to_s}"
67
- end
68
- dir
69
- end
70
- end
@@ -1,35 +0,0 @@
1
- require 'vagrant'
2
- require 'uri'
3
- require 'pe_build'
4
-
5
- class PEBuild::Config < Vagrant::Config::Base
6
- attr_writer :download_root
7
- attr_writer :version
8
- attr_writer :filename
9
- attr_writer :suffix
10
-
11
- def download_root
12
- @download_root
13
- end
14
-
15
- def version
16
- @version
17
- end
18
-
19
- def filename
20
- @filename
21
- end
22
-
23
- def suffix
24
- @suffix || :all
25
- end
26
-
27
- def validate(env, errors)
28
- URI.parse(download_root)
29
- rescue
30
- # TODO I18n
31
- errors.add("Invalid download root '#{download_root.inspect}'")
32
- end
33
- end
34
-
35
- Vagrant.config_keys.register(:pe_build) { PEBuild::Config }
@@ -1,9 +0,0 @@
1
- require 'pe_build'
2
- require 'vagrant'
3
-
4
- module PEBuild::Provisioners; end
5
-
6
- require 'pe_build/provisioners/puppet_enterprise_bootstrap'
7
- #require 'pe_build/provisioners/puppet_enterprise'
8
-
9
- Vagrant.provisioners.register(:puppet_enterprise_bootstrap) { PEBuild::Provisioners::PuppetEnterpriseBootstrap}