foreman_envsync 0.1.3 → 1.1.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 +407 -15
- data/exe/foreman_envsync +7 -7
- data/foreman_envsync.gemspec +5 -5
- data/lib/foreman_envsync/version.rb +1 -1
- 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: e24a84a49de5dd8e5e547b63e05ce952fc348e34d670898b468642e8c058a6ee
|
4
|
+
data.tar.gz: 230d4a1832eca3c43a98bc0ac7e67cc9e82195c14810ab5c0f564c7e279d0549
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2c94787e431273cc84f2a57cb72f257130cd3918e25dba5ef99a53e817185d3a8a483528e75c0ac7d1639718a611fff227edc54eef6c33188d31c1da6e225fb
|
7
|
+
data.tar.gz: 7032245360fe4ab1db78a830e8a75091c41be1bc569ac5b4abc4ccf432a5b2872dec4648cf13d74864fb880eedd85dfdb6ab8cb40af45161f0cfb3f70027aeac
|
data/README.md
CHANGED
@@ -1,38 +1,430 @@
|
|
1
|
-
#
|
1
|
+
# foreman_envsync
|
2
2
|
|
3
|
-
|
3
|
+
A highly opinionated utility to sync foreman puppet environments with the set
|
4
|
+
of environments known to a `puppetserver` instance *without* also importing the
|
5
|
+
classes within those puppet environments.
|
6
|
+
|
7
|
+
|
8
|
+
## The Problem
|
9
|
+
|
10
|
+
When using [`r10k`](https://github.com/puppetlabs/r10k) with the [Dynamic
|
11
|
+
Environments](https://github.com/puppetlabs/r10k/blob/main/doc/dynamic-environments.mkd)
|
12
|
+
pattern in concert with foreman as an ENC, it is highly desirable for new
|
13
|
+
environments to automatically appear within foreman. Foreman has a built in
|
14
|
+
"import environments" feature which triggers a poll of a `puppetserver`'s known
|
15
|
+
environments. Foreman's `hammer` CLI has the ability to trigger an import of
|
16
|
+
all environments (and classes) with the `proxy import-classes` sub-sub-command.
|
17
|
+
E.g.:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
/bin/hammer proxy import-classes --id=1
|
21
|
+
```
|
22
|
+
|
23
|
+
`r10k` provides a hook to run a shell commands after completing an environment
|
24
|
+
build, which can be used to invoke `hammer`. E.g.:
|
25
|
+
|
26
|
+
```yaml
|
27
|
+
---
|
28
|
+
:postrun: ["/bin/hammer", "proxy", "import-classes", "--id=1"]
|
29
|
+
```
|
30
|
+
|
31
|
+
This automation setup is known to work reasonable well on a VM hosting both
|
32
|
+
`foreman 2.4.0` + `puppetserver 6.15.3` provisioned with 16 x64 cores / 32GiB
|
33
|
+
RAM / SSD storage under the following conditions:
|
34
|
+
|
35
|
+
* The `puppetserver` environment class cache is **enabled**.
|
36
|
+
* The number of puppet environments is relatively small. I.e. `<= 10`
|
37
|
+
* [Probably?] The environments are of moderate complexity. I.e. `< ~100` modules
|
38
|
+
* `r10k` is triggering an import via `hammer` 10s of times per day.
|
39
|
+
|
40
|
+
However, it has been observed that all foreman puma workers (regardless of the
|
41
|
+
number configured) will over time creep up to consume 100% of a core,
|
42
|
+
interactivity via the www console is abysmal, and environment import may fail
|
43
|
+
completely when:
|
44
|
+
|
45
|
+
* The `puppetserver` environment class cache is **disabled**.
|
46
|
+
* The puppet environments have `> 100` modules.
|
47
|
+
* `r10k` is triggering an import via `hammer` 10s of times per day.
|
48
|
+
* There are `> 10` puppet environments.
|
49
|
+
|
50
|
+
Distressingly, when the puppetserver environment cache is **disabled**, even a
|
51
|
+
small number of puppet agent hosts (~10) will trigger foreman to consume all
|
52
|
+
available CPU cores. Reducing the number of puppet environments to `< 10` is
|
53
|
+
helpful but not a guarantee that an environment/class import will succeed. It
|
54
|
+
was observed that above `40` environments, an import is virtually guaranteed to
|
55
|
+
fail.
|
56
|
+
|
57
|
+
|
58
|
+
## What Is The Malfunction?
|
59
|
+
|
60
|
+
*Disclaimer: This is essentially speculation based on observed behavior and
|
61
|
+
isn't backed up by careful inspection of the code.*
|
62
|
+
|
63
|
+
From external observation of foreman's behavior, it appears that there is a
|
64
|
+
strong built-in assumption that the `puppetserver` environment class cache is
|
65
|
+
always enabled and `ETag`s will turn most queries for the classes in an
|
66
|
+
environment into essentially a no-op.
|
67
|
+
|
68
|
+
When a foreman environment import is triggered, foreman not only enumerates
|
69
|
+
`puppetserver`'s set of known environments via the `/puppet/v3/environments`
|
70
|
+
API endpoint, it also queries for all the classes within an environment using
|
71
|
+
`/puppet/v3/environment_classes`. When the environment class cache is disabled
|
72
|
+
the time for this query to return seems to be highly variable for the test
|
73
|
+
environment with response times ranging from a few seconds to over 30s *per
|
74
|
+
environment*. This means that an import cycle with many environments can take
|
75
|
+
10s of minutes. It appears that something in this process causes foreman's
|
76
|
+
puma workers to consume 100% of a CPU. It isn't known if this is busy waiting,
|
77
|
+
parsing the class list, or something else all together.
|
78
|
+
|
79
|
+
Compounding the extremely slow performance caused by bulk environment
|
80
|
+
importation, foreman also is calling `/puppet/v3/environment_classes` when it
|
81
|
+
is invoked as an ENC. This means that every puppet agent run results in a
|
82
|
+
puppetserver instance compiling an environment to provide a class list to
|
83
|
+
foreman and then again after ENC/fact data has been supplied to create a
|
84
|
+
catalog for the agent.
|
85
|
+
|
86
|
+
To add insult to injury, in this situation the foreman enc is used solely to
|
87
|
+
supply parameters and never for class inclusion. All of the effort to produce
|
88
|
+
environment class lists and parsing them is completely wasted.
|
89
|
+
|
90
|
+
|
91
|
+
## How Does This Thing Help?
|
92
|
+
|
93
|
+
`foreman_envsync` directly obtains the list of puppet environments from
|
94
|
+
`puppetserver` without requesting class information. It then removes any
|
95
|
+
environments which are present in foreman but not within `puppetserver`. If
|
96
|
+
there are any unknown-to-foreman environments, then are created as members of
|
97
|
+
all foreman organizations and locations. This completely avoids foreman
|
98
|
+
having to wait on `puppetserver` to provide class lists and parsing them.
|
99
|
+
|
100
|
+
|
101
|
+
## Narrow Use-case
|
102
|
+
|
103
|
+
This utility is opinionated and has many hard-coded assumptions. Including:
|
104
|
+
|
105
|
+
* It is being installed on Centos 7.
|
106
|
+
* Foreman and `puppetserver` are installed on the same host.
|
107
|
+
* Foreman has been installed via `foreman-installer` / puppet code.
|
108
|
+
* The `puppetserver` TLS related files are in the standard Puppetlabs locations.
|
109
|
+
* `hammer` CLI has been installed and pre-configure with credentials.
|
110
|
+
* "new" puppet environments should be visible to all foreman organizations and locations.
|
111
|
+
|
112
|
+
|
113
|
+
## Obvious Improvements
|
114
|
+
|
115
|
+
`foreman_envsync` is shelling out to invoke `hammer`. It should probably be
|
116
|
+
converted to be a `hammer` plugin.
|
117
|
+
|
118
|
+
It probably makes sense to use `foreman-proxy` rather than connecting to
|
119
|
+
`puppetserver` directly as it avoid needing to deal with TLS authentication.
|
120
|
+
|
121
|
+
It would be fantastic if foreman's puppet integration was better able to handle
|
122
|
+
the environment class cache being disabled. Including:
|
123
|
+
|
124
|
+
* Not requesting an environment's class list any time the ENC functionality was invoked.
|
125
|
+
* A configuration setting to completely disable class handling when it is not needed.
|
126
|
+
* An option to import environments only (similar to `foreman_envsync`).
|
127
|
+
* A configuration setting to disable the "import environments" feature which
|
128
|
+
also requests class lists.
|
4
129
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
130
|
|
7
131
|
## Installation
|
8
132
|
|
9
|
-
|
133
|
+
This gem is currently intended to provide `foreman_envsync` CLI utility and not
|
134
|
+
for use as a library.
|
135
|
+
|
136
|
+
It is recommend that it is installed into the foreman `tfm` SCL and that all
|
137
|
+
dependencies are ignore to avoid disrupting foreman. It is expected to function
|
138
|
+
with foremans' gem deps at least as of foreman `2.4.0`.
|
139
|
+
|
140
|
+
|
141
|
+
```bash
|
142
|
+
scl enable tfm -- gem install --bindir /bin --ignore-dependencies --no-ri --no-rdoc --version 0.1.4 foreman_envsync
|
143
|
+
```
|
144
|
+
|
145
|
+
**If** dependencies need to be installed, the ruby devel package a compiler will be needed. E.g.:
|
146
|
+
|
147
|
+
```bash
|
148
|
+
yum install -y rh-ruby25-ruby-devel devtoolset-7
|
149
|
+
scl enable devtoolset-7 tfm -- gem install --bindir /bin --ignore-dependencies --no-ri --no-rdoc --version 0.1.4 foreman_envsync
|
150
|
+
```
|
151
|
+
|
152
|
+
### `r10k` Config
|
153
|
+
|
154
|
+
It is is highly recommend that the `systemd-cat` utility to be used when configuring the `postrun` hook in `/etc/puppetlabs/r10k/r10k.yaml` so that status output is logged. E.g.:
|
155
|
+
|
156
|
+
```yaml
|
157
|
+
---
|
158
|
+
:postrun: ["/bin/scl", "enable", "tfm", "--", "systemd-cat", "-t", "foreman_envsync", "/bin/foreman_envsync", "--verbose"]
|
159
|
+
```
|
160
|
+
|
161
|
+
Example of output in the journal when using `systemd-cat`:
|
10
162
|
|
11
|
-
```ruby
|
12
|
-
gem 'foreman_envsync'
|
13
163
|
```
|
164
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: found 13 puppetserver environment(s).
|
165
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: ---
|
166
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - IT_2978_foreman_tuning_ruby
|
167
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - IT_2953_dds_debugging
|
168
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - IT_2907_tu_reip
|
169
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - production
|
170
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - coredev_production
|
171
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - IT_2978_foreman_tuning
|
172
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - IT_2373_velero
|
173
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - IT_2949_poc_encrypt
|
174
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - IT_2452_pagerduty
|
175
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - IT_2471_opsgenie
|
176
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - IT_2879_ipam
|
177
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - IT_2935_pathfinder_hcu01
|
178
|
+
Jun 08 23:00:38 foreman.example.org foreman_envsync[10643]: - IT_2987_rpi_puppet
|
179
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: found 13 foreman environment(s).
|
180
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: ---
|
181
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - coredev_production
|
182
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - IT_2373_velero
|
183
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - IT_2452_pagerduty
|
184
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - IT_2471_opsgenie
|
185
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - IT_2879_ipam
|
186
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - IT_2907_tu_reip
|
187
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - IT_2935_pathfinder_hcu01
|
188
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - IT_2949_poc_encrypt
|
189
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - IT_2953_dds_debugging
|
190
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - IT_2978_foreman_tuning
|
191
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - IT_2978_foreman_tuning_ruby
|
192
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - IT_2987_rpi_puppet
|
193
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: - production
|
194
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: found 0 foreman environment(s) unknown to puppetserver.
|
195
|
+
Jun 08 23:00:39 foreman.example.org foreman_envsync[10643]: found 0 puppetserver environment(s) unknown to foreman.
|
196
|
+
```
|
197
|
+
|
198
|
+
### `foreman-proxy` Config
|
199
|
+
|
200
|
+
If `foreman_envsync` is being considered then it is probably that foreman is also not being used for class inclusion. In that case, there is no reason for foreman to waste wallclock-time waiting for `puppetserver` to return class lists.
|
14
201
|
|
15
|
-
|
202
|
+
The wasted time may be minimized by setting
|
16
203
|
|
17
|
-
|
204
|
+
```yaml
|
205
|
+
:api_timeout: 1
|
206
|
+
```
|
18
207
|
|
19
|
-
|
208
|
+
in `/etc/foreman-proxy/settings.d/puppet_proxy_puppet_api.yml` (and restarting
|
209
|
+
`foreman-proxy`).
|
20
210
|
|
21
|
-
$ gem install foreman_envsync
|
22
211
|
|
23
212
|
## Usage
|
24
213
|
|
25
|
-
|
214
|
+
*Note that `foreman_envsync` requires permissions to read `puppetserver`'s TLS
|
215
|
+
related files under `/etc/puppetlabs/puppet/ssl`. This may typically be
|
216
|
+
achieved by membership in the `puppet` group or running as `root`.*
|
217
|
+
|
218
|
+
`foreman_envsync` is silent, except for fatal errors, by default:
|
219
|
+
|
220
|
+
```bash
|
221
|
+
scl enable tfm -- foreman_envsync
|
222
|
+
```
|
223
|
+
|
224
|
+
The `--verbose` enables detailed output.
|
225
|
+
|
226
|
+
```bash
|
227
|
+
scl enable tfm -- foreman_envsync --verbose
|
228
|
+
```
|
229
|
+
|
230
|
+
Example of verbose output:
|
26
231
|
|
27
|
-
|
232
|
+
```bash
|
233
|
+
# scl enable tfm -- foreman_envsync --verbose
|
234
|
+
found 22 puppetserver environment(s).
|
235
|
+
---
|
236
|
+
- master
|
237
|
+
- IT_2953_dds_debugging
|
238
|
+
- corecp_production
|
239
|
+
- IT_2935_pathfinder_hcu01
|
240
|
+
- coredev_production
|
241
|
+
- IT_2949_poc_encrypt
|
242
|
+
- production
|
243
|
+
- IT_2907_tu_reip
|
244
|
+
- IT_2373_velero
|
245
|
+
- IT_2452_pagerduty
|
246
|
+
- IT_2978_foreman_tuning
|
247
|
+
- IT_2987_rpi_puppet
|
248
|
+
- corels_production
|
249
|
+
- ncsa_production
|
250
|
+
- disable_IT_2569_tomcat_tls
|
251
|
+
- tu_production
|
252
|
+
- disable_IT_2483_letencrypt_renewal
|
253
|
+
- disable_IT_2417_maddash
|
254
|
+
- disable_jhoblitt_rspec
|
255
|
+
- disable_jhoblitt_colina
|
256
|
+
- IT_2879_ipam
|
257
|
+
- IT_2471_opsgenie
|
28
258
|
|
29
|
-
|
259
|
+
found 36 foreman environment(s).
|
260
|
+
---
|
261
|
+
- corecp_production
|
262
|
+
- coredev_production
|
263
|
+
- corels_production
|
264
|
+
- coretu_production
|
265
|
+
- IT_2373_velero
|
266
|
+
- IT_2417_maddash
|
267
|
+
- IT_2441_dns3_cp
|
268
|
+
- IT_2452_pagerduty
|
269
|
+
- IT_2471_opsgenie
|
270
|
+
- IT_2483_letencrypt_renewal
|
271
|
+
- IT_2494_nfs
|
272
|
+
- IT_2569_tomcat_tls
|
273
|
+
- IT_2613_no_ccs_sal
|
274
|
+
- IT_2655_net_audit_ls
|
275
|
+
- IT_2657_dhcp
|
276
|
+
- IT_2667_poc
|
277
|
+
- IT_2693_arista
|
278
|
+
- IT_2694_vlan_change
|
279
|
+
- IT_2753_comcam_software_v2
|
280
|
+
- IT_2820_auxtel_ccs
|
281
|
+
- IT_2854_nfs_export
|
282
|
+
- IT_2879_ipam
|
283
|
+
- IT_2907_tu_reip
|
284
|
+
- IT_2911_ntp
|
285
|
+
- IT_2935_pathfinder_hcu01
|
286
|
+
- IT_2949_poc_encrypt
|
287
|
+
- IT_2953_dds_debugging
|
288
|
+
- IT_2978_foreman_tuning
|
289
|
+
- jhoblitt_colina
|
290
|
+
- jhoblitt_rspec
|
291
|
+
- master
|
292
|
+
- ncsa_production
|
293
|
+
- production
|
294
|
+
- tickets_DM_25966
|
295
|
+
- tickets_DM_27839
|
296
|
+
- tu_production
|
297
|
+
|
298
|
+
found 20 foreman environment(s) unknown to puppetserver.
|
299
|
+
---
|
300
|
+
- coretu_production
|
301
|
+
- IT_2417_maddash
|
302
|
+
- IT_2441_dns3_cp
|
303
|
+
- IT_2483_letencrypt_renewal
|
304
|
+
- IT_2494_nfs
|
305
|
+
- IT_2569_tomcat_tls
|
306
|
+
- IT_2613_no_ccs_sal
|
307
|
+
- IT_2655_net_audit_ls
|
308
|
+
- IT_2657_dhcp
|
309
|
+
- IT_2667_poc
|
310
|
+
- IT_2693_arista
|
311
|
+
- IT_2694_vlan_change
|
312
|
+
- IT_2753_comcam_software_v2
|
313
|
+
- IT_2820_auxtel_ccs
|
314
|
+
- IT_2854_nfs_export
|
315
|
+
- IT_2911_ntp
|
316
|
+
- jhoblitt_colina
|
317
|
+
- jhoblitt_rspec
|
318
|
+
- tickets_DM_25966
|
319
|
+
- tickets_DM_27839
|
320
|
+
|
321
|
+
deleted 20 foreman environment(s).
|
322
|
+
---
|
323
|
+
- message: Environment deleted.
|
324
|
+
id: 12
|
325
|
+
name: coretu_production
|
326
|
+
- message: Environment deleted.
|
327
|
+
id: 4602
|
328
|
+
name: IT_2417_maddash
|
329
|
+
- message: Environment deleted.
|
330
|
+
id: 4664
|
331
|
+
name: IT_2441_dns3_cp
|
332
|
+
- message: Environment deleted.
|
333
|
+
id: 4637
|
334
|
+
name: IT_2483_letencrypt_renewal
|
335
|
+
- message: Environment deleted.
|
336
|
+
id: 4649
|
337
|
+
name: IT_2494_nfs
|
338
|
+
- message: Environment deleted.
|
339
|
+
id: 4658
|
340
|
+
name: IT_2569_tomcat_tls
|
341
|
+
- message: Environment deleted.
|
342
|
+
id: 4676
|
343
|
+
name: IT_2613_no_ccs_sal
|
344
|
+
- message: Environment deleted.
|
345
|
+
id: 4691
|
346
|
+
name: IT_2655_net_audit_ls
|
347
|
+
- message: Environment deleted.
|
348
|
+
id: 4688
|
349
|
+
name: IT_2657_dhcp
|
350
|
+
- message: Environment deleted.
|
351
|
+
id: 4736
|
352
|
+
name: IT_2667_poc
|
353
|
+
- message: Environment deleted.
|
354
|
+
id: 4709
|
355
|
+
name: IT_2693_arista
|
356
|
+
- message: Environment deleted.
|
357
|
+
id: 4710
|
358
|
+
name: IT_2694_vlan_change
|
359
|
+
- message: Environment deleted.
|
360
|
+
id: 4771
|
361
|
+
name: IT_2753_comcam_software_v2
|
362
|
+
- message: Environment deleted.
|
363
|
+
id: 4746
|
364
|
+
name: IT_2820_auxtel_ccs
|
365
|
+
- message: Environment deleted.
|
366
|
+
id: 4792
|
367
|
+
name: IT_2854_nfs_export
|
368
|
+
- message: Environment deleted.
|
369
|
+
id: 4762
|
370
|
+
name: IT_2911_ntp
|
371
|
+
- message: Environment deleted.
|
372
|
+
id: 4735
|
373
|
+
name: jhoblitt_colina
|
374
|
+
- message: Environment deleted.
|
375
|
+
id: 4619
|
376
|
+
name: jhoblitt_rspec
|
377
|
+
- message: Environment deleted.
|
378
|
+
id: 4581
|
379
|
+
name: tickets_DM_25966
|
380
|
+
- message: Environment deleted.
|
381
|
+
id: 4686
|
382
|
+
name: tickets_DM_27839
|
383
|
+
|
384
|
+
found 6 puppetserver environment(s) unknown to foreman.
|
385
|
+
---
|
386
|
+
- IT_2987_rpi_puppet
|
387
|
+
- disable_IT_2569_tomcat_tls
|
388
|
+
- disable_IT_2483_letencrypt_renewal
|
389
|
+
- disable_IT_2417_maddash
|
390
|
+
- disable_jhoblitt_rspec
|
391
|
+
- disable_jhoblitt_colina
|
392
|
+
|
393
|
+
found 1 foreman location(s).
|
394
|
+
---
|
395
|
+
- 2
|
396
|
+
|
397
|
+
found 1 foreman organization(s).
|
398
|
+
---
|
399
|
+
- 1
|
400
|
+
|
401
|
+
created 6 foreman environment(s).
|
402
|
+
---
|
403
|
+
- message: Environment created.
|
404
|
+
id: 4800
|
405
|
+
name: IT_2987_rpi_puppet
|
406
|
+
- message: Environment created.
|
407
|
+
id: 4801
|
408
|
+
name: disable_IT_2569_tomcat_tls
|
409
|
+
- message: Environment created.
|
410
|
+
id: 4802
|
411
|
+
name: disable_IT_2483_letencrypt_renewal
|
412
|
+
- message: Environment created.
|
413
|
+
id: 4803
|
414
|
+
name: disable_IT_2417_maddash
|
415
|
+
- message: Environment created.
|
416
|
+
id: 4804
|
417
|
+
name: disable_jhoblitt_rspec
|
418
|
+
- message: Environment created.
|
419
|
+
id: 4805
|
420
|
+
name: disable_jhoblitt_colina
|
421
|
+
```
|
30
422
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
423
|
|
33
424
|
## Contributing
|
34
425
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
426
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lsst-it/foreman_envsync.
|
427
|
+
|
36
428
|
|
37
429
|
## License
|
38
430
|
|
data/exe/foreman_envsync
CHANGED
@@ -41,21 +41,21 @@ def key_file(file)
|
|
41
41
|
OpenSSL::PKey::RSA.new(File.read(file))
|
42
42
|
end
|
43
43
|
|
44
|
-
def hammer_cmd(cmd)
|
44
|
+
def hammer_cmd(cmd, ignore_exitstatus: false)
|
45
45
|
stdout, stderr, s = Open3.capture3(cmd)
|
46
46
|
unless s.success?
|
47
47
|
puts "command #{cmd} failed"
|
48
48
|
puts stderr
|
49
|
-
exit s.exitstatus
|
49
|
+
exit s.exitstatus unless ignore_exitstatus
|
50
50
|
end
|
51
51
|
|
52
52
|
stdout
|
53
53
|
end
|
54
54
|
|
55
|
-
def hammer_cmd_parse(cmd)
|
56
|
-
stdout = hammer_cmd(cmd)
|
55
|
+
def hammer_cmd_parse(cmd, **opt)
|
56
|
+
stdout = hammer_cmd(cmd, opt)
|
57
57
|
|
58
|
-
JSON.parse(stdout)
|
58
|
+
JSON.parse(stdout) unless stdout.empty?
|
59
59
|
end
|
60
60
|
|
61
61
|
def collect_one_field(data, field)
|
@@ -78,7 +78,7 @@ end
|
|
78
78
|
def foreman_env_delete(name)
|
79
79
|
cmd = "hammer --output=json puppet-environment delete --name #{name}"
|
80
80
|
|
81
|
-
hammer_cmd_parse(cmd)
|
81
|
+
hammer_cmd_parse(cmd, ignore_exitstatus: true)
|
82
82
|
end
|
83
83
|
|
84
84
|
def foreman_env_create(name, location_ids, org_ids)
|
@@ -143,7 +143,7 @@ verbose_list "found %d foreman environment(s) unknown to puppetserver.", extra_e
|
|
143
143
|
# Remove any foreman envs unknown to puppetserver
|
144
144
|
#
|
145
145
|
report = extra_envs.collect { |x| foreman_env_delete(x) } unless extra_envs.empty?
|
146
|
-
verbose_list "deleted %d foreman environment(s).", report
|
146
|
+
verbose_list "deleted %d foreman environment(s).", report.nil? ? nil : report.compact
|
147
147
|
|
148
148
|
# update foreman envs if anything was deleted
|
149
149
|
f_envs = foreman_env_list unless report.nil?
|
data/foreman_envsync.gemspec
CHANGED
@@ -26,11 +26,11 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
|
-
spec.
|
30
|
-
spec.
|
31
|
-
spec.
|
32
|
-
spec.
|
33
|
-
spec.
|
29
|
+
spec.add_runtime_dependency "hammer_cli"
|
30
|
+
spec.add_runtime_dependency "hammer_cli_foreman"
|
31
|
+
spec.add_runtime_dependency "rest-client", "~> 2.0"
|
32
|
+
spec.add_development_dependency "rubocop-rake"
|
33
|
+
spec.add_development_dependency "rubocop-rspec"
|
34
34
|
|
35
35
|
# For more information and examples about making a new gem, checkout our
|
36
36
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_envsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Hoblitt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hammer_cli
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
type: :
|
62
|
+
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
@@ -73,7 +73,7 @@ dependencies:
|
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
|
-
type: :
|
76
|
+
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|