vagrant-pe_build 0.12.0 → 0.13.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +24 -0
  3. data/README.markdown +152 -71
  4. data/acceptance/pe_build/pe_bootstrap_2015x_spec.rb +61 -13
  5. data/acceptance/pe_build/pe_bootstrap_3x_spec.rb +6 -3
  6. data/acceptance/pe_build/pe_bootstrap_latest_spec.rb +6 -3
  7. data/acceptance/skeletons/2015x_acceptance/Vagrantfile +25 -49
  8. data/acceptance/skeletons/pe_build/Vagrantfile +1 -1
  9. data/lib/pe_build/cap.rb +9 -0
  10. data/lib/pe_build/cap/detect_installer/base.rb +18 -0
  11. data/lib/pe_build/cap/detect_installer/posix.rb +0 -15
  12. data/lib/pe_build/cap/detect_installer/windows.rb +22 -4
  13. data/lib/pe_build/cap/facts/base.rb +119 -0
  14. data/lib/pe_build/cap/facts/debian.rb +37 -0
  15. data/lib/pe_build/cap/facts/posix.rb +36 -0
  16. data/lib/pe_build/cap/facts/redhat.rb +37 -0
  17. data/lib/pe_build/cap/facts/solaris.rb +46 -0
  18. data/lib/pe_build/cap/facts/suse.rb +38 -0
  19. data/lib/pe_build/cap/facts/ubuntu.rb +35 -0
  20. data/lib/pe_build/cap/facts/windows.rb +58 -0
  21. data/lib/pe_build/command.rb +1 -0
  22. data/lib/pe_build/command/base.rb +2 -1
  23. data/lib/pe_build/command/facts.rb +63 -0
  24. data/lib/pe_build/config.rb +1 -0
  25. data/lib/pe_build/config/pe_agent.rb +120 -0
  26. data/lib/pe_build/config_builder.rb +1 -0
  27. data/lib/pe_build/config_builder/pe_agent.rb +44 -0
  28. data/lib/pe_build/plugin.rb +44 -0
  29. data/lib/pe_build/provisioner/pe_agent.rb +262 -0
  30. data/lib/pe_build/release.rb +1 -1
  31. data/lib/pe_build/release/2015_2.rb +1 -0
  32. data/lib/pe_build/util/machine_comms.rb +51 -0
  33. data/lib/pe_build/util/pe_packaging.rb +57 -0
  34. data/lib/pe_build/version.rb +1 -1
  35. data/spec/unit/config/pe_agent_spec.rb +154 -0
  36. data/spec/unit/provisioner/pe_agent_spec.rb +101 -0
  37. data/tasks/acceptance.rake +2 -1
  38. data/templates/locales/en.yml +53 -0
  39. data/vagrant-pe_build.gemspec +4 -4
  40. data/vagrant-spec.config.example.rb +1 -1
  41. metadata +24 -5
@@ -1,3 +1,3 @@
1
1
  module PEBuild
2
- VERSION = '0.12.0'
2
+ VERSION = '0.13.0'
3
3
  end
