vagrant-pe_build 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/CHANGELOG +59 -0
  2. data/README.markdown +148 -5
  3. data/lib/pe_build.rb +5 -3
  4. data/lib/pe_build/action.rb +5 -0
  5. data/lib/pe_build/action/pe_build_dir.rb +18 -0
  6. data/lib/pe_build/archive.rb +39 -46
  7. data/lib/pe_build/cap.rb +17 -0
  8. data/lib/pe_build/cap/detect_installer/base.rb +15 -0
  9. data/lib/pe_build/cap/detect_installer/debian.rb +23 -0
  10. data/lib/pe_build/cap/detect_installer/posix.rb +73 -0
  11. data/lib/pe_build/cap/detect_installer/redhat.rb +18 -0
  12. data/lib/pe_build/cap/detect_installer/ubuntu.rb +23 -0
  13. data/lib/pe_build/cap/run_install/posix.rb +26 -0
  14. data/lib/pe_build/command.rb +6 -63
  15. data/lib/pe_build/command/base.rb +55 -0
  16. data/lib/pe_build/command/copy.rb +22 -23
  17. data/lib/pe_build/command/download.rb +4 -8
  18. data/lib/pe_build/command/list.rb +1 -6
  19. data/lib/pe_build/config/global.rb +13 -4
  20. data/lib/pe_build/config/pe_bootstrap.rb +4 -0
  21. data/lib/pe_build/idempotent.rb +1 -1
  22. data/lib/pe_build/on_machine.rb +10 -0
  23. data/lib/pe_build/plugin.rb +58 -22
  24. data/lib/pe_build/provisioner/pe_bootstrap.rb +123 -156
  25. data/lib/pe_build/provisioner/pe_bootstrap/answers_file.rb +49 -0
  26. data/lib/pe_build/release.rb +23 -0
  27. data/lib/pe_build/release/2_0.rb +25 -0
  28. data/lib/pe_build/release/2_5.rb +28 -0
  29. data/lib/pe_build/release/2_6.rb +27 -0
  30. data/lib/pe_build/release/2_7.rb +28 -0
  31. data/lib/pe_build/release/2_8.rb +35 -0
  32. data/lib/pe_build/release/3_0.rb +36 -0
  33. data/lib/pe_build/release/instance.rb +63 -0
  34. data/lib/pe_build/transfer.rb +25 -0
  35. data/lib/pe_build/transfer/file.rb +11 -9
  36. data/lib/pe_build/transfer/open_uri.rb +62 -0
  37. data/lib/pe_build/version.rb +1 -1
  38. data/templates/answers/{agent.txt.erb → agent-2.x.txt.erb} +1 -1
  39. data/templates/answers/agent-3.x.txt.erb +16 -0
  40. data/templates/answers/{master.txt.erb → master-2.x.txt.erb} +0 -0
  41. data/templates/answers/master-3.x.txt.erb +44 -0
  42. data/templates/locales/en.yml +16 -3
  43. metadata +28 -6
  44. data/lib/pe_build/transfer/uri.rb +0 -53
  45. data/templates/answers/master-existing-db.txt.erb +0 -52
data/CHANGELOG CHANGED
@@ -1,6 +1,65 @@
1
1
  vagrant-pe_build
2
2
  ================
3
3
 
