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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5aafd856a39efeb605c0a8569b500301c0c7205716e2fe66f0baba72625b7247
4
- data.tar.gz: 6808ed021bb4f5dc80fb2bdb8a31de09824c06e4fccb9ca8b697d25144cbdc8f
3
+ metadata.gz: 3c020a10d892a679413785b7c67a81848994b173543df654cec75001ca03fc37
4
+ data.tar.gz: aa7f4b513266264e07e09077f0d4de5118824673a4d5cd7d794ec0333573732b
5
5
  SHA512:
6
- metadata.gz: a1b43e47df906018f2712fc079c294ab69fa2e83be38d135ab54dd638345c111d5a60c17493fb4f76649b7da1502d3af992f39b33ed029ce9d47ae6e8ef60918
7
- data.tar.gz: 16665d3837d3655898fcd475095cec53b69fe84488fa3c2601fd23d0319ce5f996bfed8670dcd47e3974a2b1aaadfdbadc65625c263632312885492e5481f27e
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 7","value":7,"collection":"puppet7"},{"name":"Puppet 6","value":6,"collection":"puppet6"}]
20
- puppet_unit_test_matrix=[{"puppet":7,"ruby":"2.7"},{"puppet":6,"ruby":"2.5"}]
21
- github_action_test_matrix=[{"setfile":{"name":"Debian 11","value":"debian11-64"},"puppet":{"name":"Puppet 7","value":7,"collection":"puppet7"}},{"setfile":{"name":"Debian 11","value":"debian11-64"},"puppet":{"name":"Puppet 6","value":6,"collection":"puppet6"}}]
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": 7,
45
- "ruby": "2.7"
44
+ "puppet": 8,
45
+ "ruby": "3.2"
46
46
  },
47
47
  {
48
- "puppet": 6,
49
- "ruby": "2.5"
48
+ "puppet": 7,
49
+ "ruby": "2.7"
50
50
  }
51
51
  ]
52
52
  ```
53
53
 
54
- GitHub Action test matrix formatted for readability
54
+ Beaker test matrix formatted for readability
55
55
  ```json
56
56
  [
57
57
  {
58
- "setfile": {
59
- "name": "Debian 11",
60
- "value": "debian11-64"
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
- "setfile": {
70
- "name": "Debian 11",
71
- "value": "debian11-64"
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 also 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).
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
- "value": "centos7-64{hostname=centos7-64.example.com,image=centos:7.6.1810}"
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 10",
97
- "value": "debian10-64{hostname=debian10-64.example.com}"
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 18.04",
101
- "value": "ubuntu1804-64{hostname=ubuntu1804-64.example.com}"
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
- It is also possible to specify a comma separated list of operating systems as used in `metadata.json` (`CentOS,Ubuntu`).
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
- hostname = (puppet_version.nil? && puppet_version != 'none') ? name : "#{name}-#{puppet_version}"
71
+ human_name = "#{os} #{release}"
68
72
  domain ||= 'example.com' if use_fqdn
69
73
 
70
- options = {}
71
- options[:hostname] = "#{hostname}.#{domain}" if domain
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
- options[:image] = image
109
+ image_to_use = image
80
110
  end
81
111
  end
82
112
 
83
- human_name = "#{os} #{release}"
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
- [build_setfile(name, options), human_name]
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
@@ -144,6 +144,7 @@ module PuppetMetadata
144
144
  pidfile_workaround: options[:beaker_pidfile_workaround],
145
145
  domain: options[:domain],
146
146
  puppet_version: puppet_collection,
147
+ hosts: options[:beaker_hosts],
147
148
  )
148
149
  end
149
150
  end
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.6.0
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-03-07 00:00:00.000000000 Z
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.5.0
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.5.0
117
+ version: 2.6.0
118
118
  - !ruby/object:Gem::Dependency
119
119
  name: yard
120
120
  requirement: !ruby/object:Gem::Requirement