vagrant-pe_build 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,7 +1,38 @@
1
1
  vagrant-pe_build
2
2
  ================
3
3
 
4
+ 0.5.0
5
+ -----
6
+
7
+ 2013-09-17
8
+
9
+ This is a backwards compatible bugfix and feature release.
10
+
11
+ ### User notes:
12
+
13
+ * Added detect_installer capability for SLES
14
+ * (GH-32) Added detect_installer capability for Solaris
15
+ * (GH-32) run_install capability uses posix compliant `at` command syntax
16
+ * (GH-33) Added detect_installer and run_install capabilities for Windows
17
+
18
+ ### Developer notes:
19
+
20
+ * All StandardError exceptions emitted from transfer/open_uri are now rescued,
21
+ so errors generated during downloads won't cause Vagrant to die with a
22
+ stacktrace.
23
+ * cap/detect_installer exceptions now subclass Vagrant::Errors::VagrantErrors
24
+ so that detection errors don't cause stacktraces.
25
+ * Archive unpacking logic has been generalized to support multiple implementations
26
+ like 'pe_build/transfer'
27
+
28
+ Thanks to Reid Vandewiele for implementing the Windows and Solaris fixes and
29
+ extracting the 'unpack' logic.
30
+
31
+ Thanks to Charlie Sharpsteen for validating the new platform support and
32
+ correcting the issues around open_uri error handling.
33
+
4
34
  0.4.3
35
+ -----
5
36
 
6
37
  2013-09-09
7
38
 
@@ -3,8 +3,7 @@ require 'pe_build/idempotent'
3
3
  require 'pe_build/archive_collection'
4
4
 
5
5
  require 'pe_build/transfer'
6
-
7
- require 'pe_build/unpack/tar'
6
+ require 'pe_build/unpack'
8
7
 
9
8
  module PEBuild
10
9
 
@@ -66,11 +65,9 @@ class Archive
66
65
  raise "Tried to unpack #{@filename} but it was not downloaded!"
67
66
  end
68
67
 
69
- tar = PEBuild::Unpack::Tar.new(archive_path, fs_dir)
70
- path = File.join(fs_dir, tar.dirname)
71
-
72
- idempotent(path, "Unpacked archive #{versioned_path filename}") do
73
- tar.unpack
68
+ archive = PEBuild::Unpack.generate(archive_path, fs_dir)
69
+ idempotent(archive.creates, "Unpacked archive #{versioned_path filename}") do
70
+ archive.unpack
74
71
  end
75
72
  end
76
73
 
data/lib/pe_build/cap.rb CHANGED
@@ -1,17 +1,25 @@
1
1
  module PEBuild
2
2
  module Cap
3
3
  module DetectInstaller
4
+
5
+ class DetectFailed < Vagrant::Errors::VagrantError
6
+ error_key(:detect_failed, 'pebuild.cap.detect_installer')
7
+ end
8
+
4
9
  require 'pe_build/cap/detect_installer/base'
5
10
  require 'pe_build/cap/detect_installer/posix'
11
+ require 'pe_build/cap/detect_installer/windows'
6
12
 
7
13
  require 'pe_build/cap/detect_installer/redhat'
8
14
  require 'pe_build/cap/detect_installer/debian'
9
15
  require 'pe_build/cap/detect_installer/ubuntu'
10
- #require 'pe_build/cap/detect_installer/suse'
16
+ require 'pe_build/cap/detect_installer/sles'
17
+ require 'pe_build/cap/detect_installer/solaris'
11
18
  end
12
19
 
13
20
  module RunInstall
14
21
  require 'pe_build/cap/run_install/posix'
22
+ require 'pe_build/cap/run_install/windows'
15
23
  end
16
24
  end
17
25
  end
@@ -21,24 +21,29 @@ class PEBuild::Cap::DetectInstaller::POSIX < PEBuild::Cap::DetectInstaller::Base
21
21
  # @abstract
22
22
  # @return [Array<String>] All supported releases for the distribution
23
23
 
24
-
25
24
  def detect
26
25
  dist_version = parse_release_file
27
26
 
28
27
  unless supported_releases.include? dist_version
29
- raise "#{self.class.name} release #{dist_version} not supported"
28
+ raise PEBuild::Cap::DetectInstaller::DetectFailed,
29
+ :name => @machine.name,
30
+ :error => "#{self.class.name} release #{dist_version} not supported"
30
31
  end
31
32
 
32
33
  "puppet-enterprise-#{@version}-#{name}-#{dist_version}-#{arch}.#{ext}"
33
34
  end
34
35
 
35
36
  def arch