@@ -0,0 +1,154 @@
1
+ require 'spec_helper'
2
+
3
+ require 'pe_build/config'
4
+
5
+ describe PEBuild::Config::PEAgent do
6
+ let(:machine) { double('machine') }
7
+ let(:env) { double('vagrant environment') }
8
+
9
+ before(:each) do
10
+ allow(machine).to receive(:env).and_return(env)
11
+ allow(env).to receive(:machine_names).and_return([:master])
12
+ end
13
+
14
+ describe 'autosign' do
15
+ it 'defaults to true if master_vm is set' do
16
+ subject.master_vm = 'master'
17
+ subject.finalize!
18
+
19
+ expect(subject.autosign).to eq true
20
+ end
21
+
22
+ context 'when master_vm is unset' do
23
+ it 'defaults to false' do
24
+ subject.master_vm = nil
25
+ subject.finalize!
26
+
27
+ expect(subject.autosign).to eq false
28
+ end
29
+
30
+ it 'fails validation if set to true' do
31
+ subject.master = 'some-hostname'
32
+ subject.master_vm = nil
33
+ subject.autosign = true
34
+ subject.finalize!
35
+
36
+ errors = subject.validate(machine)
37
+
38
+ expect(errors['pe_agent provisioner'].to_s).to match(/Use of the .* setting requires master_vm/)
39
+ end
40
+ end
41
+ end
42
+
43
+ describe 'autopurge' do
44
+ it 'defaults to true if master_vm is set' do
45
+ subject.master_vm = 'master'
46
+ subject.finalize!
47
+
48
+ expect(subject.autopurge).to eq true
49
+ end
50
+
51
+ context 'when master_vm is unset' do
52
+ it 'defaults to false' do
53
+ subject.master_vm = nil
54
+ subject.finalize!
55
+
56
+ expect(subject.autopurge).to eq false
57
+ end
58
+
59
+ it 'fails validation if set to true' do
60
+ subject.master = 'some-hostname'
61
+ subject.master_vm = nil
62
+ subject.autopurge = true
63
+ subject.finalize!
64
+
65
+ errors = subject.validate(machine)
66
+
67
+ expect(errors['pe_agent provisioner'].to_s).to match(/Use of the .* setting requires master_vm/)
68
+ end
69
+ end
70
+ end
71
+
72
+ describe 'master' do
73
+ it 'must be set if master_vm is nil' do
74
+ subject.master_vm = nil
75
+ subject.finalize!
76
+
77
+ errors = subject.validate(machine)
78
+
79
+ expect(errors['pe_agent provisioner'].to_s).to match(/No master or master_vm setting has been configured/)
80
+ end
81
+
82
+ it 'may be unset if master_vm is not nil' do
83
+ subject.master_vm = 'master'
84
+ subject.finalize!
85
+
86
+ errors = subject.validate(machine)
87
+
88
+ # Comparision against an empty array produces a better diff.
89
+ expect(errors['pe_agent provisioner']).to eq []
90
+ end
91
+ end
92
+
93
+ describe 'master_vm' do
94
+ it 'must be set to a defined machine' do
95
+ allow(env).to receive(:machine_names).and_return([:master])
96
+
97
+ subject.master_vm = 'some_machine'
98
+ subject.finalize!
99
+
100
+ errors = subject.validate(machine)
101
+
102
+ expect(errors['pe_agent provisioner'].to_s).to match(/The specified master_vm,.*, is not defined/)
103
+ end
104
+ end
105
+
106
+ describe 'version' do
107
+ before(:each) { subject.master = 'master.company.com' }
108
+
109
+ it 'defaults to "current"' do
110
+ subject.finalize!
111
+
112
+ expect(subject.version).to eq 'current'
113
+ end
114
+
115
+ it 'may be of the form x.y.z' do
116
+ subject.version = '2015.2.1'
117
+
118
+ subject.finalize!
119
+ errors = subject.validate(machine)
120
+
121
+ expect(errors['pe_agent provisioner']).to eq []
122
+ end
123
+
124
+ it 'may be of the form x.y.z[-other-arbitrary-stuff]' do
125
+ subject.version = '2015.2.1-r42-gsomesha'
126
+
127
+ subject.finalize!
128
+ errors = subject.validate(machine)
129
+
130
+ expect(errors['pe_agent provisioner']).to eq []
131
+ end
132
+
133
+ it 'may not be x.y' do
134
+ subject.version = '2015.2'
135
+
136
+ subject.finalize!
137
+ errors = subject.validate(machine)
138
+
139
+ # Casting the array to a string and using a regex matcher gives a nice
140
+ # diff in the case of failure.
141
+ expect(errors['pe_agent provisioner'].to_s).to match(/The agent version.*is invalid./)
142
+ end
143
+
144
+ it "must be greater than #{PEBuild::Config::PEAgent::MINIMUM_VERSION}" do
145
+ subject.version = '3.8.2'
146
+
147
+ subject.finalize!
148
+ errors = subject.validate(machine)
149
+
150
+ expect(errors['pe_agent provisioner'].to_s).to match(/The agent version.*is too old./)
151
+ end
152
+ end
153
+
154
+ end
@@ -0,0 +1,101 @@
1
+ require 'spec_helper'
2
+
3
+ require 'pe_build/provisioner/pe_agent'
4
+
5
+ describe PEBuild::Provisioner::PEAgent do
6
+ include_context 'vagrant-unit'
7
+
8
+ subject { described_class.new(agent_vm, config) }
9
+
10
+ let(:test_env) do
11
+ env = isolated_environment
12
+ env.vagrantfile <<-EOF
13
+ Vagrant.configure('2') do |config|
14
+ config.vm.define :agent_vm
15
+ config.vm.define :master_vm
16
+ end
17
+ EOF
18
+
19
+ env
20
+ end
21
+
22
+ let(:env) { test_env.create_vagrant_env }
23
+ let(:agent_vm) { env.machine(:agent_vm, :dummy) }
24
+ let(:master_vm) { env.machine(:master_vm, :dummy) }
25
+ let(:config) { PEBuild::Config::PEAgent.new }
26
+ # Mock the communicator to prevent SSH commands from being executed.
27
+ let(:agent_comm) { double('agent_comm') }
28
+ let(:master_comm) { double('master_comm') }
29
+ # Mock Vagrant IO.
30
+ let(:agent_ui) { double('agent_ui') }
31
+ let(:master_ui) { double('master_ui') }
32
+
33
+ before(:each) do
34
+ allow(agent_vm).to receive(:communicate).and_return(agent_comm)
35
+ allow(agent_vm).to receive(:ui).and_return(agent_ui)
36
+ allow(master_vm).to receive(:communicate).and_return(master_comm)
37
+ allow(master_vm).to receive(:ui).and_return(master_ui)
38
+
39
+ config.finalize!
40
+ # Skip provision-time inspection of machines.
41
+ agent_vm.stub_chain(:guest, :capability)
42
+ allow(subject).to receive(:provision_init!)
43
+ end
44
+
45
+ after(:each) { test_env.close }
46
+
47
+ context 'when an agent is installed' do
48
+ before(:each) do
49
+ allow(subject).to receive(:agent_version).and_return('1.0.0')
50
+ end
51
+
52
+ it 'logs a message and returns early' do
53
+ expect(agent_ui).to receive(:info).with(/Puppet agent .* is already installed/)
54
+ expect(subject).to_not receive(:provision_posix_agent)
55
+
56
+ subject.provision
57
+ end
58
+ end
59
+
60
+ context 'when an agent is not installed' do
61
+ before(:each) do
62
+ allow(subject).to receive(:agent_version).and_return(nil)
63
+ allow(subject).to receive(:provision_windows?).and_return(false)
64
+ end
65
+
66
+ context 'when master_vm is set' do
67
+ before(:each) do
68
+ allow(config).to receive(:master_vm).and_return(master_vm)
69
+ end
70
+
71
+ it 'raises an error if the master_vm is unreachable' do
72
+ allow(master_comm).to receive(:ready?).and_return(false)
73
+
74
+ expect { subject.provision }.to raise_error(::PEBuild::Util::MachineComms::MachineNotReachable)
75
+ end
76
+ end
77
+
78
+ context 'when osfamily is windows' do
79
+ before(:each) do
80
+ allow(subject).to receive(:provision_windows?).and_return(true)
81
+ allow(config).to receive(:master_vm).and_return(master_vm)
82
+ end
83
+
84
+ it 'invokes the windows provisioner and skips pe_repo' do
85
+ expect(subject).to receive(:provision_windows_agent)
86
+ expect(subject).to receive(:provision_pe_repo).never
87
+
88
+ subject.provision
89
+ end
90
+ end
91
+
92
+ context 'when osfamily is not windows' do
93
+ it 'invokes the posix agent provisioner' do
94
+ expect(subject).to receive(:provision_posix_agent)
95
+
96
+ subject.provision
97
+ end
98
+ end
99
+
100
+ end
101
+ end
@@ -1,7 +1,8 @@
1
1
  namespace :acceptance do
