From b70cd772033083dac440f270196d03b555dfbeae Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 17 Oct 2019 13:51:03 +0100 Subject: [PATCH] ansible-lint: resolved 4 skips Fixed several skips on ansible-lint Change-Id: I7416332b67593d1cd6b3177333c8bf1055aa3456 --- .ansible-lint | 5 +---- roles/multinodes/tasks/delete_stack.yml | 1 + roles/multinodes/tasks/main.yml | 1 + .../tasks/ovb-create-stack.yml | 1 + .../tasks/delete-original-node.yml | 15 +++++++++------ roles/overcloud-scale/tasks/pre-scale.yml | 19 +++++++++++-------- roles/overcloud-scale/tasks/scale-nodes.yml | 5 +++-- roles/set-libvirt-type/tasks/main.yml | 6 ++++++ roles/snapshot-libvirt/tasks/main.yml | 1 + roles/undercloud-deploy/tasks/tripleo-ui.yml | 2 +- .../validate-tobiko/tasks/prepare-tobiko.yml | 5 +++-- 11 files changed, 38 insertions(+), 23 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index 3f25da515..d7a75b397 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -9,10 +9,7 @@ skip_list: - 204 # Lines should be no longer than 160 chars - 302 # rm used in place of argument state=absent to file module - 303 # sed used in place of template, replace or lineinfile module - - 306 # Shells that use pipes should set the pipefail option - - 504 # Do not use 'local_action', use 'delegate_to: localhost' - - 601 # Don't compare to literal True/False - 602 # Don't compare to empty string + - 504 # Do not use 'local_action', use 'delegate_to: localhost' - 701 # No 'galaxy_info' found - - 703 # Should change default metadata: author verbosity: 1 diff --git a/roles/multinodes/tasks/delete_stack.yml b/roles/multinodes/tasks/delete_stack.yml index 252c10a7b..798a1bd63 100644 --- a/roles/multinodes/tasks/delete_stack.yml +++ b/roles/multinodes/tasks/delete_stack.yml @@ -1,5 +1,6 @@ --- - name: Delete stack + # noqa: 306 shell: > echo "Executing 'openstack stack delete {{ stack_name }} --yes'" >> {{ stack_log }}; openstack stack delete {{ stack_name }} --yes &>> {{ stack_log }} && { diff --git a/roles/multinodes/tasks/main.yml b/roles/multinodes/tasks/main.yml index e504e23c0..83ed90138 100644 --- a/roles/multinodes/tasks/main.yml +++ b/roles/multinodes/tasks/main.yml @@ -83,6 +83,7 @@ dest: "{{ local_working_dir }}/params_multinode.yaml" - name: Create stack + # noqa: 306 shell: > echo "Executing 'openstack stack create {{ stack_name }} --template {{ local_working_dir }}/multinode_stack.yaml -e {{ local_working_dir }}/params_multinode.yaml &>> {{ stack_log }}'" | tee -a {{ stack_log }}; diff --git a/roles/ovb-manage-stack/tasks/ovb-create-stack.yml b/roles/ovb-manage-stack/tasks/ovb-create-stack.yml index 15dd0868e..ce94eeb47 100644 --- a/roles/ovb-manage-stack/tasks/ovb-create-stack.yml +++ b/roles/ovb-manage-stack/tasks/ovb-create-stack.yml @@ -69,6 +69,7 @@ changed_when: true - name: Return stack state + # noqa: 306 shell: > export OS_USERNAME="{{ os_username }}"; export OS_PASSWORD="{{ os_password }}"; diff --git a/roles/overcloud-scale/tasks/delete-original-node.yml b/roles/overcloud-scale/tasks/delete-original-node.yml index 2801e38c3..374e33ad5 100644 --- a/roles/overcloud-scale/tasks/delete-original-node.yml +++ b/roles/overcloud-scale/tasks/delete-original-node.yml @@ -13,15 +13,17 @@ when: heat_stack_list_result.stdout.find('COMPLETE') == -1 - name: Register uuid of original {{ node_to_scale }} node - shell: > - source {{ working_dir }}/stackrc; + shell: | + set -eo pipefail + source {{ working_dir }}/stackrc nova list | grep -m 1 {{ node_to_scale }} | sed -e 's/|//g' | awk '{print $1}' register: node_id_to_delete changed_when: false - name: Register the Name of the original {{ node_to_scale }} node - shell: > - source {{ working_dir }}/stackrc; + shell: | + set -eo pipefail + source {{ working_dir }}/stackrc nova list | grep -m 1 {{ node_to_scale }} | sed -e 's/|//g' | awk '{print $2}' register: node_name_to_delete changed_when: false @@ -55,8 +57,9 @@ changed_when: false - name: Determine the post scale node count - shell: > - source {{ working_dir }}/stackrc; + shell: | + set -eo pipefail + source {{ working_dir }}/stackrc nova list | grep {{ node_to_scale }} | cut -f2- -d':' | wc -l register: post_scale_node_count changed_when: false diff --git a/roles/overcloud-scale/tasks/pre-scale.yml b/roles/overcloud-scale/tasks/pre-scale.yml index 5e0e13d8e..b54bc5ee0 100644 --- a/roles/overcloud-scale/tasks/pre-scale.yml +++ b/roles/overcloud-scale/tasks/pre-scale.yml @@ -20,29 +20,32 @@ # Prep for scaling overcloud - name: Determine initial number of node(s) that will be scaled - shell: > - source {{ working_dir }}/stackrc; + shell: | + set -eo pipefail + source {{ working_dir }}/stackrc nova list | grep {{ node_to_scale }} | cut -f2- -d':' | wc -l register: initial_node_count changed_when: false - name: Register uuid of original {{ node_to_scale }} node - shell: > - source {{ working_dir }}/stackrc; + shell: | + set -eo pipefail + source {{ working_dir }}/stackrc nova list | grep -m 1 {{ node_to_scale }} | sed -e 's/|//g' | awk '{print $1}' register: node_id_to_delete changed_when: false - name: Register the Name of the original {{ node_to_scale }} node - shell: > - source {{ working_dir }}/stackrc; + shell: | + set -eo pipefail + source {{ working_dir }}/stackrc nova list | grep -m 1 {{ node_to_scale }} | sed -e 's/|//g' | awk '{print $2}' register: node_name_to_delete changed_when: false - name: Register pre-scale nova list - shell: > - source {{ working_dir }}/stackrc; + shell: | + source {{ working_dir }}/stackrc nova list register: pre_scale_nova_list changed_when: false diff --git a/roles/overcloud-scale/tasks/scale-nodes.yml b/roles/overcloud-scale/tasks/scale-nodes.yml index 783ad3c4f..fb289d2cc 100644 --- a/roles/overcloud-scale/tasks/scale-nodes.yml +++ b/roles/overcloud-scale/tasks/scale-nodes.yml @@ -33,8 +33,9 @@ # Verify the scale - name: Determine the post scale node count - shell: > - source {{ working_dir }}/stackrc; + shell: | + set -eo pipefail + source {{ working_dir }}/stackrc nova list | grep {{ node_to_scale }} | cut -f2- -d':' | wc -l register: post_scale_node_count changed_when: false diff --git a/roles/set-libvirt-type/tasks/main.yml b/roles/set-libvirt-type/tasks/main.yml index f09597c34..191b7e762 100644 --- a/roles/set-libvirt-type/tasks/main.yml +++ b/roles/set-libvirt-type/tasks/main.yml @@ -3,6 +3,7 @@ setup: gather_subset: "!all,!min,hardware" when: ansible_processor is not defined + - name: Check cpu vendor set_fact: cpu_vendor: "{{ item }}" @@ -10,20 +11,25 @@ with_items: - intel - amd + - name: Check virt extensions on cpu flags + # noqa 306 shell: egrep 'vmx|svm' /proc/cpuinfo register: cpuflags failed_when: false no_log: true when: cpu_vendor is defined + - name: Set qemu as virt type set_fact: virt_type: qemu when: cpu_vendor is not defined or cpuflags.stdout == "" + - name: Set kvm as virt type set_fact: virt_type: kvm when: cpu_vendor is defined and cpuflags.stdout != "" + - name: Print virtualization type debug: var: virt_type diff --git a/roles/snapshot-libvirt/tasks/main.yml b/roles/snapshot-libvirt/tasks/main.yml index 29950de01..d65880ca1 100644 --- a/roles/snapshot-libvirt/tasks/main.yml +++ b/roles/snapshot-libvirt/tasks/main.yml @@ -21,6 +21,7 @@ async: 300 poll: 0 shell: | + set -eo pipefail while true do virsh list | grep -E '{{ libvirt_oc_names }}' > /dev/null || break done diff --git a/roles/undercloud-deploy/tasks/tripleo-ui.yml b/roles/undercloud-deploy/tasks/tripleo-ui.yml index 7fa15621a..791cf546a 100644 --- a/roles/undercloud-deploy/tasks/tripleo-ui.yml +++ b/roles/undercloud-deploy/tasks/tripleo-ui.yml @@ -98,7 +98,7 @@ - when: - enable_port_forward_for_tripleo_ui|bool - hostvars[groups['virthost'][0]].ansible_host is defined - - tripleo_ui_secure_access|bool == false + - not (tripleo_ui_secure_access|bool) - ooo_ui_config_file.stat.exists block: - name: update config in tripleo_ui_config.js, connect via virthost ip with ssl diff --git a/roles/validate-tobiko/tasks/prepare-tobiko.yml b/roles/validate-tobiko/tasks/prepare-tobiko.yml index 526ee4bf0..b17531e6d 100644 --- a/roles/validate-tobiko/tasks/prepare-tobiko.yml +++ b/roles/validate-tobiko/tasks/prepare-tobiko.yml @@ -37,8 +37,9 @@ recursive: true - name: Get number of existing tobiko log files - shell: > - number_of_files=$(ls {{ tobiko_log_dir }} | grep -E "{{ tobiko_log_file_base }}-[0-9]+.log$" -c); + shell: | + set -eo pipefail + number_of_files=$(ls {{ tobiko_log_dir }} | grep -E "{{ tobiko_log_file_base }}-[0-9]+.log$" -c) echo $(( $number_of_files + 1 )); register: current_tobiko_log_file_number changed_when: true