36
- content = ""
37
- @machine.communicate.execute("uname -m") do |type, data|
38
- raise "Could not run 'uname -m' on #{@machine}: got #{data}" if type == :stderr
39
- content << data.chomp
37
+ results = execute_command("uname -m")
38
+
39
+ unless results[:retval] == 0
40
+ raise PEBuild::Cap::DetectInstaller::DetectFailed,
41
+ :name => @machine.name,
42
+ :error => "Could not run 'uname -m' on #{@machine.name}: got #{results[:stderr]}"
40
43
  end
41
44
 
45
+ content = results[:stdout]
46
+
42
47
  content = 'i386' if content.match /i\d86/
43
48
 
44
49
  content
@@ -51,23 +56,41 @@ class PEBuild::Cap::DetectInstaller::POSIX < PEBuild::Cap::DetectInstaller::Base
51
56
  private
52
57
 
53
58
  def release_content
54
- content = ""
59
+ results = execute_command("cat #{release_file}")
55
60
 
56
- @machine.communicate.execute("cat #{release_file}") do |type, data|
57
- raise "Could not read #{release_file} on #{@machine}: got #{data}" if type == :stderr
58
- content << data
61
+ unless results[:retval] == 0
62
+ raise PEBuild::Cap::DetectInstaller::DetectFailed,
63
+ :name => @machine.name,
64
+ :error => "Could not read #{release_file} on #{@machine.name}: got #{results[:stderr]}"
59
65
  end
60
66
 
61
- content
67
+ results[:stdout]
62
68
  end
63
69
 
64
70
  def parse_release_file
65
71
  matchdata = release_content.match(release_file_format)
66
72
 
67
73
  if matchdata.nil? or matchdata[1].nil?
68
- raise "#{self.class.name} could not determine release value: content #{release_content.inspect} did not match #{release_file_format}"
74
+ raise PEBuild::Cap::DetectInstaller::DetectFailed,
75
+ :name => @machine.name,
76
+ :error => "#{self.class.name} could not determine release value: content #{release_content.inspect} did not match #{release_file_format}"
69
77
  end
70
78
 
71
79
  matchdata[1]
72
80
  end
81
+
82
+ def execute_command(cmd)
83
+ stdout = ''
84
+ stderr = ''
85
+
86
+ retval = @machine.communicate.execute(cmd, :error_check => false) do |type, data|
87
+ if type == :stderr
88
+ stderr << data
89
+ else
90
+ stdout << data
91
+ end
92
+ end
93
+
94
+ {:stdout => stdout.chomp, :stderr => stderr.chomp, :retval => retval}
95
+ end
73
96
  end
@@ -0,0 +1,19 @@
1
+ class PEBuild::Cap::DetectInstaller::SLES < PEBuild::Cap::DetectInstaller::POSIX
2
+
3
+ def name
4
+ 'sles'
5
+ end
6
+
7
+ def release_file
8
+ '/etc/SuSE-release'
9
+ end
10
+
11
+ def release_file_format
12
+ %r[^SUSE Linux Enterprise Server (\d+)]
13
+ end
14
+
15
+ def supported_releases
16
+ %w[11]
17
+ end
18
+ end
19
+
@@ -0,0 +1,24 @@
1
+ class PEBuild::Cap::DetectInstaller::Solaris < PEBuild::Cap::DetectInstaller::POSIX
2
+
3
+ def name
4
+ 'solaris'
5
+ end
6
+
7
+ def release_file
8
+ '/etc/release'
9
+ end
10
+
11
+ def release_file_format
12
+ %r[^(?:\s)*(?:Oracle )?Solaris (\d+)]
13
+ end
14
+
15
+ def supported_releases
16
+ %w[10]
17
+ end
18
+
19
+ def arch
20
+ retval = super
21
+ (retval == 'i86pc') ? 'i386' : retval
22
+ end
23
+
24
+ end
@@ -0,0 +1,13 @@
1
+ # Provide an abstract base class for detecting the installer name on
2
+ # POSIX systems.
3
+ #
4
+ # @abstract
5
+ # @protected
6
+ class PEBuild::Cap::DetectInstaller::Windows < PEBuild::Cap::DetectInstaller::Base
7
+
8
+ def detect
9
+ # Yes, it really is this simple. For Windows anyway.
10
+ "puppet-enterprise-#{@version}.msi"
11
+ end
12
+
13
+ end
@@ -29,7 +29,7 @@ class PEBuild::Cap::RunInstall::POSIX
29
29
 
30
30
  if machine.communicate.test('which at')
31
31
  machine.ui.info I18n.t('pebuild.cap.run_install.scheduling_run')
32
- machine.communicate.sudo("echo '/opt/puppet/bin/puppet agent -t --waitforcert 10' | at next minute")
32
+ machine.communicate.sudo("echo '/opt/puppet/bin/puppet agent -t --waitforcert 10' | at now '+ 1min'")
33
33
  end
34
34
  end
35
35
  end
