puppet_metadata 3.5.0 → 3.7.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 +4 -4
- data/README.md +143 -36
- data/bin/metadata2gha +10 -0
- data/lib/puppet_metadata/aio.rb +1 -0
- data/lib/puppet_metadata/beaker.rb +46 -8
- data/lib/puppet_metadata/github_actions.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28aa43873472b811f5e9cc1fb83463e9cdaf413dc0ffc7b3e30674f7f82e19ba
|
4
|
+
data.tar.gz: b8965851efccac5ffd2045f8cbbc944a7fc5db0df386806ec371af8fc86221ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06df9e652fd704478bc5c95fa86406ea587daf0b21af5bfe5a12a988801c6ee81965713d4e90a484b0e10e2c739147a6b06730ac0ce001be68943598cb5860ce
|
7
|
+
data.tar.gz: 87fb2e005ccfb3ab28808d56113541e3a96d6e4ae05064e60818a6abe18249ff7fb94af34fb517ca296ab15136d503ed9ae57fd19ca68adcf7a3a0d54a2779e6
|
data/README.md
CHANGED
@@ -16,23 +16,23 @@ To get outputs [usable in Github Actions](https://docs.github.com/en/free-pro-te
|
|
16
16
|
|
17
17
|
```console
|
18
18
|
$ metadata2gha
|
19
|
-
puppet_major_versions=[{"name":"Puppet
|
20
|
-
puppet_unit_test_matrix=[{"puppet":
|
21
|
-
|
19
|
+
puppet_major_versions=[{"name":"Puppet 8","value":8,"collection":"puppet8"},{"name":"Puppet 7","value":7,"collection":"puppet7"}]
|
20
|
+
puppet_unit_test_matrix=[{"puppet":8,"ruby":"3.2"},{"puppet":7,"ruby":"2.7"}]
|
21
|
+
puppet_beaker_test_matrix=[{"name":"Puppet 8 - Debian 12","env":{"BEAKER_PUPPET_COLLECTION":"puppet8","BEAKER_SETFILE":"debian12-64{hostname=debian12-64-puppet8}"}},{"name":"Puppet 7 - Debian 12","env":{"BEAKER_PUPPET_COLLECTION":"puppet7","BEAKER_SETFILE":"debian12-64{hostname=debian12-64-puppet7}"}}]
|
22
22
|
```
|
23
23
|
|
24
24
|
Puppet major versions formatted for readability:
|
25
25
|
```json
|
26
26
|
[
|
27
|
+
{
|
28
|
+
"name": "Puppet 8",
|
29
|
+
"value": 8,
|
30
|
+
"collection": "puppet8"
|
31
|
+
},
|
27
32
|
{
|
28
33
|
"name": "Puppet 7",
|
29
34
|
"value": 7,
|
30
35
|
"collection": "puppet7"
|
31
|
-
},
|
32
|
-
{
|
33
|
-
"name": "Puppet 6",
|
34
|
-
"value": 6,
|
35
|
-
"collection": "puppet6"
|
36
36
|
}
|
37
37
|
]
|
38
38
|
```
|
@@ -40,70 +40,177 @@ Puppet major versions formatted for readability:
|
|
40
40
|
Puppet unit test matrix formatted for readability:
|
41
41
|
```json
|
42
42
|
[
|
43
|
+
{
|
44
|
+
"puppet": 8,
|
45
|
+
"ruby": "3.2"
|
46
|
+
},
|
43
47
|
{
|
44
48
|
"puppet": 7,
|
45
49
|
"ruby": "2.7"
|
50
|
+
}
|
51
|
+
]
|
52
|
+
```
|
53
|
+
|
54
|
+
Beaker test matrix formatted for readability
|
55
|
+
```json
|
56
|
+
[
|
57
|
+
{
|
58
|
+
"name": "Puppet 8 - Debian 12",
|
59
|
+
"env": {
|
60
|
+
"BEAKER_PUPPET_COLLECTION": "puppet8",
|
61
|
+
"BEAKER_SETFILE": "debian12-64{hostname=debian12-64-puppet8}"
|
62
|
+
}
|
46
63
|
},
|
47
64
|
{
|
48
|
-
"
|
49
|
-
"
|
65
|
+
"name": "Puppet 7 - Debian 12",
|
66
|
+
"env": {
|
67
|
+
"BEAKER_PUPPET_COLLECTION": "puppet7",
|
68
|
+
"BEAKER_SETFILE": "debian12-64{hostname=debian12-64-puppet7}"
|
69
|
+
}
|
50
70
|
}
|
51
71
|
]
|
52
72
|
```
|
53
73
|
|
54
|
-
|
74
|
+
It is possible to specify the path to metadata.json and customize the setfiles. For example, to ensure the setfiles use FQDNs and apply the [systemd PIDFile workaround under docker](https://github.com/docker/for-linux/issues/835). This either means either using an older image (CentOS 7, Ubuntu 16.04) or skipping (CentOS 8).
|
75
|
+
|
76
|
+
```console
|
77
|
+
$ metadata2gha --use-fqdn --pidfile-workaround true /path/to/metadata.json
|
78
|
+
```
|
79
|
+
|
80
|
+
This results in the following JSON data
|
55
81
|
```json
|
56
82
|
[
|
57
83
|
{
|
58
|
-
"
|
59
|
-
|
60
|
-
"
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
84
|
+
"name": "Puppet 7 - CentOS 7",
|
85
|
+
"env": {
|
86
|
+
"BEAKER_PUPPET_COLLECTION": "puppet7",
|
87
|
+
"BEAKER_SETFILE": "centos7-64{hostname=centos7-64-puppet7.example.com,image=centos:7.6.1810}"
|
88
|
+
}
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"name": "Puppet 7 - Debian 12",
|
92
|
+
"env": {
|
93
|
+
"BEAKER_PUPPET_COLLECTION": "puppet7",
|
94
|
+
"BEAKER_SETFILE": "debian12-64{hostname=debian12-64-puppet7.example.com}"
|
66
95
|
}
|
67
96
|
},
|
68
97
|
{
|
69
|
-
"
|
70
|
-
|
71
|
-
"
|
72
|
-
|
73
|
-
"puppet": {
|
74
|
-
"name": "Puppet 6",
|
75
|
-
"value": 6,
|
76
|
-
"collection": "puppet6"
|
98
|
+
"name": "Puppet 7 - Ubuntu 22.04",
|
99
|
+
"env": {
|
100
|
+
"BEAKER_PUPPET_COLLECTION": "puppet7",
|
101
|
+
"BEAKER_SETFILE": "ubuntu2204-64{hostname=ubuntu2204-64-puppet7.example.com}"
|
77
102
|
}
|
78
103
|
}
|
79
104
|
]
|
80
105
|
```
|
81
106
|
|
82
|
-
|
107
|
+
If you need custom hostname or multiple hosts in your integration tests this could be achived by using the --beaker-hosts option
|
108
|
+
|
109
|
+
Option argument is 'HOSTNAME:ROLES;HOSTNAME:..;..' where
|
110
|
+
- hosts are separated by ';'
|
111
|
+
- host number and roles are separated by ':'
|
112
|
+
- Roles follow beaker-hostgenerator syntax
|
113
|
+
If you don't need any extra roles use '1;2;..'
|
83
114
|
|
84
115
|
```console
|
85
|
-
$ metadata2gha --
|
116
|
+
$ metadata2gha --beaker-hosts 'foo:primary.ma;bar:secondary.a'
|
117
|
+
```
|
118
|
+
|
119
|
+
This results in the following JSON data
|
120
|
+
```json
|
121
|
+
[
|
122
|
+
{
|
123
|
+
"name": "Puppet 7 - Debian 12",
|
124
|
+
"env": {
|
125
|
+
"BEAKER_PUPPET_COLLECTION": "puppet7",
|
126
|
+
"BEAKER_SETFILE": "debian12-64primary.ma{hostname=foo-puppet7}-debian12-64secondary.a{hostname=bar-puppet7}"
|
127
|
+
}
|
128
|
+
}
|
129
|
+
]
|
130
|
+
```
|
131
|
+
|
132
|
+
If you need to Expand the matrix ie by product versions it could be achived by using the --beaker-facter option
|
133
|
+
|
134
|
+
Option argument is 'FACT:LABEL:VALUE,VALUE,..' where
|
135
|
+
- Fact, label and values are separated by ':'
|
136
|
+
- Values are separated by ','
|
137
|
+
|
138
|
+
```console
|
139
|
+
$ metadata2gha --beaker-facter 'mongodb_repo_version:MongoDB:4.4,5.0,6.0,7.0'
|
86
140
|
```
|
87
141
|
|
88
142
|
This results in the following JSON data
|
89
143
|
```json
|
90
144
|
[
|
91
145
|
{
|
92
|
-
"name": "
|
93
|
-
"
|
146
|
+
"name": "Puppet 7 - Debian 12 - MongoDB 4.4",
|
147
|
+
"env": {
|
148
|
+
"BEAKER_PUPPET_COLLECTION": "puppet7",
|
149
|
+
"BEAKER_SETFILE": "debian12-64{hostname=debian12-64-puppet7}",
|
150
|
+
"BEAKER_FACTER_mongodb_repo_version": "4.4"
|
151
|
+
}
|
152
|
+
},
|
153
|
+
{
|
154
|
+
"name": "Puppet 7 - Debian 12 - MongoDB 5.0",
|
155
|
+
"env": {
|
156
|
+
"BEAKER_PUPPET_COLLECTION": "puppet7",
|
157
|
+
"BEAKER_SETFILE": "debian12-64{hostname=debian12-64-puppet7}",
|
158
|
+
"BEAKER_FACTER_mongodb_repo_version": "5.0"
|
159
|
+
}
|
94
160
|
},
|
95
161
|
{
|
96
|
-
"name": "Debian
|
97
|
-
"
|
162
|
+
"name": "Puppet 7 - Debian 12 - MongoDB 6.0",
|
163
|
+
"env": {
|
164
|
+
"BEAKER_PUPPET_COLLECTION": "puppet7",
|
165
|
+
"BEAKER_SETFILE": "debian12-64{hostname=debian12-64-puppet7}",
|
166
|
+
"BEAKER_FACTER_mongodb_repo_version": "6.0"
|
167
|
+
}
|
98
168
|
},
|
99
169
|
{
|
100
|
-
"name": "
|
101
|
-
"
|
170
|
+
"name": "Puppet 7 - Debian 12 - MongoDB 7.0",
|
171
|
+
"env": {
|
172
|
+
"BEAKER_PUPPET_COLLECTION": "puppet7",
|
173
|
+
"BEAKER_SETFILE": "debian12-64{hostname=debian12-64-puppet7}",
|
174
|
+
"BEAKER_FACTER_mongodb_repo_version": "7.0"
|
175
|
+
}
|
102
176
|
}
|
103
177
|
]
|
104
178
|
```
|
105
179
|
|
106
|
-
|
180
|
+
## Work with the API
|
181
|
+
|
182
|
+
The API can be initialised like this:
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
require 'puppet_metadata'
|
186
|
+
metadata = PuppetMetadata.read('/path/to/a/metadata.json')
|
187
|
+
```
|
188
|
+
|
189
|
+
The metadata object has several different methods that we can call
|
190
|
+
|
191
|
+
### List all supported operating systems
|
192
|
+
|
193
|
+
```
|
194
|
+
[9] pry(main)> metadata.operatingsystems
|
195
|
+
=> {"Archlinux"=>nil, "Gentoo"=>nil, "Fedora"=>["32", "33"], "CentOS"=>["7", "8"], "RedHat"=>["7", "8"], "Ubuntu"=>["18.04"], "Debian"=>["9", "10"], "VirtuozzoLinux"=>["7"]}
|
196
|
+
[10] pry(main)>
|
197
|
+
```
|
198
|
+
|
199
|
+
### List supported major puppet versions
|
200
|
+
|
201
|
+
```
|
202
|
+
[10] pry(main)> metadata.puppet_major_versions
|
203
|
+
=> [6, 7]
|
204
|
+
[11] pry(main)>
|
205
|
+
```
|
206
|
+
|
207
|
+
### Check if an operating systems is supported
|
208
|
+
|
209
|
+
```
|
210
|
+
[6] pry(main)> metadata.os_release_supported?('Archlinux', nil)
|
211
|
+
=> true
|
212
|
+
[7] pry(main)>
|
213
|
+
```
|
107
214
|
|
108
215
|
## Transfer Notice
|
109
216
|
|
data/bin/metadata2gha
CHANGED
@@ -11,6 +11,7 @@ options = {
|
|
11
11
|
domain: nil,
|
12
12
|
minimum_major_puppet_version: nil,
|
13
13
|
beaker_fact: nil,
|
14
|
+
beaker_hosts: nil,
|
14
15
|
}
|
15
16
|
|
16
17
|
OptionParser.new do |opts|
|
@@ -40,6 +41,15 @@ OptionParser.new do |opts|
|
|
40
41
|
options[:beaker_facter] = [fact, label, values.split(',')]
|
41
42
|
end
|
42
43
|
end
|
44
|
+
opts.on('--beaker-hosts HOSTNAME:ROLES;HOSTNAME:ROLES;...', 'Expand the setfile string to create multiple hosts with custom roles. Roles string; see beaker-hostgenerator') do |opt|
|
45
|
+
options[:beaker_hosts] = {}
|
46
|
+
if opt != 'false'
|
47
|
+
opt.split(';').each do |host|
|
48
|
+
hostname, roles = host.split(':', 2)
|
49
|
+
options[:beaker_hosts][hostname] = roles
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
43
53
|
end.parse!
|
44
54
|
|
45
55
|
filename = ARGV[0]
|
data/lib/puppet_metadata/aio.rb
CHANGED
@@ -19,6 +19,9 @@ module PuppetMetadata
|
|
19
19
|
# unit files
|
20
20
|
PIDFILE_INCOMPATIBLE = {
|
21
21
|
'CentOS' => ['8'],
|
22
|
+
'AlmaLinux' => ['8'],
|
23
|
+
'OracleLinux' => ['7', '8'],
|
24
|
+
'Rocky' => ['8'],
|
22
25
|
}.freeze
|
23
26
|
class << self
|
24
27
|
# modifies the operating system name to suit beaker-hostgenerator
|
@@ -52,34 +55,69 @@ module PuppetMetadata
|
|
52
55
|
# Enforce a domain to be appended to the hostname, making it an FQDN
|
53
56
|
# @param [Optional[String]] puppet_version
|
54
57
|
# The desired puppet version. Will be appended to the hostname
|
58
|
+
# @param [Optional[Hash]] hosts
|
59
|
+
# Key: hostname, Value: roles (roles string as defined by beaker-hostgenerator )
|
60
|
+
# Override the automatically generated hostname and optionally add roles
|
61
|
+
# If more than one entry this will generate multiple hosts in the setfile
|
62
|
+
# The domain may still be set via the `domain` param.
|
55
63
|
#
|
56
64
|
# @return [nil] If no setfile is available
|
57
65
|
# @return [Array<(String, String)>] The beaker setfile description with a readable name
|
58
|
-
def os_release_to_setfile(os, release, use_fqdn: false, pidfile_workaround: false, domain: nil, puppet_version: nil)
|
66
|
+
def os_release_to_setfile(os, release, use_fqdn: false, pidfile_workaround: false, domain: nil, puppet_version: nil, hosts: nil)
|
59
67
|
return unless os_supported?(os)
|
60
68
|
|
61
69
|
aos = adjusted_os(os)
|
62
|
-
|
63
70
|
name = "#{aos}#{release.tr('.', '')}-64"
|
64
|
-
|
71
|
+
human_name = "#{os} #{release}"
|
65
72
|
domain ||= 'example.com' if use_fqdn
|
66
73
|
|
67
|
-
|
68
|
-
|
74
|
+
hosts_settings = []
|
75
|
+
if hosts
|
76
|
+
hosts.each do |hostname, roles|
|
77
|
+
hosts_settings << {
|
78
|
+
'name' => if roles
|
79
|
+
name + roles
|
80
|
+
elsif hosts.size > 1
|
81
|
+
hosts_settings.empty? ? "#{name}.ma" : "#{name}.a"
|
82
|
+
else
|
83
|
+
name
|
84
|
+
end,
|
85
|
+
'hostname' => ((puppet_version.nil? || puppet_version == 'none') ? hostname : "#{hostname}-#{puppet_version}") + (domain ? ".#{domain}" : ''),
|
86
|
+
}
|
87
|
+
end
|
88
|
+
else
|
89
|
+
hosts_settings << {
|
90
|
+
'name' => name,
|
91
|
+
'hostname' => if puppet_version && puppet_version != 'none'
|
92
|
+
"#{name}-#{puppet_version}" + (domain ? ".#{domain}" : '')
|
93
|
+
elsif domain
|
94
|
+
name + (domain ? ".#{domain}" : '')
|
95
|
+
else
|
96
|
+
''
|
97
|
+
end,
|
98
|
+
}
|
99
|
+
end
|
69
100
|
|
101
|
+
options = {}
|
70
102
|
# Docker messes up cgroups and some systemd versions can't deal with
|
71
103
|
# that when PIDFile is used.
|
104
|
+
image_to_use = nil
|
72
105
|
if pidfile_workaround?(pidfile_workaround, os)
|
73
106
|
return if PIDFILE_INCOMPATIBLE[os]&.include?(release)
|
74
107
|
|
75
108
|
if (image = PIDFILE_COMPATIBLE_IMAGES.dig(os, release))
|
76
|
-
|
109
|
+
image_to_use = image
|
77
110
|
end
|
78
111
|
end
|
79
112
|
|
80
|
-
|
113
|
+
setfile_parts = []
|
114
|
+
hosts_settings.each do |host_settings|
|
115
|
+
options[:hostname] = host_settings['hostname'] unless host_settings['hostname'].empty?
|
116
|
+
options[:image] = image_to_use if image_to_use
|
117
|
+
setfile_parts << build_setfile(host_settings['name'], options)
|
118
|
+
end
|
81
119
|
|
82
|
-
[
|
120
|
+
[setfile_parts.join('-'), human_name]
|
83
121
|
end
|
84
122
|
|
85
123
|
# Return whether a Beaker setfile can be generated for the given OS
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet_metadata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vox Pupuli
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: metadata-json-lint
|
@@ -107,14 +107,14 @@ dependencies:
|
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.
|
110
|
+
version: 2.6.0
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.
|
117
|
+
version: 2.6.0
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
119
|
name: yard
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|