From 338e2202bde782d97b782b87dbabd89210af2732 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Fri, 21 Sep 2018 14:58:47 -0400 Subject: [PATCH] Fix tasks in check mode These tasks should have check_mode:no set so that they run in check mode, as the variables they register are used in later tasks. Otherwise, ansible in check mode fails with undefined variable errors. Also, some tasks may fail due to not all requirements being available since those requirements were not created by previous tasks that were also ran in check mode. This adds ignore_errors to these tasks, and sets the value to the boolean ansible_check_mode which is provided by ansible and set based on whether or not --check was passed to the ansible command line. Change-Id: I84bc3c14ede37959a4078fd14ce4661b7bd23f84 (cherry picked from commit 16dff38eb41d1ffb9a651e10b1a3be86c7550ae0) --- common/deploy-steps-tasks.yaml | 2 ++ docker/services/nova-libvirt.yaml | 1 + docker/services/swift-storage.yaml | 1 + puppet/services/container-image-prepare.j2.yaml | 4 ++++ 4 files changed, 8 insertions(+) diff --git a/common/deploy-steps-tasks.yaml b/common/deploy-steps-tasks.yaml index 44f5ac1a02..6a79ebf5b0 100644 --- a/common/deploy-steps-tasks.yaml +++ b/common/deploy-steps-tasks.yaml @@ -368,6 +368,7 @@ failed_when: outputs.rc not in [0, 2] tags: - host_config + ignore_errors: "{{ ansible_check_mode }}" ###################################### # Generate config via docker-puppet.py @@ -399,6 +400,7 @@ failed_when: outputs.rc != 0 tags: - container_config + ignore_errors: "{{ ansible_check_mode }}" - name: Diff docker-puppet.py puppet-generated changes for check mode shell: | diff --git a/docker/services/nova-libvirt.yaml b/docker/services/nova-libvirt.yaml index de4f6d5a4d..18401d92df 100644 --- a/docker/services/nova-libvirt.yaml +++ b/docker/services/nova-libvirt.yaml @@ -434,6 +434,7 @@ outputs: command: /usr/bin/rpm -q libvirt-daemon failed_when: false register: libvirt_installed + check_mode: no - name: make sure libvirt services are disabled service: name: "{{ item }}" diff --git a/docker/services/swift-storage.yaml b/docker/services/swift-storage.yaml index 77357b9297..a10a69202a 100644 --- a/docker/services/swift-storage.yaml +++ b/docker/services/swift-storage.yaml @@ -474,6 +474,7 @@ outputs: src: /var/log/swift dest: /var/log/containers/swift state: link + ignore_errors: "{{ ansible_check_mode }}" - name: swift logs readme copy: dest: /var/log/swift/readme.txt diff --git a/puppet/services/container-image-prepare.j2.yaml b/puppet/services/container-image-prepare.j2.yaml index ec6fdcdf9e..839d021f01 100644 --- a/puppet/services/container-image-prepare.j2.yaml +++ b/puppet/services/container-image-prepare.j2.yaml @@ -84,11 +84,13 @@ outputs: state: file suffix: -prepare-param register: prepare_param + check_mode: no - name: Create temp file for role data tempfile: state: file suffix: -role-data register: role_data + check_mode: no - name: Write ContainerImagePrepare parameter file copy: dest: "{{ '{{' }} prepare_param.path {{ '}}' }}" @@ -111,7 +113,9 @@ outputs: file: dest: "{{ '{{' }} prepare_param.path {{ '}}' }}" state: absent + check_mode: no - name: Delete role file file: dest: "{{ '{{' }} role_data.path {{ '}}' }}" state: absent + check_mode: no