@@ -0,0 +1,35 @@
1
+ require 'pe_build/on_machine'
2
+ class PEBuild::Cap::RunInstall::Windows
3
+
4
+ extend PEBuild::OnMachine
5
+
6
+ def self.run_install(machine, config, archive)
7
+
8
+ gt_win2k3_path = '${Env:ALLUSERSPROFILE}\\PuppetLabs'
9
+ le_win2k3_path = '${Env:ALLUSERSPROFILE}\\Application Data\\PuppetLabs'
10
+ testpath = "(Test-Path \"#{gt_win2k3_path}\") -or (Test-Path \"#{le_win2k3_path}\")"
11
+
12
+ if machine.communicate.test("If (#{testpath}) { Exit 0 } Else { Exit 1 }")
13
+ machine.ui.warn I18n.t('pebuild.cap.run_install.already_installed'),
14
+ :name => machine.name
15
+ return
16
+ end
17
+
18
+ root = File.join('\\\\VBOXSVR\\vagrant', PEBuild::WORK_DIR)
19
+
20
+ # The installer will be fed to msiexec. That means the File.join() method
21
+ # is of limited use since it won't execute on the Windows system
22
+ installer = File.join(root, archive.to_s).gsub('/', '\\')
23
+
24
+ cmd = []
25
+ cmd << 'msiexec' << '/qn' << '/i' << installer
26
+
27
+ cmd << "PUPPET_MASTER_SERVER=#{config.master}"
28
+ cmd << "PUPPET_AGENT_CERTNAME=#{machine.name}"
29
+
30
+ argv = cmd.join(' ')
31
+
32
+ on_machine(machine, argv)
33
+
34
+ end
35
+ end
@@ -39,6 +39,8 @@ module PEBuild
39
39
 
40
40
  # Guest capabilities for installing PE
41
41
 
42
+ ## Detect installer
43
+
42
44
  guest_capability('debian', 'detect_installer') do
43
45
  require_relative 'cap'
44
46
  PEBuild::Cap::DetectInstaller::Debian
@@ -54,6 +56,23 @@ module PEBuild
54
56
  PEBuild::Cap::DetectInstaller::Ubuntu
55
57
  end
56
58
 
59
+ guest_capability('suse', 'detect_installer') do
60
+ require_relative 'cap'
61
+ PEBuild::Cap::DetectInstaller::SLES
62
+ end
63
+
64
+ guest_capability('solaris', 'detect_installer') do
65
+ require_relative 'cap'
66
+ PEBuild::Cap::DetectInstaller::Solaris
67
+ end
68
+
69
+ guest_capability('windows', 'detect_installer') do
70
+ require_relative 'cap'
71
+ PEBuild::Cap::DetectInstaller::Windows
72
+ end
73
+
74
+ ## Run install
75
+
57
76
  guest_capability('linux', 'run_install') do
58
77
  require_relative 'cap'
59
78
  PEBuild::Cap::RunInstall::POSIX
@@ -64,6 +83,11 @@ module PEBuild
64
83
  PEBuild::Cap::RunInstall::POSIX
65
84
  end
66
85
 
86
+ guest_capability('windows', 'run_install') do
87
+ require_relative 'cap'
88
+ PEBuild::Cap::RunInstall::Windows
89
+ end
90
+
67
91
  # internal action hooks
68
92
 
69
93
  action_hook('PE Build: initialize build dir') do |hook|
@@ -1,3 +1,5 @@
1
+ require 'pe_build'
2
+
1
3
  module PEBuild
2
4
  module Release
3
5
 
@@ -1,3 +1,5 @@
1
+ require 'pe_build/release'
2
+
1
3
  module PEBuild::Release
2
4
 
3
5
  two_oh_x = newrelease do
@@ -1,3 +1,5 @@
1
+ require 'pe_build/release'
2
+
1
3
  module PEBuild::Release
2
4
 
3
5
  two_five_x = newrelease do
@@ -1,3 +1,5 @@
1
+ require 'pe_build/release'
2
+
1
3
  module PEBuild::Release
2
4
 
3
5
  two_six_x = newrelease do
@@ -1,3 +1,5 @@
1
+ require 'pe_build/release'
2
+
1
3
  module PEBuild::Release
2
4
 
3
5
  two_seven_x = newrelease do
@@ -1,3 +1,5 @@
1
+ require 'pe_build/release'
2
+
1
3
  module PEBuild::Release
2
4
 
3
5
  two_eight_x = newrelease do
@@ -1,3 +1,5 @@
1
+ require 'pe_build/release'
2
+
1
3
  module PEBuild::Release
2
4
 
3
5
  three_oh_oh = newrelease do
@@ -25,7 +25,7 @@ class PEBuild::Transfer::OpenURI
25
25
  tmpfile = download_file
