Remove syntax warnings for when statements

Ansible>=2.3.0 will output warnings if `when` statements contain jinja2
templating delimiters such as curly braces (the playbooks are executing
fine, despite the warnings).

This patch changes these statements to use the correct syntax as
suggested in the docs.

Change-Id: I58657253bdc46e90eec6dea7ea5e07a2bf6c466e
Closes-Bug: #1721213
This commit is contained in:
Florian Fuchs 2017-07-18 14:53:01 +00:00 committed by Gael Chamoulaud
parent 33894d083d
commit c16a61649c
13 changed files with 24 additions and 24 deletions

View File

@ -15,5 +15,5 @@
shell: "ls /sys/class/block/"
- name: Detect whether the drive uses Advanced Format
advanced_format: drive={{ item }}
when: '"{{ item }}" | match("^sd.$")'
when: item|match("^sd.$")
with_items: "{{ drive_list.stdout_lines }}"

View File

@ -20,6 +20,6 @@
- name: "Test network_gateway if different from local_ip"
icmp_ping: host={{ undercloud_conf.DEFAULT.network_gateway }}
when: >
"{{ undercloud_conf.DEFAULT.local_ip | default('0.0.0.0') | ipaddr('address') }}"
"undercloud_conf.DEFAULT.local_ip | default('0.0.0.0') | ipaddr('address')"
!=
"{{ undercloud_conf.DEFAULT.network_gateway | default('0.0.0.0') | ipaddr('address') }}"
"undercloud_conf.DEFAULT.network_gateway | default('0.0.0.0') | ipaddr('address')"

View File

@ -22,7 +22,7 @@
msg: >
nofiles is set to {{ nofilesval.stdout }}. It should be at least
{{ nofiles_min }} or higher, depending on available resources.
failed_when: "{{ nofilesval.stdout|int }} < {{ nofiles_min }}"
failed_when: "nofilesval.stdout|int < nofiles_min"
- name: Get nproc limit
become: true
@ -35,4 +35,4 @@
msg: >
nproc is set to {{ nprocval.stdout }}. It should be at least
{{ nproc_min }} or higher, depending on available resources.
failed_when: "{{ nprocval.stdout|int }} < {{ nproc_min }}"
failed_when: "nprocval.stdout|int < nproc_min"

View File

@ -19,19 +19,19 @@
haproxy_conf: path="{{ config_file }}"
- name: Verify global maxconn
fail: msg="The 'global maxconn' value '{{ haproxy_conf.global.maxconn}}' must be greater than {{ global_maxconn_min }}"
failed_when: "{{ haproxy_conf.global.maxconn}} < {{ global_maxconn_min }}"
failed_when: "haproxy_conf.global.maxconn < global_maxconn_min"
- name: Verify defaults maxconn
fail: msg="The 'defaults maxconn' value '{{ haproxy_conf.defaults.maxconn }}' must be greater than {{ defaults_maxconn_min }}"
failed_when: "{{ haproxy_conf.defaults.maxconn }} < {{ defaults_maxconn_min }}"
failed_when: "haproxy_conf.defaults.maxconn < defaults_maxconn_min"
- name: Verify defaults timeout queue
fail: msg="The 'timeout queue' option in 'defaults' is '{{ haproxy_conf.defaults['timeout queue'] }}', but must be set to {{ defaults_timeout_queue }}"
failed_when: "'{{ haproxy_conf.defaults['timeout queue'] }}' != '{{ defaults_timeout_queue }}'"
failed_when: "haproxy_conf.defaults['timeout queue'] != defaults_timeout_queue"
- name: Verify defaults timeout client
fail: msg="The 'timeout client' option in 'defaults' is '{{ haproxy_conf.defaults['timeout client'] }}', but must be set to {{ defaults_timeout_client }}"
failed_when: "'{{ haproxy_conf.defaults['timeout client'] }}' != '{{ defaults_timeout_client }}'"
failed_when: "haproxy_conf.defaults['timeout client'] != defaults_timeout_client"
- name: Verify defaults timeout server
fail: msg="The 'timeout server' option in 'defaults' is '{{ haproxy_conf.defaults['timeout server'] }}', but must be set to {{ defaults_timeout_server }}"
failed_when: "'{{ haproxy_conf.defaults['timeout server'] }}' != '{{ defaults_timeout_server }}'"
failed_when: "haproxy_conf.defaults['timeout server'] != defaults_timeout_server"
- name: Verify defaults timeout check
fail: msg="The 'timeout check' option in 'defaults' is '{{ haproxy_conf.defaults['timeout check'] }}', but must be set to {{ defaults_timeout_check }}"
failed_when: "'{{ haproxy_conf.defaults['timeout check'] }}' != '{{ defaults_timeout_check }}'"
failed_when: "haproxy_conf.defaults['timeout check'] != defaults_timeout_check"

View File

