beaker-answers 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/HISTORY.md +66 -2
- data/MAINTAINERS +33 -0
- data/README.md +24 -1
- data/lib/beaker-answers.rb +1 -0
- data/lib/beaker-answers/pe_conf.rb +162 -0
- data/lib/beaker-answers/version.rb +1 -1
- data/lib/beaker-answers/versions/version20162.rb +2 -17
- data/lib/beaker-answers/versions/version20171.rb +0 -69
- data/lib/beaker-answers/versions/version20172.rb +21 -0
- data/spec/beaker-answers/pe_conf_spec.rb +97 -0
- data/spec/beaker-answers/versions/version20171_spec.rb +15 -36
- data/spec/beaker-answers/versions/version20172_spec.rb +99 -0
- data/spec/shared/context.rb +27 -9
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmJlYjRlM2IyOTA2MjZlNjk3NzY4NWI4NTZkZDFlZTU2NzBkYmI5ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTlhZmQyZDVhNzZjYmZjMmE5NzFhZmVkMThmZDYzOTFlMjY0Y2UzMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTg3ZWNiZDY1MWI3NThlMzBmODU2ZmIyYjJhMWQ4ZGU5YTJhMWVlYjFjZjE4
|
10
|
+
Y2I3MTA1ODc2OGViZjUxYTI4NDI5MGU3M2FkMjUxZjAwMWY2NzkzMTZmYzQ0
|
11
|
+
ZWJjZTMzMjgzMjhmZGMzYTU5Zjg1ZDBmZTZiYzE1ZTA2ODc0Yzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjUxZmIwMmE5Nzk4ZDcwODdiY2M1YzMwOWYyZmNkMTQyZDg5M2ViNzU2YjIy
|
14
|
+
MjgzMWI3NzM0YmZjMTdhODZlZWFlZDVlZTQzMmRjM2QwYzIyOTU3ODY2YmEx
|
15
|
+
MjcyNmEyNjU5NGRjNDUwNmEwMDRkYzJmYTk5YzE2OTg0NzZlODE=
|
data/HISTORY.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# default - History
|
2
2
|
## Tags
|
3
|
-
* [LATEST -
|
3
|
+
* [LATEST - 19 Jan, 2017 (2aaa08e1)](#LATEST)
|
4
|
+
* [0.13.0 - 9 Nov, 2016 (729ddd0b)](#0.13.0)
|
4
5
|
* [0.12.0 - 28 Oct, 2016 (b18d96b7)](#0.12.0)
|
5
6
|
* [0.11.0 - 22 Aug, 2016 (39591691)](#0.11.0)
|
6
7
|
* [0.10.0 - 15 Aug, 2016 (30507062)](#0.10.0)
|
@@ -24,7 +25,70 @@
|
|
24
25
|
* [0.1.0 - 26 Aug, 2015 (ef47972d)](#0.1.0)
|
25
26
|
|
26
27
|
## Details
|
27
|
-
### <a name = "LATEST">LATEST -
|
28
|
+
### <a name = "LATEST">LATEST - 19 Jan, 2017 (2aaa08e1)
|
29
|
+
|
30
|
+
* (GEM) update beaker-answers version to 0.14.0 (2aaa08e1)
|
31
|
+
|
32
|
+
* Merge pull request #31 from jpartlow/issue/master/pe-19203-revert-meep-classification (f4d3c6ee)
|
33
|
+
|
34
|
+
|
35
|
+
```
|
36
|
+
Merge pull request #31 from jpartlow/issue/master/pe-19203-revert-meep-classification
|
37
|
+
|
38
|
+
(PE-19203,PE-16706) Revert meep classification from Flanders
|
39
|
+
```
|
40
|
+
* (PE-19203) Only generate 1.0 pe.conf in 20171 (49a7230b)
|
41
|
+
|
42
|
+
|
43
|
+
```
|
44
|
+
(PE-19203) Only generate 1.0 pe.conf in 20171
|
45
|
+
|
46
|
+
...and move pe.conf generation based on meep_schema_version flag into
|
47
|
+
2017.2 which is the first version where we'll be testing with variable
|
48
|
+
pe-modules packages.
|
49
|
+
```
|
50
|
+
* (PE-16706) Add a 2017.2 version (8eed8fb7)
|
51
|
+
|
52
|
+
* (PE-19203,PE-17621) Generate a meep 2.0 format based on version flag (29e2dff3)
|
53
|
+
|
54
|
+
|
55
|
+
```
|
56
|
+
(PE-19203,PE-17621) Generate a meep 2.0 format based on version flag
|
57
|
+
|
58
|
+
Previously there was a hard version break set on PE 2017.1 which would
|
59
|
+
produce a 2.0 format pe.conf, but since we've had to back out meep
|
60
|
+
classification in Flanders, this needs to change.
|
61
|
+
|
62
|
+
Added a PeConf object to generate 1.0 and 2.0 format files based on a
|
63
|
+
meep_schema_version flag. It defaults to the original 1.0 format. It
|
64
|
+
will be up to beaker-pe to submit this flag in the beaker options based
|
65
|
+
on its use_meep_for_classification?() test.
|
66
|
+
|
67
|
+
There is one change to the 1.0 hiera_host_config implementation in that
|
68
|
+
it no longer uses answer_for to set the master, db, console settings. I
|
69
|
+
don't think this matters because there are no defaults for these
|
70
|
+
settings, and beaker answer overrides are merged afterwards in
|
71
|
+
generate_hiera_config() regardless.
|
72
|
+
```
|
73
|
+
* Merge pull request #29 from kevpl/docs_README_fill (760e80c9)
|
74
|
+
|
75
|
+
|
76
|
+
```
|
77
|
+
Merge pull request #29 from kevpl/docs_README_fill
|
78
|
+
|
79
|
+
(MAINT) fill README with Rubydocs & release info
|
80
|
+
```
|
81
|
+
* (MAINT) fill README with Rubydocs & release info (45a853ec)
|
82
|
+
|
83
|
+
|
84
|
+
```
|
85
|
+
(MAINT) fill README with Rubydocs & release info
|
86
|
+
|
87
|
+
[skip ci]
|
88
|
+
```
|
89
|
+
### <a name = "0.13.0">0.13.0 - 9 Nov, 2016 (729ddd0b)
|
90
|
+
|
91
|
+
* (HISTORY) update beaker-answers history for gem release 0.13.0 (729ddd0b)
|
28
92
|
|
29
93
|
* (GEM) update beaker-answers version to 0.13.0 (f415b5e1)
|
30
94
|
|
data/MAINTAINERS
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"version": 1,
|
3
|
+
"file_format": "This MAINTAINERS file format is described at http://pup.pt/maintainers",
|
4
|
+
"issues": "https://tickets.puppet.com/browse/PE",
|
5
|
+
"internal_list": "https://groups.google.com/a/puppet.com/forum/?hl=en#!forum/discuss-organizational-scale",
|
6
|
+
"people": [
|
7
|
+
{
|
8
|
+
"github": "kevpl",
|
9
|
+
"email": "ki@puppet.com",
|
10
|
+
"name": "Kevin Imber"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"github": "tvpartytonight",
|
14
|
+
"email": "tv@puppet.com",
|
15
|
+
"name": "Tony Vu"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"github": "jpartlow",
|
19
|
+
"email": "joshua.partlow@puppet.com",
|
20
|
+
"name": "Josh Partlow"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"github": "demophoon",
|
24
|
+
"email": "britt@puppet.com",
|
25
|
+
"name": "Britt Gresham"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"github": "highb",
|
29
|
+
"email": "brandon.high@puppet.com",
|
30
|
+
"name": "Brandon High"
|
31
|
+
}
|
32
|
+
]
|
33
|
+
}
|
data/README.md
CHANGED
@@ -1,2 +1,25 @@
|
|
1
1
|
# beaker-answers
|
2
|
-
|
2
|
+
|
3
|
+
beaker-answers is a beaker library that constructs answer files for Puppet
|
4
|
+
Enterprise installation.
|
5
|
+
|
6
|
+
# Documentation
|
7
|
+
|
8
|
+
- [Rubydocs](http://www.rubydoc.info/github/puppetlabs/beaker-answers) contain the
|
9
|
+
technical reference for APIs and other aspects of beaker-answers. They describe
|
10
|
+
how it works and how to use it but assume that you have a basic understanding of
|
11
|
+
key concepts.
|
12
|
+
|
13
|
+
# Release
|
14
|
+
|
15
|
+
To release a new version, we use a
|
16
|
+
[Jenkins job](https://jenkins-qe.delivery.puppetlabs.net/job/qe_beaker-answers_btc-rls/)
|
17
|
+
(access to internal infrastructure will be required to view job).
|
18
|
+
|
19
|
+
To release a new version (from the master branch), you'll need to just provide
|
20
|
+
a new beaker-answers version number to the job, and you're off to the races.
|
21
|
+
|
22
|
+
# Questions
|
23
|
+
|
24
|
+
If you have questions, please reach out to our
|
25
|
+
[MAINTAINERS](MAINTAINERS).
|
data/lib/beaker-answers.rb
CHANGED
@@ -0,0 +1,162 @@
|
|
1
|
+
module BeakerAnswers
|
2
|
+
# Used to generate a Hash of configuration appropriate for generating
|
3
|
+
# the initial MEEP pe.conf for a given set of hosts and a particular
|
4
|
+
# MEEP pe.conf schema version.
|
5
|
+
class PeConf
|
6
|
+
|
7
|
+
# The default pe.conf schema version.
|
8
|
+
DEFAULT_VERSION = '1.0'.freeze
|
9
|
+
|
10
|
+
# This lists various aliases for different PE components that might
|
11
|
+
# be installed on a host.
|
12
|
+
#
|
13
|
+
# The first entry in the list is the canonical name for the
|
14
|
+
# component from the PuppetX::Puppetlabs::Meep::Config.pe_components()
|
15
|
+
# from the pe_infrastructure module.
|
16
|
+
#
|
17
|
+
# Secondary aliases are the various working names that have been used
|
18
|
+
# with beaker in CI to establish that a host has that component
|
19
|
+
# installed on it.
|
20
|
+
COMPONENTS = [
|
21
|
+
["primary_master", "master"],
|
22
|
+
["primary_master_replica"],
|
23
|
+
# the 'database' alias will be troublesome if/when we begin
|
24
|
+
# breaking out a managed database (as opposed to external)
|
25
|
+
# in future PE layouts.
|
26
|
+
["puppetdb", "database"],
|
27
|
+
["console", "classifier", "dashboard"],
|
28
|
+
["compile_master"],
|
29
|
+
["mco_hub", "hub"],
|
30
|
+
["mco_broker", "spoke"],
|
31
|
+
]
|
32
|
+
|
33
|
+
attr_accessor :hosts, :meep_schema_version, :options
|
34
|
+
|
35
|
+
# The array of Beaker hosts are inspected to provide configuration
|
36
|
+
# for master, database, console nodes, and other configuration data
|
37
|
+
# as required by the particular pe.conf version.
|
38
|
+
#
|
39
|
+
# @param hosts [Array<Beaker::Host>]
|
40
|
+
# @param meep_schema_version [String] Determines the implementation which
|
41
|
+
# will be used to generate pe.conf data. Defaults to '1.0'
|
42
|
+
# @param options [Hash] of additional option parameters. Used to supply
|
43
|
+
# specific master, puppetdb, console hosts for the 1.0 implementation.
|
44
|
+
# (Optional)
|
45
|
+
def initialize(hosts, meep_schema_version, options = {})
|
46
|
+
self.hosts = hosts
|
47
|
+
self.meep_schema_version = meep_schema_version || DEFAULT_VERSION
|
48
|
+
self.options = options || {}
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [Hash] of pe.conf configuration data
|
52
|
+
# @raise RuntimeError if no implementation can be found for the
|
53
|
+
# meep_schema_version.
|
54
|
+
def configuration_hash
|
55
|
+
case meep_schema_version
|
56
|
+
when '1.0'
|
57
|
+
_generate_1_0_data
|
58
|
+
when '2.0'
|
59
|
+
_generate_2_0_data
|
60
|
+
else raise(RuntimeError, "Unknown how to produce pe.conf data for meep_schema_version: '#{meep_schema_version}'")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
# Relies on a :master, :puppetdb and :console host having been passed
|
67
|
+
# in the options.
|
68
|
+
def _generate_1_0_data
|
69
|
+
pe_conf = {}
|
70
|
+
ns = "puppet_enterprise"
|
71
|
+
|
72
|
+
master = the_host_with_role('master')
|
73
|
+
puppetdb = the_host_with_role('database')
|
74
|
+
console = the_host_with_role('dashboard')
|
75
|
+
|
76
|
+
pe_conf["#{ns}::puppet_master_host"] = master.hostname
|
77
|
+
|
78
|
+
# Monolithic installs now only require the puppet_master_host, so only
|
79
|
+
# pass in the console and puppetdb host if it is a split install
|
80
|
+
if [master, puppetdb, console].uniq.length != 1
|
81
|
+
pe_conf["#{ns}::console_host"] = console.hostname
|
82
|
+
pe_conf["#{ns}::puppetdb_host"] = puppetdb.hostname
|
83
|
+
end
|
84
|
+
|
85
|
+
pe_conf
|
86
|
+
end
|
87
|
+
|
88
|
+
def _generate_2_0_data
|
89
|
+
pe_conf = {
|
90
|
+
"node_roles" => {}
|
91
|
+
}
|
92
|
+
hosts_by_component = {}
|
93
|
+
|
94
|
+
COMPONENTS.each do |aliases|
|
95
|
+
meep_component_name = aliases.first
|
96
|
+
# Only generate node_role settings for installing primary nodes
|
97
|
+
# Secondary infrastructure will be added dynamically later
|
98
|
+
next unless ['primary_master', 'puppetdb', 'console'].include?(meep_component_name)
|
99
|
+
hosts_by_component[meep_component_name] = all_hostnames_with_component(aliases)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Reject console and puppetdb lists if they are the same as master
|
103
|
+
hosts_by_component.reject! do |component,hosts|
|
104
|
+
["puppetdb", "console"].include?(component) &&
|
105
|
+
hosts_by_component["primary_master"].sort == hosts.sort
|
106
|
+
end
|
107
|
+
|
108
|
+
# Which is also sufficient to determine our architecture at the moment
|
109
|
+
architecture = (hosts_by_component.keys & ["puppetdb", "console"]).empty? ?
|
110
|
+
"monolithic" :
|
111
|
+
"split"
|
112
|
+
|
113
|
+
# Set the node_roles
|
114
|
+
hosts_by_component.reduce(pe_conf) do |conf,entry|
|
115
|
+
component, hosts = entry
|
116
|
+
if !hosts.empty?
|
117
|
+
conf["node_roles"]["pe_role::#{architecture}::#{component}"] = hosts
|
118
|
+
end
|
119
|
+
conf
|
120
|
+
end
|
121
|
+
|
122
|
+
# Collect a uniq array of all host platforms modified to pe_repo class format
|
123
|
+
platforms = hosts.map do |h|
|
124
|
+
h['platform'].gsub(/-/, '_').gsub(/\./,'')
|
125
|
+
end.uniq
|
126
|
+
pe_conf["agent_platforms"] = platforms
|
127
|
+
|
128
|
+
pe_conf["meep_schema_version"] = "2.0"
|
129
|
+
|
130
|
+
pe_conf
|
131
|
+
end
|
132
|
+
|
133
|
+
# @param host_role_aliases [Array<String>] list of strings to search for in
|
134
|
+
# each host's role array
|
135
|
+
# @return [Array<String>] of hostnames from @hosts that include at least
|
136
|
+
# one of the passed aliases
|
137
|
+
def all_hostnames_with_component(host_role_aliases)
|
138
|
+
found_hosts = hosts.select do |h|
|
139
|
+
!(Array(h['roles']) & host_role_aliases).empty?
|
140
|
+
end
|
141
|
+
found_hosts.map { |h| h.hostname }
|
142
|
+
end
|
143
|
+
|
144
|
+
# Find a single host with the role provided. Raise an error if more than
|
145
|
+
# one host is found to have the provided role.
|
146
|
+
#
|
147
|
+
# @param [String] role The host returned will have this role in its role list
|
148
|
+
# @return [Host] The single host with the desired role in its roles list
|
149
|
+
# @raise [ArgumentError] Raised if more than one host has the given role
|
150
|
+
# defined, or if no host has the role defined.
|
151
|
+
def the_host_with_role(role)
|
152
|
+
found_hosts = hosts.select do |h|
|
153
|
+
Array(h['roles']).include?(role.to_s)
|
154
|
+
end
|
155
|
+
|
156
|
+
if found_hosts.length == 0 or found_hosts.length > 1
|
157
|
+
raise ArgumentError, "There should be one host with #{role} defined, found #{found_hosts.length} matching hosts (#{found_hosts})"
|
158
|
+
end
|
159
|
+
found_hosts.first
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
@@ -62,23 +62,8 @@ module BeakerAnswers
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def hiera_host_config
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
master = only_host_with_role(@hosts, 'master')
|
69
|
-
puppetdb = only_host_with_role(@hosts, 'database')
|
70
|
-
console = only_host_with_role(@hosts, 'dashboard')
|
71
|
-
|
72
|
-
config["#{ns}::puppet_master_host"] = answer_for(@options, "#{ns}::puppet_master_host", master.hostname)
|
73
|
-
|
74
|
-
# Monolithic installs now only require the puppet_master_host, so only pass in the console
|
75
|
-
# and puppetdb host if it is a split install
|
76
|
-
if [master, puppetdb, console].uniq.length != 1
|
77
|
-
config["#{ns}::console_host"] = answer_for(@options, "#{ns}::console_host", console.hostname)
|
78
|
-
config["#{ns}::puppetdb_host"] = answer_for(@options, "#{ns}::puppetdb_host", puppetdb.hostname)
|
79
|
-
end
|
80
|
-
|
81
|
-
return config
|
65
|
+
pe_conf = BeakerAnswers::PeConf.new(@hosts, '1.0')
|
66
|
+
pe_conf.configuration_hash
|
82
67
|
end
|
83
68
|
|
84
69
|
def hiera_db_config
|
@@ -10,74 +10,5 @@ module BeakerAnswers
|
|
10
10
|
/\A2017\.1/
|
11
11
|
end
|
12
12
|
|
13
|
-
# This lists various aliases for different PE components that might
|
14
|
-
# be installed on a host.
|
15
|
-
#
|
16
|
-
# The first entry in the list is the canonical name for the
|
17
|
-
# component from the PuppetX::Puppetlabs::Meep::Config.pe_components()
|
18
|
-
# from the pe_infrastructure module.
|
19
|
-
#
|
20
|
-
# Secondary aliases are the various working names that have been used
|
21
|
-
# with beaker in CI to establish that a host has that component
|
22
|
-
# installed on it.
|
23
|
-
COMPONENTS = [
|
24
|
-
["primary_master", "master"],
|
25
|
-
["primary_master_replica"],
|
26
|
-
# the 'database' alias will be troublesome if/when we begin
|
27
|
-
# breaking out a managed database (as opposed to external)
|
28
|
-
# in future PE layouts.
|
29
|
-
["puppetdb", "database"],
|
30
|
-
["console", "classifier", "dashboard"],
|
31
|
-
["compile_master"],
|
32
|
-
["mco_hub", "hub"],
|
33
|
-
["mco_broker", "spoke"],
|
34
|
-
]
|
35
|
-
|
36
|
-
# @param host_role_aliases [Array<String>] list of strings to search for in
|
37
|
-
# each host's role array
|
38
|
-
# @return [Array<String>] of hostnames from @hosts that include at least
|
39
|
-
# one of the passed aliases
|
40
|
-
def all_hosts_with_component(host_role_aliases)
|
41
|
-
hosts = @hosts.select do |h|
|
42
|
-
!(Array(h['roles']) & host_role_aliases).empty?
|
43
|
-
end
|
44
|
-
hosts.map { |h| h.hostname }
|
45
|
-
end
|
46
|
-
|
47
|
-
# This used to generate the profile host parameters, but now generates a MEEP
|
48
|
-
# 2.0 node_roles hash mapping roles -> node certs based on the same host and
|
49
|
-
# role information.
|
50
|
-
def hiera_host_config
|
51
|
-
pe_conf = {
|
52
|
-
"node_roles" => {}
|
53
|
-
}
|
54
|
-
hosts_by_component = {}
|
55
|
-
|
56
|
-
COMPONENTS.each do |aliases|
|
57
|
-
meep_component_name = aliases.first
|
58
|
-
hosts_by_component[meep_component_name] = all_hosts_with_component(aliases)
|
59
|
-
end
|
60
|
-
|
61
|
-
# Reject console and puppetdb lists if they are the same as master
|
62
|
-
hosts_by_component.reject! do |component,hosts|
|
63
|
-
["puppetdb", "console"].include?(component) &&
|
64
|
-
hosts_by_component["primary_master"].sort == hosts.sort
|
65
|
-
end
|
66
|
-
|
67
|
-
# Which is also sufficient to determine our architecture at the moment
|
68
|
-
architecture = (hosts_by_component.keys & ["puppetdb", "console"]).empty? ?
|
69
|
-
"monolithic" :
|
70
|
-
"split"
|
71
|
-
|
72
|
-
hosts_by_component.reduce(pe_conf) do |conf,entry|
|
73
|
-
component, hosts = entry
|
74
|
-
if !hosts.empty?
|
75
|
-
conf["node_roles"]["pe_role::#{architecture}::#{component}"] = hosts
|
76
|
-
end
|
77
|
-
conf
|
78
|
-
end
|
79
|
-
|
80
|
-
pe_conf
|
81
|
-
end
|
82
13
|
end
|
83
14
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'beaker-answers/versions/version20171'
|
2
|
+
|
3
|
+
module BeakerAnswers
|
4
|
+
# This class provides answer file information for PE version 2017.2
|
5
|
+
#
|
6
|
+
# @api private
|
7
|
+
class Version20172 < Version20171
|
8
|
+
# The version of PE that this set of answers is appropriate for
|
9
|
+
def self.pe_version_matcher
|
10
|
+
/\A2017\.2/
|
11
|
+
end
|
12
|
+
|
13
|
+
# This is used to generate the profile host parameters, but now passes the
|
14
|
+
# options[:meep_schema_version] to determine which form of pe.conf is to be
|
15
|
+
# generated.
|
16
|
+
def hiera_host_config
|
17
|
+
pe_conf = BeakerAnswers::PeConf.new(@hosts, @options[:meep_schema_version])
|
18
|
+
pe_conf.configuration_hash
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'BeakerAnswers::PeConf' do
|
4
|
+
let(:basic_hosts) { make_hosts({'pe_ver' => ver }, host_count) }
|
5
|
+
|
6
|
+
RSpec.shared_examples 'pe.conf configuration' do
|
7
|
+
context 'monolithic' do
|
8
|
+
let(:host_count) { 2 }
|
9
|
+
let(:hosts) do
|
10
|
+
basic_hosts[0]['roles'] = ['master', 'dashboard', 'database', 'agent']
|
11
|
+
basic_hosts[0]['platform'] = 'el-6-x86_64'
|
12
|
+
basic_hosts[1]['roles'] = ['agent']
|
13
|
+
basic_hosts[1]['platform'] = 'el-7-x86_64'
|
14
|
+
basic_hosts
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'generates a hash of monolithic configuration data' do
|
18
|
+
expect(BeakerAnswers::PeConf.new(hosts, meep_schema_version).configuration_hash).to(
|
19
|
+
match(gold_mono_configuration_hash)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'split' do
|
25
|
+
let(:host_count) { 5 }
|
26
|
+
let(:hosts) do
|
27
|
+
basic_hosts[0]['roles'] = ['master', 'agent']
|
28
|
+
basic_hosts[0]['platform'] = 'el-6-x86_64'
|
29
|
+
basic_hosts[1]['roles'] = ['dashboard', 'agent']
|
30
|
+
basic_hosts[1]['platform'] = 'el-6-x86_64'
|
31
|
+
basic_hosts[2]['roles'] = ['database', 'agent']
|
32
|
+
basic_hosts[2]['platform'] = 'el-6-x86_64'
|
33
|
+
basic_hosts[3]['roles'] = ['agent']
|
34
|
+
basic_hosts[3]['platform'] = 'el-7-x86_64'
|
35
|
+
basic_hosts[4]['roles'] = ['agent']
|
36
|
+
basic_hosts[4]['platform'] = 'ubuntu-14.04-amd64'
|
37
|
+
basic_hosts
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'generates a hash of split configuration data' do
|
41
|
+
expect(BeakerAnswers::PeConf.new(hosts, meep_schema_version).configuration_hash).to(
|
42
|
+
match(gold_split_configuration_hash)
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context '1.0 schema' do
|
49
|
+
let(:ver) { '2016.2.0' }
|
50
|
+
let(:meep_schema_version) { '1.0' }
|
51
|
+
let(:gold_mono_configuration_hash) do
|
52
|
+
{
|
53
|
+
"puppet_enterprise::puppet_master_host" => basic_hosts[0].hostname,
|
54
|
+
}
|
55
|
+
end
|
56
|
+
let(:gold_split_configuration_hash) do
|
57
|
+
{
|
58
|
+
"puppet_enterprise::puppet_master_host" => basic_hosts[0].hostname,
|
59
|
+
"puppet_enterprise::console_host" => basic_hosts[1].hostname,
|
60
|
+
"puppet_enterprise::puppetdb_host" => basic_hosts[2].hostname,
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
include_examples 'pe.conf configuration'
|
65
|
+
end
|
66
|
+
|
67
|
+
context '2.0 schema' do
|
68
|
+
let(:ver) { '2017.2.0' }
|
69
|
+
let(:meep_schema_version) { '2.0' }
|
70
|
+
let(:gold_mono_configuration_hash) do
|
71
|
+
{
|
72
|
+
"node_roles" => {
|
73
|
+
"pe_role::monolithic::primary_master" => [basic_hosts[0].hostname],
|
74
|
+
},
|
75
|
+
"agent_platforms" => match_array(['el_6_x86_64', 'el_7_x86_64']),
|
76
|
+
"meep_schema_version" => "2.0",
|
77
|
+
}
|
78
|
+
end
|
79
|
+
let(:gold_split_configuration_hash) do
|
80
|
+
{
|
81
|
+
"node_roles" => {
|
82
|
+
"pe_role::split::primary_master" => [basic_hosts[0].hostname],
|
83
|
+
"pe_role::split::console" => [basic_hosts[1].hostname],
|
84
|
+
"pe_role::split::puppetdb" => [basic_hosts[2].hostname],
|
85
|
+
},
|
86
|
+
"agent_platforms" => match_array([
|
87
|
+
'el_6_x86_64',
|
88
|
+
'el_7_x86_64',
|
89
|
+
'ubuntu_1404_amd64'
|
90
|
+
]),
|
91
|
+
"meep_schema_version" => "2.0",
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
include_examples 'pe.conf configuration'
|
96
|
+
end
|
97
|
+
end
|
@@ -2,50 +2,29 @@ require 'spec_helper'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
describe BeakerAnswers::Version20171 do
|
5
|
-
let(
|
6
|
-
let(
|
7
|
-
let(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
let(
|
5
|
+
let(:ver) { '2017.1.0' }
|
6
|
+
let(:options) { StringifyHash.new }
|
7
|
+
let(:mono_hosts) do
|
8
|
+
basic_hosts = make_hosts({'pe_ver' => ver }, 1)
|
9
|
+
basic_hosts[0]['roles'] = ['master', 'agent', 'dashboard', 'database']
|
10
|
+
basic_hosts[0]['platform'] = 'el-7-x86_64'
|
11
|
+
basic_hosts
|
12
|
+
end
|
13
|
+
let(:answers) { BeakerAnswers::Answers.create(ver, hosts, options) }
|
14
|
+
let(:answer_hash) { answers.answers }
|
14
15
|
|
15
|
-
context 'when generating a
|
16
|
+
context 'when generating a default 1.0 config' do
|
16
17
|
context 'for a monolithic install' do
|
17
|
-
let(
|
18
|
-
let(
|
19
|
-
basic_hosts }
|
20
|
-
let( :gold_role_answers ) do
|
21
|
-
{
|
22
|
-
"console_admin_password" => default_password,
|
23
|
-
"node_roles" => {
|
24
|
-
"pe_role::monolithic::primary_master" => [basic_hosts[0].hostname],
|
25
|
-
}
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
it "accepts overrides to node_roles from beaker conf answers"
|
30
|
-
|
31
|
-
include_examples 'pe.conf'
|
32
|
-
include_examples 'valid MEEP 2.0 pe.conf'
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'for a split install' do
|
36
|
-
let( :gold_role_answers ) do
|
18
|
+
let(:hosts) { mono_hosts }
|
19
|
+
let(:gold_role_answers) do
|
37
20
|
{
|
38
21
|
"console_admin_password" => default_password,
|
39
|
-
"
|
40
|
-
"pe_role::split::primary_master" => [basic_hosts[0].hostname],
|
41
|
-
"pe_role::split::console" => [basic_hosts[1].hostname],
|
42
|
-
"pe_role::split::puppetdb" => [basic_hosts[2].hostname],
|
43
|
-
}
|
22
|
+
"puppet_enterprise::puppet_master_host" => hosts[0].hostname,
|
44
23
|
}
|
45
24
|
end
|
46
25
|
|
47
26
|
include_examples 'pe.conf'
|
48
|
-
include_examples 'valid MEEP
|
27
|
+
include_examples 'valid MEEP 1.0 pe.conf'
|
49
28
|
end
|
50
29
|
end
|
51
30
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe BeakerAnswers::Version20172 do
|
5
|
+
let(:ver) { '2017.2.0' }
|
6
|
+
let(:options) { StringifyHash.new }
|
7
|
+
let(:mono_hosts) do
|
8
|
+
basic_hosts = make_hosts({'pe_ver' => ver }, 1)
|
9
|
+
basic_hosts[0]['roles'] = ['master', 'agent', 'dashboard', 'database']
|
10
|
+
basic_hosts[0]['platform'] = 'el-7-x86_64'
|
11
|
+
basic_hosts
|
12
|
+
end
|
13
|
+
let(:split_hosts) do
|
14
|
+
basic_hosts = make_hosts({'pe_ver' => ver }, 4)
|
15
|
+
basic_hosts[0]['roles'] = ['master', 'agent']
|
16
|
+
basic_hosts[0]['platform'] = 'el-6-x86_64'
|
17
|
+
basic_hosts[1]['roles'] = ['dashboard', 'agent']
|
18
|
+
basic_hosts[1]['platform'] = 'el-6-x86_64'
|
19
|
+
basic_hosts[2]['roles'] = ['database', 'agent']
|
20
|
+
basic_hosts[2]['platform'] = 'el-6-x86_64'
|
21
|
+
basic_hosts[3]['roles'] = ['agent']
|
22
|
+
basic_hosts[3]['platform'] = 'ubuntu-14.04-amd64'
|
23
|
+
basic_hosts
|
24
|
+
end
|
25
|
+
let(:answers) { BeakerAnswers::Answers.create(ver, hosts, options) }
|
26
|
+
let(:answer_hash) { answers.answers }
|
27
|
+
|
28
|
+
context 'when generating a default 1.0 config' do
|
29
|
+
context 'for a monolithic install' do
|
30
|
+
let(:hosts) { mono_hosts }
|
31
|
+
let(:gold_role_answers) do
|
32
|
+
{
|
33
|
+
"console_admin_password" => default_password,
|
34
|
+
"puppet_enterprise::puppet_master_host" => hosts[0].hostname,
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
include_examples 'pe.conf'
|
39
|
+
include_examples 'valid MEEP 1.0 pe.conf'
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'for a split install' do
|
43
|
+
let(:hosts) { split_hosts }
|
44
|
+
let( :gold_role_answers ) do
|
45
|
+
{
|
46
|
+
"console_admin_password" => default_password,
|
47
|
+
"puppet_enterprise::puppet_master_host" => hosts[0].hostname,
|
48
|
+
"puppet_enterprise::console_host" => hosts[1].hostname,
|
49
|
+
"puppet_enterprise::puppetdb_host" => hosts[2].hostname,
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
include_examples 'pe.conf'
|
54
|
+
include_examples 'valid MEEP 1.0 pe.conf'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when generating a meep 2.0 config' do
|
59
|
+
before(:each) do
|
60
|
+
options[:meep_schema_version] = '2.0'
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'for a monolithic install' do
|
64
|
+
let(:hosts) { mono_hosts }
|
65
|
+
let(:gold_role_answers) do
|
66
|
+
{
|
67
|
+
"console_admin_password" => default_password,
|
68
|
+
"node_roles" => {
|
69
|
+
"pe_role::monolithic::primary_master" => [hosts[0].hostname],
|
70
|
+
},
|
71
|
+
"agent_platforms" => match_array(['el_7_x86_64']),
|
72
|
+
"meep_schema_version" => "2.0",
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
include_examples 'pe.conf'
|
77
|
+
include_examples 'valid MEEP 2.0 pe.conf'
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'for a split install' do
|
81
|
+
let(:hosts) { split_hosts }
|
82
|
+
let( :gold_role_answers ) do
|
83
|
+
{
|
84
|
+
"console_admin_password" => default_password,
|
85
|
+
"node_roles" => {
|
86
|
+
"pe_role::split::primary_master" => [hosts[0].hostname],
|
87
|
+
"pe_role::split::console" => [hosts[1].hostname],
|
88
|
+
"pe_role::split::puppetdb" => [hosts[2].hostname],
|
89
|
+
},
|
90
|
+
"agent_platforms" => match_array(['el_6_x86_64', 'ubuntu_1404_amd64']),
|
91
|
+
"meep_schema_version" => "2.0",
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
include_examples 'pe.conf'
|
96
|
+
include_examples 'valid MEEP 2.0 pe.conf'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/spec/shared/context.rb
CHANGED
@@ -57,7 +57,7 @@ RSpec.shared_examples 'pe.conf' do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'has just the role and values for default install' do
|
60
|
-
expect(answer_hash).to
|
60
|
+
expect(answer_hash).to match(
|
61
61
|
gold_role_answers
|
62
62
|
)
|
63
63
|
end
|
@@ -72,12 +72,12 @@ RSpec.shared_examples 'pe.conf' do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'has only the role values' do
|
75
|
-
expect(answer_hash).to
|
75
|
+
expect(answer_hash).to match(gold_role_answers)
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'also includes any explicitly added database parameters' do
|
79
79
|
options.merge!(:answers => overridden_database_parameters)
|
80
|
-
expect(answer_hash).to
|
80
|
+
expect(answer_hash).to match(
|
81
81
|
gold_role_answers
|
82
82
|
.merge(overridden_database_parameters)
|
83
83
|
)
|
@@ -93,7 +93,7 @@ RSpec.shared_examples 'pe.conf' do
|
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'has the role values and database defaults' do
|
96
|
-
expect(answer_hash).to
|
96
|
+
expect(answer_hash).to match(
|
97
97
|
gold_role_answers
|
98
98
|
.merge(gold_db_answers)
|
99
99
|
)
|
@@ -101,7 +101,7 @@ RSpec.shared_examples 'pe.conf' do
|
|
101
101
|
|
102
102
|
it 'overrides defaults with explicitly added database parameters' do
|
103
103
|
options.merge!(:answers => overridden_database_parameters)
|
104
|
-
expect(answer_hash).to
|
104
|
+
expect(answer_hash).to match(
|
105
105
|
gold_role_answers
|
106
106
|
.merge(overridden_database_parameters)
|
107
107
|
)
|
@@ -144,7 +144,7 @@ RSpec.shared_examples 'pe.conf' do
|
|
144
144
|
end
|
145
145
|
|
146
146
|
it 'matches expected answers' do
|
147
|
-
expect(answer_hash).to
|
147
|
+
expect(answer_hash).to match(gold_answers_with_overrides)
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
@@ -163,7 +163,7 @@ RSpec.shared_examples 'pe.conf' do
|
|
163
163
|
end
|
164
164
|
|
165
165
|
it 'matches expected answers' do
|
166
|
-
expect(answer_hash).to
|
166
|
+
expect(answer_hash).to match(gold_answers_with_overrides)
|
167
167
|
end
|
168
168
|
end
|
169
169
|
end
|
@@ -173,7 +173,25 @@ RSpec.shared_examples "valid MEEP 2.0 pe.conf" do
|
|
173
173
|
expect(answer_hiera).not_to be_empty
|
174
174
|
expect { JSON.load(answer_hiera) }.not_to raise_error
|
175
175
|
expect(answer_hiera).to match(%r{"node_roles"\s*:\s*\{})
|
176
|
-
expect(answer_hiera).to match(%r{"pe_role::\w+::primary_master"\s*:\s*\[\s*"#{
|
176
|
+
expect(answer_hiera).to match(%r{"pe_role::\w+::primary_master"\s*:\s*\[\s*"#{hosts[0].hostname}"\s*\]}m)
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'sets the schema version' do
|
180
|
+
expect(answer_hash['meep_schema_version']).to eq('2.0')
|
181
|
+
end
|
182
|
+
|
183
|
+
context 'with beaker overrides' do
|
184
|
+
before(:each) do
|
185
|
+
options[:answers] = {
|
186
|
+
'pe_infrastructure::use_meep_for_classification' => true
|
187
|
+
}
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'accepts overrides from beaker config' do
|
191
|
+
expect(answer_hiera).to match(
|
192
|
+
%r{"pe_infrastructure::use_meep_for_classification"\s*:\s*true}
|
193
|
+
)
|
194
|
+
end
|
177
195
|
end
|
178
196
|
end
|
179
197
|
|
@@ -181,6 +199,6 @@ RSpec.shared_examples "valid MEEP 1.0 pe.conf" do
|
|
181
199
|
it 'generates valid MEEP 1.0 json if #answer_hiera is called' do
|
182
200
|
expect(answer_hiera).not_to be_empty
|
183
201
|
expect { JSON.load(answer_hiera) }.not_to raise_error
|
184
|
-
expect(answer_hiera).to match(%r{"puppet_enterprise::puppet_master_host"\s*:\s*"#{
|
202
|
+
expect(answer_hiera).to match(%r{"puppet_enterprise::puppet_master_host"\s*:\s*"#{hosts[0].hostname}"}m)
|
185
203
|
end
|
186
204
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker-answers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppetlabs
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- Gemfile
|
194
194
|
- HISTORY.md
|
195
195
|
- LICENSE
|
196
|
+
- MAINTAINERS
|
196
197
|
- README.md
|
197
198
|
- Rakefile
|
198
199
|
- beaker-answers.gemspec
|
@@ -200,6 +201,7 @@ files:
|
|
200
201
|
- lib/beaker-answers.rb
|
201
202
|
- lib/beaker-answers/answers.rb
|
202
203
|
- lib/beaker-answers/helpers.rb
|
204
|
+
- lib/beaker-answers/pe_conf.rb
|
203
205
|
- lib/beaker-answers/version.rb
|
204
206
|
- lib/beaker-answers/versions/upgrade.rb
|
205
207
|
- lib/beaker-answers/versions/upgrade38.rb
|
@@ -211,6 +213,7 @@ files:
|
|
211
213
|
- lib/beaker-answers/versions/version20164.rb
|
212
214
|
- lib/beaker-answers/versions/version20165.rb
|
213
215
|
- lib/beaker-answers/versions/version20171.rb
|
216
|
+
- lib/beaker-answers/versions/version20172.rb
|
214
217
|
- lib/beaker-answers/versions/version28.rb
|
215
218
|
- lib/beaker-answers/versions/version30.rb
|
216
219
|
- lib/beaker-answers/versions/version32.rb
|
@@ -219,10 +222,12 @@ files:
|
|
219
222
|
- lib/beaker-answers/versions/version40.rb
|
220
223
|
- spec/beaker-answers/beaker-answers_spec.rb
|
221
224
|
- spec/beaker-answers/helpers_spec.rb
|
225
|
+
- spec/beaker-answers/pe_conf_spec.rb
|
222
226
|
- spec/beaker-answers/upgrade_spec.rb
|
223
227
|
- spec/beaker-answers/versions/version20162_spec.rb
|
224
228
|
- spec/beaker-answers/versions/version20163_spec.rb
|
225
229
|
- spec/beaker-answers/versions/version20171_spec.rb
|
230
|
+
- spec/beaker-answers/versions/version20172_spec.rb
|
226
231
|
- spec/helpers.rb
|
227
232
|
- spec/shared/context.rb
|
228
233
|
- spec/spec_helper.rb
|