Evaluating ansible_check_mode as a boolean

Evaluating ansible_check_mode as a bare variable is deprecated in
Ansible 2.8 and its support will be removed in 2.12.

Change-Id: I4d566bf8b7b3085d693fe94b53384e667f81b092
(cherry picked from commit 7e73fac11a)
This commit is contained in:
Emilien Macchi 2019-04-17 16:54:31 -04:00
parent c630f13fd0
commit d4218d1f39
2 changed files with 28 additions and 28 deletions

View File

@ -68,7 +68,7 @@
- container_config_scripts - container_config_scripts
- container_startup_configs - container_startup_configs
when: when:
- ansible_check_mode - ansible_check_mode|bool
ignore_errors: true ignore_errors: true
check_mode: no check_mode: no
@ -86,7 +86,7 @@
- container_config_scripts - container_config_scripts
- container_startup_configs - container_startup_configs
when: when:
- ansible_check_mode - ansible_check_mode|bool
check_mode: no check_mode: no
# Puppet manifest for baremetal host configuration # Puppet manifest for baremetal host configuration
@ -94,7 +94,7 @@
no_log: True no_log: True
copy: copy:
content: "{{ lookup('file', tripleo_role_name + '/step_config.pp', errors='ignore') | default('', True) }}" content: "{{ lookup('file', tripleo_role_name + '/step_config.pp', errors='ignore') | default('', True) }}"
dest: /var/lib/tripleo-config/{{ ansible_check_mode | ternary('check-mode/', '') }}puppet_step_config.pp dest: /var/lib/tripleo-config/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}puppet_step_config.pp
force: yes force: yes
mode: '0600' mode: '0600'
tags: tags:
@ -110,7 +110,7 @@
- host_config - host_config
check_mode: no check_mode: no
when: when:
- ansible_check_mode - ansible_check_mode|bool
- ansible_diff_mode - ansible_diff_mode
failed_when: false failed_when: false
changed_when: diff_results.rc == 1 changed_when: diff_results.rc == 1
@ -120,7 +120,7 @@
var: diff_results.stdout_lines var: diff_results.stdout_lines
changed_when: diff_results.rc == 1 changed_when: diff_results.rc == 1
when: when:
- ansible_check_mode - ansible_check_mode|bool
- ansible_diff_mode - ansible_diff_mode
tags: tags:
- host_config - host_config
@ -172,7 +172,7 @@
ignore_errors: true ignore_errors: true
check_mode: no check_mode: no
when: when:
- ansible_check_mode - ansible_check_mode|bool
- name: Create /var/lib/container-puppet/check-mode for check mode - name: Create /var/lib/container-puppet/check-mode for check mode
file: file:
@ -184,13 +184,13 @@
- container_config - container_config
check_mode: no check_mode: no
when: when:
- ansible_check_mode - ansible_check_mode|bool
- name: Write container-puppet.json file - name: Write container-puppet.json file
no_log: True no_log: True
copy: copy:
content: "{{ lookup('file', tripleo_role_name + '/puppet_config.yaml', errors='ignore') | default([], True) | from_yaml | to_nice_json }}" content: "{{ lookup('file', tripleo_role_name + '/puppet_config.yaml', errors='ignore') | default([], True) | from_yaml | to_nice_json }}"
dest: /var/lib/container-puppet/{{ ansible_check_mode | ternary('check-mode/', '') }}container-puppet.json dest: /var/lib/container-puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}container-puppet.json
force: yes force: yes
mode: '0600' mode: '0600'
tags: tags:
@ -206,7 +206,7 @@
- container_config - container_config
check_mode: no check_mode: no
when: when:
- ansible_check_mode - ansible_check_mode|bool
- ansible_diff_mode - ansible_diff_mode
failed_when: false failed_when: false
changed_when: diff_results.rc == 1 changed_when: diff_results.rc == 1
@ -216,7 +216,7 @@
var: diff_results.stdout_lines var: diff_results.stdout_lines
changed_when: diff_results.rc == 1 changed_when: diff_results.rc == 1
when: when:
- ansible_check_mode - ansible_check_mode|bool
- ansible_diff_mode - ansible_diff_mode
tags: tags:
- container_config - container_config
@ -345,7 +345,7 @@
stat: stat:
path: /etc/puppet/check-mode path: /etc/puppet/check-mode
register: check_mode_dir register: check_mode_dir
when: ansible_check_mode when: ansible_check_mode|bool
tags: tags:
- host_config - host_config
- container_config - container_config
@ -359,7 +359,7 @@
recurse: true recurse: true
check_mode: no check_mode: no
when: when:
- ansible_check_mode - ansible_check_mode|bool
- not check_mode_dir.stat.exists - not check_mode_dir.stat.exists
tags: tags:
- host_config - host_config
@ -369,7 +369,7 @@
no_log: True no_log: True
copy: copy:
content: "{{ dict(step=step|int) | to_json }}" content: "{{ dict(step=step|int) | to_json }}"
dest: /etc/puppet/{{ ansible_check_mode | ternary('check-mode/', '') }}hieradata/config_step.json dest: /etc/puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}hieradata/config_step.json
force: true force: true
mode: '0600' mode: '0600'
check_mode: no check_mode: no
@ -382,7 +382,7 @@
cp -a /etc/puppet/hieradata/* /etc/puppet/check-mode/hieradata/ cp -a /etc/puppet/hieradata/* /etc/puppet/check-mode/hieradata/
sed -i 's/\/etc\/puppet\/hieradata/\/etc\/puppet\/check-mode\/hieradata/' /etc/puppet/check-mode/hiera.yaml sed -i 's/\/etc\/puppet\/hieradata/\/etc\/puppet\/check-mode\/hieradata/' /etc/puppet/check-mode/hiera.yaml
when: when:
- ansible_check_mode - ansible_check_mode|bool
- not check_mode_dir.stat.exists - not check_mode_dir.stat.exists
check_mode: no check_mode: no
tags: tags:
@ -397,9 +397,9 @@
--detailed-exitcodes --detailed-exitcodes
--summarize --summarize
--logdest syslog --logdest console --color=false --logdest syslog --logdest console --color=false
{{ ansible_check_mode | ternary('--noop', '') }} {{ ansible_check_mode | bool | ternary('--noop', '') }}
{{ ansible_check_mode | ternary('--hiera_config /etc/puppet/check-mode/hiera.yaml', '') }} {{ ansible_check_mode | bool | ternary('--hiera_config /etc/puppet/check-mode/hiera.yaml', '') }}
/var/lib/tripleo-config/{{ ansible_check_mode | ternary('check-mode/', '') }}puppet_step_config.pp /var/lib/tripleo-config/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}puppet_step_config.pp
changed_when: outputs.rc == 2 changed_when: outputs.rc == 2
register: outputs register: outputs
failed_when: false failed_when: false
@ -417,7 +417,7 @@
failed_when: outputs.rc not in [0, 2] failed_when: outputs.rc not in [0, 2]
tags: tags:
- host_config - host_config
ignore_errors: "{{ ansible_check_mode }}" ignore_errors: "{{ ansible_check_mode|bool }}"
###################################### ######################################
# Generate config via container-puppet.py # Generate config via container-puppet.py
@ -430,10 +430,10 @@
DEBUG: '{{ docker_puppet_debug | bool }}' DEBUG: '{{ docker_puppet_debug | bool }}'
PROCESS_COUNT: '{{ docker_puppet_process_count }}' PROCESS_COUNT: '{{ docker_puppet_process_count }}'
CONTAINER_CLI: "{{ container_cli }}" CONTAINER_CLI: "{{ container_cli }}"
CONFIG: '/var/lib/container-puppet/{{ ansible_check_mode | ternary("check-mode/", "") }}container-puppet.json' CONFIG: '/var/lib/container-puppet/{{ ansible_check_mode | bool | ternary("check-mode/", "") }}container-puppet.json'
CONFIG_VOLUME_PREFIX: '/var/lib/config-data{{ ansible_check_mode | ternary("/check-mode", "") }}' CONFIG_VOLUME_PREFIX: '/var/lib/config-data{{ ansible_check_mode | bool | ternary("/check-mode", "") }}'
CHECK_MODE: '{{ ansible_check_mode | ternary(1, 0) }}' CHECK_MODE: '{{ ansible_check_mode | bool | ternary(1, 0) }}'
STARTUP_CONFIG_PATTERN: '/var/lib/tripleo-config/{{ ansible_check_mode | ternary("check-mode/", "") }}container-startup-config-step_*.json' STARTUP_CONFIG_PATTERN: '/var/lib/tripleo-config/{{ ansible_check_mode | bool | ternary("check-mode/", "") }}container-startup-config-step_*.json'
MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet | default(true)}}' MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet | default(true)}}'
CONTAINER_LOG_STDOUT_PATH: "{{ container_log_stdout_path }}" CONTAINER_LOG_STDOUT_PATH: "{{ container_log_stdout_path }}"
CONTAINER_HEALTHCHECK_DISABLED: "{{ container_healthcheck_disabled }}" CONTAINER_HEALTHCHECK_DISABLED: "{{ container_healthcheck_disabled }}"
@ -453,7 +453,7 @@
failed_when: outputs.rc != 0 failed_when: outputs.rc != 0
tags: tags:
- container_config - container_config
ignore_errors: "{{ ansible_check_mode }}" ignore_errors: "{{ ansible_check_mode|bool }}"
- name: Diff container-puppet.py puppet-generated changes for check mode - name: Diff container-puppet.py puppet-generated changes for check mode
shell: | shell: |
@ -465,7 +465,7 @@
check_mode: no check_mode: no
when: when:
- step == "1" - step == "1"
- ansible_check_mode - ansible_check_mode|bool
- ansible_diff_mode - ansible_diff_mode
failed_when: false failed_when: false
changed_when: diff_results.rc == 1 changed_when: diff_results.rc == 1
@ -476,7 +476,7 @@
changed_when: diff_results.rc == 1 changed_when: diff_results.rc == 1
when: when:
- step == "1" - step == "1"
- ansible_check_mode - ansible_check_mode|bool
- ansible_diff_mode - ansible_diff_mode
tags: tags:
- container_config - container_config
@ -548,8 +548,8 @@
- name: Run container-puppet tasks (bootstrap tasks) for step {{ step }} - name: Run container-puppet tasks (bootstrap tasks) for step {{ step }}
shell: "{{ python_cmd }} /var/lib/container-puppet/container-puppet.py" shell: "{{ python_cmd }} /var/lib/container-puppet/container-puppet.py"
environment: environment:
CONFIG: /var/lib/container-puppet/{{ ansible_check_mode | ternary('check-mode/', '') }}container-puppet-tasks{{ step }}.json CONFIG: /var/lib/container-puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}container-puppet-tasks{{ step }}.json
CONFIG_VOLUME_PREFIX: '/var/lib/config-data{{ ansible_check_mode | ternary("/check-mode", "") }}' CONFIG_VOLUME_PREFIX: '/var/lib/config-data{{ ansible_check_mode | bool | ternary("/check-mode", "") }}'
NET_HOST: "true" NET_HOST: "true"
NO_ARCHIVE: "true" NO_ARCHIVE: "true"
STEP: "{{ step }}" STEP: "{{ step }}"

View File

@ -590,7 +590,7 @@ outputs:
src: /var/log/swift src: /var/log/swift
dest: /var/log/containers/swift dest: /var/log/containers/swift
state: link state: link
ignore_errors: "{{ ansible_check_mode }}" ignore_errors: "{{ ansible_check_mode|bool }}"
when: swift_log_stat.stat.exists when: swift_log_stat.stat.exists
- name: swift logs readme - name: swift logs readme
copy: copy: