vagrant-pe_build 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,6 +1,25 @@
1
1
  vagrant-pe_build
2
2
  ================
3
3
 
4
+ 0.7.0
5
+
6
+ 2013-10-14
7
+
8
+ This is a backwards incompatible bugfix and feature release.
9
+
10
+ ### User notes:
11
+
12
+ * At long last, The pe_bootstrap `steps` option has been entirely removed.
13
+ * The pe_bootstrap role value is now normalized; users can specify a string
14
+ or symbol and the right thing will happen.
15
+
16
+ ### Developer notes:
17
+
18
+ * Error handling and messages around missing and unreadable archives have
19
+ been improved.
20
+
21
+ Thanks to Charlie Sharpsteen for his contributions to this release.
22
+
4
23
  0.6.0
5
24
  -----
6
25
 
@@ -6,97 +6,108 @@ require 'pe_build/transfer'
6
6
  require 'pe_build/unpack'
7
7
 
8
8
  module PEBuild
9
+ class ArchiveNoInstallerSource < Vagrant::Errors::VagrantError
10
+ error_key(:no_installer_source, "pebuild.archive")
11
+ end
9
12
 
10
- class ArchiveNoInstallerSource < Vagrant::Errors::VagrantError
11
- error_key(:no_installer_source, "pebuild.archive")
12
- end
13
+ class ArchiveMissing < Vagrant::Errors::VagrantError
14
+ error_key(:missing, "pebuild.archive")
15
+ end
13
16
 
14
- class Archive
15
- # Represents a packed Puppet Enterprise archive
17
+ class ArchiveUnreadable < Vagrant::Errors::VagrantError
18
+ error_key(:unreadable, "pebuild.archive")
19
+ end
16
20
 
17
- include PEBuild::Idempotent
21
+ # Represents a packed Puppet Enterprise archive
22
+ class Archive
18
23
 
19
- # @!attribute [rw] version
20
- # @return [String] The version of Puppet Enterprise
21
- attr_accessor :version
24
+ include PEBuild::Idempotent
22
25
 
23
- # @!attribute [rw] filename
24
- # @return [String] The filename. Thing
25
- attr_accessor :filename
26
+ # @!attribute [rw] version
27
+ # @return [String] The version of Puppet Enterprise
28
+ attr_accessor :version
26
29
 
27
- attr_accessor :env
30
+ # @!attribute [rw] filename
31
+ # @return [String] The filename. Thing
32
+ attr_accessor :filename
28
33
 
29
- # @param filename [String] The uninterpolated filename
30
- # @param env [Hash]
31
- def initialize(filename, env)
32
- @filename = filename
33
- @env = env
34
+ attr_accessor :env
34
35
 
35
- @archive_dir = PEBuild.archive_directory(@env)
36
+ # @param filename [String] The uninterpolated filename
37
+ # @param env [Hash]
38
+ def initialize(filename, env)
39
+ @filename = filename
40
+ @env = env
36
41
 
37
- @logger = Log4r::Logger.new('vagrant::pe_build::archive')
38
- end
42
+ @archive_dir = PEBuild.archive_directory(@env)
39
43
 
40
- # @param base_uri [String] A string representation of the download source URI
41
- def fetch(str)
42
- return if self.exist?
44
+ @logger = Log4r::Logger.new('vagrant::pe_build::archive')
45
+ end
43
46
 
44
- if str.nil?
45
- @env.ui.error "Cannot fetch installer #{versioned_path @filename}; no download source available."
46
- @env.ui.error ""
47
- @env.ui.error "Installers available for use:"
47
+ # @param base_uri [String] A string representation of the download source URI
48
+ def fetch(str)
49
+ return if self.exist?
48
50
 
49
- collection = PEBuild::ArchiveCollection.new(@archive_dir, @env)
50
- collection.display
51
+ if str.nil?
52
+ @env.ui.error "Cannot fetch installer #{versioned_path @filename}; no download source available."
53
+ @env.ui.error ""
54
+ @env.ui.error "Installers available for use:"
51
55
 
52
- raise PEBuild::ArchiveNoInstallerSource, :filename => versioned_path(@filename)
53
- end
56
+ collection = PEBuild::ArchiveCollection.new(@archive_dir, @env)
57
+ collection.display
54
58
 
55
- uri = URI.parse(versioned_path(str + '/' + @filename))
56
- dst = File.join(@archive_dir, versioned_path(@filename))
59
+ raise PEBuild::ArchiveNoInstallerSource, :filename => versioned_path(@filename)
60
+ end
57
61
 
58
- transfer = PEBuild::Transfer.generate(uri, dst)
59
- transfer.copy
60
- end
62
+ uri = URI.parse(versioned_path(str + '/' + @filename))
63
+ dst = File.join(@archive_dir, versioned_path(@filename))
61
64
 
62
- # @param fs_dir [String] The base directory to extract the installer to
63
- def unpack_to(fs_dir)
64
- unless exist?
65
- raise "Tried to unpack #{@filename} but it was not downloaded!"
65
+ transfer = PEBuild::Transfer.generate(uri, dst)
66
+ transfer.copy
66
67
  end
67
68
 
68
- archive = PEBuild::Unpack.generate(archive_path, fs_dir)
69
- idempotent(archive.creates, "Unpacked archive #{versioned_path filename}") do
70
- archive.unpack
69
+ # @param fs_dir [String] The base directory to extract the installer to
70
+ def unpack_to(fs_dir)
71
+ unless exist?
72
+ raise PEBuild::ArchiveMissing, :filename => @filename
73
+ end
74
+
75
+ archive = PEBuild::Unpack.generate(archive_path, fs_dir)
76
+ begin
77
+ idempotent(archive.creates, "Unpacked archive #{versioned_path filename}") do
78
+ archive.unpack
79
+ end
80
+ rescue Zlib::GzipFile::Error => e
81
+ raise PEBuild::ArchiveUnreadable, :filename => @filename, :message => e.message
82
+ end
71
83
  end
72
- end
73
84
 
74
- def exist?
75
- File.exist? archive_path
76
- end
85
+ def exist?
86
+ File.exist? archive_path
87
+ end
77
88
 
78
- def to_s
79
- versioned_path(@filename)
80
- end
89
+ def to_s
90
+ versioned_path(@filename)
91
+ end
81
92
 
82
- def installer_dir
83
- versioned_path(@filename).gsub(/.tar(?:\.gz)?/, '')
84
- end
93
+ def installer_dir
94
+ versioned_path(@filename).gsub(/.tar(?:\.gz)?/, '')
95
+ end
85
96
 
86
- private
97
+ private
87
98
 
88
- # @return [String] The interpolated archive path
89
- def archive_path
90
- path = File.join(@archive_dir, @filename)
91
- versioned_path(path)
92
- end
99
+ # @return [String] The interpolated archive path
100
+ def archive_path
101
+ path = File.join(@archive_dir, @filename)
102
+ versioned_path(path)
103
+ end
93
104
 
94
- def versioned_path(path)
95
- if @version
96
- path.gsub(/:version/, @version)
97
- else
98
- path
105
+ def versioned_path(path)
106
+ if @version
107
+ path.gsub(/:version/, @version)
108
+ else
109
+ path
110
+ end
99
111
  end
100
112
  end
101
113
  end
102
- end
@@ -1,43 +1,42 @@
1
1
  require 'pe_build/archive'
2
2
 
3
3
  module PEBuild
4
+ class ArchiveCollection
4
5
 
5
- class ArchiveCollection
6
+ #ARCHIVE_REGEX = %r[puppet-enterprise-([\d.])-(.*?)\.(?:tar\.gz|msi)]
6
7
 
7
- #ARCHIVE_REGEX = %r[puppet-enterprise-([\d.])-(.*?)\.(?:tar\.gz|msi)]
8
+ attr_reader :path
8
9
 
9
- attr_reader :path
10
+ def initialize(path, env)
11
+ @path, @env = path, env
12
+ @archives = []
10
13
 
11
- def initialize(path, env)
12
- @path, @env = path, env
13
- @archives = []
14
-
15
- load_archives
16
- end
14
+ load_archives
15
+ end
17
16
 
18
- def archives
19
- @archives
20
- end
17
+ def archives
18
+ @archives
19
+ end
21
20
 