4
+ 0.3.0
5
+ -----
6
+
7
+ 2013-08-14
8
+
9
+ This is a backwards compatible feature and bugfix release.
10
+
11
+ ### User notes:
12
+
13
+ #### Enhancements:
14
+
15
+ * Puppet Enterprise 3 is now fully supported and should have answers that
16
+ work out of the box.
17
+ * (GH-25) The installer for a given platform will be detected based on the
18
+ guest platform, which means that the most precise installer will be used
19
+ instead of the `all` installer.
20
+ * pe_build.download_root now fully supports a local directory with URIs using
21
+ the "file" URI.
22
+ * As part of GH-25 pe_build.suffix defaults to detect, which will auto-select
23
+ the correct installer name
24
+
25
+ #### Fixes:
26
+
27
+ * (GH-23) Removed double expansion of files when running `vagrant pe-build copy`
28
+ * (GH-24) Installer files are downloaded at provision time instead of before
29
+ VMs are constructed
30
+
31
+ #### Deprecations:
32
+
33
+ * Shell scripts run with the `add_step` hash are deprecated and will be
34
+ removed in the next 'major development' release (either 0.4.0, 0.5.0,
35
+ or 1.0.0). This behavior is effectively provided by the `shell` provisioner.
36
+
37
+ ### Developer notes (AKA the gory details):
38
+
39
+ * Informational logging has been expanded and is directed to the Vagrant
40
+ internal loggers.
41
+ * Answers file generation has been extracted out of the pe_bootstrap
42
+ provisioner and into an independent class to respect the single
43
+ responsibility principle.
44
+ * New guest capability: "detect_installer" detects the correct installer
45
+ for the given guest platform. Initial supported platforms are Debian,
46
+ Ubuntu, and Redhat.
47
+ * New guest capability: "run_install" extracts the actual command generation
48
+ and execution to install PE on a guest. Initial supported platforms are
49
+ Linux and Solaris.
50
+ * Installer file transfer has been fully extracted from the PEBuild::Archive
51
+ class and pushed into pe_build/transfer classes.
52
+ * File transfer behavior has been abstracted behind the PEBuild::Transfer
53
+ module and the implementing class is selected based on the scheme of the
54
+ requested URI.
55
+ * Almost everything ever has been beaten with the refactor hammer.
56
+
57
+ ### Thanks
58
+
59
+ * Thanks to Tom Linkin as always for his awesome work and contributions to
60
+ this plugin.
61
+ * Thanks to Jon Mosco for reporting GH-23.
62
+
4
63
  0.2.0
5
64
  -----
6
65
 
data/README.markdown CHANGED
@@ -9,25 +9,168 @@ Synopsis
9
9
  `vagrant-pe_build` manages the downloading and installation of Puppet Enterprise
10
10
  on Vagrant boxes to rapidly build a functioning Puppet environment.
11
11
 
12
- Usage
13
- -----
12
+ Vagrantfile Settings
13
+ -------------------
14
+
15
+ #### Config Namespace `config.pe_build`
16
+
17
+ These settings go in the config object namespace and act as defaults in
18
+ the event multiple machines are being provisioned. These settings are
19
+ optional and can be overridden in a VM's individual provisioner config.
20
+
21
+ * `config.pe_build.version`
22
+ * Description: The version of Puppet Enterprise to install.
23
+ * `config.pe_build.suffix` - Suffix of the Puppet Enterprise installer to use.
24
+ * Description: The distribution specifix suffix of the Puppet Enterprise
25
+ installer to use.
26
+ * Default: `:detect`
27
+ * `config.pe_build.filename`
28
+ * Description: The filename of the Puppet Enterprise installer.
29
+ * Default: this will use the version and suffix provided to guess a filename
30
+ of the form `puppet-enterprise-<version>-<suffix>.tar.gz`.
31
+ * `config.pe_build.download_root`
32
+ * Description: The URI to the directory containing Puppet Enterprise
33
+ installers if the installer is not yet cached. This setting is optional.
34
+ * Supported URI schemes:
35
+ * http
36
+ * https
37
+ * ftp
38
+ * file
39
+ * A blank URI will default to `file`.
40
+
41
+ #### Provisioner Namespace
42
+
43
+ These settings are on a per provisioner basis. They configure the individual
44
+ behaviors of the provisioner. All of the `config.pe_build` options can be
45
+ overridden at this point.
46
+
47
+ * `role`
48
+ * Description: The role of the Puppet Enterprise install.
49
+ * Options: `:agent`, `:master`
50
+ * Default: `:agent`
51
+ * `verbose`
52
+ * Description: Whether or not to show the verbose output of the Puppet
53
+ Enterprise install.
54
+ * Options: `true`, `false`
55
+ * Default: `true`
56
+ * `master`
57
+ * Description: The address of the puppet master
58
+ * Default: `master`
59
+ * `answer_file`
60
+ * Description: The location of alternate answer file for PE installation.
61
+ Values can be paths relative to the Vagrantfile's project directory.
62
+ * Default: The default answer file for the Puppet Enterprise version and
63
+ role.
64
+ * `relocate_manifests`
65
+ * Description: Whether or not to change the PE master to use a config of
66
+ `manifestdir=/manifests` and `modulepath=/modules`. This is meant to be
67
+ used when the vagrant working directory manifests and modules are
68
+ remounted on the guest.
69
+ * Options: `true`, `false`
70
+ * Default: `false`
71
+
72
+ Commands
73
+ --------
74
+
75
+ Usage Example
76
+ -------------
77
+
78
+ ### Minimal configuration
79
+
80
+ This requires that the necessary installers have already been downloaded and
81
+ added with `vagrant pe-build copy`.
14
82
 
