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
@@ -0,0 +1,23 @@
1
+ module PEBuild
2
+ module Release
3
+
4
+ require 'pe_build/release/instance'
5
+
6
+ @releases = {}
7
+
8
+ def self.[](ver)
9
+ @releases[ver]
10
+ end
11
+
12
+ def self.newrelease(&blk)
13
+ PEBuild::Release::Instance.new(&blk)
14
+ end
15
+
16
+ require 'pe_build/release/2_0'
17
+ require 'pe_build/release/2_5'
18
+ require 'pe_build/release/2_6'
19
+ require 'pe_build/release/2_7'
20
+ require 'pe_build/release/2_8'
21
+ require 'pe_build/release/3_0'
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ module PEBuild::Release
2
+
3
+ two_oh_x = newrelease do
4
+ add_release :debian, 5
5
+ add_release :debian, 6
6
+
7
+ add_release :el, 4
8
+ add_release :el, 5
9
+ add_release :el, 6
10
+
11
+ add_release :sles, 11
12
+
13
+ add_release :solaris, 10
14
+
15
+ add_release :ubuntu, '10.04'
16
+
17
+ set_answer_file :master, File.join(PEBuild.template_dir, 'answers', 'master-2.x.txt.erb')
18
+ set_answer_file :agent, File.join(PEBuild.template_dir, 'answers', 'agent-2.x.txt.erb')
19
+ end
20
+
21
+ @releases['2.0.0'] = two_oh_x
22
+ @releases['2.0.1'] = two_oh_x
23
+ @releases['2.0.2'] = two_oh_x
24
+ @releases['2.0.3'] = two_oh_x
25
+ end
@@ -0,0 +1,28 @@
1
+ module PEBuild::Release
2
+
3
+ two_five_x = newrelease do
4
+
5
+ add_release :debian, 6
6
+
7
+ add_release :el, 5
8
+ add_release :el, 6
9
+
10
+ add_release :sles, 11
11
+
12
+ add_release :solaris, 10
13
+
14
+ add_release :ubuntu, '10.04'
15
+
16
+ add_release :windows, '2003'
17
+ add_release :windows, '2008R2'
18
+ add_release :windows, 7
19
+
20
+ set_answer_file :master, File.join(PEBuild.template_dir, 'answers', 'master-2.x.txt.erb')
21
+ set_answer_file :agent, File.join(PEBuild.template_dir, 'answers', 'agent-2.x.txt.erb')
22
+ end
23
+
24
+ @releases['2.5.0'] = two_five_x
25
+ @releases['2.5.1'] = two_five_x
26
+ @releases['2.5.2'] = two_five_x
27
+ @releases['2.5.3'] = two_five_x
28
+ end
@@ -0,0 +1,27 @@
1
+ module PEBuild::Release
2
+
3
+ two_six_x = newrelease do
4
+
5
+ add_release :debian, 6
6
+
7
+ add_release :el, 5
8
+ add_release :el, 6
9
+
10
+ add_release :sles, 11
11
+
12
+ add_release :solaris, 10
13
+
14
+ add_release :ubuntu, '10.04'
15
+ add_release :ubuntu, '12.04'
16
+
17
+ add_release :windows, '2003'
18
+ add_release :windows, '2008R2'
19
+ add_release :windows, 7
20
+
21
+ set_answer_file :master, File.join(PEBuild.template_dir, 'answers', 'master-2.x.txt.erb')
22
+ set_answer_file :agent, File.join(PEBuild.template_dir, 'answers', 'agent-2.x.txt.erb')
23
+ end
24
+
25
+ @releases['2.6.0'] = two_six_x
26
+ @releases['2.6.1'] = two_six_x
27
+ end
@@ -0,0 +1,28 @@
1
+ module PEBuild::Release
2
+
3
+ two_seven_x = newrelease do
4
+
5
+ add_release :debian, 6
6
+
7
+ add_release :el, 5
8
+ add_release :el, 6
9
+
10
+ add_release :sles, 11
11
+
12
+ add_release :solaris, 10
13
+
14
+ add_release :ubuntu, '10.04'
15
+ add_release :ubuntu, '12.04'
16
+
17
+ add_release :windows, '2003'
18
+ add_release :windows, '2008R2'
19
+ add_release :windows, 7
20
+
21
+ set_answer_file :master, File.join(PEBuild.template_dir, 'answers', 'master-2.x.txt.erb')
22
+ set_answer_file :agent, File.join(PEBuild.template_dir, 'answers', 'agent-2.x.txt.erb')
23
+ end
24
+
25
+ @releases['2.7.0'] = two_seven_x
26
+ @releases['2.7.1'] = two_seven_x
27
+ @releases['2.7.2'] = two_seven_x
28
+ end
@@ -0,0 +1,35 @@
1
+ module PEBuild::Release
2
+
3
+ two_eight_x = newrelease do
4
+
5
+ add_release :debian, 6
6
+
7
+ add_release :el, 5
8
+ add_release :el, 6
9
+
10
+ add_release :sles, 11
11
+
12
+ add_release :solaris, 10
13
+
14
+ add_release :ubuntu, '10.04'
15
+ add_release :ubuntu, '12.04'
16
+
17
+ add_release :windows, '2003'
18
+ add_release :windows, '2008R2'
19
+ add_release :windows, 7
20
+
21
+ # PE 2.8 adds support for AIX, but as of 2013-08-12 Vagrant has nothing
22
+ # remotely resembling support for AIX WPARs or LPARs. Since it's meaningless
23
+ # to try to add support for AIX, we just leave this commented out.
24
+ #
25
+ # add_release :aix, '5.3'
26
+ # add_release :aix, '6.1'
27
+ # add_release :aix, '7.1'
28
+
29
+ set_answer_file :master, File.join(PEBuild.template_dir, 'answers', 'master-2.x.txt.erb')
30
+ set_answer_file :agent, File.join(PEBuild.template_dir, 'answers', 'agent-2.x.txt.erb')
31
+ end
32
+
33
+ @releases['2.8.1'] = two_eight_x
34
+ @releases['2.8.2'] = two_eight_x
35
+ end
@@ -0,0 +1,36 @@
1
+ module PEBuild::Release
2
+
3
+ three_oh_x = newrelease do
4
+
5
+ add_release :debian, 6
6
+
7
+ add_release :el, 5
8
+ add_release :el, 6
9
+
10
+ #add_release :sles, 11
11
+
12
+ add_release :solaris, 10
13
+
14
+ add_release :ubuntu, '10.04'
15
+ add_release :ubuntu, '12.04'
16
+
17
+ add_release :windows, '2003'
18
+ add_release :windows, '2008R2'
19
+ add_release :windows, 7
20
+ add_release :windows, '2012'
21
+
22
+ # PE 2.8 adds support for AIX, but as of 2013-08-12 Vagrant has nothing
23
+ # remotely resembling support for AIX WPARs or LPARs. Since it's meaningless
24
+ # to try to add support for AIX, we just leave this commented out.
25
+ #
26
+ # add_release :aix, '5.3'
27
+ # add_release :aix, '6.1'
28
+ # add_release :aix, '7.1'
29
+
30
+ set_answer_file :master, File.join(PEBuild.template_dir, 'answers', 'master-3.x.txt.erb')
31
+ set_answer_file :agent, File.join(PEBuild.template_dir, 'answers', 'agent-3.x.txt.erb')
32
+ end
33
+
34
+ @releases['3.0.0'] = three_oh_x
35
+ end
36
+
@@ -0,0 +1,63 @@
1
+ # Define a Puppet Enterprise release
2
+ #
3
+ # @api private
4
+ class PEBuild::Release::Instance
5
+
6
+ attr_reader :version
7
+
8
+ def initialize(&blk)
9
+
10
+ @supported = Hash.new { |hash, key| hash[key] = Set.new }
11
+
12
+ @answer_files = {}
13
+
14
+ instance_eval(&blk) if blk
15
+ end
16
+
17
+ # Determine if Puppet Enterprise supports the specific release
18
+ #
19
+ # @param distro [String] The distribution to check
20
+ # @param dist_version [String] The version release to check
21
+ #
22
+ # @return [true, false]
23
+ def supports?(distro, dist_release)
24
+ distro = distro.to_sym unless distro.is_a? Symbol
25
+ dist_release = dist_release.to_s unless dist_release.is_a? String
26
+
27
+ @supported[distro].include? dist_release
28
+ end
29
+
30
+ # Return the answer file template for the given role and release of PE
31
+ #
32
+ # @param role [Symbol] The role for the template
33
+ #
34
+ # @return
35
+ def answer_file(role)
36
+ @answer_files[role]
37
+ end
38
+
39
+ private
40
+
41
+ # Define a distribution release as supported.
42
+ #
43
+ # @param distro [String] The distribution to add
44
+ # @param dist_version [String] The version release to add
45
+ #
46
+ # @return [void]
47
+ def add_release(distro, dist_release)
48
+ distro = distro.to_sym unless distro.is_a? Symbol
49
+ dist_release = dist_release.to_s unless dist_release.is_a? String
50
+
51
+ @supported[distro].add dist_release
52
+ end
53
+
54
+ # Set the answer file template for a given role
55
+ #
56
+ # @param role [Symbol] The role for the template
57
+ # @param path [String] The path to the template
58
+ #
59
+ # @return [void]
60
+ def set_answer_file(role, path)
61
+ @answer_files[role] = path
62
+ end
63
+ end
@@ -0,0 +1,25 @@
1
+ module PEBuild
2
+ module Transfer
3
+ require 'pe_build/transfer/open_uri'
4
+ require 'pe_build/transfer/file'
5
+
6
+ IMPLEMENTATIONS = {
7
+ 'http' => PEBuild::Transfer::OpenURI,
8
+ 'https' => PEBuild::Transfer::OpenURI,
9
+ 'ftp' => PEBuild::Transfer::OpenURI,
10
+ 'file' => PEBuild::Transfer::File,
11
+ nil => PEBuild::Transfer::File, # Assume that URIs without a scheme are files
12
+ }
13
+
14
+ def self.generate(src, dst)
15
+ scheme = src.scheme
16
+
17
+ if (klass = IMPLEMENTATIONS[scheme])
18
+ klass.new(src, dst)
19
+ else
20
+ raise "URI scheme #{scheme.inspect} cannot be handled by any file transferrers"
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -1,18 +1,20 @@
1
1
  require 'fileutils'