2
2
  ARTIFACT_DIR = File.join('acceptance', 'artifacts')
3
3
  TEST_BOXES = {
4
- 'virtualbox.box' => 'https://s3.amazonaws.com/puppetlabs-vagrantcloud/centos-6.6-x86_64-virtualbox-nocm-1.0.1.box'
4
+ 'centos-virtualbox.box' => 'https://s3.amazonaws.com/puppetlabs-vagrantcloud/centos-6.6-x86_64-virtualbox-nocm-1.0.2.box',
5
+ 'ubuntu-virtualbox.box' => 'https://s3.amazonaws.com/puppetlabs-vagrantcloud/ubuntu-14.04-x86_64-virtualbox-nocm-1.0.2.box'
5
6
  }
6
7
 
7
8
  directory ARTIFACT_DIR
@@ -1,5 +1,16 @@
1
1
  en:
2
2
  pebuild:
3
+ command:
4
+ facts:
5
+ vm_not_running: |-
6
+ Could not establish a connection to %{vm_name} in order to retrieve
7
+ facts. This usually means the machine is either shut down,
8
+ or has not been created.
9
+ errors:
10
+ machine_not_reachable: |-
11
+ The specified Vagrant machine, %{vm_name}, is not able to recieve
12
+ communication. This typically means the machine has not been created,
13
+ is shut down, or there is an issue with the SSH or WinRM communicator.
3
14
  archive:
4
15
  no_installer_source: |-
