vagrant-pe_build 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -0
- data/README.markdown +10 -10
- data/lib/pe_build.rb +15 -7
- data/lib/pe_build/archive.rb +112 -0
- data/lib/pe_build/archive_collection.rb +43 -0
- data/lib/pe_build/command.rb +48 -11
- data/lib/pe_build/command/copy.rb +38 -0
- data/lib/pe_build/command/download.rb +34 -3
- data/lib/pe_build/command/list.rb +16 -4
- data/lib/pe_build/config/global.rb +69 -0
- data/lib/pe_build/config/pe_bootstrap.rb +110 -0
- data/lib/pe_build/config_default.rb +16 -0
- data/lib/pe_build/idempotent.rb +16 -0
- data/lib/pe_build/plugin.rb +38 -0
- data/lib/pe_build/provisioner/pe_bootstrap.rb +202 -0
- data/lib/pe_build/transfer/file.rb +18 -0
- data/lib/pe_build/transfer/uri.rb +53 -0
- data/lib/pe_build/unpack/tar.rb +38 -0
- data/lib/pe_build/util/config.rb +29 -0
- data/lib/pe_build/version.rb +1 -1
- data/lib/{vagrant_init.rb → vagrant-pe_build.rb} +0 -0
- data/templates/answers/agent.txt.erb +1 -1
- data/templates/answers/master-existing-db.txt.erb +2 -2
- data/templates/answers/master.txt.erb +2 -2
- data/templates/locales/en.yml +7 -0
- data/{bootstrap/master/post/relocate_puppet.sh → templates/scripts/relocate_installation.sh} +0 -0
- data/vagrant-pe_build.gemspec +2 -1
- metadata +40 -17
- data/bootstrap/base/provision/install_puppet_enterprise.sh +0 -10
- data/lib/pe_build/action.rb +0 -20
- data/lib/pe_build/action/download.rb +0 -56
- data/lib/pe_build/action/unpackage.rb +0 -70
- data/lib/pe_build/config.rb +0 -35
- data/lib/pe_build/provisioners.rb +0 -9
- data/lib/pe_build/provisioners/puppet_enterprise.rb +0 -1
- data/lib/pe_build/provisioners/puppet_enterprise_bootstrap.rb +0 -171
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -12,19 +12,19 @@ on Vagrant boxes to rapidly build a functioning Puppet environment.
|
|
12
12
|
Usage
|
13
13
|
-----
|
14
14
|
|
15
|
-
Vagrant
|
15
|
+
Vagrant.configure('2') do |config|
|
16
16
|
config.pe_build.download_root = 'http://my.pe.download.mirror/installers'
|
17
17
|
config.pe_build.version = '2.7.0'
|
18
18
|
config.pe_build.filename = 'puppet-enterprise-2.7.0-all.tar.gz'
|
19
19
|
|
20
20
|
config.vm.define 'master' do |node|
|
21
|
-
node.vm.provision :
|
21
|
+
node.vm.provision :pe_bootstrap do |provisioner|
|
22
22
|
provisioner.role = :master
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
config.vm.define 'agent1' do |node|
|
27
|
-
node.vm.provision :
|
27
|
+
node.vm.provision :pe_bootstrap do |provisioner|
|
28
28
|
provisioner.role = :agent
|
29
29
|
end
|
30
30
|
end
|
@@ -33,20 +33,20 @@ Usage
|
|
33
33
|
Requirements
|
34
34
|
------------
|
35
35
|
|
36
|
-
`vagrant-pe_build` shells out to `curl` and `tar` so you'll need those
|
37
|
-
available.
|
38
|
-
|
39
36
|
[vagranthosts]: https://github.com/adrienthebo/vagrant-hosts
|
40
37
|
|
41
38
|
Puppet Enterprise relies on SSL for security so you'll need to ensure that your
|
42
39
|
SSL configuration isn't borked. [vagrant-hosts][vagranthosts] is recommended to
|
43
40
|
configure VMs with semi-sane DNS.
|
44
41
|
|
42
|
+
Guest VMs need to be able to directly communicate. You'll need to ensure that
|
43
|
+
they have private network interfaces prepared.
|
44
|
+
|
45
45
|
Contact
|
46
46
|
-------
|
47
47
|
|
48
|
-
* Source code
|
49
|
-
* Issue tracker
|
48
|
+
* [Source code](https://github.com/adrienthebo/vagrant-pe_build)
|
49
|
+
* [Issue tracker](https://github.com/adrienthebo/vagrant-pe_build/issues)
|
50
50
|
|
51
|
-
If you have questions or concerns about this module, contact finch on
|
52
|
-
|
51
|
+
If you have questions or concerns about this module, contact finch on on
|
52
|
+
Freenode, or email adrien@puppetlabs.com.
|
data/lib/pe_build.rb
CHANGED
@@ -1,17 +1,25 @@
|
|
1
1
|
require 'vagrant'
|
2
2
|
|
3
3
|
module PEBuild
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
# Return the path to the archived PE builds
|
6
|
+
#
|
7
|
+
# @param env [Vagrant::Environment]
|
8
|
+
def self.archive_directory(env)
|
9
|
+
File.expand_path('pe_builds', env.home_path)
|
6
10
|
end
|
7
11
|
|
8
12
|
def self.source_root
|
9
|
-
|
13
|
+
File.expand_path('..', File.dirname(__FILE__))
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.template_dir
|
17
|
+
File.expand_path('templates', source_root)
|
10
18
|
end
|
11
19
|
end
|
12
20
|
|
21
|
+
# I18n to load the en locale
|
22
|
+
I18n.load_path << File.expand_path("locales/en.yml", PEBuild.template_dir)
|
23
|
+
|
24
|
+
require 'pe_build/plugin'
|
13
25
|
require 'pe_build/version'
|
14
|
-
require 'pe_build/action'
|
15
|
-
require 'pe_build/config'
|
16
|
-
require 'pe_build/command'
|
17
|
-
require 'pe_build/provisioners'
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'pe_build'
|
2
|
+
require 'pe_build/idempotent'
|
3
|
+
require 'pe_build/archive_collection'
|
4
|
+
|
5
|
+
require 'pe_build/transfer/file'
|
6
|
+
require 'pe_build/transfer/uri'
|
7
|
+
|
8
|
+
require 'pe_build/unpack/tar'
|
9
|
+
|
10
|
+
require 'fileutils'
|
11
|
+
|
12
|
+
module PEBuild
|
13
|
+
|
14
|
+
class ArchiveNoInstallerSource < Vagrant::Errors::VagrantError
|
15
|
+
error_key(:no_installer_source, "pebuild.archive")
|
16
|
+
end
|
17
|
+
|
18
|
+
class Archive
|
19
|
+
# Represents a packed Puppet Enterprise archive
|
20
|
+
|
21
|
+
include PEBuild::Idempotent
|
22
|
+
|
23
|
+
# @!attribute [rw] version
|
24
|
+
# @return [String] The version of Puppet Enterprise
|
25
|
+
attr_accessor :version
|
26
|
+
|
27
|
+
# @!attribute [rw] filename
|
28
|
+
# @return [String] The filename. Thing
|
29
|
+
attr_accessor :filename
|
30
|
+
|
31
|
+
attr_accessor :env
|
32
|
+
|
33
|
+
# @param filename [String] The uninterpolated filename
|
34
|
+
# @param env [Hash]
|
35
|
+
def initialize(filename, env)
|
36
|
+
@filename = filename
|
37
|
+
@env = env
|
38
|
+
end
|
39
|
+
|
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)
|
44
|
+
|
45
|
+
idempotent(path, "Unpacked archive #{versioned_path filename}") do
|
46
|
+
tar.unpack
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
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))
|
53
|
+
|
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
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
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."
|
66
|
+
|
67
|
+
archive_dir = PEBuild.archive_directory(@env)
|
68
|
+
|
69
|
+
collection = PEBuild::ArchiveCollection.new(archive_dir, @env)
|
70
|
+
collection.display
|
71
|
+
|
72
|
+
raise PEBuild::ArchiveNoInstallerSource
|
73
|
+
else
|
74
|
+
str = versioned_path("#{download_dir}/#{@filename}")
|
75
|
+
|
76
|
+
prepare_for_copy!
|
77
|
+
transfer = PEBuild::Transfer::URI.new(str, archive_path)
|
78
|
+
transfer.copy
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
# Initialize the PE directory
|
86
|
+
#
|
87
|
+
# @todo respect Vagrant home setting
|
88
|
+
def prepare_for_copy!
|
89
|
+
archive_dir = PEBuild.archive_directory(@env)
|
90
|
+
|
91
|
+
if not File.directory? archive_dir
|
92
|
+
FileUtils.mkdir_p archive_dir
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
# @return [String] The interpolated archive path
|
98
|
+
def archive_path
|
99
|
+
archive_dir = PEBuild.archive_directory(@env)
|
100
|
+
path = File.join(archive_dir, @filename)
|
101
|
+
versioned_path(path)
|
102
|
+
end
|
103
|
+
|
104
|
+
def versioned_path(path)
|
105
|
+
if @version
|
106
|
+
path.gsub(/:version/, @version)
|
107
|
+
else
|
108
|
+
path
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'pe_build/archive'
|
2
|
+
|
3
|
+
module PEBuild
|
4
|
+
|
5
|
+
class ArchiveCollection
|
6
|
+
|
7
|
+
#ARCHIVE_REGEX = %r[puppet-enterprise-([\d.])-(.*?)\.(?:tar\.gz|msi)]
|
8
|
+
|
9
|
+
attr_reader :path
|
10
|
+
|
11
|
+
def initialize(path, env)
|
12
|
+
@path, @env = path, env
|
13
|
+
@archives = []
|
14
|
+
|
15
|
+
load_archives
|
16
|
+
end
|
17
|
+
|
18
|
+
def archives
|
19
|
+
@archives
|
20
|
+
end
|
21
|
+
|
22
|
+
include Enumerable
|
23
|
+
def each(&blk)
|
24
|
+
@archives.each { |archive| yield archive }
|
25
|
+
end
|
26
|
+
|
27
|
+
def display
|
28
|
+
@archives.each do |archive|
|
29
|
+
@env.ui.info " - #{archive.filename}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
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)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/pe_build/command.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
require 'pe_build'
|
2
1
|
require 'vagrant'
|
3
2
|
|
4
|
-
|
3
|
+
module PEBuild
|
4
|
+
class Command < Vagrant.plugin(2, :command)
|
5
|
+
|
5
6
|
def initialize(argv, env)
|
6
|
-
|
7
|
+
super
|
7
8
|
|
8
9
|
@main_args, @subcommand, @sub_args = split_main_and_subcommand(argv)
|
9
10
|
|
10
|
-
# Is this even remotely sane? Are we verging on cargo cult programming?
|
11
11
|
@subcommands = Vagrant::Registry.new
|
12
12
|
|
13
|
-
|
14
|
-
@subcommands.register('list') { PEBuild::Command::List }
|
13
|
+
register_subcommands
|
15
14
|
end
|
16
15
|
|
17
16
|
def execute
|
@@ -20,12 +19,50 @@ class PEBuild::Command < Vagrant::Command::Base
|
|
20
19
|
elsif @subcommand
|
21
20
|
raise "Unrecognized subcommand #{@subcommand}"
|
22
21
|
else
|
23
|
-
|
22
|
+
print_help
|
24
23
|
end
|
25
24
|
end
|
26
|
-
end
|
27
25
|
|
28
|
-
|
29
|
-
|
26
|
+
private
|
27
|
+
|
28
|
+
def register_subcommands
|
29
|
+
@subcommands.register('copy') do
|
30
|
+
require_relative 'command/copy'
|
31
|
+
PEBuild::Command::Copy
|
32
|
+
end
|
33
|
+
|
34
|
+
@subcommands.register('download') do
|
35
|
+
require_relative 'command/download'
|
36
|
+
PEBuild::Command::Download
|
37
|
+
end
|
38
|
+
|
39
|
+
@subcommands.register('list') do
|
40
|
+
require_relative 'command/list'
|
41
|
+
PEBuild::Command::List
|
42
|
+
end
|
43
|
+
end
|
30
44
|
|
31
|
-
|
45
|
+
def print_help
|
46
|
+
cmd = 'vagrant pe-build'
|
47
|
+
opts = OptionParser.new do |opts|
|
48
|
+
opts.banner = "Usage: #{cmd} <command> [<args>]"
|
49
|
+
opts.separator ""
|
50
|
+
opts.separator "Available subcommands:"
|
51
|
+
|
52
|
+
# Add the available subcommands as separators in order to print them
|
53
|
+
# out as well.
|
54
|
+
keys = []
|
55
|
+
@subcommands.each { |key, value| keys << key.to_s }
|
56
|
+
|
57
|
+
keys.sort.each do |key|
|
58
|
+
opts.separator " #{key}"
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.separator ""
|
62
|
+
opts.separator "For help on any individual command run `#{cmd} COMMAND -h`"
|
63
|
+
end
|
64
|
+
|
65
|
+
@env.ui.info(opts.help, :prefix => false)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require 'optparse'
|
3
|
+
require 'pe_build/archive'
|
4
|
+
|
5
|
+
module PEBuild
|
6
|
+
class Command
|
7
|
+
class Copy < Vagrant.plugin(2, :command)
|
8
|
+
|
9
|
+
def execute
|
10
|
+
|
11
|
+
options = {}
|
12
|
+
|
13
|
+
parser = OptionParser.new do |o|
|
14
|
+
o.banner = "Usage: vagrant pe-build copy path/to/installer.tar.gz"
|
15
|
+
o.separator ''
|
16
|
+
|
17
|
+
o.on('-v', '--version=val', String, "The version of PE to fetch") do |val|
|
18
|
+
options[:version] = val
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
argv = parse_options(parser)
|
23
|
+
fpath = argv.last
|
24
|
+
|
25
|
+
basename = File.basename(fpath)
|
26
|
+
dirname = File.dirname(fpath)
|
27
|
+
|
28
|
+
#unless options[:version]
|
29
|
+
# raise Vagrant::Errors::CLIInvalidUsage, :help => parser.help.chomp
|
30
|
+
#end
|
31
|
+
|
32
|
+
archive = PEBuild::Archive.new(fpath, @env)
|
33
|
+
archive.version = options[:version]
|
34
|
+
archive.copy_from(dirname)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,8 +1,39 @@
|
|
1
|
-
require 'pe_build'
|
2
1
|
require 'vagrant'
|
2
|
+
require 'optparse'
|
3
|
+
require 'pe_build/archive'
|
4
|
+
|
5
|
+
module PEBuild
|
6
|
+
class Command
|
7
|
+
class Download < Vagrant.plugin(2, :command)
|
3
8
|
|
4
|
-
class PEBuild::Command::Download < Vagrant::Command::Base
|
5
9
|
def execute
|
6
|
-
|
10
|
+
|
11
|
+
options = {}
|
12
|
+
|
13
|
+
parser = OptionParser.new do |o|
|
14
|
+
o.banner = "Usage: vagrant pe-build download --version <version> --dir <dir>"
|
15
|
+
o.separator ''
|
16
|
+
|
17
|
+
o.on('-v', '--version=val', String, "The version of PE to fetch") do |val|
|
18
|
+
options[:version] = val
|
19
|
+
end
|
20
|
+
|
21
|
+
o.on('-d', '--dir=val', String, 'The URL basedir containing the file') do |val|
|
22
|
+
options[:dir] = val
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
argv = parse_options(parser)
|
27
|
+
filename = argv.last
|
28
|
+
|
29
|
+
unless options[:version]
|
30
|
+
raise Vagrant::Errors::CLIInvalidUsage, :help => parser.help.chomp
|
31
|
+
end
|
32
|
+
|
33
|
+
archive = PEBuild::Archive.new(filename, @env)
|
34
|
+
archive.version = options[:version]
|
35
|
+
archive.download_from(options[:dir])
|
7
36
|
end
|
8
37
|
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,10 +1,22 @@
|
|
1
1
|
require 'vagrant'
|
2
|
-
|
2
|
+
require 'pe_build/archive_collection'
|
3
|
+
|
4
|
+
module PEBuild
|
5
|
+
class Command
|
6
|
+
class List < Vagrant.plugin(2, :command)
|
3
7
|
def execute
|
4
|
-
|
5
|
-
|
8
|
+
archive_dir = PEBuild.archive_directory(@env)
|
9
|
+
|
10
|
+
if File.directory? archive_dir
|
11
|
+
@env.ui.info "PE versions available (at #{archive_dir})"
|
12
|
+
@env.ui.info "---"
|
13
|
+
|
14
|
+
collection = PEBuild::ArchiveCollection.new(archive_dir, @env)
|
15
|
+
collection.display
|
6
16
|
else
|
7
|
-
warn "No PE versions
|
17
|
+
@env.ui.warn "No PE versions available at #{archive_dir}"
|
8
18
|
end
|
9
19
|
end
|
10
20
|
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'vagrant'
|
3
|
+
|
4
|
+
require 'pe_build/config_default'
|
5
|
+
|
6
|
+
module PEBuild
|
7
|
+
module Config
|
8
|
+
|
9
|
+
class Global < Vagrant.plugin('2', :config)
|
10
|
+
|
11
|
+
# @todo This value should be discovered based on what versions of the
|
12
|
+
# installer are cached.
|
13
|
+
#DEFAULT_PE_VERSION = '2.7.2'
|
14
|
+
|
15
|
+
# @!attribute download_root
|
16
|
+
attr_accessor :download_root
|
17
|
+
|
18
|
+
# @!attribute version
|
19
|
+
attr_accessor :version
|
20
|
+
|
21
|
+
# @!attribute suffix
|
22
|
+
attr_accessor :suffix
|
23
|
+
|
24
|
+
# @!attribute filename
|
25
|
+
attr_accessor :filename
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@download_root = UNSET_VALUE
|
29
|
+
@version = UNSET_VALUE
|
30
|
+
@suffix = UNSET_VALUE
|
31
|
+
@filename = UNSET_VALUE
|
32
|
+
end
|
33
|
+
|
34
|
+
include PEBuild::ConfigDefault
|
35
|
+
|
36
|
+
def finalize!
|
37
|
+
set_default :@suffix, 'all'
|
38
|
+
#set_default :@version, DEFAULT_PE_VERSION
|
39
|
+
set_default :@filename, "puppet-enterprise-:version-#{suffix}.tar.gz"
|
40
|
+
|
41
|
+
set_default :@download_root, nil
|
42
|
+
end
|
43
|
+
|
44
|
+
# @todo Convert error strings to I18n
|
45
|
+
def validate(machine)
|
46
|
+
errors = []
|
47
|
+
|
48
|
+
# Allow Global version to be unset, rendering it essentially optional. If it is
|
49
|
+
# discovered to be unset by a configuration on the next level up who cannot provide a
|
50
|
+
# value, it is that configuration's job to take action.
|
51
|
+
if @version.kind_of? String
|
52
|
+
unless @version.match /\d+\.\d+(\.\d+)?/
|
53
|
+
errors << "version must be a valid version string, got #{@version.inspect}"
|
54
|
+
end
|
55
|
+
elsif @version != UNSET_VALUE
|
56
|
+
errors << "version only accepts a string, got #{@version.class}"
|
57
|
+
end
|
58
|
+
|
59
|
+
uri = URI.parse(@download_root) rescue nil
|
60
|
+
unless @download_root == UNSET_VALUE or @download_root.nil? or File.directory?(File.expand_path(@download_root)) or uri.kind_of? (URI::HTTP||URI::HTTPS) or uri.kind_of? URI::FTP
|
61
|
+
errors << "download_root must be valid URL or present local file path, got #{@download_root}"
|
62
|
+
end
|
63
|
+
|
64
|
+
{"PE Build global config" => errors}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|