2
+ require 'pe_build/idempotent'
2
3
 
3
- module PEBuild
4
- module Transfer
5
- class File
4
+ class PEBuild::Transfer::File
6
5
 
7
- # @param src [String] The path to the file to copy
6
+ # @param src [URI] The local file path path to the file to copy
8
7
  # @param dst [String] The path to destination of the copied file
9
- def initialize(src, dst)
10
- @src, @dst = src, dst
8
+ def initialize(uri, dst)
9
+ @src = uri.path
10
+ @dst = dst
11
+
12
+ @logger = Log4r::Logger.new('vagrant::pe_build::transfer::file')
11
13
  end
12
14
 
15
+ include PEBuild::Idempotent
16
+
13
17
  def copy
14
- FileUtils.cp @src, @dst
18
+ idempotent(@dst) { FileUtils.cp @src, @dst }
15
19
  end
16
20
  end
17
- end
18
- end
@@ -0,0 +1,62 @@
1
+ require 'pe_build/version'
2
+ require 'pe_build/idempotent'
3
+
4
+ require 'open-uri'
5
+ require 'progressbar'
6
+
7
+ class PEBuild::Transfer::OpenURI
8
+
9
+ class DownloadFailed < Vagrant::Errors::VagrantError
10
+ error_key(:download_failed, 'pebuild.transfer.open_uri')
11
+ end
12
+
13
+ # @param uri [URI] The http(s) URI to the file to copy
14
+ # @param dst [String] The path to destination of the copied file
15
+ def initialize(uri, dst)
16
+ @uri, @dst = uri, dst
17
+
18
+ @logger = Log4r::Logger.new('vagrant::pe_build::transfer::open_uri')
19
+ end
20
+
21
+ include PEBuild::Idempotent
22
+
23
+ def copy
24
+ idempotent(@dst) do
25
+ tmpfile = download_file
26
+ FileUtils.mv(tmpfile, @dst)
27
+ end
28
+ rescue ::OpenURI::HTTPError => e
29
+ raise DownloadFailed, :uri => @uri, :msg => e.message
30
+ end
31
+
32
+ HEADERS = {'User-Agent' => "Vagrant/PEBuild (v#{PEBuild::VERSION})"}
33
+
34
+ private
35
+
36
+ # Open a open-uri file handle for the given URL
37
+ #
38
+ # @return [IO]
39
+ def download_file
40
+ progress = nil
41
+
42
+ content_length_proc = lambda do |length|
43
+ if length and length > 0
44
+ progress = ProgressBar.new('Fetching file', length)
45
+ progress.file_transfer_mode
46
+ end
47
+ end
48
+
49
+ progress_proc = lambda do |size|
50
+ progress.set(size) if progress
51
+ end
52
+
53
+ options = HEADERS.merge({
54
+ :content_length_proc => content_length_proc,
55
+ :progress_proc => progress_proc,
56
+ })
57
+
58
+ @logger.info "Fetching file from #{@uri}"
59
+
60
+ @uri.open(options)
61
+ end
62
+ end
@@ -1,3 +1,3 @@
1
1
  module PEBuild
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -4,7 +4,7 @@ q_puppet_enterpriseconsole_install=n
4
4
  q_puppet_symlinks_install=y