26
26
  FileUtils.mv(tmpfile, @dst)
27
27
  end
28
- rescue ::OpenURI::HTTPError, ::OpenSSL::SSL::SSLError, ::SocketError => e
28
+ rescue StandardError => e
29
29
  raise DownloadFailed, :uri => @uri, :msg => e.message
30
30
  end
31
31
 
@@ -0,0 +1,28 @@
1
+ module PEBuild
2
+ module Unpack
3
+
4
+ class UnknownInstallerType < Vagrant::Errors::VagrantError
5
+ error_key(:unknown_installer_type, "pebuild.unpack")
6
+ end
7
+
8
+ require 'pe_build/unpack/tar'
9
+ require 'pe_build/unpack/copy'
10
+
11
+ IMPLEMENTATIONS = {
12
+ '.tar.gz' => PEBuild::Unpack::Tar,
13
+ '.msi' => PEBuild::Unpack::Copy,
14
+ }
15
+
16
+ # @param src [String]
17
+ # @param dst [String]
18
+ def self.generate(src, dst)
19
+ klass = IMPLEMENTATIONS.find do |key,v|
20
+ src.end_with?(key)
21
+ end.last
22
+
23
+ raise UnknownInstallerType, :src => src unless klass
24
+ klass.new(src, dst)
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ require 'fileutils'
2
+
3
+ module PEBuild
4
+ module Unpack
5
+ class Copy
6
+
7
+ # @param src [String]
8
+ # @param dst [String]
9
+ def initialize(src, dst)
10
+ @src, @dst = src, dst
11
+ end
12
+
13
+ def unpack
14
+ FileUtils.cp(@src, creates)
15
+ end
16
+
17
+ # @return [String] The file/dir that will be created as a result of unpack
18
+ def creates
19
+ basename = File.basename(@src)
20
+ deploy_path = File.join(@dst, basename)
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -15,6 +15,11 @@ class Tar
15
15
  ::Archive::Tar::Minitar.unpack(zip, @dst)
16
16
  end
17
17
 
18
+ # @return [String] The file/dir that will be created as a result of unpack
19
+ def creates
20
+ File.join(@dst, dirname)
21
+ end
22
+
18
23
  # @return [String] The base directory contained in the tar archive
19
24
  def dirname
20
25
  input = ::Archive::Tar::Minitar::Input.new(zip)
@@ -1,3 +1,3 @@
1
1
  module PEBuild
2
- VERSION = '0.4.3'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -19,6 +19,10 @@ en:
19
19
  unhandled_uri_scheme: |-
20
20
  The URI scheme "%{scheme}" cannot be handled by any file transferrers.
21
21
  Supported URI schemes: %{supported}
22
+ unpack:
23
+ unknown_installer_type: |-
24
+ PEBuild does not know how to unpack the installer archive file type.
25
+ The installer file is %{src}.
22
26
  config:
23
27
  global:
24
28
  errors:
@@ -53,3 +57,8 @@ en:
53
57
  Puppet Enterprise is already installed, skipping installation.
54
58
  scheduling_run: |-
55
59
  Scheduling Puppet run to kickstart node classification.
60
+ detect_installer:
61
+ detect_failed: |-
62
+ The VM "%{name}" could not detect the version of Puppet Enterprise and failed with
63
+ the following error:
64
+ "%{error}"
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.4.3
4
+ version: 0.5.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-09-09 00:00:00.000000000 Z
12
+ date: 2013-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: progressbar
@@ -70,8 +70,12 @@ files:
70
70
  - lib/pe_build/cap/detect_installer/debian.rb
71
71
  - lib/pe_build/cap/detect_installer/posix.rb
72
72
  - lib/pe_build/cap/detect_installer/redhat.rb
73
+ - lib/pe_build/cap/detect_installer/sles.rb
74
+ - lib/pe_build/cap/detect_installer/solaris.rb
73
75
  - lib/pe_build/cap/detect_installer/ubuntu.rb
76
+ - lib/pe_build/cap/detect_installer/windows.rb
74
77
  - lib/pe_build/cap/run_install/posix.rb
78
+ - lib/pe_build/cap/run_install/windows.rb
75
79
  - lib/pe_build/command.rb
76
80
  - lib/pe_build/command/base.rb
77
81
  - lib/pe_build/command/copy.rb
@@ -101,6 +105,8 @@ files:
101
105
  - lib/pe_build/transfer.rb
102
106
  - lib/pe_build/transfer/file.rb
103
107
  - lib/pe_build/transfer/open_uri.rb
108
+ - lib/pe_build/unpack.rb
109
+ - lib/pe_build/unpack/copy.rb
104
110
  - lib/pe_build/unpack/tar.rb
105
111
  - lib/pe_build/util/config.rb
106
112
  - lib/pe_build/version.rb