@ -20,4 +20,4 @@
msg: >
The open_files_limit option for mysql must be higher than
{{ min_open_files_limit }}. Right now it's {{ mysqld_open_files_limit.msg }}.
failed_when: "{{ mysqld_open_files_limit.msg|int }} < {{ min_open_files_limit }}"
failed_when: "mysqld_open_files_limit.msg|int < min_open_files_limit"

View File

@ -19,4 +19,4 @@
The firewall_driver value in /etc/nova/nova.conf is
{{ nova_firewall_driver.value or 'unset' }}, but it must be set to:
nova.virt.firewall.NoopFirewallDriver
failed_when: "{{ nova_firewall_driver.value != 'nova.virt.firewall.NoopFirewallDriver' }}"
failed_when: "nova_firewall_driver.value != 'nova.virt.firewall.NoopFirewallDriver'"

View File

@ -17,4 +17,4 @@
- name: Verify the actual limit exceeds the minimal value
fail:
msg: "{{ actual_fd_limit.stdout }} must be greater than or equal to {{ min_fd_limit }}"
failed_when: "{{ actual_fd_limit.stdout|int }} < {{ min_fd_limit }}"
failed_when: "actual_fd_limit.stdout|int < min_fd_limit"

View File

@ -5,8 +5,8 @@
- name: Verify disk space in /var (if it exists)
fail: msg="The available space on the /var partition is {{ (item.size_available|int / const_bytes_in_gb|int)|round(1) }} GB, but it should be at least {{ min_undercloud_disk_gb }} GB."
with_items: "{{ ansible_mounts }}"
when: "'/var' == '{{ item.mount }}'"
failed_when: "{{ min_undercloud_disk_gb|int * const_bytes_in_gb|int }} >= {{ item.size_available|int }}"
when: "'/var' == item.mount"
failed_when: "min_undercloud_disk_gb|int * const_bytes_in_gb|int >= item.size_available|int"
# Notify the next task that we've checked /var (and that it exists)
changed_when: True
register: previous
@ -15,5 +15,5 @@
fail: msg="The available space on the root partition is {{ (item.size_available|int / const_bytes_in_gb|int)|round(1) }} GB, but it should be at least {{ min_undercloud_disk_gb }} GB."
with_items: "{{ ansible_mounts }}"
# Only run this when /var doesn't exist
when: "{{ not previous.changed }} and '/' == '{{ item.mount }}'"
failed_when: "{{ min_undercloud_disk_gb|int * const_bytes_in_gb|int }} >= {{ item.size_available|int }}"
when: "not previous.changed and '/' == item.mount"
failed_when: "min_undercloud_disk_gb|int * const_bytes_in_gb|int >= item.size_available|int"

View File

@ -14,4 +14,4 @@
tasks:
- name: Verify the number of CPU cores
fail: msg="There are {{ ansible_processor_vcpus }} cores in the system, but there should be at least {{ min_undercloud_cpu_count }}"
failed_when: "{{ ansible_processor_vcpus|int }} < {{ min_undercloud_cpu_count|int }}"
failed_when: "ansible_processor_vcpus|int < min_undercloud_cpu_count|int"

View File

@ -36,10 +36,10 @@
command: echo "There are {{ item.stdout }} {{ item.item }} processes running. Having more than {{ max_process_count }} risks running out of memory."
register: process_warnings
with_items: "{{ process_count.results }}"
when: "{{ item.stdout|int }} > {{ max_process_count }}"
when: "item.stdout|int > max_process_count"
- name: Output warning message
warn: msg={{ warning_msg }}
when: "{{ warning_msg|length > 0}}"
when: "warning_msg|length > 0"
vars:
warning_msg: "{{ process_warnings.results|selectattr('changed')|map(attribute='stdout')|join('\n') }}"

View File

@ -16,4 +16,4 @@
- name: Verify the RAM requirements
fail: msg="The RAM on the undercloud node is {{ ansible_memtotal_mb }} MB, the minimal recommended value is {{ min_undercloud_ram_gb|int * 1024 }} MB."
# NOTE(shadower): converting GB to MB
failed_when: "({{ ansible_memtotal_mb }}) < {{ min_undercloud_ram_gb|int * 1024 }}"
failed_when: "(ansible_memtotal_mb) < min_undercloud_ram_gb|int * 1024"

View File

@ -17,5 +17,5 @@
ignore_errors: true
- name: Fail if services were not running
fail: msg="One of the undercloud services was not active. Please check {{ item.item }} first and then confirm the status of undercloud services in general before attempting to update or upgrade the environment."
failed_when: "{{ item.stdout != 'ActiveState=active' }}"
failed_when: "item.stdout != 'ActiveState=active'"
with_items: "{{ check_services.results }}"

View File

@ -18,4 +18,4 @@
-
name: Check keystone crontab
fail: msg="keystone token_flush does not appear to be enabled via cron. You should add '<desired interval > {{ cron_check }}' to the keystone users crontab."
failed_when: "'{{ cron_check }}' not in cron_result.stdout"
failed_when: "cron_check not in cron_result.stdout"