22
- include Enumerable
23
- def each(&blk)
24
- @archives.each { |archive| yield archive }
25
- end
21
+ include Enumerable
22
+ def each(&blk)
23
+ @archives.each { |archive| yield archive }
24
+ end
26
25
 
27
- def display
28
- @archives.each do |archive|
29
- @env.ui.info " - #{archive.filename}"
26
+ def display
27
+ @archives.each do |archive|
28
+ @env.ui.info " - #{archive.filename}"
29
+ end
30
30
  end
31
- end
32
31
 
33
- private
32
+ private
34
33
 
35
- def load_archives
36
- dir = File.join(path, '*')
37
- Dir.glob(dir).sort.each do |path|
38
- basename = File.basename(path)
39
- @archives << PEBuild::Archive.new(basename, @env)
34
+ def load_archives
35
+ dir = File.join(path, '*')
36
+ Dir.glob(dir).sort.each do |path|
37
+ basename = File.basename(path)
38
+ @archives << PEBuild::Archive.new(basename, @env)
39
+ end
40
40
  end
41
41
  end
42
42
  end
43
- end
@@ -25,14 +25,6 @@ class PEBuild::Config::PEBootstrap < PEBuild::Config::Global
25
25
  # @api private
26
26
  VALID_ROLES = [:agent, :master]
27
27
 
28
- # @!attribute step
29
- # @return [Hash<Symbol, String>] a hash whose keys are step levels, and whose
30
- # keys are directories to optional steps.
31
- # @deprecated This duplicates the behavior of the shell provider and will
32
- # be removed in a future release.
33
- # @since 0.1.0
34
- attr_accessor :step
35
-
36
28
  # @!attribute relocate_manifests
37
29
  # @return [TrueClass, FalseClass] if the puppet master should use manifests
38
30
  # out of the vagrant directory.
@@ -65,17 +57,21 @@ class PEBuild::Config::PEBootstrap < PEBuild::Config::Global
65
57
  @relocate_manifests = UNSET_VALUE
66
58
 
67
59
  @autosign = UNSET_VALUE
68
-
69
- @step = {}
70
60
  end
71
61
 
72
62
  include PEBuild::ConfigDefault
73
63
 
64
+ # Finalize all configuration variables
65
+ #
66
+ # @note This does _not_ finalize values for config options inherited from the
67
+ # global configuration; it's assumed that the late configuration merging in
68
+ # the provisioner will handle that.
74
69
  def finalize!
75
- # This does _not_ set default values for config options inherited from the
76
- # global configuration. If configuration is not set for a value on the
77
- # global config or here it will be passed through as `UNSET_VALUE`, which
78
- # is not ideal.
70
+
71
+ # The value of role is normalized to a symbol so that users don't have to
72
+ # know the underlying representation, and we don't have to cast everything
73
+ # to a string and symbols later on.
74
+ @role &&= @role.intern
79
75
 
80
76
  set_default :@role, :agent
81
77
  set_default :@verbose, true
@@ -86,21 +82,10 @@ class PEBuild::Config::PEBootstrap < PEBuild::Config::Global
86
82
  set_default :@relocate_manifests, false
87
83
  end
88
84
 
89
- # @deprecated This duplicates the behavior of the shell provider and will
90
- # be removed in a future release.
91
- def add_step(name, script_path)
92
- name = (name.is_a?(Symbol)) ? name : name.intern
93
- step[name] = script_path
94
- end
95
-
96
85
  # @param machine [Vagrant::Machine]
97
86
  def validate(machine)
98
87
  h = super
99
88
 
100
- unless @step.empty?
101
- machine.ui.warn I18n.t('pebuild.config.pe_bootstrap.steps_deprecated')
102
- end
103
-
104
89
  errors = []
105
90
 
106
91
  validate_role(errors, machine)
@@ -123,9 +108,9 @@ class PEBuild::Config::PEBootstrap < PEBuild::Config::Global
123
108
  end
124
109
 
125
110
  def validate_role(errors, machine)
126
- unless VALID_ROLES.any? {|sym| @role == sym}
111
+ unless VALID_ROLES.any? {|sym| @role == sym.intern}
127
112
  errors << I18n.t(
128
- 'pebuild.config.pe_bootstrap.errors.unhandled_role',
113
+ 'pebuild.config.pe_bootstrap.errors.unknown_role',
129
114
  :role => @role.inspect,
130
115
  :known_roles => VALID_ROLES,
131
116
  )