15
83
  Vagrant.configure('2') do |config|
84
+ config.pe_build.version = '3.0.0'
85
+
86
+ config.vm.define 'master' do |node|
87
+ node.vm.box = 'centos-6-i386'
88
+
89
+ node.vm.provision :pe_bootstrap do |provisioner|
90
+ provisioner.role = :master
91
+ end
92
+ end
93
+
94
+ config.vm.define 'agent1' do |node|
95
+ node.vm.box = 'centos-6-i386'
96
+ node.vm.provision :pe_bootstrap
97
+ end
98
+ end
99
+ end
100
+
101
+ ### Specifying a download root
102
+
103
+ Vagrant.configure('2') do |config|
104
+ config.pe_build.version = '3.0.0'
16
105
  config.pe_build.download_root = 'http://my.pe.download.mirror/installers'
17
- config.pe_build.version = '2.7.0'
18
- config.pe_build.filename = 'puppet-enterprise-2.7.0-all.tar.gz'
106
+
107
+ # Alternately, a local directory can be specified
108
+ #config.pe_build.download_root = 'file://Users/luke/Downloads'
19
109
 
20
110
  config.vm.define 'master' do |node|
111
+ node.vm.box = 'centos-6-i386'
112
+
21
113
  node.vm.provision :pe_bootstrap do |provisioner|
22
114
  provisioner.role = :master
23
115
  end
24
116
  end
25
117
 
26
118
  config.vm.define 'agent1' do |node|
119
+ node.vm.box = 'centos-6-i386'
120
+
121
+ node.vm.provision :pe_bootstrap
122
+ end
123
+ end
124
+
125
+ ### Using a manual answers file
126
+
127
+ Vagrant.configure('2') do |config|
128
+ config.pe_build.version = '3.0.0'
129
+ config.pe_build.download_root = 'http://my.pe.download.mirror/installers'
130
+
131
+ # Alternately, a local directory can be specified
132
+ #config.pe_build.download_root = 'file://Users/luke/Downloads'
133
+
134
+ config.vm.define 'master' do |node|
135
+ node.vm.box = 'centos-6-i386'
136
+
137
+ node.vm.provision :pe_bootstrap do |provisioner|
138
+ provisioner.role = :master
139
+ provisioner.answer_file = 'answers/vagrant_master.answers.txt'
140
+ end
141
+ end
142
+
143
+ config.vm.define 'agent1' do |node|
144
+ node.vm.box = 'centos-6-i386'
145
+
146
+ node.vm.provision :pe_bootstrap
147
+ end
148
+ end
149
+
150
+ ### Manually setting a filename
151
+
152
+ Vagrant.configure('2') do |config|
153
+ config.pe_build.version = '3.0.0'
154
+ config.pe_build.filename = 'puppet-enterprise-3.0.0-all.tar.gz'
155
+
156
+ # Alternately, a local directory can be specified
157
+ #config.pe_build.download_root = 'file://Users/luke/Downloads'
158
+
159
+ config.vm.define 'master' do |node|
160
+ node.vm.box = 'centos-6-i386'
161
+
27
162
  node.vm.provision :pe_bootstrap do |provisioner|
28
- provisioner.role = :agent
163
+ provisioner.role = :master
164
+ provisioner.answer_file = 'answers/vagrant_master.answers.txt'
29
165
  end
30
166
  end