5
16
  The Puppet Enterprise installer %{filename}
@@ -21,6 +32,33 @@ en:
21
32
  unset_version: |-
22
33
  The Puppet Enterprise version must be set either on the global pe_build config
23
34
  object or specified on a per-provisioner basis, but both were unset.
35
+ pe_agent:
36
+ already_installed: |-
37
+ Puppet agent %{version} is already installed, skipping installation.
38
+ pe_repo_present: |-
39
+ The Puppet Server on %{vm_name} is configured with Agent repositories for:
40
+ %{platform_tag}
41
+ adding_pe_repo: |-
42
+ Configuring Puppet Server on %{vm_name} with Agent repositories for:
43
+ %{platform_tag}
44
+ no_csr_pending: |-
45
+ No pending signing request for %{certname} on %{master}. Skipping autosign.
46
+ signing_agent_cert: |-
47
+ Signing request for %{certname} on %{master}.
48
+ skip_purge_no_master: |-
49
+ The VM hosting the Puppet Master, %{master}, is no longer available.
50
+ This commonly means the machine has been destroyed.
51
+ Skipping purge of agent data.
52
+ skip_purge_master_not_reachable: |-
53
+ The VM hosting the Puppet Master, %{master}, is not accepting SSH or
54
+ WinRM communication. This commonly means the machine has been
55
+ shut down.
56
+ Skipping purge of agent data.
57
+ agent_purged: |-
58
+ No certificate for %{certname} on %{master}.
59
+ Skipping purge of agent data.
60
+ purging_agent: |-
61
+ Purging agent data for %{certname} from %{master}.
24
62
  transfer:
25
63
  open_uri:
26
64
  download_failed: |-
@@ -60,6 +98,21 @@ en:
60
98
  Autosign must be one of %{autosign_classes}, but was of type %{autosign}.
61
99
  invalid_answer_extras: |-
62
100
  Answer_extras must be an Array, got a %{class}.
101
+ pe_agent:
102
+ errors:
103
+ master_vm_required: |-
104
+ Use of the %{setting} setting requires master_vm to be specified.
105
+ no_master: |-
106
+ No master or master_vm setting has been configured for this agent.
107
+ master_vm_not_defined: |-
108
+ The specified master_vm, %{vm_name}, is not defined by the current
109
+ Vagrant environment.
110
+ malformed_version: |-
111
+ The agent version "%{version}":%{version_class} is invalid; it must be a String of
112
+ the format "x.y.z[-optional-stuff]" or "current".
113
+ version_too_old: |-
114
+ The agent version %{version} is too old; pe_agent can only provision versions
115
+ newer than %{minimum_version}.
63
116
  cap:
64
117
  run_install:
65
118
  already_installed: |-
@@ -7,11 +7,11 @@ Gem::Specification.new do |gem|
7
7
  gem.name = "vagrant-pe_build"
8
8
  gem.version = PEBuild::VERSION
9
9
 
10
- gem.authors = 'Adrien Thebo'
11
- gem.email = 'adrien@somethingsinistral.net'
12
- gem.homepage = 'https://github.com/adrienthebo/vagrant-pe_build'
10
+ gem.authors = ['Adrien Thebo', 'Charlie Sharpsteen']
11
+ gem.email = ['adrien@somethingsinistral.net', 'source@sharpsteen.net']
12
+ gem.homepage = 'https://github.com/oscar-stack/vagrant-pe_build'
13
13
 
14
- gem.summary = "Vagrant provisioner for installing Puppet Enterprise"
14
+ gem.summary = "Vagrant provisioners for installing Puppet Enterprise"
15
15
 
16
16
  gem.files = %x{git ls-files -z}.split("\0")
17
17
  gem.require_path = 'lib'
@@ -10,7 +10,7 @@ Vagrant::Spec::Acceptance.configure do |c|
10
10
  c.skeleton_paths = [(acceptance_dir + 'skeletons').to_s]
11
11
 
12
12
  c.provider 'virtualbox',
13
- box: (acceptance_dir + 'artifacts' + 'virtualbox.box').to_s,
13
+ boxes: Dir[acceptance_dir + 'artifacts' + '*-virtualbox.box'],
14
14
  # This folder should be filled with PE tarballs for CentOS.
15
15
  archive_path: (acceptance_dir + 'artifacts' + 'pe_archives').to_s,
16
16
  pe_latest: '2015.2.0',
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-pe_build
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
+ - Charlie Sharpsteen
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-09-24 00:00:00.000000000 Z
12
+ date: 2015-10-18 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: progressbar
@@ -67,7 +68,9 @@ dependencies:
67
68
  - !ruby/object:Gem::Version
