beaker-pe 1.9.1 → 1.10.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.
- checksums.yaml +8 -8
- data/Gemfile +0 -4
- data/HISTORY.md +230 -2
- data/PULL_REQUEST_TEMPLATE.md +10 -0
- data/lib/beaker-pe.rb +0 -1
- data/lib/beaker-pe/install/pe_utils.rb +291 -15
- data/lib/beaker-pe/version.rb +1 -1
- data/spec/beaker-pe/install/pe_utils_spec.rb +314 -3
- data/spec/beaker-pe/pe-client-tools/config_file_helper_spec.rb +0 -1
- data/spec/beaker-pe/pe-client-tools/executable_helper_spec.rb +0 -1
- data/spec/beaker-pe/pe-client-tools/installer_helper_spec.rb +2 -1
- data/spec/helpers.rb +2 -4
- data/spec/spec_helper.rb +2 -2
- metadata +3 -3
- data/spec/beaker_test_helpers.rb +0 -17
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
ZDgzOGU0MzZjMWJmODI4MTkyNzM3NzkyY2M5ZmExYzY5MGYxM2M4Yg==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
ZTA0YjhkODA1OWU3YTI1ODdmZjZhZWM3ZTYzYmYzMzA1NGEyOWM4Yw==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
NWVmNDA0Zjg5MTE5ZWI1NjczYTIwMTVlZjQzYmZiN2VhOGNmYjRiODYwZDNi
|
|
10
|
+
MmY5MzNmYjk2OWIzMDRlZGE5OTg4OGU4NTA5NWNiYWQ3YTRlM2FkNzk3ODZi
|
|
11
|
+
YTA0NmZkYTBhNGQ4NzZkMGJmZTI1MjYxMjljMjI1MDhmNDMyZjM=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
NTI5NGJkNzdlYzViNmZhOTcxNjkxZTU4NWIwNjU1ODQzMzUzZWUzNDBiYjM1
|
|
14
|
+
ZDNmYmJmNGU5M2U5Zjk5OTRkMTUzZjg2Yjc1NTBlYzllZDcxNzkxNTY4MmM4
|
|
15
|
+
MWNhNzc4ODMxZDlhMWQzZTYyNjZjYjk0NTkyYzQzNDJmY2E0ODg=
|
data/Gemfile
CHANGED
|
@@ -2,8 +2,6 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org"
|
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
5
|
def location_for(place, fake_version = nil)
|
|
8
6
|
if place =~ /^(git:[^#]*)#(.*)/
|
|
9
7
|
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
|
|
@@ -14,7 +12,6 @@ def location_for(place, fake_version = nil)
|
|
|
14
12
|
end
|
|
15
13
|
end
|
|
16
14
|
|
|
17
|
-
|
|
18
15
|
# We don't put beaker in as a test dependency because we
|
|
19
16
|
# don't want to create a transitive dependency
|
|
20
17
|
group :acceptance_testing do
|
|
@@ -25,7 +22,6 @@ if ENV['GEM_SOURCE'] =~ /rubygems\.delivery\.puppetlabs\.net/
|
|
|
25
22
|
gem "scooter", *location_for(ENV['SCOOTER_VERSION'] || '~> 3.0')
|
|
26
23
|
end
|
|
27
24
|
|
|
28
|
-
|
|
29
25
|
if File.exists? "#{__FILE__}.local"
|
|
30
26
|
eval(File.read("#{__FILE__}.local"), binding)
|
|
31
27
|
end
|
data/HISTORY.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# worker - History
|
|
2
2
|
## Tags
|
|
3
|
-
* [LATEST -
|
|
3
|
+
* [LATEST - 20 Mar, 2017 (a796b850)](#LATEST)
|
|
4
|
+
* [1.9.1 - 22 Feb, 2017 (3b0bd457)](#1.9.1)
|
|
4
5
|
* [1.9.0 - 7 Feb, 2017 (efae323b)](#1.9.0)
|
|
5
6
|
* [1.8.2 - 6 Jan, 2017 (625c17e3)](#1.8.2)
|
|
6
7
|
* [1.8.1 - 30 Dec, 2016 (3cefad28)](#1.8.1)
|
|
@@ -31,7 +32,234 @@
|
|
|
31
32
|
* [0.1.0 - 29 Feb, 2016 (4fc88d8c)](#0.1.0)
|
|
32
33
|
|
|
33
34
|
## Details
|
|
34
|
-
### <a name = "LATEST">LATEST -
|
|
35
|
+
### <a name = "LATEST">LATEST - 20 Mar, 2017 (a796b850)
|
|
36
|
+
|
|
37
|
+
* (GEM) update beaker-pe version to 1.10.0 (a796b850)
|
|
38
|
+
|
|
39
|
+
* Merge pull request #59 from jpartlow/pe-modules-next (b130ad2f)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
Merge pull request #59 from jpartlow/pe-modules-next
|
|
44
|
+
|
|
45
|
+
(PE-19049) Add a meep classification feature flag
|
|
46
|
+
```
|
|
47
|
+
* Merge branch 'issue/flanders/pe-19049-add-meep-classification-feature-flag' into pe-modules-next (f9b3ecd5)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Merge branch 'issue/flanders/pe-19049-add-meep-classification-feature-flag' into pe-modules-next
|
|
52
|
+
|
|
53
|
+
* issue/flanders/pe-19049-add-meep-classification-feature-flag:
|
|
54
|
+
(PE-19831) Remove pe_repo classes from meep classification
|
|
55
|
+
(PE-19438) Mock `scp_from` for `do_install`
|
|
56
|
+
(PE-19438) Move pe.conf setup into descriptive function
|
|
57
|
+
(PE-19438) Stop passing -c to upgrades from MEEP
|
|
58
|
+
(PE-19049) Remove get_console_dispatcher_for_beaker_pe specs
|
|
59
|
+
(PE-19049) use_meep_for_classification for configure_puppet_agent_service
|
|
60
|
+
(PE-19049) Add helper method to read a hocon key from pe.conf
|
|
61
|
+
(PE-19049) Add method to create or update a meep node.conf file
|
|
62
|
+
(PE-19049) Can remove parameters from pe.conf
|
|
63
|
+
(PE-19049,PE-11353) Ensure puppet service is stopped in 2017.1+ builds
|
|
64
|
+
(maint) Use a Beaker::Host instance when mocking hosts
|
|
65
|
+
(PE-19049) Modify how we obtain console dispatcher for frictionless
|
|
66
|
+
(maint) Require beaker directly in spec_helper
|
|
67
|
+
(PE-19049,PE-18718,PE-18799) Provide a test method for meep classification
|
|
68
|
+
(maint) Remove unused variables
|
|
69
|
+
```
|
|
70
|
+
* (PE-19831) Remove pe_repo classes from meep classification (b2b3d9df)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
(PE-19831) Remove pe_repo classes from meep classification
|
|
75
|
+
|
|
76
|
+
This commit stops beaker from setting up additional pe_repo platform
|
|
77
|
+
classes on the master node group when using meep for classification as
|
|
78
|
+
this is handled in pe.conf with the agent_platform array with an array
|
|
79
|
+
of platform tags instead.
|
|
80
|
+
```
|
|
81
|
+
* (PE-19049) Remove get_console_dispatcher_for_beaker_pe specs (e3515a02)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
(PE-19049) Remove get_console_dispatcher_for_beaker_pe specs
|
|
86
|
+
|
|
87
|
+
Because scooter can in fact be in the bundle based on the GEM_SOURCE
|
|
88
|
+
setting, these specs can break, and it is not worth the effort reworking
|
|
89
|
+
the tests to be conditional based on presence or absence of the scooter
|
|
90
|
+
gem. RE-8616 should make the scooter gem public and then we don't need
|
|
91
|
+
to dance around it like this.
|
|
92
|
+
```
|
|
93
|
+
* (PE-19438) Mock `scp_from` for `do_install` (1353f7bf)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
(PE-19438) Mock `scp_from` for `do_install`
|
|
98
|
+
|
|
99
|
+
The new functionality in `do_install` to copy the `conf.d` folder
|
|
100
|
+
```
|
|
101
|
+
* (PE-19438) Move pe.conf setup into descriptive function (80b78e04)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
(PE-19438) Move pe.conf setup into descriptive function
|
|
106
|
+
|
|
107
|
+
The `do_install` method was getting a bit cluttered with too many
|
|
108
|
+
levels of logic, so I've moved the pe.conf setup steps out
|
|
109
|
+
into their own method, `setup_pe_conf`
|
|
110
|
+
```
|
|
111
|
+
* Merge pull request #60 from kevpl/docs_pr_template2 (f22ac7fb)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
Merge pull request #60 from kevpl/docs_pr_template2
|
|
116
|
+
|
|
117
|
+
(MAINT) add pull request template
|
|
118
|
+
```
|
|
119
|
+
* (MAINT) add pull request template (f730e767)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
(MAINT) add pull request template
|
|
124
|
+
|
|
125
|
+
adds a template that will make understanding
|
|
126
|
+
who to ping to get your PR reviewed clearer.
|
|
127
|
+
[skip ci]
|
|
128
|
+
```
|
|
129
|
+
* (PE-19438) Stop passing -c to upgrades from MEEP (2af29a43)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
(PE-19438) Stop passing -c to upgrades from MEEP
|
|
134
|
+
|
|
135
|
+
Prior to this commit we were essentially always passing in a config
|
|
136
|
+
to the installer during upgrades because we typically provide some
|
|
137
|
+
sort of custom answers for many tests. This meant that we were not
|
|
138
|
+
really testing upgrades without a config file being passed in.
|
|
139
|
+
This commit updates the beaker to not pass in a config/`-c` option
|
|
140
|
+
on upgrades from a MEEP install. In order to pass in the custom answers,
|
|
141
|
+
I have instead made use of the `update_pe_conf` method to inject the
|
|
142
|
+
answers.
|
|
143
|
+
```
|
|
144
|
+
* (PE-19049) use_meep_for_classification for configure_puppet_agent_service (570694db)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
(PE-19049) use_meep_for_classification for configure_puppet_agent_service
|
|
149
|
+
|
|
150
|
+
This commit updates the condition on performing the
|
|
151
|
+
`configure_puppet_agent_service` to be gated with
|
|
152
|
+
`use_meep_for_classification` so that it will automatically be set to
|
|
153
|
+
whatever arbitrary version we activate MEEP on.
|
|
154
|
+
```
|
|
155
|
+
* (PE-19049) Add helper method to read a hocon key from pe.conf (02c0b356)
|
|
156
|
+
|
|
157
|
+
* (PE-19049) Add method to create or update a meep node.conf file (bb4094ae)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
(PE-19049) Add method to create or update a meep node.conf file
|
|
162
|
+
|
|
163
|
+
This is necessary if we need to adjust parameters for a specific node
|
|
164
|
+
rather than for all infrastructure via pe.conf.
|
|
165
|
+
```
|
|
166
|
+
* (PE-19049) Can remove parameters from pe.conf (d4bab316)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
(PE-19049) Can remove parameters from pe.conf
|
|
171
|
+
|
|
172
|
+
...using the update_pe_conf function. Since a null isn't meaningful
|
|
173
|
+
for a hocon lookup parameter in pe.conf (or at least, I can't think of
|
|
174
|
+
why it would be, at the moment), a nil can be used to remove a parameter
|
|
175
|
+
that we want to clean up from the file. It's possible I am overlooking
|
|
176
|
+
something tricky about nil, undef in hiera/lookup...it might be
|
|
177
|
+
applicable to a nodes.conf file where we wanted to clear a parameter on
|
|
178
|
+
a specific node that had been set in pe.conf, but this function only
|
|
179
|
+
applies to pe.conf, so I think this is acceptable for now.
|
|
180
|
+
```
|
|
181
|
+
* (maint) Use a Beaker::Host instance when mocking hosts (7154c008)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
(maint) Use a Beaker::Host instance when mocking hosts
|
|
186
|
+
|
|
187
|
+
The mock hosts being generated for tests where failing when :exec was
|
|
188
|
+
called, despite the allow() in the helpers.rb make_host() function.
|
|
189
|
+
Using a Beaker::Host resolved this.
|
|
190
|
+
```
|
|
191
|
+
* (PE-19049,PE-11353) Ensure puppet service is stopped in 2017.1+ builds (ed5d1499)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
(PE-19049,PE-11353) Ensure puppet service is stopped in 2017.1+ builds
|
|
196
|
+
|
|
197
|
+
We began managing the puppet service in 2017.1.0 and need to ensure it
|
|
198
|
+
is stopped and disabled after installation, otherwise each subsequent
|
|
199
|
+
puppet agent run will restart the agent service, causing potential havoc
|
|
200
|
+
in smoke tests or other setup steps.
|
|
201
|
+
```
|
|
202
|
+
* (PE-19049) Modify how we obtain console dispatcher for frictionless (858e63a9)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
(PE-19049) Modify how we obtain console dispatcher for frictionless
|
|
207
|
+
|
|
208
|
+
platform configuration of the master node. Expect to use the
|
|
209
|
+
beaker-pe-large-environments::classification#get_dispatcher()
|
|
210
|
+
method, which will only be present during a pe_acceptance_tests run,
|
|
211
|
+
when beaker-pe-large-environments is part of the gem bundle.
|
|
212
|
+
```
|
|
213
|
+
* (maint) Require beaker directly in spec_helper (1dbf8198)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
(maint) Require beaker directly in spec_helper
|
|
218
|
+
|
|
219
|
+
The individual specs were already requiring beaker. This change just
|
|
220
|
+
centralizes that into the spec_helper, and removes the
|
|
221
|
+
beaker_test_helper now that we are using Beaker 3.
|
|
222
|
+
```
|
|
223
|
+
* (PE-19049,PE-18718,PE-18799) Provide a test method for meep classification (6b9c6184)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
(PE-19049,PE-18718,PE-18799) Provide a test method for meep classification
|
|
228
|
+
|
|
229
|
+
so we can adjust tests and setup steps that need to work either with old
|
|
230
|
+
pe node groups, or with meep.
|
|
231
|
+
|
|
232
|
+
Ultimately the test is just based on version boundary. But while we are
|
|
233
|
+
validating meep classification, we need to be able to toggle around a
|
|
234
|
+
temporary feature flag: the pe_infrastructure::use_meep_for_classification
|
|
235
|
+
parameter.
|
|
236
|
+
|
|
237
|
+
The function checks to see if this has been passed into
|
|
238
|
+
beaker via the hosts file answers hash. These are answers which
|
|
239
|
+
beaker-answers would include in the pe.conf it generates.
|
|
240
|
+
|
|
241
|
+
It can also be set from an ENV['PE_USE_MEEP_FOR_CLASSIFICATION']
|
|
242
|
+
variable. This will make it easier to setup temporary ci jobs.
|
|
243
|
+
|
|
244
|
+
The answer file setting will take precedence over the environment
|
|
245
|
+
variable.
|
|
246
|
+
```
|
|
247
|
+
* (maint) Remove unused variables (7dce71cd)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
(maint) Remove unused variables
|
|
252
|
+
|
|
253
|
+
The version variable is not used in the fetch_pe_on_windows method (and
|
|
254
|
+
hopefully wasn't producing a useful side effect...)
|
|
255
|
+
|
|
256
|
+
The removed snapshot and box keys in HOST_DEFAULTS were being
|
|
257
|
+
overwritten by later keys in the same hash definition and were producing
|
|
258
|
+
warnings...
|
|
259
|
+
```
|
|
260
|
+
### <a name = "1.9.1">1.9.1 - 22 Feb, 2017 (3b0bd457)
|
|
261
|
+
|
|
262
|
+
* (HISTORY) update beaker-pe history for gem release 1.9.1 (3b0bd457)
|
|
35
263
|
|
|
36
264
|
* (GEM) update beaker-pe version to 1.9.1 (e2c53400)
|
|
37
265
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Please delete any headings that don't apply to this Pull Request (PR).
|
|
2
|
+
|
|
3
|
+
#### What's this PR do?
|
|
4
|
+
#### Who would you like to review this PR?
|
|
5
|
+
|
|
6
|
+
@puppetlabs/integration, @puppetlabs/beaker (repo owners)
|
|
7
|
+
|
|
8
|
+
#### Should any of this be tested outside the normal PR CI cycle?
|
|
9
|
+
#### Any background context you want to provide?
|
|
10
|
+
#### Questions for reviewers?
|
data/lib/beaker-pe.rb
CHANGED
|
@@ -26,6 +26,18 @@ module Beaker
|
|
|
26
26
|
|
|
27
27
|
# Version of PE when we switched from legacy installer to MEEP.
|
|
28
28
|
MEEP_CUTOVER_VERSION = '2016.2.0'
|
|
29
|
+
# Version of PE when we switched to using meep for classification
|
|
30
|
+
# instead of PE node groups
|
|
31
|
+
MEEP_CLASSIFICATION_VERSION = '2017.2.0'
|
|
32
|
+
# PE-18799 temporary default used for meep classification check while
|
|
33
|
+
# we navigate the switchover.
|
|
34
|
+
# PE-18718 switch flag to true once beaker-pe, beaker-answers,
|
|
35
|
+
# beaker-pe-large-environments and pe_acceptance_tests are ready
|
|
36
|
+
DEFAULT_MEEP_CLASSIFICATION = false
|
|
37
|
+
MEEP_DATA_DIR = '/etc/puppetlabs/enterprise'
|
|
38
|
+
PE_CONF_FILE = "#{MEEP_DATA_DIR}/conf.d/pe.conf"
|
|
39
|
+
NODE_CONF_PATH = "#{MEEP_DATA_DIR}/conf.d/nodes"
|
|
40
|
+
BEAKER_MEEP_TMP = "pe_conf"
|
|
29
41
|
|
|
30
42
|
# @!macro [new] common_opts
|
|
31
43
|
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
|
@@ -120,9 +132,11 @@ module Beaker
|
|
|
120
132
|
pe_cmd += " -y"
|
|
121
133
|
end
|
|
122
134
|
|
|
123
|
-
# If
|
|
135
|
+
# If we are doing an upgrade from 2016.2.0,
|
|
124
136
|
# we can assume there will be a valid pe.conf in /etc that we can re-use.
|
|
125
|
-
|
|
137
|
+
# We also expect that any custom_answers specified to beaker have been
|
|
138
|
+
# added to the pe.conf in /etc.
|
|
139
|
+
if opts[:type] == :upgrade && use_meep?(host[:previous_pe_ver])
|
|
126
140
|
"#{pe_cmd}"
|
|
127
141
|
else
|
|
128
142
|
"#{pe_cmd} #{host['pe_installer_conf_setting']}"
|
|
@@ -177,7 +191,6 @@ module Beaker
|
|
|
177
191
|
def fetch_pe_on_windows(host, opts)
|
|
178
192
|
path = host['pe_dir'] || opts[:pe_dir]
|
|
179
193
|
local = File.directory?(path)
|
|
180
|
-
version = host['pe_ver'] || opts[:pe_ver_win]
|
|
181
194
|
filename = "#{host['dist']}"
|
|
182
195
|
extension = ".msi"
|
|
183
196
|
if local
|
|
@@ -282,10 +295,13 @@ module Beaker
|
|
|
282
295
|
end
|
|
283
296
|
end
|
|
284
297
|
|
|
285
|
-
#Classify the master so that it can deploy frictionless packages for a given host.
|
|
298
|
+
#Classify the master so that it can deploy frictionless packages for a given host.
|
|
299
|
+
#This function does nothing when using meep for classification.
|
|
286
300
|
# @param [Host] host The host to install pacakges for
|
|
287
301
|
# @api private
|
|
288
302
|
def deploy_frictionless_to_master(host)
|
|
303
|
+
return if use_meep_for_classification?(master[:pe_ver], options)
|
|
304
|
+
|
|
289
305
|
platform = host['platform']
|
|
290
306
|
|
|
291
307
|
# We don't have a separate AIX 7.2 build, so it is
|
|
@@ -310,19 +326,12 @@ module Beaker
|
|
|
310
326
|
on dashboard, "cd /opt/puppet/share/puppet-dashboard && /opt/puppet/bin/bundle exec /opt/puppet/bin/rake node:addclass[#{master},#{klass}]"
|
|
311
327
|
on master, puppet("agent -t"), :acceptable_exit_codes => [0,2]
|
|
312
328
|
else
|
|
313
|
-
|
|
314
|
-
begin
|
|
315
|
-
require 'scooter'
|
|
316
|
-
rescue LoadError => e
|
|
317
|
-
@logger.notify('WARNING: gem scooter is required for frictionless installation post 3.8')
|
|
318
|
-
raise e
|
|
319
|
-
end
|
|
320
|
-
dispatcher = Scooter::HttpDispatchers::ConsoleDispatcher.new(dashboard)
|
|
329
|
+
_console_dispatcher = get_console_dispatcher_for_beaker_pe!
|
|
321
330
|
|
|
322
331
|
# Check if we've already created a frictionless agent node group
|
|
323
332
|
# to avoid errors creating the same node group when the beaker hosts file contains
|
|
324
333
|
# multiple hosts with the same platform
|
|
325
|
-
node_group =
|
|
334
|
+
node_group = _console_dispatcher.get_node_group_by_name('Beaker Frictionless Agent')
|
|
326
335
|
if node_group.nil? || node_group.empty?
|
|
327
336
|
node_group = {}
|
|
328
337
|
node_group['name'] = "Beaker Frictionless Agent"
|
|
@@ -334,7 +343,7 @@ module Beaker
|
|
|
334
343
|
# add the pe_repo platform class
|
|
335
344
|
node_group['classes'][klass] = {}
|
|
336
345
|
|
|
337
|
-
|
|
346
|
+
_console_dispatcher.create_new_node_group_model(node_group)
|
|
338
347
|
on master, puppet("agent -t"), :acceptable_exit_codes => [0,2]
|
|
339
348
|
end
|
|
340
349
|
end
|
|
@@ -447,9 +456,11 @@ module Beaker
|
|
|
447
456
|
else
|
|
448
457
|
prepare_host_installer_options(host)
|
|
449
458
|
register_feature_flags!(opts)
|
|
450
|
-
|
|
459
|
+
setup_pe_conf(host, hosts, opts)
|
|
460
|
+
|
|
451
461
|
on host, installer_cmd(host, opts)
|
|
452
462
|
configure_type_defaults_on(host)
|
|
463
|
+
download_pe_conf_if_master(host)
|
|
453
464
|
end
|
|
454
465
|
end
|
|
455
466
|
# On each agent, we ensure the certificate is signed
|
|
@@ -507,6 +518,11 @@ module Beaker
|
|
|
507
518
|
on dashboard, "/opt/puppet/bin/rake -sf /opt/puppet/share/puppet-dashboard/Rakefile #{task} RAILS_ENV=production"
|
|
508
519
|
end
|
|
509
520
|
|
|
521
|
+
# PE-18799 replace the version_is_less with a use_meep_for_classification? test
|
|
522
|
+
if use_meep_for_classification?(master[:pe_ver], options)
|
|
523
|
+
configure_puppet_agent_service(:ensure => 'stopped', :enabled => false)
|
|
524
|
+
end
|
|
525
|
+
|
|
510
526
|
step "Final puppet agent run" do
|
|
511
527
|
# Now that all hosts are in the dashbaord, run puppet one more
|
|
512
528
|
# time to configure mcollective
|
|
@@ -634,6 +650,31 @@ module Beaker
|
|
|
634
650
|
(host['platform'] =~ /windows/ && (version_is_less(host['pe_ver'], '2016.4.0') && !version_is_less(host['pe_ver'], '3.99'))) || (host['platform'] =~ /windows-2008r2/ && (version_is_less(host['pe_ver'], '2016.4.3') && !version_is_less(host['pe_ver'], '3.99')))
|
|
635
651
|
end
|
|
636
652
|
|
|
653
|
+
# True if version is greater than or equal to MEEP_CLASSIFICATION_VERSION
|
|
654
|
+
# (PE-18718) AND the temporary feature flag is true.
|
|
655
|
+
#
|
|
656
|
+
# The temporary feature flag is pe_modules_next and can be set in
|
|
657
|
+
# the :answers hash given in beaker's host.cfg, inside a feature_flags
|
|
658
|
+
# hash. It will also be picked up from the environment as
|
|
659
|
+
# PE_MODULES_NEXT. (See register_feature_flags!())
|
|
660
|
+
#
|
|
661
|
+
# The :answers hash value will take precedence over the env variable.
|
|
662
|
+
#
|
|
663
|
+
# @param version String the current PE version
|
|
664
|
+
# @param opts Hash options hash to inspect for :answers
|
|
665
|
+
# @return Boolean true if version and flag allows for meep classification
|
|
666
|
+
# feature.
|
|
667
|
+
def use_meep_for_classification?(version, opts)
|
|
668
|
+
# PE-19470 remove vv
|
|
669
|
+
register_feature_flags!(opts)
|
|
670
|
+
|
|
671
|
+
temporary_flag = feature_flag?('pe_modules_next', opts)
|
|
672
|
+
temporary_flag = DEFAULT_MEEP_CLASSIFICATION if temporary_flag.nil?
|
|
673
|
+
# ^^
|
|
674
|
+
|
|
675
|
+
!version_is_less(version, MEEP_CLASSIFICATION_VERSION) && temporary_flag
|
|
676
|
+
end
|
|
677
|
+
|
|
637
678
|
# For PE 3.8.5 to PE 2016.1.2 they have an expired gpg key. This method is
|
|
638
679
|
# for deb nodes to ignore the gpg-key expiration warning
|
|
639
680
|
def ignore_gpg_key_warning_on_hosts(hosts, opts)
|
|
@@ -927,6 +968,7 @@ module Beaker
|
|
|
927
968
|
hosts.each do |host|
|
|
928
969
|
prep_host_for_upgrade(host, opts, path)
|
|
929
970
|
end
|
|
971
|
+
|
|
930
972
|
do_install(sorted_hosts, opts.merge({:type => :upgrade, :set_console_password => set_console_password}))
|
|
931
973
|
opts['upgrade'] = true
|
|
932
974
|
end
|
|
@@ -1063,6 +1105,240 @@ module Beaker
|
|
|
1063
1105
|
scp_to host, "#{local_dir}/#{filename}#{extension}", host['working_dir']
|
|
1064
1106
|
end
|
|
1065
1107
|
|
|
1108
|
+
# Being able to modify PE's classifier requires the Scooter gem and
|
|
1109
|
+
# helpers which are in beaker-pe-large-environments.
|
|
1110
|
+
def get_console_dispatcher_for_beaker_pe(raise_exception = false)
|
|
1111
|
+
# XXX RE-8616, once scooter is public, we can remove this and just
|
|
1112
|
+
# reference ConsoleDispatcher directly.
|
|
1113
|
+
if !respond_to?(:get_dispatcher)
|
|
1114
|
+
begin
|
|
1115
|
+
require 'scooter'
|
|
1116
|
+
Scooter::HttpDispatchers::ConsoleDispatcher.new(dashboard)
|
|
1117
|
+
rescue LoadError => e
|
|
1118
|
+
logger.notify('WARNING: gem scooter is required for frictionless installation post 3.8')
|
|
1119
|
+
raise e if raise_exception
|
|
1120
|
+
|
|
1121
|
+
return nil
|
|
1122
|
+
end
|
|
1123
|
+
else
|
|
1124
|
+
get_dispatcher
|
|
1125
|
+
end
|
|
1126
|
+
end
|
|
1127
|
+
|
|
1128
|
+
# Will raise a LoadError if unable to require Scooter.
|
|
1129
|
+
def get_console_dispatcher_for_beaker_pe!
|
|
1130
|
+
get_console_dispatcher_for_beaker_pe(true)
|
|
1131
|
+
end
|
|
1132
|
+
|
|
1133
|
+
# In PE versions >= 2017.1.0, allows you to configure the puppet agent
|
|
1134
|
+
# service for all nodes.
|
|
1135
|
+
#
|
|
1136
|
+
# @param parameters [Hash] - agent profile parameters
|
|
1137
|
+
# @option parameters [Boolean] :managed - whether or not to manage the
|
|
1138
|
+
# agent resource at all (Optional, defaults to true).
|
|
1139
|
+
# @option parameters [String] :ensure - 'stopped', 'running'
|
|
1140
|
+
# @option parameters [Boolean] :enabled - whether the service will be
|
|
1141
|
+
# enabled (for restarts)
|
|
1142
|
+
# @raise [StandardError] if master version is less than 2017.1.0
|
|
1143
|
+
def configure_puppet_agent_service(parameters)
|
|
1144
|
+
raise(StandardError, "Can only manage puppet service in PE versions >= 2017.1.0; tried for #{master['pe_ver']}") if version_is_less(master['pe_ver'], '2017.1.0')
|
|
1145
|
+
puppet_managed = parameters.include?(:managed) ? parameters[:managed] : true
|
|
1146
|
+
puppet_ensure = parameters[:ensure]
|
|
1147
|
+
puppet_enabled = parameters[:enabled]
|
|
1148
|
+
|
|
1149
|
+
msg = puppet_managed ?
|
|
1150
|
+
"Configure agents '#{puppet_ensure}' and #{puppet_enabled ? 'enabled' : 'disabled'}" :
|
|
1151
|
+
"Do not manage agents"
|
|
1152
|
+
|
|
1153
|
+
step msg do
|
|
1154
|
+
# PE-18799 and remove this conditional
|
|
1155
|
+
if use_meep_for_classification?(master[:pe_ver], options)
|
|
1156
|
+
group_name = 'Puppet Enterprise Agent'
|
|
1157
|
+
class_name = 'pe_infrastructure::agent'
|
|
1158
|
+
else
|
|
1159
|
+
group_name = 'PE Agent'
|
|
1160
|
+
class_name = 'puppet_enterprise::profile::agent'
|
|
1161
|
+
end
|
|
1162
|
+
|
|
1163
|
+
# update pe conf
|
|
1164
|
+
# only the pe_infrastructure::agent parameters are relevant in pe.conf
|
|
1165
|
+
update_pe_conf({
|
|
1166
|
+
"pe_infrastructure::agent::puppet_service_managed" => puppet_managed,
|
|
1167
|
+
"pe_infrastructure::agent::puppet_service_ensure" => puppet_ensure,
|
|
1168
|
+
"pe_infrastructure::agent::puppet_service_enabled" => puppet_enabled,
|
|
1169
|
+
})
|
|
1170
|
+
|
|
1171
|
+
if _console_dispatcher = get_console_dispatcher_for_beaker_pe
|
|
1172
|
+
agent_group = _console_dispatcher.get_node_group_by_name(group_name)
|
|
1173
|
+
agent_class = agent_group['classes'][class_name]
|
|
1174
|
+
agent_class['puppet_service_managed'] = puppet_managed
|
|
1175
|
+
agent_class['puppet_service_ensure'] = puppet_ensure
|
|
1176
|
+
agent_class['puppet_service_enabled'] = puppet_enabled
|
|
1177
|
+
|
|
1178
|
+
_console_dispatcher.update_node_group(agent_group['id'], agent_group)
|
|
1179
|
+
end
|
|
1180
|
+
end
|
|
1181
|
+
end
|
|
1182
|
+
|
|
1183
|
+
# Given a hash of parameters, updates the primary master's pe.conf, adding or
|
|
1184
|
+
# replacing, or removing the given parameters.
|
|
1185
|
+
#
|
|
1186
|
+
# To remove a parameter, pass a nil as its value
|
|
1187
|
+
#
|
|
1188
|
+
# Handles stringifying and quoting namespaced keys, and also preparing non
|
|
1189
|
+
# string values using Hocon::ConfigValueFactory.
|
|
1190
|
+
#
|
|
1191
|
+
# Logs the state of pe.conf before and after.
|
|
1192
|
+
#
|
|
1193
|
+
# @example
|
|
1194
|
+
# # Assuming pe.conf looks like:
|
|
1195
|
+
# # {
|
|
1196
|
+
# # "bar": "baz"
|
|
1197
|
+
# # "old": "item"
|
|
1198
|
+
# # }
|
|
1199
|
+
#
|
|
1200
|
+
# update_pe_conf(
|
|
1201
|
+
# {
|
|
1202
|
+
# "foo" => "a",
|
|
1203
|
+
# "bar" => "b",
|
|
1204
|
+
# "old" => nil,
|
|
1205
|
+
# }
|
|
1206
|
+
# )
|
|
1207
|
+
#
|
|
1208
|
+
# # Will produce a pe.conf like:
|
|
1209
|
+
# # {
|
|
1210
|
+
# # "bar": "b"
|
|
1211
|
+
# # "foo": "a"
|
|
1212
|
+
# # }
|
|
1213
|
+
#
|
|
1214
|
+
# @param parameters [Hash] Hash of parameters to be included in pe.conf.
|
|
1215
|
+
# @param pe_conf_file [String] The file to update
|
|
1216
|
+
# (/etc/puppetlabs/enterprise/conf.d/pe.conf by default)
|
|
1217
|
+
def update_pe_conf(parameters, pe_conf_file = PE_CONF_FILE)
|
|
1218
|
+
step "Update #{pe_conf_file} with #{parameters}" do
|
|
1219
|
+
hocon_file_edit_in_place_on(master, pe_conf_file) do |host,doc|
|
|
1220
|
+
updated_doc = parameters.reduce(doc) do |pe_conf,param|
|
|
1221
|
+
key, value = param
|
|
1222
|
+
|
|
1223
|
+
hocon_key = quoted_hocon_key(key)
|
|
1224
|
+
|
|
1225
|
+
hocon_value = case value
|
|
1226
|
+
when String
|
|
1227
|
+
# ensure unquoted string values are quoted for uniformity
|
|
1228
|
+
then value.match(/^[^"]/) ? %Q{"#{value}"} : value
|
|
1229
|
+
else Hocon::ConfigValueFactory.from_any_ref(value, nil)
|
|
1230
|
+
end
|
|
1231
|
+
|
|
1232
|
+
updated = case value
|
|
1233
|
+
when String
|
|
1234
|
+
pe_conf.set_value(hocon_key, hocon_value)
|
|
1235
|
+
when nil
|
|
1236
|
+
pe_conf.remove_value(hocon_key)
|
|
1237
|
+
else
|
|
1238
|
+
pe_conf.set_config_value(hocon_key, hocon_value)
|
|
1239
|
+
end
|
|
1240
|
+
|
|
1241
|
+
updated
|
|
1242
|
+
end
|
|
1243
|
+
|
|
1244
|
+
# return the modified document
|
|
1245
|
+
updated_doc
|
|
1246
|
+
end
|
|
1247
|
+
on(master, "cat #{pe_conf_file}")
|
|
1248
|
+
end
|
|
1249
|
+
end
|
|
1250
|
+
|
|
1251
|
+
# If the key is unquoted and does not contain pathing ('.'),
|
|
1252
|
+
# quote to ensure that puppet namespaces are protected
|
|
1253
|
+
#
|
|
1254
|
+
# @example
|
|
1255
|
+
# quoted_hocon_key("puppet_enterprise::database_host")
|
|
1256
|
+
# # => '"puppet_enterprise::database_host"'
|
|
1257
|
+
#
|
|
1258
|
+
def quoted_hocon_key(key)
|
|
1259
|
+
case key
|
|
1260
|
+
when /^[^"][^.]+/
|
|
1261
|
+
then %Q{"#{key}"}
|
|
1262
|
+
else key
|
|
1263
|
+
end
|
|
1264
|
+
end
|
|
1265
|
+
|
|
1266
|
+
# @return a Ruby object of any root key in pe.conf.
|
|
1267
|
+
#
|
|
1268
|
+
# @param key [String] to lookup
|
|
1269
|
+
# @param pe_conf_path [String] defaults to /etc/puppetlabs/enterprise/conf.d/pe.conf
|
|
1270
|
+
def get_unwrapped_pe_conf_value(key, pe_conf_path = PE_CONF_FILE)
|
|
1271
|
+
file_contents = on(master, "cat #{pe_conf_path}").stdout
|
|
1272
|
+
# Seem to need to use ConfigFactory instead of ConfigDocumentFactory
|
|
1273
|
+
# to get something that we can read values from?
|
|
1274
|
+
doc = Hocon::ConfigFactory.parse_string(file_contents)
|
|
1275
|
+
hocon_key = quoted_hocon_key(key)
|
|
1276
|
+
doc.has_path?(hocon_key) ?
|
|
1277
|
+
doc.get_value(hocon_key).unwrapped :
|
|
1278
|
+
nil
|
|
1279
|
+
end
|
|
1280
|
+
|
|
1281
|
+
# Creates a new /etc/puppetlabs/enterprise/conf.d/nodes/*.conf file for the
|
|
1282
|
+
# given host's certname, and adds the passed parameters, or updates with the
|
|
1283
|
+
# passed parameters if the file already exists.
|
|
1284
|
+
#
|
|
1285
|
+
# Does not remove an empty file.
|
|
1286
|
+
#
|
|
1287
|
+
# @param host [Beaker::Host] to create a node file for
|
|
1288
|
+
# @param parameters [Hash] of key value pairs to add to the nodes conf file
|
|
1289
|
+
# @param node_conf_path [String] defaults to /etc/puppetlabs/enterprise/conf.d/nodes
|
|
1290
|
+
def create_or_update_node_conf(host, parameters, node_conf_path = NODE_CONF_PATH)
|
|
1291
|
+
node_conf_file = "#{node_conf_path}/#{host.node_name}.conf"
|
|
1292
|
+
step "Create or Update #{node_conf_file} with #{parameters}" do
|
|
1293
|
+
if !master.file_exist?(node_conf_file)
|
|
1294
|
+
if !master.file_exist?(node_conf_path)
|
|
1295
|
+
# potentially create the nodes directory
|
|
1296
|
+
on(master, "mkdir #{node_conf_path}")
|
|
1297
|
+
end
|
|
1298
|
+
# The hocon gem will create a list of comma separated parameters
|
|
1299
|
+
# on the same line unless we start with something in the file.
|
|
1300
|
+
create_remote_file(master, node_conf_file, %Q|{\n}\n|)
|
|
1301
|
+
on(master, "chown pe-puppet #{node_conf_file}")
|
|
1302
|
+
end
|
|
1303
|
+
update_pe_conf(parameters, node_conf_file)
|
|
1304
|
+
end
|
|
1305
|
+
end
|
|
1306
|
+
|
|
1307
|
+
def setup_pe_conf(host, hosts, opts={})
|
|
1308
|
+
if opts[:type] == :upgrade && use_meep?(host['previous_pe_ver'])
|
|
1309
|
+
# In this scenario, Beaker runs the installer such that we make
|
|
1310
|
+
# use of recovery code in the configure face of the installer.
|
|
1311
|
+
if host['roles'].include?('master')
|
|
1312
|
+
step "Updating #{MEEP_DATA_DIR}/conf.d with answers/custom_answers" do
|
|
1313
|
+
# merge answers into pe.conf
|
|
1314
|
+
if opts[:answers] && !opts[:answers].empty?
|
|
1315
|
+
update_pe_conf(opts[:answers])
|
|
1316
|
+
end
|
|
1317
|
+
|
|
1318
|
+
if opts[:custom_answers] && !opts[:custom_answers].empty?
|
|
1319
|
+
update_pe_conf(opts[:custom_answers])
|
|
1320
|
+
end
|
|
1321
|
+
end
|
|
1322
|
+
else
|
|
1323
|
+
step "Uploading #{BEAKER_MEEP_TMP}/conf.d that was generated on the master" do
|
|
1324
|
+
# scp conf.d to host
|
|
1325
|
+
scp_to(host, "#{BEAKER_MEEP_TMP}/conf.d", MEEP_DATA_DIR)
|
|
1326
|
+
end
|
|
1327
|
+
end
|
|
1328
|
+
else
|
|
1329
|
+
# Beaker creates a fresh pe.conf using beaker-answers, as if we were doing an install
|
|
1330
|
+
generate_installer_conf_file_for(host, hosts, opts)
|
|
1331
|
+
end
|
|
1332
|
+
end
|
|
1333
|
+
|
|
1334
|
+
def download_pe_conf_if_master(host)
|
|
1335
|
+
if host['roles'].include?('master')
|
|
1336
|
+
step "Downloading generated #{MEEP_DATA_DIR}/conf.d locally" do
|
|
1337
|
+
# scp conf.d over from master
|
|
1338
|
+
scp_from(host, "#{MEEP_DATA_DIR}/conf.d", BEAKER_MEEP_TMP)
|
|
1339
|
+
end
|
|
1340
|
+
end
|
|
1341
|
+
end
|
|
1066
1342
|
end
|
|
1067
1343
|
end
|
|
1068
1344
|
end
|
data/lib/beaker-pe/version.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require 'beaker'
|
|
3
2
|
|
|
4
3
|
class ClassMixedWithDSLInstallUtils
|
|
5
4
|
include Beaker::DSL::InstallUtils
|
|
@@ -10,10 +9,11 @@ class ClassMixedWithDSLInstallUtils
|
|
|
10
9
|
include Beaker::DSL::Patterns
|
|
11
10
|
include Beaker::DSL::PE
|
|
12
11
|
|
|
13
|
-
attr_accessor :hosts, :metadata
|
|
12
|
+
attr_accessor :hosts, :metadata, :options
|
|
14
13
|
|
|
15
14
|
def initialize
|
|
16
15
|
@metadata = {}
|
|
16
|
+
@options = {}
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
# Because some the methods now actually call out to the `step` method, we need to
|
|
@@ -364,7 +364,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
|
364
364
|
end
|
|
365
365
|
|
|
366
366
|
def slice_installer_options(host)
|
|
367
|
-
host.select { |k,v| [ :pe_installer_conf_file, :pe_installer_conf_setting].include?(k) }
|
|
367
|
+
host.host_hash.select { |k,v| [ :pe_installer_conf_file, :pe_installer_conf_setting].include?(k) }
|
|
368
368
|
end
|
|
369
369
|
|
|
370
370
|
context 'when version < 2016.2.0' do
|
|
@@ -391,6 +391,82 @@ describe ClassMixedWithDSLInstallUtils do
|
|
|
391
391
|
end
|
|
392
392
|
end
|
|
393
393
|
|
|
394
|
+
describe 'use_meep_for_classification?' do
|
|
395
|
+
let(:feature_flag) { nil }
|
|
396
|
+
let(:environment_feature_flag) { nil }
|
|
397
|
+
let(:answers) do
|
|
398
|
+
{
|
|
399
|
+
:answers => {
|
|
400
|
+
'feature_flags' => {
|
|
401
|
+
'pe_modules_next' => feature_flag,
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
}
|
|
405
|
+
end
|
|
406
|
+
let(:options) do
|
|
407
|
+
feature_flag.nil? ?
|
|
408
|
+
opts :
|
|
409
|
+
opts.merge(answers)
|
|
410
|
+
end
|
|
411
|
+
let(:host) { unixhost }
|
|
412
|
+
|
|
413
|
+
before(:each) do
|
|
414
|
+
subject.options = options
|
|
415
|
+
if !environment_feature_flag.nil?
|
|
416
|
+
ENV['PE_MODULES_NEXT'] = environment_feature_flag
|
|
417
|
+
end
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
after(:each) do
|
|
421
|
+
ENV.delete('PE_MODULES_NEXT')
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
|
|
425
|
+
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(false) }
|
|
426
|
+
|
|
427
|
+
context 'feature flag false' do
|
|
428
|
+
let(:feature_flag) { false }
|
|
429
|
+
|
|
430
|
+
it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
|
|
431
|
+
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(false) }
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
context 'feature flag true' do
|
|
435
|
+
let(:feature_flag) { true }
|
|
436
|
+
|
|
437
|
+
it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
|
|
438
|
+
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(true) }
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
context 'environment feature flag true' do
|
|
442
|
+
let(:environment_feature_flag) { 'true' }
|
|
443
|
+
|
|
444
|
+
it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
|
|
445
|
+
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(true) }
|
|
446
|
+
|
|
447
|
+
context 'answers feature flag false' do
|
|
448
|
+
let(:feature_flag) { false }
|
|
449
|
+
|
|
450
|
+
it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
|
|
451
|
+
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(false) }
|
|
452
|
+
end
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
context 'environment feature flag false' do
|
|
456
|
+
let(:environment_feature_flag) { 'false' }
|
|
457
|
+
|
|
458
|
+
it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
|
|
459
|
+
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(false) }
|
|
460
|
+
|
|
461
|
+
context 'answers feature flag true' do
|
|
462
|
+
let(:feature_flag) { true }
|
|
463
|
+
|
|
464
|
+
it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
|
|
465
|
+
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(true) }
|
|
466
|
+
end
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
|
|
394
470
|
describe 'generate_installer_conf_file_for' do
|
|
395
471
|
let(:master) { hosts.first }
|
|
396
472
|
|
|
@@ -821,6 +897,8 @@ describe ClassMixedWithDSLInstallUtils do
|
|
|
821
897
|
allow( subject ).to receive( :hosts ).and_return( hosts )
|
|
822
898
|
#create answers file per-host, except windows
|
|
823
899
|
expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
|
|
900
|
+
# copy the pe.conf
|
|
901
|
+
expect( subject ).to receive( :scp_from ).and_return(true)
|
|
824
902
|
#run installer on all hosts
|
|
825
903
|
expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
|
|
826
904
|
expect( subject ).to receive( :install_msi_on ).with ( any_args ) do | host, msi_path, msi_opts, opts |
|
|
@@ -965,6 +1043,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
|
965
1043
|
allow( subject ).to receive( :configure_type_defaults_on ).with( host )
|
|
966
1044
|
end
|
|
967
1045
|
|
|
1046
|
+
expect( subject ).to receive( :scp_from ).and_return(true)
|
|
968
1047
|
subject.do_install( hosts, opts )
|
|
969
1048
|
end
|
|
970
1049
|
|
|
@@ -1030,6 +1109,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
|
1030
1109
|
allow( subject ).to receive( :configure_type_defaults_on ).with( host )
|
|
1031
1110
|
end
|
|
1032
1111
|
|
|
1112
|
+
expect( subject ).to receive( :scp_from ).and_return(true)
|
|
1033
1113
|
subject.do_install( hosts, opts )
|
|
1034
1114
|
end
|
|
1035
1115
|
|
|
@@ -1100,6 +1180,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
|
1100
1180
|
allow( subject ).to receive( :configure_type_defaults_on ).with( host )
|
|
1101
1181
|
end
|
|
1102
1182
|
|
|
1183
|
+
expect( subject ).to receive( :scp_from ).and_return(true)
|
|
1103
1184
|
subject.do_install( hosts, opts )
|
|
1104
1185
|
end
|
|
1105
1186
|
|
|
@@ -1521,4 +1602,234 @@ describe ClassMixedWithDSLInstallUtils do
|
|
|
1521
1602
|
end
|
|
1522
1603
|
end
|
|
1523
1604
|
end
|
|
1605
|
+
|
|
1606
|
+
def assert_meep_conf_edit(input, output, path, &test)
|
|
1607
|
+
# mock reading pe.conf
|
|
1608
|
+
expect(master).to receive(:exec).with(
|
|
1609
|
+
have_attributes(:command => match(%r{cat #{path}})),
|
|
1610
|
+
anything
|
|
1611
|
+
).and_return(
|
|
1612
|
+
double('result', :stdout => input)
|
|
1613
|
+
)
|
|
1614
|
+
|
|
1615
|
+
# mock writing pe.conf and check for parameters
|
|
1616
|
+
expect(subject).to receive(:create_remote_file).with(
|
|
1617
|
+
master,
|
|
1618
|
+
path,
|
|
1619
|
+
output
|
|
1620
|
+
)
|
|
1621
|
+
|
|
1622
|
+
yield
|
|
1623
|
+
end
|
|
1624
|
+
|
|
1625
|
+
describe 'configure_puppet_agent_service' do
|
|
1626
|
+
let(:pe_version) { '2017.1.0' }
|
|
1627
|
+
let(:master) { hosts[0] }
|
|
1628
|
+
|
|
1629
|
+
before(:each) do
|
|
1630
|
+
hosts.each { |h| h[:pe_ver] = pe_version }
|
|
1631
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
|
1632
|
+
end
|
|
1633
|
+
|
|
1634
|
+
it 'requires parameters' do
|
|
1635
|
+
expect { subject.configure_puppet_agent_service }.to raise_error(ArgumentError, /wrong number/)
|
|
1636
|
+
end
|
|
1637
|
+
|
|
1638
|
+
context 'master prior to 2017.1.0' do
|
|
1639
|
+
let(:pe_version) { '2016.5.1' }
|
|
1640
|
+
|
|
1641
|
+
it 'raises an exception about version' do
|
|
1642
|
+
expect { subject.configure_puppet_agent_service({}) }.to(
|
|
1643
|
+
raise_error(StandardError, /Can only manage.*2017.1.0; tried.* 2016.5.1/)
|
|
1644
|
+
)
|
|
1645
|
+
end
|
|
1646
|
+
end
|
|
1647
|
+
|
|
1648
|
+
context '2017.1.0 master' do
|
|
1649
|
+
let(:pe_conf_path) { '/etc/puppetlabs/enterprise/conf.d/pe.conf' }
|
|
1650
|
+
let(:pe_conf) do
|
|
1651
|
+
<<-EOF
|
|
1652
|
+
"node_roles": {
|
|
1653
|
+
"pe_role::monolithic::primary_master": ["#{master.name}"],
|
|
1654
|
+
}
|
|
1655
|
+
EOF
|
|
1656
|
+
end
|
|
1657
|
+
let(:gold_pe_conf) do
|
|
1658
|
+
<<-EOF
|
|
1659
|
+
"node_roles": {
|
|
1660
|
+
"pe_role::monolithic::primary_master": ["#{master.name}"],
|
|
1661
|
+
}
|
|
1662
|
+
"pe_infrastructure::agent::puppet_service_managed": true
|
|
1663
|
+
"pe_infrastructure::agent::puppet_service_ensure": "stopped"
|
|
1664
|
+
"pe_infrastructure::agent::puppet_service_enabled": false
|
|
1665
|
+
EOF
|
|
1666
|
+
end
|
|
1667
|
+
|
|
1668
|
+
it "modifies the agent puppet service settings in pe.conf" do
|
|
1669
|
+
# mock hitting the console
|
|
1670
|
+
dispatcher = double('dispatcher').as_null_object
|
|
1671
|
+
expect(subject).to receive(:get_console_dispatcher_for_beaker_pe)
|
|
1672
|
+
.and_return(dispatcher)
|
|
1673
|
+
|
|
1674
|
+
assert_meep_conf_edit(pe_conf, gold_pe_conf, pe_conf_path) do
|
|
1675
|
+
subject.configure_puppet_agent_service(:ensure => 'stopped', :enabled => false)
|
|
1676
|
+
end
|
|
1677
|
+
end
|
|
1678
|
+
end
|
|
1679
|
+
end
|
|
1680
|
+
|
|
1681
|
+
describe 'update_pe_conf' do
|
|
1682
|
+
let(:pe_version) { '2017.1.0' }
|
|
1683
|
+
let(:master) { hosts[0] }
|
|
1684
|
+
|
|
1685
|
+
before(:each) do
|
|
1686
|
+
hosts.each { |h| h[:pe_ver] = pe_version }
|
|
1687
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
|
1688
|
+
end
|
|
1689
|
+
|
|
1690
|
+
it 'requires parameters' do
|
|
1691
|
+
expect { subject.update_pe_conf}.to raise_error(ArgumentError, /wrong number/)
|
|
1692
|
+
end
|
|
1693
|
+
|
|
1694
|
+
context '2017.1.0 master' do
|
|
1695
|
+
let(:pe_conf_path) { '/etc/puppetlabs/enterprise/conf.d/pe.conf' }
|
|
1696
|
+
let(:pe_conf) do
|
|
1697
|
+
<<-EOF
|
|
1698
|
+
"node_roles": {
|
|
1699
|
+
"pe_role::monolithic::primary_master": ["#{master.name}"],
|
|
1700
|
+
}
|
|
1701
|
+
"namespace::removed": "bye"
|
|
1702
|
+
"namespace::changed": "old"
|
|
1703
|
+
EOF
|
|
1704
|
+
end
|
|
1705
|
+
let(:gold_pe_conf) do
|
|
1706
|
+
<<-EOF
|
|
1707
|
+
"node_roles": {
|
|
1708
|
+
"pe_role::monolithic::primary_master": ["#{master.name}"],
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
"namespace::changed": "new"
|
|
1712
|
+
"namespace::add": "hi"
|
|
1713
|
+
"namespace::add2": "other"
|
|
1714
|
+
EOF
|
|
1715
|
+
end
|
|
1716
|
+
|
|
1717
|
+
it "adds, changes and removes hocon parameters from pe.conf" do
|
|
1718
|
+
assert_meep_conf_edit(pe_conf, gold_pe_conf, pe_conf_path) do
|
|
1719
|
+
subject.update_pe_conf(
|
|
1720
|
+
{
|
|
1721
|
+
"namespace::add" => "hi",
|
|
1722
|
+
"namespace::changed" => "new",
|
|
1723
|
+
"namespace::removed" => nil,
|
|
1724
|
+
"namespace::add2" => "other",
|
|
1725
|
+
}
|
|
1726
|
+
)
|
|
1727
|
+
end
|
|
1728
|
+
end
|
|
1729
|
+
end
|
|
1730
|
+
end
|
|
1731
|
+
|
|
1732
|
+
describe 'create_or_update_node_conf' do
|
|
1733
|
+
let(:pe_version) { '2017.1.0' }
|
|
1734
|
+
let(:master) { hosts[0] }
|
|
1735
|
+
let(:node) { hosts[1] }
|
|
1736
|
+
let(:node_conf_path) { "/etc/puppetlabs/enterprise/conf.d/nodes/vm2.conf" }
|
|
1737
|
+
let(:node_conf) do
|
|
1738
|
+
<<-EOF
|
|
1739
|
+
"namespace::removed": "bye"
|
|
1740
|
+
"namespace::changed": "old"
|
|
1741
|
+
EOF
|
|
1742
|
+
end
|
|
1743
|
+
let(:updated_node_conf) do
|
|
1744
|
+
<<-EOF
|
|
1745
|
+
|
|
1746
|
+
"namespace::changed": "new"
|
|
1747
|
+
"namespace::add": "hi"
|
|
1748
|
+
EOF
|
|
1749
|
+
end
|
|
1750
|
+
let(:created_node_conf) do
|
|
1751
|
+
<<-EOF
|
|
1752
|
+
{
|
|
1753
|
+
"namespace::one": "red"
|
|
1754
|
+
"namespace::two": "blue"
|
|
1755
|
+
}
|
|
1756
|
+
EOF
|
|
1757
|
+
end
|
|
1758
|
+
|
|
1759
|
+
before(:each) do
|
|
1760
|
+
hosts.each { |h| h[:pe_ver] = pe_version }
|
|
1761
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
|
1762
|
+
end
|
|
1763
|
+
|
|
1764
|
+
it 'requires parameters' do
|
|
1765
|
+
expect { subject.update_pe_conf}.to raise_error(ArgumentError, /wrong number/)
|
|
1766
|
+
end
|
|
1767
|
+
|
|
1768
|
+
it 'creates a node file that did not exist' do
|
|
1769
|
+
expect(master).to receive(:file_exist?).with(node_conf_path).and_return(false)
|
|
1770
|
+
expect(master).to receive(:file_exist?).with("/etc/puppetlabs/enterprise/conf.d/nodes").and_return(false)
|
|
1771
|
+
expect(subject).to receive(:create_remote_file).with(master, node_conf_path, %Q|{\n}\n|)
|
|
1772
|
+
|
|
1773
|
+
assert_meep_conf_edit(%Q|{\n}\n|, created_node_conf, node_conf_path) do
|
|
1774
|
+
subject.create_or_update_node_conf(
|
|
1775
|
+
node,
|
|
1776
|
+
{
|
|
1777
|
+
"namespace::one" => "red",
|
|
1778
|
+
"namespace::two" => "blue",
|
|
1779
|
+
},
|
|
1780
|
+
)
|
|
1781
|
+
end
|
|
1782
|
+
end
|
|
1783
|
+
|
|
1784
|
+
it 'updates a node file that did exist' do
|
|
1785
|
+
assert_meep_conf_edit(node_conf, updated_node_conf, node_conf_path) do
|
|
1786
|
+
subject.create_or_update_node_conf(
|
|
1787
|
+
node,
|
|
1788
|
+
{
|
|
1789
|
+
"namespace::add" => "hi",
|
|
1790
|
+
"namespace::changed" => "new",
|
|
1791
|
+
"namespace::removed" => nil,
|
|
1792
|
+
},
|
|
1793
|
+
)
|
|
1794
|
+
end
|
|
1795
|
+
end
|
|
1796
|
+
end
|
|
1797
|
+
|
|
1798
|
+
describe "get_unwrapped_pe_conf_value" do
|
|
1799
|
+
let(:pe_version) { '2017.1.0' }
|
|
1800
|
+
let(:master) { hosts[0] }
|
|
1801
|
+
let(:pe_conf_path) { "/etc/puppetlabs/enterprise/conf.d/pe.conf" }
|
|
1802
|
+
let(:pe_conf) do
|
|
1803
|
+
<<-EOF
|
|
1804
|
+
"namespace::bool": true
|
|
1805
|
+
"namespace::string": "stringy"
|
|
1806
|
+
"namespace::array": ["of", "things"]
|
|
1807
|
+
"namespace::hash": {
|
|
1808
|
+
"foo": "a"
|
|
1809
|
+
"bar": "b"
|
|
1810
|
+
}
|
|
1811
|
+
EOF
|
|
1812
|
+
end
|
|
1813
|
+
|
|
1814
|
+
before(:each) do
|
|
1815
|
+
hosts.each { |h| h[:pe_ver] = pe_version }
|
|
1816
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
|
1817
|
+
expect(master).to receive(:exec).with(
|
|
1818
|
+
have_attributes(:command => match(%r{cat #{pe_conf_path}})),
|
|
1819
|
+
anything
|
|
1820
|
+
).and_return(
|
|
1821
|
+
double('result', :stdout => pe_conf)
|
|
1822
|
+
)
|
|
1823
|
+
end
|
|
1824
|
+
|
|
1825
|
+
it { expect(subject.get_unwrapped_pe_conf_value("namespace::bool")).to eq(true) }
|
|
1826
|
+
it { expect(subject.get_unwrapped_pe_conf_value("namespace::string")).to eq("stringy") }
|
|
1827
|
+
it { expect(subject.get_unwrapped_pe_conf_value("namespace::array")).to eq(["of","things"]) }
|
|
1828
|
+
it do
|
|
1829
|
+
expect(subject.get_unwrapped_pe_conf_value("namespace::hash")).to eq({
|
|
1830
|
+
'foo' => 'a',
|
|
1831
|
+
'bar' => 'b',
|
|
1832
|
+
})
|
|
1833
|
+
end
|
|
1834
|
+
end
|
|
1524
1835
|
end
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
class ClassPEClientToolsMixedWithPatterns
|
|
4
4
|
include Beaker::DSL::InstallUtils::PEClientTools
|
|
5
5
|
include Beaker::DSL::Patterns
|
|
6
6
|
end
|
|
7
|
+
|
|
7
8
|
describe ClassPEClientToolsMixedWithPatterns do
|
|
8
9
|
describe "#install_pe_client_tools_on" do
|
|
9
10
|
let(:hosts) do
|
data/spec/helpers.rb
CHANGED
|
@@ -26,8 +26,6 @@ end
|
|
|
26
26
|
|
|
27
27
|
module HostHelpers
|
|
28
28
|
HOST_DEFAULTS = { :platform => 'unix',
|
|
29
|
-
:snapshot => 'pe',
|
|
30
|
-
:box => 'box_name',
|
|
31
29
|
:roles => ['agent'],
|
|
32
30
|
:snapshot => 'snap',
|
|
33
31
|
:ip => 'default.ip.address',
|
|
@@ -78,9 +76,9 @@ module HostHelpers
|
|
|
78
76
|
end
|
|
79
77
|
|
|
80
78
|
def make_host name, host_hash
|
|
81
|
-
host_hash =
|
|
79
|
+
host_hash = Beaker::Options::OptionsHash.new.merge(HOST_DEFAULTS.merge(host_hash))
|
|
82
80
|
|
|
83
|
-
host =
|
|
81
|
+
host = Beaker::Host.create( name, host_hash, make_opts)
|
|
84
82
|
|
|
85
83
|
allow(host).to receive( :name ).and_return( name )
|
|
86
84
|
allow(host).to receive( :hostname ).and_return( "#{name}.test" )
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: beaker-pe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Puppetlabs
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-03-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -179,6 +179,7 @@ files:
|
|
|
179
179
|
- HISTORY.md
|
|
180
180
|
- LICENSE
|
|
181
181
|
- MAINTAINERS
|
|
182
|
+
- PULL_REQUEST_TEMPLATE.md
|
|
182
183
|
- README.md
|
|
183
184
|
- Rakefile
|
|
184
185
|
- acceptance/config/nodes/vagrant-ubuntu-1404.yml
|
|
@@ -204,7 +205,6 @@ files:
|
|
|
204
205
|
- spec/beaker-pe/pe-client-tools/config_file_helper_spec.rb
|
|
205
206
|
- spec/beaker-pe/pe-client-tools/executable_helper_spec.rb
|
|
206
207
|
- spec/beaker-pe/pe-client-tools/installer_helper_spec.rb
|
|
207
|
-
- spec/beaker_test_helpers.rb
|
|
208
208
|
- spec/helpers.rb
|
|
209
209
|
- spec/spec_helper.rb
|
|
210
210
|
homepage: https://github.com/puppetlabs/beaker-pe
|
data/spec/beaker_test_helpers.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# These are specifically to mock Beaker methods necessary for testing
|
|
2
|
-
# that will be available during runtime because this is never run separate
|
|
3
|
-
# from Beaker itself.
|
|
4
|
-
#
|
|
5
|
-
# Including Beaker as a dependency would not work as a solution to this issue,
|
|
6
|
-
# since that would make a cycle in the dependency graph, at least until
|
|
7
|
-
# Beaker 3.0 happens and this is no longer a dependency of Beaker's.
|
|
8
|
-
module BeakerTestHelpers
|
|
9
|
-
include Beaker::DSL
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
module Beaker
|
|
13
|
-
module DSL
|
|
14
|
-
def self.register( helper )
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|