From d191423e86512e6101523ccea23f7f47e21087dd Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Wed, 7 Aug 2019 08:33:34 -0400 Subject: [PATCH] Force "Pre-cache" tasks to run in dry run We don't want the pre-cache tasks to be skipped in dry-run so we force check_mode to "no". For example, "command" is skipped in check mode because we don't provide "creates" nor "removes"; and since we need to cache facts when running Puppet in dry mode, we need to make sure this task is run anyway. See https://docs.ansible.com/ansible/latest/modules/command_module.html For "file", "copy", and "synchronize", they aren't skipped in dry mode but the resources aren't executed for real. So this patch disable check_mode for all these tasks. We also move the tasks in a block which avoid tags & check_mode duplication for each task and avoid problems in the future if a task is added. Closes-Bug: #1839321 Change-Id: I21524419b8b416d0879fc61aa3274d2e30537438 (cherry picked from commit 9581614e9353576c6a7b83136793631473851b31) --- common/deploy-steps-tasks.yaml | 91 ++++++++++++++++------------------ 1 file changed, 42 insertions(+), 49 deletions(-) diff --git a/common/deploy-steps-tasks.yaml b/common/deploy-steps-tasks.yaml index 9f081c518c..b78d9bd8f2 100644 --- a/common/deploy-steps-tasks.yaml +++ b/common/deploy-steps-tasks.yaml @@ -424,58 +424,51 @@ ######################################### # Pre-cache facts for container-puppet.py ######################################### - - - name: Create puppet caching structures - file: - path: /var/lib/container-puppet/puppetlabs - state: directory - setype: svirt_sandbox_file_t - selevel: s0 - recurse: True - tags: - - container_config - - container_config_tasks - - name: Write facter cache config - copy: - dest: /var/lib/container-puppet/puppetlabs/facter.conf - content: | - facts : { - ttls: [ - { "kernel" : 8 hour }, - { "memory" : 8 hour }, - { "networking" : 8 hour }, - { "operating system" : 8 hour }, - { "processor" : 8 hour }, - ] - } - setype: svirt_sandbox_file_t - selevel: s0 - tags: - - container_config - - container_config_tasks - - name: Cleanup facter cache if exists - file: - path: /opt/puppetlabs/facter - state: absent - ignore_errors: True - tags: - - container_config - - container_config_tasks - - name: Pre-cache facts - command: facter --config /var/lib/container-puppet/puppetlabs/facter.conf - no_log: True - ignore_errors: True - tags: - - container_config - - container_config_tasks - - name: Sync cached facts - synchronize: - src: /opt/puppetlabs/ - dest: /var/lib/container-puppet/puppetlabs/ - delegate_to: "{{ inventory_hostname }}" + # We don't want the pre-cache tasks to be skipped in dry-run so we force + # check_mode to "no". + # https://bugzilla.redhat.com/show_bug.cgi?id=1738529 + - name: Pre-cache facts for container-puppet.py + check_mode: no tags: - container_config - container_config_tasks + block: + - name: Create puppet caching structures + file: + path: /var/lib/container-puppet/puppetlabs + state: directory + setype: svirt_sandbox_file_t + selevel: s0 + recurse: True + - name: Write facter cache config + copy: + dest: /var/lib/container-puppet/puppetlabs/facter.conf + content: | + facts : { + ttls: [ + { "kernel" : 8 hour }, + { "memory" : 8 hour }, + { "networking" : 8 hour }, + { "operating system" : 8 hour }, + { "processor" : 8 hour }, + ] + } + setype: svirt_sandbox_file_t + selevel: s0 + - name: Cleanup facter cache if exists + file: + path: /opt/puppetlabs/facter + state: absent + ignore_errors: True + - name: Pre-cache facts + command: facter --config /var/lib/container-puppet/puppetlabs/facter.conf + no_log: True + ignore_errors: True + - name: Sync cached facts + synchronize: + src: /opt/puppetlabs/ + dest: /var/lib/container-puppet/puppetlabs/ + delegate_to: "{{ inventory_hostname }}" ###################################### # Generate config via container-puppet.py