5
5
  q_puppetagent_certname=<%= @machine.name %>
6
6
  q_puppetagent_install=y
7
- q_puppetagent_server=<%= config.master %>
7
+ q_puppetagent_server=<%= @config.master %>
8
8
  q_puppetmaster_install=n
9
9
  q_vendor_packages_install=y
10
10
  q_continue_or_reenter_master_hostname=c
@@ -0,0 +1,16 @@
1
+ q_fail_on_unsuccessful_master_lookup=y
2
+ q_install=y
3
+ q_puppet_cloud_install=n
4
+ q_puppet_enterpriseconsole_install=n
5
+ q_puppet_symlinks_install=y
6
+ q_puppetagent_certname=<%= @machine.name %>
7
+ q_puppetagent_install=y
8
+ q_puppetagent_server=<%= @config.master %>
9
+ q_puppetca_install=n
10
+ q_puppetdb_hostname=
11
+ q_puppetdb_install=n
12
+ q_puppetdb_port=
13
+ q_puppetmaster_install=n
14
+ q_vendor_packages_install=y
15
+ q_continue_or_reenter_master_hostname=c
16
+ q_verify_packages=y
@@ -0,0 +1,44 @@
1
+ q_all_in_one_install=y
2
+ q_database_host=localhost
3
+ q_database_install=y
4
+ q_database_port=5432
5
+ q_database_root_password=wcAdzLoHz6Vpzp6TJPLT
6
+ q_database_root_user=pe-postgres
7
+ q_install=y
8
+ q_pe_database=y
9
+ q_puppet_cloud_install=y
10
+ q_puppet_enterpriseconsole_auth_database_name=console_auth
11
+ q_puppet_enterpriseconsole_auth_database_password=y33blQzfW9ZiCSpSztlN
12
+ q_puppet_enterpriseconsole_auth_database_user=console_auth
13
+ q_puppet_enterpriseconsole_auth_password=puppetlabs
14
+ q_puppet_enterpriseconsole_auth_user_email=admin@puppetlabs.com
15
+ q_puppet_enterpriseconsole_database_name=console
16
+ q_puppet_enterpriseconsole_database_password=aX5nCiKbkjKEBVzW0tCx
17
+ q_puppet_enterpriseconsole_database_user=console
18
+ q_puppet_enterpriseconsole_httpd_port=443
19
+ q_puppet_enterpriseconsole_install=y
20
+ q_puppet_enterpriseconsole_master_hostname=master
21
+ q_puppet_enterpriseconsole_smtp_host=localhost
22
+ q_puppet_enterpriseconsole_smtp_password=
23
+ q_puppet_enterpriseconsole_smtp_port=25
24
+ q_puppet_enterpriseconsole_smtp_use_tls=n
25
+ q_puppet_enterpriseconsole_smtp_user_auth=n
26
+ q_puppet_enterpriseconsole_smtp_username=
27
+ q_puppet_symlinks_install=y
28
+ q_puppetagent_certname=<%= @machine.name %>
29
+ q_puppetagent_install=y
30
+ q_puppetagent_server=<%= @machine.name %>
31
+ q_puppetdb_database_name=pe-puppetdb
32
+ q_puppetdb_database_password=MCPaKB0ERo0FlAN60sny
33
+ q_puppetdb_database_user=pe-puppetdb
34
+ q_puppetdb_hostname=<%= @machine.name %>
35
+ q_puppetdb_install=y
36
+ q_puppetdb_port=8081
37
+ q_puppetmaster_certname=<%= @machine.name %>
38
+ q_puppetmaster_dnsaltnames=<%= @machine.name %>,puppet
39
+ q_puppetmaster_enterpriseconsole_hostname=localhost
40
+ q_puppetmaster_enterpriseconsole_port=443
41
+ q_puppetmaster_install=y
42
+ q_run_updtvpkg=n
43
+ q_vendor_packages_install=y
44
+ q_verify_packages=y