68
69
  version: 2.14.0
69
70
  description:
70
- email: adrien@somethingsinistral.net
71
+ email:
72
+ - adrien@somethingsinistral.net
73
+ - source@sharpsteen.net
71
74
  executables: []
72
75
  extensions: []
73
76
  extra_rdoc_files: []
@@ -107,22 +110,34 @@ files:
107
110
  - lib/pe_build/cap/detect_installer/solaris.rb
108
111
  - lib/pe_build/cap/detect_installer/ubuntu.rb
109
112
  - lib/pe_build/cap/detect_installer/windows.rb
113
+ - lib/pe_build/cap/facts/base.rb
114
+ - lib/pe_build/cap/facts/debian.rb
115
+ - lib/pe_build/cap/facts/posix.rb
116
+ - lib/pe_build/cap/facts/redhat.rb
117
+ - lib/pe_build/cap/facts/solaris.rb
118
+ - lib/pe_build/cap/facts/suse.rb
119
+ - lib/pe_build/cap/facts/ubuntu.rb
120
+ - lib/pe_build/cap/facts/windows.rb
110
121
  - lib/pe_build/cap/run_install/posix.rb
111
122
  - lib/pe_build/cap/run_install/windows.rb
112
123
  - lib/pe_build/command.rb
113
124
  - lib/pe_build/command/base.rb
114
125
  - lib/pe_build/command/copy.rb
126
+ - lib/pe_build/command/facts.rb
115
127
  - lib/pe_build/command/list.rb
116
128
  - lib/pe_build/config.rb
117
129
  - lib/pe_build/config/global.rb
130
+ - lib/pe_build/config/pe_agent.rb
118
131
  - lib/pe_build/config/pe_bootstrap.rb
119
132
  - lib/pe_build/config_builder.rb
120
133
  - lib/pe_build/config_builder/global.rb
134
+ - lib/pe_build/config_builder/pe_agent.rb
121
135
  - lib/pe_build/config_builder/pe_bootstrap.rb
122
136
  - lib/pe_build/config_default.rb
123
137
  - lib/pe_build/idempotent.rb
124
138
  - lib/pe_build/on_machine.rb
125
139
  - lib/pe_build/plugin.rb
140
+ - lib/pe_build/provisioner/pe_agent.rb
126
141
  - lib/pe_build/provisioner/pe_bootstrap.rb
127
142
  - lib/pe_build/provisioner/pe_bootstrap/answers_file.rb
128
143
  - lib/pe_build/provisioner/pe_bootstrap/post_install.rb
@@ -149,6 +164,8 @@ files:
149
164
  - lib/pe_build/unpack/tar.rb
150
165
  - lib/pe_build/unpack/tar_gz.rb
151
166
  - lib/pe_build/util/config.rb
167
+ - lib/pe_build/util/machine_comms.rb
168
+ - lib/pe_build/util/pe_packaging.rb
152
169
  - lib/pe_build/util/version_string.rb
153
170
  - lib/pe_build/util/versioned_path.rb
154
171
  - lib/pe_build/version.rb
@@ -156,7 +173,9 @@ files:
156
173
  - spec/shared/helpers/webserver_context.rb
157
174
  - spec/spec_helper.rb
158
175
  - spec/unit/config/global_spec.rb
176
+ - spec/unit/config/pe_agent_spec.rb
159
177
  - spec/unit/config/pe_bootstrap_spec.rb
178
+ - spec/unit/provisioner/pe_agent_spec.rb
160
179
  - spec/unit/provisioner/pe_bootstrap_answers_spec.rb
161
180
  - spec/unit/util/config_spec.rb
162
181
  - tasks/acceptance.rake
@@ -174,7 +193,7 @@ files:
174
193
  - templates/locales/en.yml
175
194
  - vagrant-pe_build.gemspec
176
195
  - vagrant-spec.config.example.rb
177
- homepage: https://github.com/adrienthebo/vagrant-pe_build
196
+ homepage: https://github.com/oscar-stack/vagrant-pe_build
178
197
  licenses:
179
198
  - Apache 2.0
180
199
  metadata: {}
@@ -197,5 +216,5 @@ rubyforge_project:
197
216
  rubygems_version: 2.0.14
198
217
  signing_key:
199
218
  specification_version: 4
200
- summary: Vagrant provisioner for installing Puppet Enterprise
219
+ summary: Vagrant provisioners for installing Puppet Enterprise
201
220
  test_files: []