puppet_metadata 3.6.0 → 3.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +109 -37
- data/bin/metadata2gha +11 -0
- data/lib/puppet_metadata/beaker.rb +43 -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: 3c020a10d892a679413785b7c67a81848994b173543df654cec75001ca03fc37
|
4
|
+
data.tar.gz: aa7f4b513266264e07e09077f0d4de5118824673a4d5cd7d794ec0333573732b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f44421da7afad6edcbc16af1d52a6017ea08db5ec58dd92b72f40af9738189e3eddb63c18b6091202831234a99277c48ae86d0524e895df76b5eb22c34a22362
|
7
|
+
data.tar.gz: 47f2a4061065f4474cd847f86d1092d3e4ed41ce2077eb2389b0526c983e7472acdbbebca643b8a1578d587f9edbeeb56c25449d494b5b2efd06f666e82255a2
|
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
|
```
|
@@ -41,45 +41,37 @@ Puppet unit test matrix formatted for readability:
|
|
41
41
|
```json
|
42
42
|
[
|
43
43
|
{
|
44
|
-
"puppet":
|
45
|
-
"ruby": "2
|
44
|
+
"puppet": 8,
|
45
|
+
"ruby": "3.2"
|
46
46
|
},
|
47
47
|
{
|
48
|
-
"puppet":
|
49
|
-
"ruby": "2.
|
48
|
+
"puppet": 7,
|
49
|
+
"ruby": "2.7"
|
50
50
|
}
|
51
51
|
]
|
52
52
|
```
|
53
53
|
|
54
|
-
|
54
|
+
Beaker test matrix formatted for readability
|
55
55
|
```json
|
56
56
|
[
|
57
57
|
{
|
58
|
-
"
|
59
|
-
|
60
|
-
"
|
61
|
-
|
62
|
-
"puppet": {
|
63
|
-
"name": "Puppet 7",
|
64
|
-
"value": 7,
|
65
|
-
"collection": "puppet7"
|
58
|
+
"name": "Puppet 8 - Debian 12",
|
59
|
+
"env": {
|
60
|
+
"BEAKER_PUPPET_COLLECTION": "puppet8",
|
61
|
+
"BEAKER_SETFILE": "debian12-64{hostname=debian12-64-puppet8}"
|
66
62
|
}
|
67
63
|
},
|
68
64
|
{
|
69
|
-
"
|
70
|
-
|
71
|
-
"
|
72
|
-
|
73
|
-
"puppet": {
|
74
|
-
"name": "Puppet 6",
|
75
|
-
"value": 6,
|
76
|
-
"collection": "puppet6"
|
65
|
+
"name": "Puppet 7 - Debian 12",
|
66
|
+
"env": {
|
67
|
+
"BEAKER_PUPPET_COLLECTION": "puppet7",
|
68
|
+
"BEAKER_SETFILE": "debian12-64{hostname=debian12-64-puppet7}"
|
77
69
|
}
|
78
70
|
}
|
79
71
|
]
|
80
72
|
```
|
81
73
|
|
82
|
-
It is
|
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).
|
83
75
|
|
84
76
|
```console
|
85
77
|
$ metadata2gha --use-fqdn --pidfile-workaround true /path/to/metadata.json
|
@@ -89,21 +81,101 @@ This results in the following JSON data
|
|
89
81
|
```json
|
90
82
|
[
|
91
83
|
{
|
92
|
-
"name": "CentOS 7",
|
93
|
-
"
|
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
|
+
}
|
94
89
|
},
|
95
90
|
{
|
96
|
-
"name": "Debian
|
97
|
-
"
|
91
|
+
"name": "Puppet 7 - Debian 12",
|
92
|
+
"env": {
|
93
|
+
"BEAKER_PUPPET_COLLECTION": "puppet7",
|
94
|
+
"BEAKER_SETFILE": "debian12-64{hostname=debian12-64-puppet7.example.com}"
|
95
|
+
}
|
98
96
|
},
|
99
97
|
{
|
100
|
-
"name": "Ubuntu
|
101
|
-
"
|
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}"
|
102
|
+
}
|
102
103
|
}
|
103
104
|
]
|
104
105
|
```
|
105
106
|
|
106
|
-
|
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;..'
|
114
|
+
|
115
|
+
```console
|
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'
|
140
|
+
```
|
141
|
+
|
142
|
+
This results in the following JSON data
|
143
|
+
```json
|
144
|
+
[
|
145
|
+
{
|
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
|
+
}
|
160
|
+
},
|
161
|
+
{
|
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
|
+
}
|
168
|
+
},
|
169
|
+
{
|
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
|
+
}
|
176
|
+
}
|
177
|
+
]
|
178
|
+
```
|
107
179
|
|
108
180
|
## Work with the API
|
109
181
|
|
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,16 @@ 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
|
+
if opt != 'false'
|
46
|
+
beaker_hosts = {}
|
47
|
+
opt.split(';').each do |host|
|
48
|
+
hostname, roles = host.split(':', 2)
|
49
|
+
beaker_hosts[hostname] = roles
|
50
|
+
end
|
51
|
+
options[:beaker_hosts] = beaker_hosts unless beaker_hosts.empty?
|
52
|
+
end
|
53
|
+
end
|
43
54
|
end.parse!
|
44
55
|
|
45
56
|
filename = ARGV[0]
|
@@ -55,34 +55,69 @@ module PuppetMetadata
|
|
55
55
|
# Enforce a domain to be appended to the hostname, making it an FQDN
|
56
56
|
# @param [Optional[String]] puppet_version
|
57
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.
|
58
63
|
#
|
59
64
|
# @return [nil] If no setfile is available
|
60
65
|
# @return [Array<(String, String)>] The beaker setfile description with a readable name
|
61
|
-
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)
|
62
67
|
return unless os_supported?(os)
|
63
68
|
|
64
69
|
aos = adjusted_os(os)
|
65
|
-
|
66
70
|
name = "#{aos}#{release.tr('.', '')}-64"
|
67
|
-
|
71
|
+
human_name = "#{os} #{release}"
|
68
72
|
domain ||= 'example.com' if use_fqdn
|
69
73
|
|
70
|
-
|
71
|
-
|
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
|
72
100
|
|
101
|
+
options = {}
|
73
102
|
# Docker messes up cgroups and some systemd versions can't deal with
|
74
103
|
# that when PIDFile is used.
|
104
|
+
image_to_use = nil
|
75
105
|
if pidfile_workaround?(pidfile_workaround, os)
|
76
106
|
return if PIDFILE_INCOMPATIBLE[os]&.include?(release)
|
77
107
|
|
78
108
|
if (image = PIDFILE_COMPATIBLE_IMAGES.dig(os, release))
|
79
|
-
|
109
|
+
image_to_use = image
|
80
110
|
end
|
81
111
|
end
|
82
112
|
|
83
|
-
|
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
|
84
119
|
|
85
|
-
[
|
120
|
+
[setfile_parts.join('-'), human_name]
|
86
121
|
end
|
87
122
|
|
88
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.1
|
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: 2024-
|
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
|