@@ -28,6 +28,18 @@ class PEBuild::ConfigBuilder::PEBootstrap < ::PEBuild::ConfigBuilder::Global
28
28
  # remounted on the guest.
29
29
  def_model_attribute :relocate_manifests
30
30
 
31
+ # @!attribute [rw] autosign
32
+ # Configure the certificates that will be autosigned by the puppet master.
33
+ #
34
+ # @return [TrueClass] All CSRs will be signed
35
+ # @return [FalseClass] The autosign config file will be unmanaged
36
+ # @return [Array<String>] CSRs with the given addresses
37
+ #
38
+ # @see http://docs.puppetlabs.com/guides/configuring.html#autosignconf
39
+ #
40
+ # @since 0.4.0
41
+ def_model_attribute :autosign
42
+
31
43
  def to_proc
32
44
  Proc.new do |vm_config|
33
45
  vm_config.provision :pe_bootstrap do |pe|
@@ -42,6 +54,7 @@ class PEBuild::ConfigBuilder::PEBootstrap < ::PEBuild::ConfigBuilder::Global
42
54
  pe.master = attr(:master) if attr(:master)
43
55
  pe.answer_file = attr(:answer_file) if attr(:answer_file)
44
56
  pe.relocate_manifests = attr(:relocate_manifests) if attr(:relocate_manifests)
57
+ pe.autosign = attr(:autosign) if attr(:autosign)
45
58
  end
46
59
  end
47
60
  end
@@ -1,16 +1,16 @@
1
1
  require 'vagrant'
2
2
 
3
3
  module PEBuild
4
- module ConfigDefault
4
+ module ConfigDefault
5
5
 
6
- # @param [Symbol] iv The instance variable to set the default value
7
- # @param [Object] default The default value
8
- def set_default(iv, default)
9
- iv_val = instance_variable_get(iv)
10
- if iv_val == Vagrant::Plugin::V2::Config::UNSET_VALUE
11
- instance_variable_set(iv, default)
6
+ # @param [Symbol] iv The instance variable to set the default value
7
+ # @param [Object] default The default value
8
+ def set_default(iv, default)
9
+ iv_val = instance_variable_get(iv)
10
+ if iv_val == Vagrant::Plugin::V2::Config::UNSET_VALUE
11
+ instance_variable_set(iv, default)
12
+ end
12
13
  end
14
+ private :set_default
13
15
  end
14
- private :set_default
15
- end
16
16
  end
@@ -1,16 +1,16 @@
1
1
  module PEBuild
2
- module Idempotent
2
+ module Idempotent
3
3
 
4
- # @param fpath [String]
5
- # @param desc [String, nil]
6
- def idempotent(fpath, desc = nil, &block)
7
- desc ||= fpath
4
+ # @param fpath [String]
5
+ # @param desc [String, nil]
6
+ def idempotent(fpath, desc = nil, &block)
7
+ desc ||= fpath
8
8
 
9
- if File.exist? fpath
10
- @logger.info "#{desc} is already present."
11
- else
12
- yield
9
+ if File.exist? fpath
10
+ @logger.info "#{desc} is already present."
11
+ else
12
+ yield
13
+ end
13
14
  end
14
15
  end
15
16
  end
16
- end
@@ -52,13 +52,9 @@ module PEBuild
52
52
  load_archive
53
53
  fetch_installer
54
54
 
55
- [:base, @config.role].each { |rolename| process_step rolename, :pre }
56
-
57
55
  @machine.guest.capability('run_install', @config, @archive)
58
56
 
59
57
  run_postinstall_tasks
60
-
61
- [:base, @config.role].each { |rolename| process_step rolename, :post }
62
58
  end
63
59
 
64
60
  private
@@ -102,38 +98,6 @@ module PEBuild
102
98
  @archive.unpack_to(@work_dir)
103
99
  end
104
100
 