167
+
168
+ config.vm.define 'agent1' do |node|
169
+ node.vm.box = 'centos-6-i386'
170
+
171
+ node.vm.provision :pe_bootstrap do |provisioner|
172
+ provisioner.role = :agent end
173
+ end
31
174
  end
32
175
 
33
176
  Requirements
data/lib/pe_build.rb CHANGED
@@ -2,6 +2,11 @@ require 'vagrant'
2
2
 
3
3
  module PEBuild
4
4
 
5
+ require 'pe_build/plugin'
6
+ require 'pe_build/version'
7
+
8
+ WORK_DIR = '.pe_build'
9
+
5
10
  # Return the path to the archived PE builds
6
11
  #
7
12
  # @param env [Vagrant::Environment]
@@ -20,6 +25,3 @@ end
20
25
 
21
26
  # I18n to load the en locale
22
27
  I18n.load_path << File.expand_path("locales/en.yml", PEBuild.template_dir)
23
-
24
- require 'pe_build/plugin'
25
- require 'pe_build/version'
@@ -0,0 +1,5 @@
1
+ module PEBuild
2
+ module Action
3
+ require 'pe_build/action/pe_build_dir'
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ # Set up the PE build cache dir
2
+ class PEBuild::Action::PEBuildDir
3
+
4
+ def initialize(app, env)
5
+ @app, @env = app, env
6
+
7
+ @build_dir = @env[:home_path].join('pe_builds')
8
+ end
9
+
10
+ def call(env)
11
+ @env = env
12
+
13
+ @build_dir.mkpath unless @build_dir.exist?
14
+ @env[:pe_build_dir] = @build_dir
15
+
16
+ @app.call(@env)
17
+ end
18
+ end
@@ -2,13 +2,10 @@ require 'pe_build'
2
2
  require 'pe_build/idempotent'
3
3
  require 'pe_build/archive_collection'
4
4
 
5
- require 'pe_build/transfer/file'
6
- require 'pe_build/transfer/uri'
5
+ require 'pe_build/transfer'
7
6
 
8
7
  require 'pe_build/unpack/tar'
9
8
 
10
- require 'fileutils'
11
-
12
9
  module PEBuild
13
10
 
14
11
  class ArchiveNoInstallerSource < Vagrant::Errors::VagrantError
@@ -35,69 +32,65 @@ class Archive
35
32
  def initialize(filename, env)
36
33
  @filename = filename
37
34
  @env = env
38
- end
39
35
 
40
- # @param fs_dir [String] The base directory to extract the installer to
41
- def unpack_to(fs_dir)
42
- tar = PEBuild::Unpack::Tar.new(archive_path, fs_dir)
43
- path = File.join(fs_dir, tar.dirname)
36
+ @archive_dir = PEBuild.archive_directory(@env)
44
37
 
45
- idempotent(path, "Unpacked archive #{versioned_path filename}") do
46
- tar.unpack
47
- end
38
+ @logger = Log4r::Logger.new('vagrant::pe_build::archive')
48
39
  end
49
40
 
50
- # @param fs_dir [String] The base directory holding the archive
51
- def copy_from(fs_dir)
52
- file_path = versioned_path(File.join(fs_dir, filename))
41
+ # @param base_uri [String] A string representation of the download source URI
42
+ def fetch(str)
43
+ return if self.exist?
44
+
45
+ if str.nil?
46
+ @env.ui.error "Cannot fetch installer #{versioned_path @filename}; no download source available."
47
+ @env.ui.error ""
48
+ @env.ui.error "Installers available for use:"
53
49
 
54
- idempotent(archive_path, "Installer #{versioned_path @filename}") do
55
- prepare_for_copy!
56
- transfer = PEBuild::Transfer::File.new(file_path, archive_path)
57
- transfer.copy
50
+ collection = PEBuild::ArchiveCollection.new(@archive_dir, @env)
51
+ collection.display
52
+
53
+ raise PEBuild::ArchiveNoInstallerSource, :filename => versioned_path(@filename)
58
54
  end
59
- end
60
55
 
