From 328fb437b1a09ad2de15f152927fcdd22da59435 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 11 Jul 2018 17:18:29 +0100 Subject: [PATCH] Fix Ansible Using tests as filters is deprecated Avoids deprecation warnings like below by adopting recommended syntax. [DEPRECATION WARNING]: Using tests as filters is deprecated. Instead of using `result|failed` instead use `result is failed`. This feature will be removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. Change-Id: I84a630415d5aee653e07de0da9321f2fa59eee24 Signed-off-by: Sorin Sbarnea --- roles/environment/teardown/tasks/main.yml | 6 ++--- roles/fetch-images/tasks/fetch.yml | 8 +++---- roles/libvirt/setup/common/tasks/main.yml | 4 ++-- .../overcloud/tasks/libvirt_nodepool.yml | 4 ++-- roles/libvirt/setup/overcloud/tasks/main.yml | 4 ++-- .../setup/supplemental/tasks/provision.yml | 2 +- roles/libvirt/setup/undercloud/tasks/main.yml | 12 +++++----- roles/libvirt/teardown/nodes/tasks/main.yml | 24 +++++++++---------- roles/provision/teardown/tasks/main.yml | 8 +++---- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/roles/environment/teardown/tasks/main.yml b/roles/environment/teardown/tasks/main.yml index b93c5e31f..b6b1cd673 100644 --- a/roles/environment/teardown/tasks/main.yml +++ b/roles/environment/teardown/tasks/main.yml @@ -13,7 +13,7 @@ changed_when: false # If libvirt is not available, we can skip the rest of the tasks. -- when: libvirt_check|success +- when: libvirt_check is success block: # Check to see if the networks exist. @@ -30,7 +30,7 @@ - name: Stop libvirt networks command: > virsh net-destroy "{{ item.item.name }}" - when: libvirt_check|success and item|success + when: libvirt_check is success and item is success with_items: "{{ network_check.results }}" ignore_errors: true become: true @@ -38,7 +38,7 @@ - name: Undefine libvirt networks command: > virsh net-undefine "{{ item.item.name }}" - when: libvirt_check|success and item|success + when: libvirt_check is success and item is success with_items: "{{ network_check.results }}" ignore_errors: true become: true diff --git a/roles/fetch-images/tasks/fetch.yml b/roles/fetch-images/tasks/fetch.yml index 52c502875..b5e06ed24 100644 --- a/roles/fetch-images/tasks/fetch.yml +++ b/roles/fetch-images/tasks/fetch.yml @@ -32,7 +32,7 @@ set_fact: image_cache_path: "{{ _latest }}" cacheable: true - when: latest_exists|success and _force_cached_image + when: latest_exists is success and _force_cached_image # The md5sum for base OS images are not hosted, they are defined in a configuration file. # Handle base os images slightly differently @@ -63,7 +63,7 @@ # Otherwise, check if there's a new image available. - when: - image.md5sum is not defined - - not _force_cached_image or latest_exists|failed + - not _force_cached_image or latest_exists is failed block: # Get the expected checksum for the remote image. @@ -96,7 +96,7 @@ # Note.. image_exists and base_image_exists are required variables because # even unused variables will overwrite each other. -- when: image_exists is defined and (image_exists|failed or base_image_exists|failed) +- when: image_exists is defined and (image_exists is failed or base_image_exists is failed) block: # This task will download the image. We're using `curl` here @@ -132,7 +132,7 @@ fail: msg: image checksum does not match when: > - image_exists|failed and + image_exists is failed and (md5_expected != md5_actual) - name: Cache image by checksum diff --git a/roles/libvirt/setup/common/tasks/main.yml b/roles/libvirt/setup/common/tasks/main.yml index 6df1ed110..bc34193d8 100644 --- a/roles/libvirt/setup/common/tasks/main.yml +++ b/roles/libvirt/setup/common/tasks/main.yml @@ -20,11 +20,11 @@ template: src: volume_pool.xml.j2 dest: "{{ working_dir }}/volume_pool.xml" - when: pool_check|failed + when: pool_check is failed - name: Define volume pool command: "virsh pool-define {{ working_dir }}/volume_pool.xml" - when: pool_check|failed + when: pool_check is failed environment: LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}" diff --git a/roles/libvirt/setup/overcloud/tasks/libvirt_nodepool.yml b/roles/libvirt/setup/overcloud/tasks/libvirt_nodepool.yml index ee1353a8c..2dc92a30e 100644 --- a/roles/libvirt/setup/overcloud/tasks/libvirt_nodepool.yml +++ b/roles/libvirt/setup/overcloud/tasks/libvirt_nodepool.yml @@ -130,7 +130,7 @@ - name: Get libvirt nodepool IP addresses script: "get-domain-ip.sh subnode-0" register: "subnode_0_ip_result" - until: "subnode_0_ip_result|success" + until: "subnode_0_ip_result is success" retries: 20 delay: 10 @@ -171,7 +171,7 @@ - name: Get libvirt nodepool IP addresses script: "get-domain-ip.sh subnode-1" register: "subnode_1_ip_result" - until: "subnode_1_ip_result|success" + until: "subnode_1_ip_result is success" retries: 20 delay: 10 diff --git a/roles/libvirt/setup/overcloud/tasks/main.yml b/roles/libvirt/setup/overcloud/tasks/main.yml index 290ab79e5..599eb86fa 100644 --- a/roles/libvirt/setup/overcloud/tasks/main.yml +++ b/roles/libvirt/setup/overcloud/tasks/main.yml @@ -39,7 +39,7 @@ '{{ item.item.name }}'.qcow2 '{{ flavors[item.item.flavor].disk }}'G --format qcow2 when: - - item|failed + - item is failed - not libvirt_nodepool_vms|default("false")|bool with_items: "{{ overcloud_vol_check.results }}" @@ -90,7 +90,7 @@ - name: Attach additional blockdevices to overcloud objectstorage VMs command: > virsh attach-disk --config {{ item.item[0].name }} {{ libvirt_volume_path }}/{{ item.item[0].name }}_{{ item.item[1] }}.img {{ item.item[1] }} - when: item|failed + when: item is failed with_items: "{{ overcloud_extradisks_check.results }}" # Generate the `instackenv.json` configuration file. Note that this diff --git a/roles/libvirt/setup/supplemental/tasks/provision.yml b/roles/libvirt/setup/supplemental/tasks/provision.yml index 67e7fd6be..23e7b8276 100644 --- a/roles/libvirt/setup/supplemental/tasks/provision.yml +++ b/roles/libvirt/setup/supplemental/tasks/provision.yml @@ -43,7 +43,7 @@ environment: LIBVIRT_DEFAULT_URI: '{{ libvirt_uri }}' -- when: supplemental_vol_check|failed +- when: supplemental_vol_check is failed block: # TODO(hrybacki): Update fetch-images role to handle supplemental images - name: Fetch centos image for ipa diff --git a/roles/libvirt/setup/undercloud/tasks/main.yml b/roles/libvirt/setup/undercloud/tasks/main.yml index 4d1388c2b..a5ab266ef 100644 --- a/roles/libvirt/setup/undercloud/tasks/main.yml +++ b/roles/libvirt/setup/undercloud/tasks/main.yml @@ -26,7 +26,7 @@ environment: LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}" -- when: undercloud_vol_check|failed +- when: undercloud_vol_check is failed environment: LIBGUESTFS_BACKEND: direct LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}" @@ -169,7 +169,7 @@ # Resize the undercloud image if it was not converted from an overcloud # image - when: - - undercloud_vol_check|failed + - undercloud_vol_check is failed - not overcloud_as_undercloud|bool block: - name: > @@ -182,7 +182,7 @@ register: undercloud_partitions - when: - - undercloud_vol_check|failed + - undercloud_vol_check is failed - not overcloud_as_undercloud|bool - undercloud_partitions.stdout=='/dev/sda1' block: @@ -207,7 +207,7 @@ '{{ working_dir }}/undercloud.qcow2' - when: - - undercloud_vol_check|failed + - undercloud_vol_check is failed - not overcloud_as_undercloud|bool - undercloud_partitions.stdout=='/dev/sda' block: @@ -265,7 +265,7 @@ overcloud_as_undercloud: true cacheable: true -- when: undercloud_vol_check|failed +- when: undercloud_vol_check is failed environment: LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}" block: @@ -341,7 +341,7 @@ - name: Get undercloud vm ip address script: "get-undercloud-ip.sh {{ undercloud_node.name }}" register: undercloud_vm_ip_result - until: undercloud_vm_ip_result|success + until: undercloud_vm_ip_result is success retries: "{{ undercloud_ip_retries }}" delay: 10 environment: diff --git a/roles/libvirt/teardown/nodes/tasks/main.yml b/roles/libvirt/teardown/nodes/tasks/main.yml index ac007ebc8..0b8983c65 100644 --- a/roles/libvirt/teardown/nodes/tasks/main.yml +++ b/roles/libvirt/teardown/nodes/tasks/main.yml @@ -17,7 +17,7 @@ LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}" # If libvirt isn't available we can skip everything else. -- when: libvirt_check|success +- when: libvirt_check is success environment: LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}" block: @@ -37,14 +37,14 @@ - name: Destroy overcloud vms command: virsh destroy "{{ item.item.name }}" - when: item|success + when: item is success with_items: "{{ overcloud_check.results }}" ignore_errors: true - name: Undefine overcloud vms command: virsh undefine "{{ item.item.name }}" - when: item|success + when: item is success with_items: "{{ overcloud_check.results }}" # The `virsh vol-dumpxml ... > /dev/null` is here (and elsewhere) due to @@ -73,13 +73,13 @@ - name: Destroy supplemental vm command: > virsh destroy "{{ supplemental_node.name|default('') }}" - when: supplemental_check|success + when: supplemental_check is success ignore_errors: true - name: Undefine supplemental vm command: > virsh undefine "{{ supplemental_node.name|default('') }}" --remove-all-storage - when: supplemental_check|success + when: supplemental_check is success ignore_errors: true # Do the same thing to the undercloud node. @@ -92,13 +92,13 @@ - name: Destroy undercloud vm command: > virsh destroy "{{ undercloud_node.name }}" - when: undercloud_check|success + when: undercloud_check is success ignore_errors: true - name: Undefine undercloud vm command: > virsh undefine "{{ undercloud_node.name }}" - when: undercloud_check|success + when: undercloud_check is success - name: Delete undercloud vm storage shell: | @@ -126,28 +126,28 @@ shell: | virsh pool-dumpxml "{{ libvirt_volume_pool }}" | virsh pool-define /dev/stdin - when: pool_check|success + when: pool_check is success - name: Destroy volume pool command: > virsh pool-destroy "{{ libvirt_volume_pool }}" - when: pool_check|success + when: pool_check is success ignore_errors: true - name: Undefine volume pool command: > virsh pool-undefine "{{ libvirt_volume_pool }}" - when: pool_check|success + when: pool_check is success - name: Get UID of pool user command: id -u "{{ ansible_user_id }}" register: pool_uid changed_when: false - when: pool_check|success + when: pool_check is success - name: Destroy pool definition file file: path: "/run/user/{{ pool_uid.stdout }}/libvirt/storage/run/{{ libvirt_volume_pool }}.xml" state: absent - when: pool_check|success + when: pool_check is success diff --git a/roles/provision/teardown/tasks/main.yml b/roles/provision/teardown/tasks/main.yml index fecda879a..3ee90395e 100644 --- a/roles/provision/teardown/tasks/main.yml +++ b/roles/provision/teardown/tasks/main.yml @@ -7,7 +7,7 @@ changed_when: false # If the non-root user exists, perform a variety of cleanup tasks. -- when: non_root_uid|success +- when: non_root_uid is success block: # Look for and kill any processes owned by the non-root user. # This will let us remove the user later on. @@ -23,7 +23,7 @@ pkill -u {{ non_root_user }} ignore_errors: true become: true - when: proc_exist|success + when: proc_exist is success - name: Wait for processes to exit command: > @@ -33,13 +33,13 @@ delay: 3 until: proc_kill.stdout == '0' ignore_errors: true - when: proc_exist|success + when: proc_exist is success become: true - name: Kill (SIGKILL) all processes owned by non-root user command: > pkill -9 -u {{ non_root_user }} - when: proc_exist|success + when: proc_exist is success ignore_errors: true become: true