105
- require 'pe_build/on_machine'
106
- include PEBuild::OnMachine
107
-
108
- def process_step(role, stepname)
109
-
110
- if role != :base && config.step[stepname]
111
- if File.file? config.step[stepname]
112
- script_list = [*config.step[stepname]]
113
- else
114
- script_list = []
115
- @machine.ui.warn "Cannot find defined step for #{role}/#{stepname.to_s} at \'#{config.step[stepname]}\'"
116
- end
117
- else
118
- # We do not have a user defined step for this role or we're processing the :base step
119
- script_dir = File.join(PEBuild.source_root, 'bootstrap', role.to_s, stepname.to_s)
120
- script_list = Dir.glob("#{script_dir}/*")
121
- end
122
-
123
- if script_list.empty?
124
- @logger.info "No steps for #{role}/#{stepname}"
125
- end
126
-
127
- script_list.each do |template_path|
128
- # A message to show which step's action is running
129
- @machine.ui.info "Running action for #{role}/#{stepname}"
130
- template = File.read(template_path)
131
- contents = ERB.new(template).result(binding)
132
-
133
- on_machine(@machine, contents)
134
- end
135
- end
136
-
137
101
  def run_postinstall_tasks
138
102
  postinstall = PostInstall.new(@machine, @config, @work_dir)
139
103
  postinstall.run
@@ -25,6 +25,5 @@ module PEBuild
25
25
  raise UnknownInstallerType, :src => src unless klass
26
26
  klass.new(src, dst)
27
27
  end
28
-
29
28
  end
30
29
  end
@@ -1,8 +1,7 @@
1
+ require 'pe_build/unpack'
1
2
  require 'fileutils'
2
3
 
3
- module PEBuild
4
- module Unpack
5
- class Copy
4
+ class PEBuild::Unpack::Copy
6
5
 
7
6
  # @param src [String]
8
7
  # @param dst [String]
@@ -21,5 +20,3 @@ class Copy
21
20
  end
22
21
 
23
22
  end
24
- end
25
- end
@@ -1,8 +1,7 @@
1
+ require 'pe_build/unpack'
1
2
  require 'archive/tar/minitar'
2
3
 
3
- module PEBuild
4
- module Unpack
5
- class Tar
4
+ class PEBuild::Unpack::Tar
6
5
 
7
6
  # @param src [String]
8
7
  # @param dst [String]
@@ -38,5 +37,3 @@ class Tar
38
37
  File.open(@src, 'rb')
39
38
  end
40
39
  end
41
- end
42
- end
@@ -3,9 +3,7 @@ require 'pe_build/unpack/tar'
3
3
 
4
4
  require 'zlib'
5
5
 
6
- module PEBuild
7
- module Unpack
8
- class TarGZ < PEBuild::Unpack::Tar
6
+ class PEBuild::Unpack::TarGZ < PEBuild::Unpack::Tar
9
7
 
10
8
  private
11
9
 
@@ -13,5 +11,3 @@ class TarGZ < PEBuild::Unpack::Tar
13
11
  Zlib::GzipReader.new(super)
14
12
  end
15
13
  end
16
- end
17
- end
@@ -1,29 +1,29 @@
1
1
  module PEBuild
2
- module Util
3
- module Config
2
+ module Util
3
+ module Config
4
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
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
22
 
23
- result = result.merge(other)
24
- result = result.merge(local)
23
+ result = result.merge(other)
24
+ result = result.merge(local)
25
+ end
26
+ end
25
27
  end
26
28
  end
27
29
  end
28
- end
29
- end
@@ -1,3 +1,3 @@
1
1
  module PEBuild
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
@@ -7,6 +7,12 @@ en:
7
7
  mirror, or add the installer yourself by using the `vagrant pe-build copy`
8
8
  command. Downloads for Puppet Enterprise are available for download at
9
9
  https://puppetlabs.com/puppet/puppet-enterprise/
10
+ missing: |-
11
+ Tried to unpack %{filename} but it was not downloaded!
12
+ unreadable: |-
13
+ Failed to unpack %{filename}.
14
+ Archive corrupted or otherwise unreadable. The error message generated was:
15
+ "%{message}"
10
16
  provisioner:
11
17
  pe_bootstrap:
12
18
  post_install: |-
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.6.0
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-04 00:00:00.000000000 Z
12
+ date: 2013-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: progressbar