61
- # @param download_dir [String] The URL base containing the archive
62
- def download_from(download_dir)
63
- idempotent(archive_path, "Installer #{versioned_path @filename}") do
64
- if download_dir.nil?
65
- @env.ui.error "Installer #{versioned_path @filename} is not available."
56
+ uri = URI.parse(versioned_path(str + '/' + @filename))
57
+ dst = File.join(@archive_dir, versioned_path(@filename))
66
58
 
67
- archive_dir = PEBuild.archive_directory(@env)
59
+ transfer = PEBuild::Transfer.generate(uri, dst)
60
+ transfer.copy
61
+ end
68
62
 
69
- collection = PEBuild::ArchiveCollection.new(archive_dir, @env)
70
- collection.display
63
+ # @param fs_dir [String] The base directory to extract the installer to
64
+ def unpack_to(fs_dir)
65
+ unless exist?
66
+ raise "Tried to unpack #{@filename} but it was not downloaded!"
67
+ end
71
68
 
72
- raise PEBuild::ArchiveNoInstallerSource
73
- else
74
- str = versioned_path("#{download_dir}/#{@filename}")
69
+ tar = PEBuild::Unpack::Tar.new(archive_path, fs_dir)
70
+ path = File.join(fs_dir, tar.dirname)
75
71
 
76
- prepare_for_copy!
77
- transfer = PEBuild::Transfer::URI.new(str, archive_path)
78
- transfer.copy
79
- end
72
+ idempotent(path, "Unpacked archive #{versioned_path filename}") do
73
+ tar.unpack
80
74
  end
81
75
  end
82
76
 
83
- private
77
+ def exist?
78
+ File.exist? archive_path
79
+ end
84
80
 
85
- # Initialize the PE directory
86
- #
87
- # @todo respect Vagrant home setting
88
- def prepare_for_copy!
89
- archive_dir = PEBuild.archive_directory(@env)
81
+ def to_s
82
+ versioned_path(@filename)
83
+ end
90
84
 
91
- if not File.directory? archive_dir
92
- FileUtils.mkdir_p archive_dir
93
- end
85
+ def installer_dir
86
+ versioned_path(@filename).gsub('.tar.gz', '')
94
87
  end
95
88
 
89
+ private
96
90
 
97
91
  # @return [String] The interpolated archive path
98
92
  def archive_path
99
- archive_dir = PEBuild.archive_directory(@env)
100
- path = File.join(archive_dir, @filename)
93
+ path = File.join(@archive_dir, @filename)
101
94
  versioned_path(path)
102
95
  end
103
96
 
@@ -0,0 +1,17 @@
1
+ module PEBuild
2
+ module Cap
3
+ module DetectInstaller
4
+ require 'pe_build/cap/detect_installer/base'
5
+ require 'pe_build/cap/detect_installer/posix'
6
+
7
+ require 'pe_build/cap/detect_installer/redhat'
8
+ require 'pe_build/cap/detect_installer/debian'
9
+ require 'pe_build/cap/detect_installer/ubuntu'
10
+ #require 'pe_build/cap/detect_installer/suse'
11
+ end
12
+
13
+ module RunInstall
14
+ require 'pe_build/cap/run_install/posix'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ class PEBuild::Cap::DetectInstaller::Base
2
+
3
+ def self.detect_installer(machine, version)
4
+ new(machine, version).detect
5
+ end
6
+
7
+ def initialize(machine, version)
8
+ @machine, @version = machine, version
9
+ end
10
+
11
+ # @!method detect
12
+ # Return the installer for the given operating system
13
+ # @abstract
14
+ # @return [String] The installer for the given operating system
15
+ end
@@ -0,0 +1,23 @@
1
+ class PEBuild::Cap::DetectInstaller::Debian < PEBuild::Cap::DetectInstaller::POSIX
2
+
3
+ def name
4
+ 'debian'
5
+ end
6
+
7
+ def release_file
8
+ '/etc/debian_version'
9
+ end
10
+
11
+ def release_file_format
12
+ %r[^(\d+)\.]
13
+ end
14
+
15
+ def supported_releases
16
+ %w[6 7]
17
+ end
18
+
19
+ def arch
20
+ retval = super
21
+ (retval == 'x86_64') ? 'amd64' : retval
22
+ end
23
+ end