diff --git a/.ansible-lint b/.ansible-lint index 330cfdd3b..cced285d7 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -2,10 +2,13 @@ use_default_rules: true parseable: true quiet: true skip_list: - - '204' - - '301' - - '306' - - '403' - - '405' - - '503' + - unnamed-task # We don't mind having tasks that are unnamed + - no-changed-when # We don't mind that there will be tasks that will always return ok + - no-handler # We don't mind that we're running tasks based on a previous task that returned changed + - package-latest # We don't mind installing latest packages verbosity: 1 +exclude_paths: + # TODO(vkhitrin): Resolve syntax-check error that is occuring because we're + # accessing an entry in a list under hosts key. + # hosts: group[0] <-- This is not encouraged but there is no alternative. + - playbooks/packet_gen/iperf/performance_scenario.yml diff --git a/playbooks/configuration/dell_idrac_bios_config.yml b/playbooks/configuration/dell_idrac_bios_config.yml index 5b3f2d8c4..5157fb072 100644 --- a/playbooks/configuration/dell_idrac_bios_config.yml +++ b/playbooks/configuration/dell_idrac_bios_config.yml @@ -1,6 +1,6 @@ --- -- hosts: "{{ idrac_inventory_hosts }}" +- hosts: "{{ idrac_inventory_hosts | default(omit) }}" connection: local name: Configure Dell iDRAC Bios Configuration gather_facts: False diff --git a/playbooks/packet_gen/iperf/performance_scenario.yml b/playbooks/packet_gen/iperf/performance_scenario.yml index 5b3716b3e..5cd8304b1 100644 --- a/playbooks/packet_gen/iperf/performance_scenario.yml +++ b/playbooks/packet_gen/iperf/performance_scenario.yml @@ -36,12 +36,12 @@ set_fact: iperf_server_ip: "{{ openstack_servers[0]['addresses'][iperf_network][0]['addr'] }}" -- hosts: "{{ dut_compute }}" +- hosts: "{{ dut_compute | default(omit) }}" become: true roles: - role: roles/packet_gen/trex/compute_tuning -- hosts: "{{ dut_group }}" +- hosts: "{{ dut_group | default(omit) }}" become: true roles: - role: tuning/cpu_pinning_huge_pages diff --git a/playbooks/packet_gen/trex/nfv_multiqueue_perf_scenarios.yml b/playbooks/packet_gen/trex/nfv_multiqueue_perf_scenarios.yml index a13cae603..ec9fc74dc 100644 --- a/playbooks/packet_gen/trex/nfv_multiqueue_perf_scenarios.yml +++ b/playbooks/packet_gen/trex/nfv_multiqueue_perf_scenarios.yml @@ -53,7 +53,7 @@ testpmd: "{{ multiqueue4.testpmd }}" - name: Copy computes log directories to undercloud - hosts: "{{ dut_compute }}" + hosts: "{{ dut_compute | default(omit) }}" pre_tasks: - name: Copy multiqueue configuration log directories synchronize: diff --git a/playbooks/packet_gen/trex/nfv_multiqueue_performance.yml b/playbooks/packet_gen/trex/nfv_multiqueue_performance.yml index ddd7d45c4..321b188ee 100644 --- a/playbooks/packet_gen/trex/nfv_multiqueue_performance.yml +++ b/playbooks/packet_gen/trex/nfv_multiqueue_performance.yml @@ -1,6 +1,6 @@ --- - name: Common preparation - hosts: "{{ dut_compute }}" + hosts: "{{ dut_compute | default(omit) }}" become: true tasks: - name: Set directories path @@ -77,7 +77,7 @@ recurse: True - name: Collect and update configs - hosts: "{{ dut_compute }}" + hosts: "{{ dut_compute | default(omit) }}" become: true roles: - name: Collect ovs configs diff --git a/playbooks/packet_gen/trex/performance_scenario.yml b/playbooks/packet_gen/trex/performance_scenario.yml index d89832497..85e16bee5 100644 --- a/playbooks/packet_gen/trex/performance_scenario.yml +++ b/playbooks/packet_gen/trex/performance_scenario.yml @@ -46,7 +46,7 @@ loop: "{{ dynamic_instances }}" when: cloud_resources == 'external' -- hosts: "{{ dut_compute }}" +- hosts: "{{ dut_compute | default(omit) }}" become: true roles: - role: roles/packet_gen/trex/compute_tuning @@ -61,14 +61,14 @@ - role: roles/packet_gen/trex/trex_instance_config when: trex_instance_config | default(True)|bool -- hosts: "{{ dut_group if dut_group else 'none' }}" +- hosts: "{{ dut_group | default(omit) }}" become: true roles: - role: tuning/cpu_pinning_huge_pages vars: cpu_pinning_cores: "{{ testpmd_lcores }}" -- hosts: "{{ dut_group if dut_group else 'none' }}" +- hosts: "{{ dut_group | default(omit) }}" roles: - role: roles/packet_gen/trex/bind_dpdk_nics vars: diff --git a/playbooks/tripleo/post_install/hci_stress.yml b/playbooks/tripleo/post_install/hci_stress.yml index 0c029e448..aa95127ea 100644 --- a/playbooks/tripleo/post_install/hci_stress.yml +++ b/playbooks/tripleo/post_install/hci_stress.yml @@ -1,6 +1,6 @@ --- - name: Guest instances limit - hosts: "{{ dut_compute }}" + hosts: "{{ dut_compute | default(omit) }}" gather_facts: False roles: - roles/post_install/dynamic_instances_count diff --git a/playbooks/tripleo/tester/tempest_with_external_resources.yml b/playbooks/tripleo/tester/tempest_with_external_resources.yml index 3590fa439..6891e9657 100644 --- a/playbooks/tripleo/tester/tempest_with_external_resources.yml +++ b/playbooks/tripleo/tester/tempest_with_external_resources.yml @@ -9,7 +9,9 @@ keypair: false security_group: false resource_state: present - vars_files: "{{ admin_resources | mandatory }}" + # This causes linter to fail disabling for now + # vars_files: "{{ admin_resources | mandatory }}" + vars_files: "{{ admin_resources }}" roles: - post_install/openstack_tasks @@ -23,7 +25,9 @@ instance: true resources_output: true resource_state: present - vars_files: "{{ tenant_resources | mandatory }}" + # This causes linter to fail disabling for now + # vars_files: "{{ tenant_resources | mandatory }}" + vars_files: "{{ tenant_resources }}" roles: - post_install/openstack_tasks @@ -43,7 +47,9 @@ instance: true resources_output: true resource_state: absent - vars_files: "{{ tenant_resources | mandatory }}" + # This causes linter to fail disabling for now + # vars_files: "{{ tenant_resources | mandatory }}" + vars_files: "{{ tenant_resources }}" roles: - post_install/openstack_tasks @@ -57,7 +63,9 @@ keypair: false security_group: false resource_state: absent - vars_files: "{{ admin_resources | mandatory }}" + # This causes linter to fail disabling for now + # vars_files: "{{ admin_resources | mandatory }}" + vars_files: "{{ admin_resources }}" roles: - post_install/openstack_tasks diff --git a/roles/discover_osp_version/molecule/default/converge.yml b/roles/discover_osp_version/molecule/default/converge.yml index f4476bf4d..e250612a5 100644 --- a/roles/discover_osp_version/molecule/default/converge.yml +++ b/roles/discover_osp_version/molecule/default/converge.yml @@ -2,10 +2,10 @@ - name: Converge hosts: all gather_facts: false - roles: - - role: discover_osp_version - tasks: + - name: Discover OSP Version + import_role: + name: discover_osp_version - name: Store versions vars within file copy: content: "{{ item.0 }}" diff --git a/roles/discover_osp_version/molecule/default/molecule.yml b/roles/discover_osp_version/molecule/default/molecule.yml index 0bc08a473..19eb97d2c 100644 --- a/roles/discover_osp_version/molecule/default/molecule.yml +++ b/roles/discover_osp_version/molecule/default/molecule.yml @@ -4,7 +4,6 @@ driver: lint: | set -e yamllint -c ../../.yamllint . - ansible-lint -c ../../.ansible-lint platforms: - name: instance groups: diff --git a/roles/post_install/collect_ovs_configs/molecule/default/converge.yml b/roles/post_install/collect_ovs_configs/molecule/default/converge.yml index 062d08699..cbbd87f19 100644 --- a/roles/post_install/collect_ovs_configs/molecule/default/converge.yml +++ b/roles/post_install/collect_ovs_configs/molecule/default/converge.yml @@ -3,5 +3,5 @@ hosts: all gather_facts: false roles: - - role: collect_ovs_configs + - role: roles/post_install/collect_ovs_configs get_pmd_rxq: false diff --git a/roles/post_install/collect_ovs_configs/molecule/default/molecule.yml b/roles/post_install/collect_ovs_configs/molecule/default/molecule.yml index 7e42054cc..1c98159a6 100644 --- a/roles/post_install/collect_ovs_configs/molecule/default/molecule.yml +++ b/roles/post_install/collect_ovs_configs/molecule/default/molecule.yml @@ -4,7 +4,6 @@ driver: lint: | set -e yamllint -c ../../../.yamllint . - ansible-lint -c ../../../.ansible-lint platforms: - name: instance image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest" @@ -17,6 +16,8 @@ platforms: privileged: true provisioner: name: ansible + env: + ANSIBLE_ROLES_PATH: ../../../../../ verifier: name: ansible scenario: diff --git a/roles/post_install/collect_ovs_configs/molecule/default/verify.yml b/roles/post_install/collect_ovs_configs/molecule/default/verify.yml index 9d0edc55b..4f34d938c 100644 --- a/roles/post_install/collect_ovs_configs/molecule/default/verify.yml +++ b/roles/post_install/collect_ovs_configs/molecule/default/verify.yml @@ -17,7 +17,7 @@ - name: Set a variable for each existing file set_fact: - "{{ item.path | basename }}": "{{ item.path }}" + "{{ item.path | basename }}": "{{ item.path }}" # noqa var-naming loop: "{{ ovs_output_files_list.files }}" register: existing_files diff --git a/roles/post_install/openstack_tasks/molecule/default/converge.yml b/roles/post_install/openstack_tasks/molecule/default/converge.yml index 68d956dac..482dcd78d 100644 --- a/roles/post_install/openstack_tasks/molecule/default/converge.yml +++ b/roles/post_install/openstack_tasks/molecule/default/converge.yml @@ -2,8 +2,12 @@ - name: Converge hosts: "{{ osp_tasks_host | default('undercloud') }}" gather_facts: false - vars_files: - - play_vars.yml - roles: - - role: openstack_tasks - resource_state: present + tasks: + - name: Include Play Variables + include_vars: + dir: vars + - name: Execute openstack_tasks Role + vars: + resource_state: present + import_role: + name: roles/post_install/openstack_tasks diff --git a/roles/post_install/openstack_tasks/molecule/default/destroy.yml b/roles/post_install/openstack_tasks/molecule/default/destroy.yml index 98691b03d..53cf2ff94 100644 --- a/roles/post_install/openstack_tasks/molecule/default/destroy.yml +++ b/roles/post_install/openstack_tasks/molecule/default/destroy.yml @@ -2,8 +2,12 @@ - name: Destroy hosts: "{{ osp_tasks_host | default('undercloud') }}" gather_facts: false - vars_files: - - play_vars.yml - roles: - - role: openstack_tasks - resource_state: absent + tasks: + - name: Include Play Variables + include_vars: + dir: vars + - name: Import openstack_tasks Role + vars: + resource_state: absent + import_role: + name: roles/post_install/openstack_tasks diff --git a/roles/post_install/openstack_tasks/molecule/default/molecule.yml b/roles/post_install/openstack_tasks/molecule/default/molecule.yml index 36ece8b51..819b6653d 100644 --- a/roles/post_install/openstack_tasks/molecule/default/molecule.yml +++ b/roles/post_install/openstack_tasks/molecule/default/molecule.yml @@ -4,13 +4,13 @@ driver: lint: | set -e yamllint -c ../../../.yamllint . - ansible-lint -c ../../../.ansible-lint platforms: - name: hypervisor provisioner: name: ansible env: ANSIBLE_LIBRARY: ../../../../../library + ANSIBLE_ROLES_PATH: ../../../../../ inventory: links: hosts: ${MOLECULE_INVENTORY_PATH:-inventory} diff --git a/roles/post_install/openstack_tasks/molecule/default/prepare.yml b/roles/post_install/openstack_tasks/molecule/default/prepare.yml index 1e05401d3..932b811ef 100644 --- a/roles/post_install/openstack_tasks/molecule/default/prepare.yml +++ b/roles/post_install/openstack_tasks/molecule/default/prepare.yml @@ -9,7 +9,7 @@ env_type: "{{ (env_type_override | length > 0) | ternary(env_type_override, 'virt') }}" inventory_generated: "{{ lookup('env', 'TEST_INV_GENERATED') }}" roles: - - role: tripleo_inventory + - role: roles/post_install/tripleo_inventory host: "{{ env_host }}" ssh_key: "{{ env_ssh_key }}" setup_type: "{{ env_type }}" diff --git a/roles/post_install/openstack_tasks/molecule/default/play_vars.yml b/roles/post_install/openstack_tasks/molecule/default/vars/main.yml similarity index 100% rename from roles/post_install/openstack_tasks/molecule/default/play_vars.yml rename to roles/post_install/openstack_tasks/molecule/default/vars/main.yml diff --git a/roles/post_install/openstack_tasks/molecule/default/verify.yml b/roles/post_install/openstack_tasks/molecule/default/verify.yml index 522c97bdb..d44c92b8d 100644 --- a/roles/post_install/openstack_tasks/molecule/default/verify.yml +++ b/roles/post_install/openstack_tasks/molecule/default/verify.yml @@ -2,9 +2,10 @@ - name: Verify hosts: undercloud gather_facts: false - vars_files: - - play_vars.yml tasks: + - name: Include Play Variables + include_vars: + dir: vars # User test - name: Fetch user state os_user_facts: @@ -47,17 +48,15 @@ - "openstack_image.name == images[0].name" # Security group test - - name: Fetch security group state - shell: > - openstack --os-cloud "{{ cloud_name }}" security group list - -c Name -f value | grep "{{ security_groups[0].name }}" + - name: Fetch security group state # noqa risky-shell-pipe + shell: "openstack --os-cloud {{ cloud_name }} security group list -c Name -f value | grep {{ security_groups[0].name }}" register: os_secgroup changed_when: false - name: Fetch security group rules command: > - openstack --os-cloud "{{ cloud_name }}" security group show - "{{ security_groups[0].name }}" -f json --noindent + openstack --os-cloud {{ cloud_name }} security group show + {{ security_groups[0].name }} -f json --noindent register: os_secgroup_rules changed_when: false @@ -97,10 +96,8 @@ - "secgroup_icmp is defined" # Keypair test - - name: Fetch keypair state - shell: > - openstack --os-cloud "{{ cloud_name }}" keypair list - -c Name -f value | grep "{{ keypairs[0].name }}" + - name: Fetch keypair state # noqa risky-shell-pipe + shell: "openstack --os-cloud {{ cloud_name }} keypair list -c Name -f value | grep {{ keypairs[0].name }}" register: os_keypair changed_when: false diff --git a/roles/post_install/openstack_tasks/tasks/clouds.yml b/roles/post_install/openstack_tasks/tasks/clouds.yml index 5e7331fdd..75c29803a 100644 --- a/roles/post_install/openstack_tasks/tasks/clouds.yml +++ b/roles/post_install/openstack_tasks/tasks/clouds.yml @@ -58,6 +58,7 @@ - name: Get Cloud variables shell: | + set -e -o pipefail for key in $(set | awk '{FS="="} /^OS_/ {print $1}'); do unset $key; done source {{ item['value'] }} echo -n "{{ item['key'] }}: \ diff --git a/roles/post_install/tripleo_inventory/molecule/default/converge.yml b/roles/post_install/tripleo_inventory/molecule/default/converge.yml index db9ac8c51..23e979b1a 100644 --- a/roles/post_install/tripleo_inventory/molecule/default/converge.yml +++ b/roles/post_install/tripleo_inventory/molecule/default/converge.yml @@ -9,7 +9,7 @@ env_type: "{{ (env_type_override | length > 0) | ternary(env_type_override, 'virt') }}" inventory_generated: "{{ lookup('env', 'TEST_INV_GENERATED') }}" roles: - - role: tripleo_inventory + - role: roles/post_install/tripleo_inventory host: "{{ env_host }}" ssh_key: "{{ env_ssh_key }}" setup_type: "{{ env_type }}" diff --git a/roles/post_install/tripleo_inventory/molecule/default/molecule.yml b/roles/post_install/tripleo_inventory/molecule/default/molecule.yml index 9cfdfeb54..d90df0125 100644 --- a/roles/post_install/tripleo_inventory/molecule/default/molecule.yml +++ b/roles/post_install/tripleo_inventory/molecule/default/molecule.yml @@ -4,7 +4,6 @@ driver: lint: | set -e yamllint -c ../../../.yamllint . - ansible-lint -c ../../../.ansible-lint platforms: - name: hypervisor provisioner: @@ -12,6 +11,8 @@ provisioner: inventory: links: hosts: ${MOLECULE_INVENTORY_PATH:-inventory} + env: + ANSIBLE_ROLES_PATH: ../../../../../ verifier: name: ansible scenario: diff --git a/roles/post_install/tripleo_inventory/tasks/hypervisor.yml b/roles/post_install/tripleo_inventory/tasks/hypervisor.yml index 05f146d5b..6c1498216 100644 --- a/roles/post_install/tripleo_inventory/tasks/hypervisor.yml +++ b/roles/post_install/tripleo_inventory/tasks/hypervisor.yml @@ -40,7 +40,9 @@ when: undercloud_vm is not defined - name: Find the Undercloud vm ip address - shell: virsh domifaddr "{{ undercloud_vm }}" | awk '/ipv4/ {print $4}' | cut -d "/" -f1 | head -1 + shell: | + set -e -o pipefail + virsh domifaddr "{{ undercloud_vm }}" | awk '/ipv4/ {print $4}' | cut -d "/" -f1 | head -1 register: undercloud_ip delegate_to: "{{ groups['hypervisor'][0] }}" diff --git a/roles/tester/tempest/molecule/containerized/converge.yml b/roles/tester/tempest/molecule/containerized/converge.yml index 68f4db238..f1fb8386e 100644 --- a/roles/tester/tempest/molecule/containerized/converge.yml +++ b/roles/tester/tempest/molecule/containerized/converge.yml @@ -2,10 +2,13 @@ - name: Converge hosts: undercloud gather_facts: false - roles: - - role: tempest - containerized: true - external_net_id: false - image_for_tempest: false - generate_accounts: true - tests_regex: '^nfv_tempest_plugin(.*basic)' + tasks: + - name: Import tempest Role + vars: + containerized: true + external_net_id: false + image_for_tempest: false + generate_accounts: true + tests_regex: '^nfv_tempest_plugin(.*basic)' + import_role: + name: roles/tester/tempest diff --git a/roles/tester/tempest/molecule/containerized/molecule.yml b/roles/tester/tempest/molecule/containerized/molecule.yml index 72213b116..45953bd00 100644 --- a/roles/tester/tempest/molecule/containerized/molecule.yml +++ b/roles/tester/tempest/molecule/containerized/molecule.yml @@ -4,13 +4,12 @@ driver: lint: | set -e yamllint -c ../../../.yamllint . - ansible-lint -c ../../../.ansible-lint platforms: - name: hypervisor provisioner: name: ansible env: - ANSIBLE_ROLES_PATH: ../../../../../roles + ANSIBLE_ROLES_PATH: ../../../../../ inventory: links: hosts: ${MOLECULE_INVENTORY_PATH:-inventory} diff --git a/roles/tester/tempest/molecule/containerized/prepare.yml b/roles/tester/tempest/molecule/containerized/prepare.yml index d18515ef1..f38f98d38 100644 --- a/roles/tester/tempest/molecule/containerized/prepare.yml +++ b/roles/tester/tempest/molecule/containerized/prepare.yml @@ -9,7 +9,7 @@ env_type: "{{ (env_type_override | length > 0) | ternary(env_type_override, 'virt') }}" inventory_generated: "{{ lookup('env', 'TEST_INV_GENERATED') }}" roles: - - role: post_install/tripleo_inventory + - role: roles/post_install/tripleo_inventory host: "{{ env_host }}" ssh_key: "{{ env_ssh_key }}" setup_type: "{{ env_type }}" diff --git a/roles/tester/tempest/molecule/containerized/verify.yml b/roles/tester/tempest/molecule/containerized/verify.yml index a3acaa198..16031ebec 100644 --- a/roles/tester/tempest/molecule/containerized/verify.yml +++ b/roles/tester/tempest/molecule/containerized/verify.yml @@ -72,7 +72,7 @@ register: unprivileged_ping changed_when: false - - name: Verify enabled unprivileged ping + - name: Verify enabled unprivileged ping # noqa no-tabs assert: that: "'net.ipv4.ping_group_range = 0\t2000000' in unprivileged_ping.stdout_lines" diff --git a/roles/tester/tempest/molecule/default/converge.yml b/roles/tester/tempest/molecule/default/converge.yml index 39378642b..efeacbd6a 100644 --- a/roles/tester/tempest/molecule/default/converge.yml +++ b/roles/tester/tempest/molecule/default/converge.yml @@ -3,7 +3,7 @@ hosts: undercloud gather_facts: false roles: - - role: tempest + - role: roles/tester/tempest containerized: false external_net_id: false image_for_tempest: false diff --git a/roles/tester/tempest/molecule/default/molecule.yml b/roles/tester/tempest/molecule/default/molecule.yml index 72213b116..45953bd00 100644 --- a/roles/tester/tempest/molecule/default/molecule.yml +++ b/roles/tester/tempest/molecule/default/molecule.yml @@ -4,13 +4,12 @@ driver: lint: | set -e yamllint -c ../../../.yamllint . - ansible-lint -c ../../../.ansible-lint platforms: - name: hypervisor provisioner: name: ansible env: - ANSIBLE_ROLES_PATH: ../../../../../roles + ANSIBLE_ROLES_PATH: ../../../../../ inventory: links: hosts: ${MOLECULE_INVENTORY_PATH:-inventory} diff --git a/roles/tester/tempest/molecule/default/prepare.yml b/roles/tester/tempest/molecule/default/prepare.yml index 8ff3d081b..932b811ef 100644 --- a/roles/tester/tempest/molecule/default/prepare.yml +++ b/roles/tester/tempest/molecule/default/prepare.yml @@ -9,7 +9,7 @@ env_type: "{{ (env_type_override | length > 0) | ternary(env_type_override, 'virt') }}" inventory_generated: "{{ lookup('env', 'TEST_INV_GENERATED') }}" roles: - - role: post_install/tripleo_inventory + - role: roles/post_install/tripleo_inventory host: "{{ env_host }}" ssh_key: "{{ env_ssh_key }}" setup_type: "{{ env_type }}" diff --git a/roles/tester/tempest/tasks/config_exec_git_tempest.yml b/roles/tester/tempest/tasks/config_exec_git_tempest.yml index 041dca0a8..2bbdd3d06 100644 --- a/roles/tester/tempest/tasks/config_exec_git_tempest.yml +++ b/roles/tester/tempest/tasks/config_exec_git_tempest.yml @@ -54,7 +54,7 @@ glance_stores: "{{ images[0]['glance_stores'] }}" cloud: "{{ images[0]['cloud_name'] | default(cloud_name) }}" import_role: - name: post_install/openstack_tasks + name: roles/post_install/openstack_tasks tasks_from: copy_image_to_glance_stores when: "'glance_stores' in images[0]" diff --git a/roles/tester/tempest/tasks/main.yml b/roles/tester/tempest/tasks/main.yml index 30c2298df..4c97e1133 100644 --- a/roles/tester/tempest/tasks/main.yml +++ b/roles/tester/tempest/tasks/main.yml @@ -13,7 +13,7 @@ - name: Check OSP version include_role: - name: discover_osp_version + name: roles/discover_osp_version - name: Prepare containerized tempest include_tasks: prep_container_tempest.yml @@ -122,7 +122,9 @@ path: "{{ tempest_dir }}/tempest.xml" state: absent -- name: Generate results report in a JunitXML format + # This task returns STDERR but we're still proceeding with it... + # We should consider refactoring this logic. +- name: Generate results report in a JunitXML format # noqa risky-shell-pipe tags: run_tempest_test shell: | {% if not containerized|bool %} diff --git a/roles/tester/tempest/tasks/register_variables.yml b/roles/tester/tempest/tasks/register_variables.yml index 7c00afa6c..1d877dfca 100644 --- a/roles/tester/tempest/tasks/register_variables.yml +++ b/roles/tester/tempest/tasks/register_variables.yml @@ -16,7 +16,9 @@ rc_vars: {} - name: Get rc params - shell: "grep {{ item.value }}= {{ rc_version_file_path }} | cut -d '=' -f 2" + shell: | + set -e -o pipefail + grep {{ item.value }}= {{ rc_version_file_path }} | cut -d '=' -f 2 loop: "{{ rc_params }}" register: rc_results changed_when: False diff --git a/roles/tuning/cpu_pinning_huge_pages/tasks/main.yml b/roles/tuning/cpu_pinning_huge_pages/tasks/main.yml index 4dd77270c..3bb94df22 100644 --- a/roles/tuning/cpu_pinning_huge_pages/tasks/main.yml +++ b/roles/tuning/cpu_pinning_huge_pages/tasks/main.yml @@ -53,7 +53,7 @@ shell: sleep 2 && shutdown -r now "Ansible updates triggered" async: 1 poll: 0 - ignore_errors: true + failed_when: False when: makegrub.changed - name: Wait for server to restart successfully diff --git a/test-requirements.txt b/test-requirements.txt index b5060aa04..57d5f9301 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,6 +3,6 @@ tox>=3.13.0 pep8>=1.7.0 sphinx!=1.6.6,>=1.6.2 -ansible-lint<5.0.0 +ansible-lint==5.3.2 yamllint>=1.25.0 molecule[docker]>=3.0.8 diff --git a/tox.ini b/tox.ini index a8a833e60..584009a1e 100644 --- a/tox.ini +++ b/tox.ini @@ -17,20 +17,20 @@ whitelist_externals = bash find git + rm [testenv:venv] commands = {posargs} [testenv:ansible-lint] # For the full ansible-lint default rules, refer to the following link: -# https://docs.ansible.com/ansible-lint/rules/default_rules.html +# https://ansible-lint.readthedocs.io/en/latest/default_rules.html # # Disabled rules: -# 204 - Lines should be no longer than 120 chars -# 301 - Commands should not change things if nothing needs doing -# 403 - Package installs should not use latest -# 405 - Remote package tasks should have a retry -# 503 - Tasks that run when changed should likely be handlers +# - 'unnamed-task' We don't mind having tasks that are unnamed +# - 'no-changed-when' We don't mind that there will be tasks that will always return ok +# - 'no-handler' We don't mind that we're running tasks based on a previous task that returned changed +# - 'package-latest' We don't mind installing latest packages usedevelop = False skip_install = True @@ -40,15 +40,19 @@ deps = -rtest-requirements.txt # time is spend installing dependencies. setenv = VIRTUALENV_NO_DOWNLOAD=1 + # ANSIBLE_CONFIG avoid the undesired case where tox->ansible would load user own ~/ansible.cfg (if any) ANSIBLE_CONFIG={toxinidir}/ansible.cfg - SKIPPED = 204,301,306,403,405,503 ANSIBLE_COLLECTIONS_PATH=/tmp/.collectinos -# ANSIBLE_CONFIG avoid the undesired case where tox->ansible would load user own ~/ansible.cfg (if any) +# Install ansible collections, if fail do not proceed. +commands_pre = ansible-galaxy collection install -r requirements.yaml -p $ANSIBLE_COLLECTIONS_PATH +# Regex for file paths in git ls-tree might not work all the times, we should consider changing this commands = - bash -c "ansible-galaxy collection install -r requirements.yaml -p $ANSIBLE_COLLECTIONS_PATH" - bash -c "git ls-tree --full-tree --name-only -r HEAD playbooks | grep -E '\.ya?ml$' | xargs ansible-lint -p --force-color -x $SKIPPED" - bash -c "git ls-tree --full-tree --name-only -r HEAD . | grep -E '\.ya?ml$' | xargs python -m yamllint" - bash -c "rm -rf $ANSIBLE_COLLECTIONS_PATH" + # Check playbooks linting + bash -c "git ls-tree --full-tree --name-only -r HEAD playbooks | grep -E '\.ya?ml$' | xargs ansible-lint -p --force-color" + # Check molecule linting + bash -c "git ls-tree --full-tree --name-only -r HEAD ./**/**/**/molecule | grep -E 'molecule' | grep -E '\.ya?ml$' | grep -vE 'molecule\.ya?ml' | xargs ansible-lint -p --force-color" +# Delete collection path regardless of outcome +commands_post = rm -rf $ANSIBLE_COLLECTIONS_PATH [testenv:docs] commands = python setup.py build_sphinx