vagrant-pe_build 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/LICENSE +14 -0
- data/bootstrap/base/provision/install_puppet_enterprise.sh +10 -0
- data/bootstrap/master/post/relocate_puppet.sh +23 -0
- data/doc/answers/README.markdown +1 -0
- data/doc/answers/agent.txt +10 -0
- data/doc/answers/master-1.1.txt +22 -0
- data/doc/answers/master-2.0.0.txt +42 -0
- data/doc/answers/master-2.5.0.txt +36 -0
- data/doc/answers/master-db.txt +52 -0
- data/lib/pe_build/action/download.rb +56 -0
- data/lib/pe_build/action/unpackage.rb +70 -0
- data/lib/pe_build/action.rb +20 -0
- data/lib/pe_build/command/download.rb +8 -0
- data/lib/pe_build/command/list.rb +10 -0
- data/lib/pe_build/command.rb +31 -0
- data/lib/pe_build/config.rb +30 -0
- data/lib/pe_build/provisioners/puppet_enterprise.rb +1 -0
- data/lib/pe_build/provisioners/puppet_enterprise_bootstrap.rb +132 -0
- data/lib/pe_build/provisioners.rb +9 -0
- data/lib/pe_build/version.rb +3 -0
- data/lib/pe_build.rb +17 -0
- data/templates/answers/agent.txt.erb +10 -0
- data/templates/answers/master.txt.erb +52 -0
- data/vagrant-pe_build.gemspec +20 -0
- metadata +85 -0
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gemspec
|
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright 2012 Adrien Thebo
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
if [ -f /opt/puppet/bin/puppet ]; then
|
2
|
+
echo "Puppet Enterprise already present, version $(/opt/puppet/bin/puppet --version)"
|
3
|
+
echo "Skipping installation."
|
4
|
+
else
|
5
|
+
<%= @installer_cmd %>
|
6
|
+
echo
|
7
|
+
echo
|
8
|
+
echo " -- Notice: scheduling Puppet run in one minute to install mcollective"
|
9
|
+
echo "/opt/puppet/bin/puppet agent --onetime --noop" | at next minute
|
10
|
+
fi
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Update puppet.conf to add the manifestdir directive to point to the
|
2
|
+
# /manifests mount, if the directive isn't already present.
|
3
|
+
sed -i '
|
4
|
+
2 {
|
5
|
+
/manifest/ !i\
|
6
|
+
manifestdir = /manifests
|
7
|
+
}
|
8
|
+
' /etc/puppetlabs/puppet/puppet.conf
|
9
|
+
|
10
|
+
# Update puppet.conf to add the modulepath directive to point to the
|
11
|
+
# /module mount, if it hasn't already been set.
|
12
|
+
sed -i '
|
13
|
+
/modulepath/ {
|
14
|
+
/vagrant/ !s,$,:/modules,
|
15
|
+
}
|
16
|
+
' /etc/puppetlabs/puppet/puppet.conf
|
17
|
+
|
18
|
+
# Rewrite the olde site.pp config since it's not used, and warn people
|
19
|
+
# about this.
|
20
|
+
echo '# /etc/puppetlabs/puppet/manifests is not used; see /manifests.' > /etc/puppetlabs/puppet/manifests/site.pp
|
21
|
+
|
22
|
+
# Enable autosigning on the master
|
23
|
+
echo '*' > /etc/puppetlabs/puppet/autosign.conf
|
@@ -0,0 +1 @@
|
|
1
|
+
These are reference answers files for the various versions of PE.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_cloud_install=n
|
3
|
+
q_puppet_enterpriseconsole_install=n
|
4
|
+
q_puppet_symlinks_install=y
|
5
|
+
q_puppetagent_certname=$(hostname -s)
|
6
|
+
q_puppetagent_install=y
|
7
|
+
q_puppetagent_server=master
|
8
|
+
q_puppetmaster_install=n
|
9
|
+
q_vendor_packages_install=y
|
10
|
+
q_continue_or_reenter_master_hostname=c
|
@@ -0,0 +1,22 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_symlinks_install=y
|
3
|
+
q_puppetagent_certname=master
|
4
|
+
q_puppetagent_install=y
|
5
|
+
q_puppetagent_pluginsync=y
|
6
|
+
q_puppetagent_server=master
|
7
|
+
q_puppetdashboard_database_install=y
|
8
|
+
q_puppetdashboard_database_name=console
|
9
|
+
q_puppetdashboard_database_password=puppet
|
10
|
+
q_puppetdashboard_database_root_password=puppet
|
11
|
+
q_puppetdashboard_database_user=console
|
12
|
+
q_puppetdashboard_httpd_port=443
|
13
|
+
q_puppetdashboard_install=y
|
14
|
+
q_puppetmaster_certdnsnames=master:puppet
|
15
|
+
q_puppetmaster_certname=master
|
16
|
+
q_puppetmaster_dashboard_hostname=master
|
17
|
+
q_puppetmaster_dashboard_port=443
|
18
|
+
q_puppetmaster_install=y
|
19
|
+
q_puppetmaster_use_dashboard_classifier=y
|
20
|
+
q_puppetmaster_use_dashboard_reports=y
|
21
|
+
q_rubydevelopment_install=y
|
22
|
+
q_vendor_packages_install=y
|
@@ -0,0 +1,42 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_cloud_install=n
|
3
|
+
q_puppet_enterpriseconsole_auth_database_name=console_auth
|
4
|
+
q_puppet_enterpriseconsole_auth_database_password=console_auth
|
5
|
+
q_puppet_enterpriseconsole_auth_database_user=console_auth
|
6
|
+
q_puppet_enterpriseconsole_auth_password=console
|
7
|
+
q_puppet_enterpriseconsole_auth_user_email=console@example.com
|
8
|
+
q_puppet_enterpriseconsole_database_install=y
|
9
|
+
q_puppet_enterpriseconsole_database_name=console
|
10
|
+
q_puppet_enterpriseconsole_database_password=console
|
11
|
+
q_puppet_enterpriseconsole_database_remote=n
|
12
|
+
q_puppet_enterpriseconsole_database_root_password=root
|
13
|
+
q_puppet_enterpriseconsole_database_user=console
|
14
|
+
q_puppet_enterpriseconsole_httpd_port=443
|
15
|
+
q_puppet_enterpriseconsole_install=y
|
16
|
+
q_puppet_enterpriseconsole_inventory_hostname=$(hostname -s)
|
17
|
+
q_puppet_enterpriseconsole_inventory_port=8140
|
18
|
+
q_puppet_enterpriseconsole_master_hostname=$(hostname -s)
|
19
|
+
q_puppet_enterpriseconsole_smtp_host=smtp.google.com
|
20
|
+
q_puppet_enterpriseconsole_smtp_password=
|
21
|
+
q_puppet_enterpriseconsole_smtp_port=25
|
22
|
+
q_puppet_enterpriseconsole_smtp_use_tls=n
|
23
|
+
q_puppet_enterpriseconsole_smtp_user_auth=n
|
24
|
+
q_puppet_enterpriseconsole_smtp_username=
|
25
|
+
q_puppet_symlinks_install=y
|
26
|
+
q_puppetagent_certname=$(hostname -s)
|
27
|
+
q_puppetagent_install=y
|
28
|
+
q_puppetagent_server=$(hostname -s)
|
29
|
+
q_puppetca_install=y
|
30
|
+
q_puppetmaster_certname=$(hostname -s)
|
31
|
+
q_puppetmaster_dnsaltnames=$(hostname -s),puppet,$(hostname -f),puppet.$(domainname)
|
32
|
+
q_puppetmaster_enterpriseconsole_hostname=localhost
|
33
|
+
q_puppetmaster_enterpriseconsole_port=443
|
34
|
+
q_puppetmaster_forward_facts=n
|
35
|
+
q_puppetmaster_install=y
|
36
|
+
q_vendor_packages_install=y
|
37
|
+
|
38
|
+
# pe 2.0 option
|
39
|
+
q_puppet_enterpriseconsole_auth_user=console
|
40
|
+
|
41
|
+
# pe 2.0 - 2.5 upgrade options
|
42
|
+
q_puppet_enterpriseconsole_setup_auth_db=y
|
@@ -0,0 +1,36 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_cloud_install=n
|
3
|
+
q_puppet_enterpriseconsole_auth_database_name=console_auth
|
4
|
+
q_puppet_enterpriseconsole_auth_database_password=console_auth
|
5
|
+
q_puppet_enterpriseconsole_auth_database_user=console_auth
|
6
|
+
q_puppet_enterpriseconsole_auth_password=console
|
7
|
+
q_puppet_enterpriseconsole_auth_user_email=console@soupkitchen.internal
|
8
|
+
q_puppet_enterpriseconsole_database_install=y
|
9
|
+
q_puppet_enterpriseconsole_database_name=console
|
10
|
+
q_puppet_enterpriseconsole_database_password=console
|
11
|
+
q_puppet_enterpriseconsole_database_remote=n
|
12
|
+
q_puppet_enterpriseconsole_database_root_password=console
|
13
|
+
q_puppet_enterpriseconsole_database_user=console
|
14
|
+
q_puppet_enterpriseconsole_httpd_port=443
|
15
|
+
q_puppet_enterpriseconsole_install=y
|
16
|
+
q_puppet_enterpriseconsole_inventory_hostname=$(hostname -s)
|
17
|
+
q_puppet_enterpriseconsole_inventory_port=8140
|
18
|
+
q_puppet_enterpriseconsole_master_hostname=$(hostname -s)
|
19
|
+
q_puppet_enterpriseconsole_smtp_host=localhost
|
20
|
+
q_puppet_enterpriseconsole_smtp_password=
|
21
|
+
q_puppet_enterpriseconsole_smtp_port=25
|
22
|
+
q_puppet_enterpriseconsole_smtp_use_tls=n
|
23
|
+
q_puppet_enterpriseconsole_smtp_user_auth=n
|
24
|
+
q_puppet_enterpriseconsole_smtp_username=
|
25
|
+
q_puppet_symlinks_install=y
|
26
|
+
q_puppetagent_certname=$(hostname -s)
|
27
|
+
q_puppetagent_install=y
|
28
|
+
q_puppetagent_server=$(hostname -s)
|
29
|
+
q_puppetca_install=y
|
30
|
+
q_puppetmaster_certname=$(hostname -s)
|
31
|
+
q_puppetmaster_dnsaltnames=$(hostname -s),puppet,$(hostname -f),puppet.$(domainname)
|
32
|
+
q_puppetmaster_enterpriseconsole_hostname=localhost
|
33
|
+
q_puppetmaster_enterpriseconsole_port=443
|
34
|
+
q_puppetmaster_forward_facts=n
|
35
|
+
q_puppetmaster_install=y
|
36
|
+
q_vendor_packages_install=y
|
@@ -0,0 +1,52 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_cloud_install=n
|
3
|
+
|
4
|
+
q_puppet_enterpriseconsole_auth_database_name=console_auth
|
5
|
+
q_puppet_enterpriseconsole_auth_database_password=console_auth
|
6
|
+
q_puppet_enterpriseconsole_auth_database_user=console_auth
|
7
|
+
q_puppet_enterpriseconsole_auth_password=console
|
8
|
+
q_puppet_enterpriseconsole_auth_user_email=console@example.com
|
9
|
+
|
10
|
+
# Use existing database
|
11
|
+
q_puppet_enterpriseconsole_database_install=n
|
12
|
+
q_puppet_enterpriseconsole_setup_db=y
|
13
|
+
|
14
|
+
q_puppet_enterpriseconsole_database_name=console
|
15
|
+
q_puppet_enterpriseconsole_database_user=console
|
16
|
+
q_puppet_enterpriseconsole_database_password=console
|
17
|
+
q_puppet_enterpriseconsole_database_remote=n
|
18
|
+
q_puppet_enterpriseconsole_database_root_password=console
|
19
|
+
|
20
|
+
q_puppet_enterpriseconsole_httpd_port=443
|
21
|
+
q_puppet_enterpriseconsole_install=y
|
22
|
+
|
23
|
+
q_puppet_enterpriseconsole_inventory_hostname=master
|
24
|
+
q_puppet_enterpriseconsole_inventory_port=8140
|
25
|
+
|
26
|
+
q_puppet_enterpriseconsole_master_hostname=master
|
27
|
+
|
28
|
+
q_puppet_enterpriseconsole_smtp_host=smtp.google.com
|
29
|
+
q_puppet_enterpriseconsole_smtp_password=
|
30
|
+
q_puppet_enterpriseconsole_smtp_port=25
|
31
|
+
q_puppet_enterpriseconsole_smtp_use_tls=n
|
32
|
+
q_puppet_enterpriseconsole_smtp_user_auth=n
|
33
|
+
q_puppet_enterpriseconsole_smtp_username=
|
34
|
+
|
35
|
+
q_puppet_symlinks_install=y
|
36
|
+
q_puppetagent_certname=master
|
37
|
+
q_puppetagent_install=y
|
38
|
+
q_puppetagent_server=master
|
39
|
+
q_puppetca_install=y
|
40
|
+
q_puppetmaster_certname=master
|
41
|
+
q_puppetmaster_dnsaltnames=master,puppet
|
42
|
+
q_puppetmaster_enterpriseconsole_hostname=localhost
|
43
|
+
q_puppetmaster_enterpriseconsole_port=443
|
44
|
+
q_puppetmaster_forward_facts=n
|
45
|
+
q_puppetmaster_install=y
|
46
|
+
q_vendor_packages_install=y
|
47
|
+
|
48
|
+
# pe 2.0 option
|
49
|
+
q_puppet_enterpriseconsole_auth_user=console
|
50
|
+
|
51
|
+
# pe 2.0 - 2.5 upgrade options
|
52
|
+
q_puppet_enterpriseconsole_setup_auth_db=y
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'pe_build'
|
2
|
+
require 'pe_build/action'
|
3
|
+
require 'vagrant'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
class PEBuild::Action::Download
|
7
|
+
# Downloads a PE build to a temp directory
|
8
|
+
|
9
|
+
def initialize(app, env)
|
10
|
+
@app, @env = app, env
|
11
|
+
load_variables
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
@env = env
|
16
|
+
perform_download
|
17
|
+
@app.call(@env)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Determine system state and download a PE build accordingly.
|
23
|
+
#
|
24
|
+
# If we are applying actions within the context of a single box, then we
|
25
|
+
# should try to prefer and box level configuration options first. If
|
26
|
+
# anything is unset then we should fall back to the global settings.
|
27
|
+
def load_variables
|
28
|
+
if @env[:box_name]
|
29
|
+
@root = @env[:vm].pe_build.download_root
|
30
|
+
@version = @env[:vm].pe_build.version
|
31
|
+
@filename = @env[:vm].pe_build.version
|
32
|
+
end
|
33
|
+
|
34
|
+
@root ||= @env[:global_config].pe_build.download_root
|
35
|
+
@version ||= @env[:global_config].pe_build.version
|
36
|
+
@filename ||= @env[:global_config].pe_build.filename
|
37
|
+
|
38
|
+
@archive_path = File.join(PEBuild.archive_directory, @filename)
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [String] The full URL to download, based on the config
|
42
|
+
def url
|
43
|
+
[@root, @version, @filename].join('/')
|
44
|
+
end
|
45
|
+
|
46
|
+
def perform_download
|
47
|
+
if File.exist? @archive_path
|
48
|
+
@env[:ui].info "#{@filename} cached, skipping download."
|
49
|
+
else
|
50
|
+
FileUtils.mkdir_p PEBuild.archive_directory unless File.directory? PEBuild.archive_directory
|
51
|
+
cmd = %{curl -L -A "Vagrant/PEBuild (v#{PEBuild::VERSION})" -O #{url}}
|
52
|
+
@env[:ui].info "Executing '#{cmd}'"
|
53
|
+
Dir.chdir(PEBuild.archive_directory) { %x{#{cmd}} }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require 'pe_build/action'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class PEBuild::Action::Unpackage
|
6
|
+
def initialize(app, env)
|
7
|
+
@app, @env = app, env
|
8
|
+
load_variables
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
@env = env
|
13
|
+
@extracted_dir = File.join(@env[:unpack_directory], destination_directory)
|
14
|
+
extract_build
|
15
|
+
@app.call(@env)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def load_variables
|
21
|
+
if @env[:box_name]
|
22
|
+
@root = @env[:vm].pe_build.download_root
|
23
|
+
@version = @env[:vm].pe_build.version
|
24
|
+
@filename = @env[:vm].pe_build.version
|
25
|
+
end
|
26
|
+
|
27
|
+
@root ||= @env[:global_config].pe_build.download_root
|
28
|
+
@version ||= @env[:global_config].pe_build.version
|
29
|
+
@filename ||= @env[:global_config].pe_build.filename
|
30
|
+
|
31
|
+
@archive_path = File.join(PEBuild.archive_directory, @filename)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Sadly, shelling out is more sane than trying to use the facilities
|
35
|
+
# provided.
|
36
|
+
def extract_build
|
37
|
+
if File.directory? @extracted_dir
|
38
|
+
@env[:ui].info "#{destination_directory} already present, skipping extraction."
|
39
|
+
else
|
40
|
+
cmd = %{tar xf #{@archive_path} -C #{@env[:unpack_directory]}}
|
41
|
+
@env[:ui].info "Extracting #{@archive_path} to #{@env[:unpack_directory]}"
|
42
|
+
%x{#{cmd}}
|
43
|
+
end
|
44
|
+
rescue => e
|
45
|
+
# If anything goes wrong while extracting, nuke the extracted directory
|
46
|
+
# as it could be incomplete. If we do this, then we can ensure that if
|
47
|
+
# the extracted directory already exists then it will be in a good state.
|
48
|
+
@env[:ui].info "Removing possibly damaged installer directory '#{@extracted_dir}'"
|
49
|
+
FileUtils.rm_r @extracted_dir
|
50
|
+
end
|
51
|
+
|
52
|
+
# Determine the name of the top level directory by peeking into the tarball
|
53
|
+
def destination_directory
|
54
|
+
raise Errno::ENOENT, "No such file \"#{@archive_path}\"" unless File.file? @archive_path
|
55
|
+
|
56
|
+
firstline = nil
|
57
|
+
dir = nil
|
58
|
+
dir_regex = %r[^(.*?)/]
|
59
|
+
IO.popen(%{tar -tf #{@archive_path}}) { |out| firstline = out.gets }
|
60
|
+
|
61
|
+
if firstline.nil? or firstline.empty?
|
62
|
+
raise "Could not get a directory listing from the installer tarfile #{File.basename @archive_path}"
|
63
|
+
elsif (match = firstline.match dir_regex)
|
64
|
+
dir = match[1]
|
65
|
+
else
|
66
|
+
raise "Could not determine the base directory name from #{firstline} - doesn't match #{dir_regex.to_s}"
|
67
|
+
end
|
68
|
+
dir
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require 'vagrant/action/builder'
|
3
|
+
require 'pe_build'
|
4
|
+
|
5
|
+
module PEBuild::Action
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'pe_build/action/download'
|
9
|
+
require 'pe_build/action/unpackage'
|
10
|
+
|
11
|
+
builder = Vagrant::Action::Builder.new do
|
12
|
+
use PEBuild::Action::Download
|
13
|
+
end
|
14
|
+
|
15
|
+
Vagrant.actions.register :download_pe_build, builder
|
16
|
+
|
17
|
+
Vagrant.actions.register(:prep_build, Vagrant::Action::Builder.new do
|
18
|
+
use PEBuild::Action::Download
|
19
|
+
use PEBuild::Action::Unpackage
|
20
|
+
end)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
class PEBuild::Command::List < Vagrant::Command::Base
|
3
|
+
def execute
|
4
|
+
if File.directory? PEBuild.archive_directory and (entries = Dir["#{PEBuild.archive_directory}/*"])
|
5
|
+
puts entries.join('\n')
|
6
|
+
else
|
7
|
+
warn "No PE versions downloaded."
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'pe_build'
|
2
|
+
require 'vagrant'
|
3
|
+
|
4
|
+
class PEBuild::Command < Vagrant::Command::Base
|
5
|
+
def initialize(argv, env)
|
6
|
+
@argv, @env = argv, env
|
7
|
+
|
8
|
+
@main_args, @subcommand, @sub_args = split_main_and_subcommand(argv)
|
9
|
+
|
10
|
+
# Is this even remotely sane? Are we verging on cargo cult programming?
|
11
|
+
@subcommands = Vagrant::Registry.new
|
12
|
+
|
13
|
+
@subcommands.register('download') { PEBuild::Command::Download }
|
14
|
+
@subcommands.register('list') { PEBuild::Command::List }
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute
|
18
|
+
if @subcommand and (klass = @subcommands.get(@subcommand))
|
19
|
+
klass.new(@argv, @env).execute
|
20
|
+
elsif @subcommand
|
21
|
+
raise "Unrecognized subcommand #{@subcommand}"
|
22
|
+
else
|
23
|
+
PEBuild::Command::List.new(@argv, @env).execute
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
require 'pe_build/command/list'
|
29
|
+
require 'pe_build/command/download'
|
30
|
+
|
31
|
+
Vagrant.commands.register(:pe_build) { PEBuild::Command }
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require 'uri'
|
3
|
+
require 'pe_build'
|
4
|
+
|
5
|
+
class PEBuild::Config < Vagrant::Config::Base
|
6
|
+
attr_writer :download_root
|
7
|
+
attr_writer :version
|
8
|
+
attr_writer :filename
|
9
|
+
|
10
|
+
def download_root
|
11
|
+
@download_root
|
12
|
+
end
|
13
|
+
|
14
|
+
def version
|
15
|
+
@version
|
16
|
+
end
|
17
|
+
|
18
|
+
def filename
|
19
|
+
@filename
|
20
|
+
end
|
21
|
+
|
22
|
+
def validate(env, errors)
|
23
|
+
URI.parse(download_root)
|
24
|
+
rescue
|
25
|
+
# TODO I18n
|
26
|
+
errors.add("Invalid download root '#{download_root.inspect}'")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Vagrant.config_keys.register(:pe_build) { PEBuild::Config }
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'pe_build/provisioners'
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'pe_build'
|
2
|
+
require 'pe_build/provisioners'
|
3
|
+
require 'vagrant'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'erb'
|
6
|
+
|
7
|
+
class PEBuild::Provisioners::PuppetEnterpriseBootstrap < Vagrant::Provisioners::Base
|
8
|
+
|
9
|
+
class Config < Vagrant::Config::Base
|
10
|
+
attr_writer :verbose, :master
|
11
|
+
|
12
|
+
def role=(rolename)
|
13
|
+
@role = (rolename.is_a?(Symbol)) ? rolename : rolename.intern
|
14
|
+
end
|
15
|
+
|
16
|
+
def role
|
17
|
+
@role || :agent
|
18
|
+
end
|
19
|
+
|
20
|
+
def verbose
|
21
|
+
@verbose || true
|
22
|
+
end
|
23
|
+
|
24
|
+
def master
|
25
|
+
@master || 'master'
|
26
|
+
end
|
27
|
+
|
28
|
+
def validate(env, errors)
|
29
|
+
errors.add("role must be one of [:master, :agent]") unless [:master, :agent].include? role
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.config_class
|
34
|
+
Config
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize(*args)
|
38
|
+
super
|
39
|
+
|
40
|
+
load_variables
|
41
|
+
|
42
|
+
@cache_path = File.join(@env[:root_path], '.pe_build')
|
43
|
+
@answers_dir = File.join(@cache_path, 'answers')
|
44
|
+
end
|
45
|
+
|
46
|
+
def validate(app, env)
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def prepare
|
51
|
+
FileUtils.mkdir @cache_path unless File.directory? @cache_path
|
52
|
+
@env[:action_runner].run(:prep_build, :unpack_directory => @cache_path)
|
53
|
+
end
|
54
|
+
|
55
|
+
def provision!
|
56
|
+
# determine if bootstrapping is necessary
|
57
|
+
|
58
|
+
prepare_answers_file
|
59
|
+
configure_installer
|
60
|
+
|
61
|
+
[:pre, :provision, :post].each do |stepname|
|
62
|
+
[:base, config.role].each do |rolename|
|
63
|
+
step rolename, stepname
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
# I HATE THIS.
|
71
|
+
def load_variables
|
72
|
+
if @env[:box_name]
|
73
|
+
@root = @env[:vm].pe_build.download_root
|
74
|
+
@version = @env[:vm].pe_build.version
|
75
|
+
@filename = @env[:vm].pe_build.version
|
76
|
+
end
|
77
|
+
|
78
|
+
@root ||= @env[:global_config].pe_build.download_root
|
79
|
+
@version ||= @env[:global_config].pe_build.version
|
80
|
+
@filename ||= @env[:global_config].pe_build.filename
|
81
|
+
end
|
82
|
+
|
83
|
+
def prepare_answers_file
|
84
|
+
FileUtils.mkdir_p @answers_dir unless File.directory? @answers_dir
|
85
|
+
@env[:ui].info "Creating answers file, node:#{@env[:vm].name}, role: #{config.role}"
|
86
|
+
|
87
|
+
template = File.read("#{PEBuild.source_root}/templates/answers/#{config.role}.txt.erb")
|
88
|
+
dest = "#{@answers_dir}/#{@env[:vm].name}.txt"
|
89
|
+
|
90
|
+
contents = ERB.new(template).result(binding)
|
91
|
+
|
92
|
+
@env[:ui].info "Writing answers file to #{dest}"
|
93
|
+
File.open(dest, "w") do |file|
|
94
|
+
file.write contents
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def step(role, stepname)
|
99
|
+
script_dir = File.join(PEBuild.source_root, 'bootstrap', role.to_s, stepname.to_s)
|
100
|
+
script_list = Dir.glob("#{script_dir}/*")
|
101
|
+
|
102
|
+
if script_list.empty?
|
103
|
+
@env[:ui].info "No steps for #{role}/#{stepname}", :color => :cyan
|
104
|
+
end
|
105
|
+
|
106
|
+
script_list.each do |template_path|
|
107
|
+
template = File.read(template_path)
|
108
|
+
contents = ERB.new(template).result(binding)
|
109
|
+
|
110
|
+
on_remote contents
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Determine the proper invocation of the PE installer
|
115
|
+
#
|
116
|
+
# @todo Don't restrict this to the universal installer
|
117
|
+
def configure_installer
|
118
|
+
vm_base_dir = "/vagrant/.pe_build"
|
119
|
+
installer = "#{vm_base_dir}/puppet-enterprise-#{@version}-all/puppet-enterprise-installer"
|
120
|
+
answers = "#{vm_base_dir}/answers/#{@env[:vm].name}.txt"
|
121
|
+
log_file = "/root/puppet-enterprise-installer-#{Time.now.strftime('%s')}.log"
|
122
|
+
|
123
|
+
@installer_cmd = "#{installer} -a #{answers} -l #{log_file}"
|
124
|
+
end
|
125
|
+
|
126
|
+
def on_remote(cmd)
|
127
|
+
env[:vm].channel.sudo(cmd) do |type, data|
|
128
|
+
color = (type == :stdout) ? :green : :red
|
129
|
+
@env[:ui].info(data.chomp, :color => color, :prefix => false)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'pe_build'
|
2
|
+
require 'vagrant'
|
3
|
+
|
4
|
+
module PEBuild::Provisioners; end
|
5
|
+
|
6
|
+
require 'pe_build/provisioners/puppet_enterprise_bootstrap'
|
7
|
+
#require 'pe_build/provisioners/puppet_enterprise'
|
8
|
+
|
9
|
+
Vagrant.provisioners.register(:puppet_enterprise_bootstrap) { PEBuild::Provisioners::PuppetEnterpriseBootstrap}
|
data/lib/pe_build.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
|
3
|
+
module PEBuild
|
4
|
+
def self.archive_directory
|
5
|
+
File.expand_path(File.join(ENV['HOME'], '.vagrant.d', 'pe_builds'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.source_root
|
9
|
+
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
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,10 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_cloud_install=n
|
3
|
+
q_puppet_enterpriseconsole_install=n
|
4
|
+
q_puppet_symlinks_install=y
|
5
|
+
q_puppetagent_certname=<%= @env[:vm].name %>
|
6
|
+
q_puppetagent_install=y
|
7
|
+
q_puppetagent_server=<%= config.master %>
|
8
|
+
q_puppetmaster_install=n
|
9
|
+
q_vendor_packages_install=y
|
10
|
+
q_continue_or_reenter_master_hostname=c
|
@@ -0,0 +1,52 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_cloud_install=n
|
3
|
+
|
4
|
+
q_puppet_enterpriseconsole_auth_database_name=console_auth
|
5
|
+
q_puppet_enterpriseconsole_auth_database_password=console_auth
|
6
|
+
q_puppet_enterpriseconsole_auth_database_user=console_auth
|
7
|
+
q_puppet_enterpriseconsole_auth_password=console
|
8
|
+
q_puppet_enterpriseconsole_auth_user_email=console@example.com
|
9
|
+
|
10
|
+
# Use existing database
|
11
|
+
q_puppet_enterpriseconsole_database_install=n
|
12
|
+
q_puppet_enterpriseconsole_setup_db=y
|
13
|
+
|
14
|
+
q_puppet_enterpriseconsole_database_name=console
|
15
|
+
q_puppet_enterpriseconsole_database_user=console
|
16
|
+
q_puppet_enterpriseconsole_database_password=console
|
17
|
+
q_puppet_enterpriseconsole_database_remote=n
|
18
|
+
q_puppet_enterpriseconsole_database_root_password=console
|
19
|
+
|
20
|
+
q_puppet_enterpriseconsole_httpd_port=443
|
21
|
+
q_puppet_enterpriseconsole_install=y
|
22
|
+
|
23
|
+
q_puppet_enterpriseconsole_inventory_hostname=master
|
24
|
+
q_puppet_enterpriseconsole_inventory_port=8140
|
25
|
+
|
26
|
+
q_puppet_enterpriseconsole_master_hostname=master
|
27
|
+
|
28
|
+
q_puppet_enterpriseconsole_smtp_host=smtp.google.com
|
29
|
+
q_puppet_enterpriseconsole_smtp_password=
|
30
|
+
q_puppet_enterpriseconsole_smtp_port=25
|
31
|
+
q_puppet_enterpriseconsole_smtp_use_tls=n
|
32
|
+
q_puppet_enterpriseconsole_smtp_user_auth=n
|
33
|
+
q_puppet_enterpriseconsole_smtp_username=
|
34
|
+
|
35
|
+
q_puppet_symlinks_install=y
|
36
|
+
q_puppetagent_certname=<%= @env[:vm].name %>
|
37
|
+
q_puppetagent_install=y
|
38
|
+
q_puppetagent_server=<%= @env[:vm].name %>
|
39
|
+
q_puppetca_install=y
|
40
|
+
q_puppetmaster_certname=master
|
41
|
+
q_puppetmaster_dnsaltnames=master,puppet
|
42
|
+
q_puppetmaster_enterpriseconsole_hostname=localhost
|
43
|
+
q_puppetmaster_enterpriseconsole_port=443
|
44
|
+
q_puppetmaster_forward_facts=n
|
45
|
+
q_puppetmaster_install=y
|
46
|
+
q_vendor_packages_install=y
|
47
|
+
|
48
|
+
# pe 2.0 option
|
49
|
+
q_puppet_enterpriseconsole_auth_user=console
|
50
|
+
|
51
|
+
# pe 2.0 - 2.5 upgrade options
|
52
|
+
q_puppet_enterpriseconsole_setup_auth_db=y
|
@@ -0,0 +1,20 @@
|
|
1
|
+
lib = File.expand_path('../lib/', __FILE__)
|
2
|
+
$:.unshift lib unless $:.include?(lib)
|
3
|
+
|
4
|
+
require 'pe_build/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "vagrant-pe_build"
|
8
|
+
gem.version = PEBuild::VERSION
|
9
|
+
|
10
|
+
gem.authors = 'Adrien Thebo'
|
11
|
+
gem.email = 'adrien@somethingsinistral.net'
|
12
|
+
gem.homepage = 'https://github.com/adrienthebo/vagrant-pe_build'
|
13
|
+
|
14
|
+
gem.summary = "Vagrant provisioner for installing Puppet Enterprise"
|
15
|
+
|
16
|
+
gem.add_dependency 'vagrant', '~> 1.0.0'
|
17
|
+
|
18
|
+
gem.files = %x{git ls-files -z}.split("\0")
|
19
|
+
gem.require_path = 'lib'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-pe_build
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Adrien Thebo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: vagrant
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0
|
30
|
+
description:
|
31
|
+
email: adrien@somethingsinistral.net
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE
|
38
|
+
- bootstrap/base/provision/install_puppet_enterprise.sh
|
39
|
+
- bootstrap/master/post/relocate_puppet.sh
|
40
|
+
- doc/answers/README.markdown
|
41
|
+
- doc/answers/agent.txt
|
42
|
+
- doc/answers/master-1.1.txt
|
43
|
+
- doc/answers/master-2.0.0.txt
|
44
|
+
- doc/answers/master-2.5.0.txt
|
45
|
+
- doc/answers/master-db.txt
|
46
|
+
- lib/pe_build.rb
|
47
|
+
- lib/pe_build/action.rb
|
48
|
+
- lib/pe_build/action/download.rb
|
49
|
+
- lib/pe_build/action/unpackage.rb
|
50
|
+
- lib/pe_build/command.rb
|
51
|
+
- lib/pe_build/command/download.rb
|
52
|
+
- lib/pe_build/command/list.rb
|
53
|
+
- lib/pe_build/config.rb
|
54
|
+
- lib/pe_build/provisioners.rb
|
55
|
+
- lib/pe_build/provisioners/puppet_enterprise.rb
|
56
|
+
- lib/pe_build/provisioners/puppet_enterprise_bootstrap.rb
|
57
|
+
- lib/pe_build/version.rb
|
58
|
+
- templates/answers/agent.txt.erb
|
59
|
+
- templates/answers/master.txt.erb
|
60
|
+
- vagrant-pe_build.gemspec
|
61
|
+
homepage: https://github.com/adrienthebo/vagrant-pe_build
|
62
|
+
licenses: []
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.8.23
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Vagrant provisioner for installing Puppet Enterprise
|
85
|
+
test_files: []
|