Browse Source

Merge "Re-Add facter cache for container configurations" into stable/queens

tags/8.4.1
Zuul 1 month ago
parent
commit
77cac21750
2 changed files with 67 additions and 0 deletions
  1. 54
    0
      common/deploy-steps-tasks.yaml
  2. 13
    0
      docker/docker-puppet.py

+ 54
- 0
common/deploy-steps-tasks.yaml View File

@@ -294,6 +294,60 @@
294 294
       tags:
295 295
         - host_config
296 296
 
297
+    #########################################
298
+    # Pre-cache facts for container-puppet.py
299
+    #########################################
300
+
301
+    - name: Create puppet caching structures
302
+      file:
303
+        path: /var/lib/container-puppet/puppetlabs
304
+        state: directory
305
+        setype: svirt_sandbox_file_t
306
+        selevel: s0
307
+        recurse: True
308
+      tags:
309
+        - container_config
310
+        - container_config_tasks
311
+    - name: Write facter cache config
312
+      copy:
313
+        dest: /var/lib/container-puppet/puppetlabs/facter.conf
314
+        content: |
315
+          facts : {
316
+            ttls: [
317
+              { "kernel" : 8 hour },
318
+              { "memory" : 8 hour },
319
+              { "networking" : 8 hour },
320
+              { "operating system" : 8 hour },
321
+              { "processor" : 8 hour },
322
+            ]
323
+          }
324
+      tags:
325
+        - container_config
326
+        - container_config_tasks
327
+    - name: Cleanup facter cache if exists
328
+      file:
329
+        path: /opt/puppetlabs/facter
330
+        state: absent
331
+      ignore_errors: True
332
+      tags:
333
+        - container_config
334
+        - container_config_tasks
335
+    - name: Pre-cache facts
336
+      command: facter --config /var/lib/container-puppet/puppetlabs/facter.conf
337
+      no_log: True
338
+      ignore_errors: True
339
+      tags:
340
+        - container_config
341
+        - container_config_tasks
342
+    - name: Sync cached facts
343
+      synchronize:
344
+        src: /opt/puppetlabs/
345
+        dest: /var/lib/container-puppet/puppetlabs/
346
+      delegate_to: "{{ inventory_hostname }}"
347
+      tags:
348
+        - container_config
349
+        - container_config_tasks
350
+
297 351
     ######################################
298 352
     # Generate config via docker-puppet.py
299 353
     ######################################

+ 13
- 0
docker/docker-puppet.py View File

@@ -263,6 +263,16 @@ with open(sh_script, 'w') as script_file:
263 263
                 exclude_files+=" --exclude=$p"
264 264
             fi
265 265
         done
266
+
267
+        # Exclude read-only mounted directories/files which we do not want
268
+        # to copy or delete.
269
+        ro_files="/etc/puppetlabs/ /opt/puppetlabs/"
270
+        for ro in $ro_files; do
271
+            if [ -e "$ro" ]; then
272
+                exclude_files+=" --exclude=$ro"
273
+            fi
274
+        done
275
+
266 276
         rsync -a -R --delay-updates --delete-after $exclude_files $rsync_srcs /var/lib/config-data/${NAME}
267 277
 
268 278
 
@@ -342,6 +352,9 @@ def mp_puppet_config((config_volume, puppet_tags, manifest, config_image, volume
342 352
                 '--volume', '/etc/pki/tls/certs/ca-bundle.crt:/etc/pki/tls/certs/ca-bundle.crt:ro',
343 353
                 '--volume', '/etc/pki/tls/certs/ca-bundle.trust.crt:/etc/pki/tls/certs/ca-bundle.trust.crt:ro',
344 354
                 '--volume', '/etc/pki/tls/cert.pem:/etc/pki/tls/cert.pem:ro',
355
+                # facter caching
356
+                '--volume', '/var/lib/container-puppet/puppetlabs/facter.conf:/etc/puppetlabs/facter/facter.conf:ro',
357
+                '--volume', '/var/lib/container-puppet/puppetlabs/:/opt/puppetlabs/:ro',
345 358
                 # script injection
346 359
                 '--volume', '%s:%s:z' % (sh_script, sh_script) ]
347 360
 

Loading…
Cancel
Save