Skip to content

Commit

Permalink
ansible-lint: Bump Version To 5.3.2
Browse files Browse the repository at this point in the history
Due to ansible/ansible-lint#1795
we are required to move to a newer ansible-lint version.

Version 5.0.0 refactored the rules and we must adapt to the new rules.

Updated .ansible-lint.
Excluding the playbook 'playbooks/packet_gen/iperf/performance_scenario.yml'
due to a linting fail that we can not satisfy.

Removing ansible-lint during molecule execution, linting occurs on the
global level during tox execution.

Fixing 'risky-shell-pipe' linting errors.
Fixing 'internal-error' linting errors for molecule and more fixes
to molecule in general.

Excluding rules:
  - '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

Change-Id: I057faab90874618933d935bb77ff28663f22e3f0
  • Loading branch information
vkhitrin committed Jan 14, 2022
1 parent 5f144a6 commit 7c41c79
Show file tree
Hide file tree
Showing 36 changed files with 116 additions and 87 deletions.
15 changes: 9 additions & 6 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion playbooks/configuration/dell_idrac_bios_config.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions playbooks/packet_gen/iperf/performance_scenario.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions playbooks/packet_gen/trex/nfv_multiqueue_performance.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Common preparation
hosts: "{{ dut_compute }}"
hosts: "{{ dut_compute | default(omit) }}"
become: true
tasks:
- name: Set directories path
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions playbooks/packet_gen/trex/performance_scenario.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion playbooks/tripleo/post_install/hci_stress.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 12 additions & 4 deletions playbooks/tripleo/tester/tempest_with_external_resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions roles/discover_osp_version/molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
1 change: 0 additions & 1 deletion roles/discover_osp_version/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ driver:
lint: |
set -e
yamllint -c ../../.yamllint .
ansible-lint -c ../../.ansible-lint
platforms:
- name: instance
groups:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -17,6 +16,8 @@ platforms:
privileged: true
provisioner:
name: ansible
env:
ANSIBLE_ROLES_PATH: ../../../../../
verifier:
name: ansible
scenario:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 9 additions & 5 deletions roles/post_install/openstack_tasks/molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 9 additions & 5 deletions roles/post_install/openstack_tasks/molecule/default/destroy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
21 changes: 9 additions & 12 deletions roles/post_install/openstack_tasks/molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions roles/post_install/openstack_tasks/tasks/clouds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }}: \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ driver:
lint: |
set -e
yamllint -c ../../../.yamllint .
ansible-lint -c ../../../.ansible-lint
platforms:
- name: hypervisor
provisioner:
name: ansible
inventory:
links:
hosts: ${MOLECULE_INVENTORY_PATH:-inventory}
env:
ANSIBLE_ROLES_PATH: ../../../../../
verifier:
name: ansible
scenario:
Expand Down
4 changes: 3 additions & 1 deletion roles/post_install/tripleo_inventory/tasks/hypervisor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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] }}"

Expand Down
17 changes: 10 additions & 7 deletions roles/tester/tempest/molecule/containerized/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions roles/tester/tempest/molecule/containerized/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion roles/tester/tempest/molecule/containerized/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
Loading

0 comments on commit 7c41c79

Please sign in to comment.