From 816d6ffde288d98bbc219c492eb47fa5275805d3 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Tue, 27 May 2025 22:08:39 +0200 Subject: [PATCH] Configure ansible-lint and fix issues found Copy ansible-lint configuration from kolla-ansible as a starting point. Also replace alint tox job by ansible-lint. Fix various issues found by ansible-lint to make it pass with the current set of rules. Change-Id: I1d6173caadbcf249330512e170af8095464f1237 --- .ansible-lint | 44 +++++++ .gitignore | 1 + ansible/apt.yml | 2 +- ansible/baremetal-compute-register.yml | 68 +++++------ ansible/baremetal-compute-serial-console.yml | 110 +++++++++--------- ansible/kayobe-target-venv.yml | 24 ++-- ansible/kolla-target-venv.yml | 4 +- ansible/mdadm.yml | 2 +- ansible/proxy.yml | 1 + .../disable-cloud-init/handlers/main.yml | 2 +- .../roles/disable-cloud-init/tasks/main.yml | 2 +- ansible/roles/dnf/tasks/main.yml | 2 +- .../roles/docker-registry/tasks/destroy.yml | 2 +- ansible/roles/infra-vms/tasks/main.yml | 2 +- ansible/roles/kolla-ansible/tasks/install.yml | 2 +- .../kolla-ansible/templates/kolla/globals.yml | 1 - .../kolla-ansible/tests/test-defaults.yml | 2 +- .../roles/kolla-openstack/defaults/main.yml | 2 +- .../roles/manage-containers/tasks/deploy.yml | 2 +- .../roles/manage-containers/tasks/destroy.yml | 3 +- .../tests/test-bootstrapped.yml | 2 +- .../tests/test-invalid-format.yml | 2 +- .../swift-block-devices/tests/test-mount.yml | 2 +- ansible/ssh-known-host.yml | 1 - ansible/tuned.yml | 2 +- dev/dev-vagrant-network-allocation.yml | 1 + doc/source/contributor/testing.rst | 4 +- tox.ini | 24 +++- 28 files changed, 191 insertions(+), 125 deletions(-) create mode 100644 .ansible-lint diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 000000000..1392b7a1c --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,44 @@ +--- +# NOTE(priteau): Rule file imported from kolla-ansible +strict: true +use_default_rules: true +skip_list: + # [E301] Commands should not change things if nothing needs doing + # TODO(mnasiadka): Fix tasks that fail this check in a later iteration + - no-changed-when + # [E503] Tasks that run when changed should likely be handlers + - no-handler + # [unnamed-task] All tasks should be named + # FIXME(mgoddard): Add names to all tasks + - unnamed-task + # disable experimental rules + - experimental + # Package installs should not use latest + - package-latest + # Most files should not contain tabs + - no-tabs + # NOTE(frickler): Agreed at Zed PTG not to use FQCN for builtin actions for now, due to + # conflicts with open patches and backports. + - fqcn-builtins + # Allow Jinja templating inside task and play names + - name[template] + # FQCNs again, now for module actions + - fqcn[action] + # role name check matching ^*$ + - role-name + # Allow long lines + - yaml[line-length] + # TODO(frickler): Discuss these in detail, skipping for now to unblock things + - command-instead-of-module + - command-instead-of-shell + - deprecated-local-action + - ignore-errors + - jinja[spacing] + - key-order[task] + - name[play] + - no-free-form + - risky-file-permissions + - risky-shell-pipe + - run-once[task] + - var-naming[no-reserved] + - var-naming[no-role-prefix] diff --git a/.gitignore b/.gitignore index f8b8b4942..edc6eab5a 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,7 @@ ansible/*.retry ansible/roles/*/tests/*.retry # Ansible Galaxy roles & collections +.ansible ansible/roles/*\.*/ ansible/collections/ diff --git a/ansible/apt.yml b/ansible/apt.yml index 0172249e0..633454563 100644 --- a/ansible/apt.yml +++ b/ansible/apt.yml @@ -11,7 +11,7 @@ tags: - apt tasks: - - name: include apt role + - name: Include apt role include_role: name: apt when: ansible_facts.os_family == 'Debian' diff --git a/ansible/baremetal-compute-register.yml b/ansible/baremetal-compute-register.yml index 0dedfe527..95b18f97e 100644 --- a/ansible/baremetal-compute-register.yml +++ b/ansible/baremetal-compute-register.yml @@ -39,42 +39,42 @@ fail_msg: One or more Ironic variables are undefined. - block: - - name: Show baremetal node - ansible.builtin.command: - cmd: "{{ venv }}/bin/openstack baremetal node show {{ inventory_hostname }}" - register: node_show - failed_when: - - '"HTTP 404" not in node_show.stderr' - - node_show.rc != 0 - changed_when: false + - name: Show baremetal node + ansible.builtin.command: + cmd: "{{ venv }}/bin/openstack baremetal node show {{ inventory_hostname }}" + register: node_show + failed_when: + - '"HTTP 404" not in node_show.stderr' + - node_show.rc != 0 + changed_when: false - # NOTE: The openstack.cloud.baremetal_node module cannot be used in this - # script due to requiring a MAC address pre-defined, instead, this should - # be discovered by inpsection following this script. - # - # NOTE: IPMI address must be passed with Redfish address to ensure existing - # Ironic nodes match with new nodes during inspection. - - name: Create baremetal nodes - ansible.builtin.shell: - cmd: | - {{ venv }}/bin/openstack baremetal node create \ - --name {{ inventory_hostname }} \ - --driver {{ ironic_driver }} \ - {% for key, value in ironic_driver_info.items() %} - --driver-info {{ key }}={{ value }} \ - {% endfor %} - {% for key, value in ironic_properties.items() %} - --property {{ key }}={{ value }} \ - {% endfor %} - --resource-class {{ ironic_resource_class }} - when: - - node_show.rc != 0 + # NOTE: The openstack.cloud.baremetal_node module cannot be used in this + # script due to requiring a MAC address pre-defined, instead, this should + # be discovered by inpsection following this script. + # + # NOTE: IPMI address must be passed with Redfish address to ensure existing + # Ironic nodes match with new nodes during inspection. + - name: Create baremetal nodes + ansible.builtin.shell: + cmd: | + {{ venv }}/bin/openstack baremetal node create \ + --name {{ inventory_hostname }} \ + --driver {{ ironic_driver }} \ + {% for key, value in ironic_driver_info.items() %} + --driver-info {{ key }}={{ value }} \ + {% endfor %} + {% for key, value in ironic_properties.items() %} + --property {{ key }}={{ value }} \ + {% endfor %} + --resource-class {{ ironic_resource_class }} + when: + - node_show.rc != 0 - - name: Manage baremetal nodes - ansible.builtin.command: - cmd: "{{ venv }}/bin/openstack baremetal node manage {{ inventory_hostname }} --wait" - when: - - node_show.rc != 0 + - name: Manage baremetal nodes + ansible.builtin.command: + cmd: "{{ venv }}/bin/openstack baremetal node manage {{ inventory_hostname }} --wait" + when: + - node_show.rc != 0 delegate_to: "{{ controller_host }}" vars: # NOTE: Without this, the controller's ansible_host variable will not diff --git a/ansible/baremetal-compute-serial-console.yml b/ansible/baremetal-compute-serial-console.yml index d6fedccb0..39acc3bd1 100644 --- a/ansible/baremetal-compute-serial-console.yml +++ b/ansible/baremetal-compute-serial-console.yml @@ -19,35 +19,35 @@ extra_args: "{% if pip_upper_constraints_file %}-c {{ pip_upper_constraints_file }}{% endif %}" - block: - - name: Fail if allocation pool start not defined - fail: - msg: > - The variable, ironic_serial_console_tcp_pool_start is not defined. - This variable is required to run this playbook. - when: not ironic_serial_console_tcp_pool_start + - name: Fail if allocation pool start not defined + fail: + msg: > + The variable, ironic_serial_console_tcp_pool_start is not defined. + This variable is required to run this playbook. + when: not ironic_serial_console_tcp_pool_start - - name: Fail if allocation pool end not defined - fail: - msg: > - The variable, ironic_serial_console_tcp_pool_end is not defined. - This variable is required to run this playbook. - when: - - not ironic_serial_console_tcp_pool_end + - name: Fail if allocation pool end not defined + fail: + msg: > + The variable, ironic_serial_console_tcp_pool_end is not defined. + This variable is required to run this playbook. + when: + - not ironic_serial_console_tcp_pool_end - - name: Get list of nodes that we should configure serial consoles on - set_fact: - baremetal_nodes: >- - {{ query('inventory_hostnames', console_compute_node_limit | - default('baremetal-compute') ) | unique }} + - name: Get list of nodes that we should configure serial consoles on + set_fact: + baremetal_nodes: >- + {{ query('inventory_hostnames', console_compute_node_limit | + default('baremetal-compute') ) | unique }} - - name: Reserve TCP ports for ironic serial consoles - include_role: - name: console-allocation - vars: - console_allocation_pool_start: "{{ ironic_serial_console_tcp_pool_start }}" - console_allocation_pool_end: "{{ ironic_serial_console_tcp_pool_end }}" - console_allocation_ironic_nodes: "{{ baremetal_nodes }}" - console_allocation_filename: "{{ kayobe_env_config_path }}/console-allocation.yml" + - name: Reserve TCP ports for ironic serial consoles + include_role: + name: console-allocation + vars: + console_allocation_pool_start: "{{ ironic_serial_console_tcp_pool_start }}" + console_allocation_pool_end: "{{ ironic_serial_console_tcp_pool_end }}" + console_allocation_ironic_nodes: "{{ baremetal_nodes }}" + console_allocation_filename: "{{ kayobe_env_config_path }}/console-allocation.yml" when: cmd == "enable" - name: Enable serial console @@ -76,37 +76,37 @@ ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}" - block: - - name: Fail if console interface is not ipmitool-socat - fail: - msg: >- - In order to use the serial console you must set the console_interface to ipmitool-socat. - when: node["Console Interface"] != "ipmitool-socat" + - name: Fail if console interface is not ipmitool-socat + fail: + msg: >- + In order to use the serial console you must set the console_interface to ipmitool-socat. + when: node["Console Interface"] != "ipmitool-socat" - - name: Set IPMI serial console terminal port - vars: - name: "{{ node['Name'] }}" - port: "{{ hostvars[controller_host].console_allocation_result.ports[name] }}" - # NOTE: Without this, the controller's ansible_host variable will not - # be respected when using delegate_to. - ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}" - command: > - {{ venv }}/bin/openstack baremetal node set {{ name }} --driver-info ipmi_terminal_port={{ port }} - delegate_to: "{{ controller_host }}" - environment: "{{ openstack_auth_env }}" - when: >- - node['Driver Info'].ipmi_terminal_port is not defined or - node['Driver Info'].ipmi_terminal_port | int != port | int + - name: Set IPMI serial console terminal port + vars: + name: "{{ node['Name'] }}" + port: "{{ hostvars[controller_host].console_allocation_result.ports[name] }}" + # NOTE: Without this, the controller's ansible_host variable will not + # be respected when using delegate_to. + ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}" + command: > + {{ venv }}/bin/openstack baremetal node set {{ name }} --driver-info ipmi_terminal_port={{ port }} + delegate_to: "{{ controller_host }}" + environment: "{{ openstack_auth_env }}" + when: >- + node['Driver Info'].ipmi_terminal_port is not defined or + node['Driver Info'].ipmi_terminal_port | int != port | int - - name: Enable the IPMI socat serial console - vars: - # NOTE: Without this, the controller's ansible_host variable will not - # be respected when using delegate_to. - ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}" - command: > - {{ venv }}/bin/openstack baremetal node console enable {{ node['Name'] }} - delegate_to: "{{ controller_host }}" - environment: "{{ openstack_auth_env }}" - when: not node['Console Enabled'] + - name: Enable the IPMI socat serial console + vars: + # NOTE: Without this, the controller's ansible_host variable will not + # be respected when using delegate_to. + ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}" + command: > + {{ venv }}/bin/openstack baremetal node console enable {{ node['Name'] }} + delegate_to: "{{ controller_host }}" + environment: "{{ openstack_auth_env }}" + when: not node['Console Enabled'] vars: matching_nodes: >- {{ (nodes.stdout | from_json) | selectattr('Name', 'defined') | diff --git a/ansible/kayobe-target-venv.yml b/ansible/kayobe-target-venv.yml index 1ca845c0e..99d22f586 100644 --- a/ansible/kayobe-target-venv.yml +++ b/ansible/kayobe-target-venv.yml @@ -15,7 +15,7 @@ tasks: - name: Set a fact about the kayobe target virtualenv set_fact: - virtualenv: "{{ ansible_python_interpreter | dirname | dirname }}" + kayobe_virtualenv: "{{ ansible_python_interpreter | dirname | dirname }}" when: - ansible_python_interpreter is defined - not ansible_python_interpreter.startswith('/bin') @@ -47,12 +47,12 @@ mode: 0755 # Check whether the virtualenv directory is a subdirectory of the # global virtualenv directory. - when: virtualenv.startswith(virtualenv_path) + when: kayobe_virtualenv.startswith(virtualenv_path) become: True - name: Ensure kayobe virtualenv directory exists file: - path: "{{ virtualenv }}" + path: "{{ kayobe_virtualenv }}" state: directory owner: "{{ ansible_facts.user_uid }}" group: "{{ ansible_facts.user_gid }}" @@ -69,7 +69,7 @@ pip: name: pip state: latest - virtualenv: "{{ virtualenv }}" + virtualenv: "{{ kayobe_virtualenv }}" # Site packages are required for using the dnf module, which is not # available via PyPI. virtualenv_site_packages: True @@ -79,14 +79,14 @@ pip: name: selinux state: latest - virtualenv: "{{ virtualenv }}" + virtualenv: "{{ kayobe_virtualenv }}" when: - ansible_facts.os_family == 'RedHat' vars: # Use the system python interpreter since the virtualenv might not # exist. ansible_python_interpreter: "{{ ansible_facts.python.executable }}" - when: virtualenv is defined + when: kayobe_virtualenv is defined # If we gathered facts earlier it would have been with a different Python # interpreter. For gathering modes that may use a fact cache, gather facts @@ -96,7 +96,7 @@ filter: "{{ kayobe_ansible_setup_filter }}" gather_subset: "{{ kayobe_ansible_setup_gather_subset }}" when: - - virtualenv is defined + - kayobe_virtualenv is defined - gather_facts is not skipped - lookup('config', 'DEFAULT_GATHERING') != 'implicit' @@ -110,15 +110,15 @@ name: "{{ packages | select | list }}" state: present become: True - when: virtualenv is not defined + when: kayobe_virtualenv is not defined - name: Ensure kolla-ansible virtualenv has docker SDK for python installed pip: name: docker state: latest - virtualenv: "{{ virtualenv | default(omit) }}" + virtualenv: "{{ kayobe_virtualenv | default(omit) }}" extra_args: "{% if docker_upper_constraints_file %}-c {{ docker_upper_constraints_file }}{% endif %}" - become: "{{ virtualenv is not defined }}" + become: "{{ kayobe_virtualenv is not defined }}" vars: docker_upper_constraints_file: "{{ pip_upper_constraints_file }}" when: @@ -127,9 +127,9 @@ - name: Ensure kayobe virtualenv has podman SDK installed import_role: - name: openstack.kolla.podman_sdk + name: openstack.kolla.podman_sdk vars: - virtualenv: "{{ virtualenv }}" + virtualenv: "{{ kayobe_virtualenv }}" podman_sdk_upper_constraints_file: "{{ pip_upper_constraints_file }}" when: - "'container-engine' in group_names" diff --git a/ansible/kolla-target-venv.yml b/ansible/kolla-target-venv.yml index 698623996..8e3b2e9c1 100644 --- a/ansible/kolla-target-venv.yml +++ b/ansible/kolla-target-venv.yml @@ -57,7 +57,7 @@ virtualenv: "{{ kolla_ansible_target_venv }}" extra_args: "{% if kolla_upper_constraints_file %}-c {{ kolla_upper_constraints_file }}{% endif %}" become: True - when: "{{ container_engine == 'docker' }}" + when: container_engine == 'docker' - name: Ensure kolla-ansible virtualenv has podman SDK installed pip: @@ -66,7 +66,7 @@ virtualenv: "{{ kolla_ansible_target_venv }}" extra_args: "{% if kolla_upper_constraints_file %}-c {{ kolla_upper_constraints_file }}{% endif %}" become: True - when: "{{ container_engine == 'podman' }}" + when: container_engine == 'podman' - name: Ensure kolla-ansible virtualenv has SELinux bindings installed pip: diff --git a/ansible/mdadm.yml b/ansible/mdadm.yml index 14338dd0a..4d69b92ef 100644 --- a/ansible/mdadm.yml +++ b/ansible/mdadm.yml @@ -9,7 +9,7 @@ tags: - mdadm roles: - - name: mrlesmithjr.mdadm + - role: mrlesmithjr.mdadm become: True when: - mdadm_arrays is defined diff --git a/ansible/proxy.yml b/ansible/proxy.yml index 1f39eb6d1..e96e5674b 100644 --- a/ansible/proxy.yml +++ b/ansible/proxy.yml @@ -1,3 +1,4 @@ +--- - name: Configure HTTP(S) proxy settings hosts: seed-hypervisor:seed:overcloud:infra-vms max_fail_percentage: >- diff --git a/ansible/roles/disable-cloud-init/handlers/main.yml b/ansible/roles/disable-cloud-init/handlers/main.yml index b30534747..8b7dc20ca 100644 --- a/ansible/roles/disable-cloud-init/handlers/main.yml +++ b/ansible/roles/disable-cloud-init/handlers/main.yml @@ -1,5 +1,5 @@ --- -- name: reload systemd daemon +- name: Reload systemd daemon systemd: name: cloud-init daemon_reload: yes diff --git a/ansible/roles/disable-cloud-init/tasks/main.yml b/ansible/roles/disable-cloud-init/tasks/main.yml index b17d59bb0..bc591a557 100644 --- a/ansible/roles/disable-cloud-init/tasks/main.yml +++ b/ansible/roles/disable-cloud-init/tasks/main.yml @@ -5,5 +5,5 @@ state: touch mode: "u=rw,g=r,o=r" notify: - - reload systemd daemon + - Reload systemd daemon become: True diff --git a/ansible/roles/dnf/tasks/main.yml b/ansible/roles/dnf/tasks/main.yml index 41feff3ff..d39b8a145 100644 --- a/ansible/roles/dnf/tasks/main.yml +++ b/ansible/roles/dnf/tasks/main.yml @@ -4,7 +4,7 @@ path: /etc/dnf/dnf.conf section: "main" option: "{{ item.key }}" - value: "{{ item.value }}" + value: "{{ item.value }}" loop: "{{ query('dict', dnf_config) }}" become: true diff --git a/ansible/roles/docker-registry/tasks/destroy.yml b/ansible/roles/docker-registry/tasks/destroy.yml index bead5b9a6..527118151 100644 --- a/ansible/roles/docker-registry/tasks/destroy.yml +++ b/ansible/roles/docker-registry/tasks/destroy.yml @@ -14,4 +14,4 @@ - volumes when: "'/' not in volume" vars: - volume: "{{ item.1.split(':')[0] }}" \ No newline at end of file + volume: "{{ item.1.split(':')[0] }}" diff --git a/ansible/roles/infra-vms/tasks/main.yml b/ansible/roles/infra-vms/tasks/main.yml index a7306935e..fc367ccd4 100644 --- a/ansible/roles/infra-vms/tasks/main.yml +++ b/ansible/roles/infra-vms/tasks/main.yml @@ -1,7 +1,7 @@ --- - import_tasks: prerequisites.yml -- name: list all VMs on hypervisor +- name: List all VMs on hypervisor virt: command: list_vms register: all_vms diff --git a/ansible/roles/kolla-ansible/tasks/install.yml b/ansible/roles/kolla-ansible/tasks/install.yml index 2e0d4c8c4..5a643b179 100644 --- a/ansible/roles/kolla-ansible/tasks/install.yml +++ b/ansible/roles/kolla-ansible/tasks/install.yml @@ -159,4 +159,4 @@ # newer versions. ANSIBLE_COLLECTIONS_SCAN_SYS_PATH: "False" # NOTE(wszumski): Don't use path configured for kayobe - ANSIBLE_COLLECTIONS_PATH: + ANSIBLE_COLLECTIONS_PATH: '' diff --git a/ansible/roles/kolla-ansible/templates/kolla/globals.yml b/ansible/roles/kolla-ansible/templates/kolla/globals.yml index 31215b3c2..f8a93be65 100644 --- a/ansible/roles/kolla-ansible/templates/kolla/globals.yml +++ b/ansible/roles/kolla-ansible/templates/kolla/globals.yml @@ -176,7 +176,6 @@ neutron_tenant_network_types: {{ kolla_neutron_ml2_tenant_network_types | join(' # ulimits: - ############# # TLS options ############# diff --git a/ansible/roles/kolla-ansible/tests/test-defaults.yml b/ansible/roles/kolla-ansible/tests/test-defaults.yml index f42353a3a..5f16456f7 100644 --- a/ansible/roles/kolla-ansible/tests/test-defaults.yml +++ b/ansible/roles/kolla-ansible/tests/test-defaults.yml @@ -137,7 +137,7 @@ - name: Check that no inventory overrides are configured assert: that: - - kolla_ansible_overcloud_inventory_overrides.matched == 0 + - kolla_ansible_overcloud_inventory_overrides.matched == 0 msg: > Overcloud group vars were found when they should not be set. diff --git a/ansible/roles/kolla-openstack/defaults/main.yml b/ansible/roles/kolla-openstack/defaults/main.yml index 63b7856c1..f74c995cd 100644 --- a/ansible/roles/kolla-openstack/defaults/main.yml +++ b/ansible/roles/kolla-openstack/defaults/main.yml @@ -138,7 +138,7 @@ kolla_openstack_custom_config_include_globs_default: glob: nova/** - enabled: '{{ kolla_enable_nova | bool }}' glob: nova_compute/** - - enabled: '{{ kolla_enable_octavia | bool }}' + - enabled: '{{ kolla_enable_octavia | bool }}' glob: octavia.conf - enabled: '{{ kolla_enable_octavia | bool }}' glob: octavia/** diff --git a/ansible/roles/manage-containers/tasks/deploy.yml b/ansible/roles/manage-containers/tasks/deploy.yml index d450ddd37..c51be7cac 100644 --- a/ansible/roles/manage-containers/tasks/deploy.yml +++ b/ansible/roles/manage-containers/tasks/deploy.yml @@ -14,4 +14,4 @@ vars: container_name: "{{ item.key }}" container_config: "{{ item.value }}" - with_dict: "{{ seed_containers }}" \ No newline at end of file + with_dict: "{{ seed_containers }}" diff --git a/ansible/roles/manage-containers/tasks/destroy.yml b/ansible/roles/manage-containers/tasks/destroy.yml index acf0d25bd..5059832fa 100644 --- a/ansible/roles/manage-containers/tasks/destroy.yml +++ b/ansible/roles/manage-containers/tasks/destroy.yml @@ -1,6 +1,7 @@ +--- - name: Destroy containers (loop) include_tasks: destroy-container.yml vars: container_name: "{{ item.key }}" container_config: "{{ item.value }}" - with_dict: "{{ seed_containers }}" \ No newline at end of file + with_dict: "{{ seed_containers }}" diff --git a/ansible/roles/swift-block-devices/tests/test-bootstrapped.yml b/ansible/roles/swift-block-devices/tests/test-bootstrapped.yml index 6917ca03f..577b19ab7 100644 --- a/ansible/roles/swift-block-devices/tests/test-bootstrapped.yml +++ b/ansible/roles/swift-block-devices/tests/test-bootstrapped.yml @@ -32,7 +32,7 @@ - block: - name: Test the swift-block-devices role include_role: - name: ../../swift-block-devices + name: ../../swift-block-devices vars: swift_block_devices: - device: "{{ loopback.stdout }}" diff --git a/ansible/roles/swift-block-devices/tests/test-invalid-format.yml b/ansible/roles/swift-block-devices/tests/test-invalid-format.yml index 66eea7521..22df7be5e 100644 --- a/ansible/roles/swift-block-devices/tests/test-invalid-format.yml +++ b/ansible/roles/swift-block-devices/tests/test-invalid-format.yml @@ -7,7 +7,7 @@ - block: - name: Test the swift-block-devices role include_role: - name: ../../swift-block-devices + name: ../../swift-block-devices vars: swift_block_devices: - /dev/fake diff --git a/ansible/roles/swift-block-devices/tests/test-mount.yml b/ansible/roles/swift-block-devices/tests/test-mount.yml index 88bdb8ef9..5489160d9 100644 --- a/ansible/roles/swift-block-devices/tests/test-mount.yml +++ b/ansible/roles/swift-block-devices/tests/test-mount.yml @@ -24,7 +24,7 @@ - block: - name: Test the swift-block-devices role include_role: - name: ../../swift-block-devices + name: ../../swift-block-devices vars: swift_block_devices: - device: "{{ loopback.stdout }}" diff --git a/ansible/ssh-known-host.yml b/ansible/ssh-known-host.yml index a13ffba3a..58d68bd8a 100644 --- a/ansible/ssh-known-host.yml +++ b/ansible/ssh-known-host.yml @@ -11,4 +11,3 @@ - ssh-known-host roles: - role: ssh-known-host - diff --git a/ansible/tuned.yml b/ansible/tuned.yml index 69c5ba8d6..b538b2553 100644 --- a/ansible/tuned.yml +++ b/ansible/tuned.yml @@ -9,7 +9,7 @@ tags: - tuned roles: - - name: giovtorres.tuned + - role: giovtorres.tuned become: true when: - tuned_active_builtin_profile != "" diff --git a/dev/dev-vagrant-network-allocation.yml b/dev/dev-vagrant-network-allocation.yml index 66bff42df..39e3fcf38 100644 --- a/dev/dev-vagrant-network-allocation.yml +++ b/dev/dev-vagrant-network-allocation.yml @@ -1,2 +1,3 @@ +--- aio_ips: controller1: 192.168.33.3 diff --git a/doc/source/contributor/testing.rst b/doc/source/contributor/testing.rst index adb7a64fa..b11cd4e48 100644 --- a/doc/source/contributor/testing.rst +++ b/doc/source/contributor/testing.rst @@ -75,10 +75,10 @@ Environments The following tox environments are provided: -alint - Run Ansible linter. ansible Run Ansible tests for some ansible roles using Ansible playbooks. +ansible-lint + Run Ansible linter. ansible-syntax Run a syntax check for all Ansible files. docs diff --git a/tox.ini b/tox.ini index 4acf49860..5801e7136 100644 --- a/tox.ini +++ b/tox.ini @@ -69,8 +69,28 @@ commands = -p {toxinidir}/ansible/roles bash -c "source {envdir}/bin/activate && {toxinidir}/tools/test-molecule.sh {posargs}" -[testenv:alint] -commands = bash -c "ansible-lint {toxinidir}/ansible/*.yml" +[testenv:linters] +# Env vars and deps need to be defined in top level tox env +setenv = + ANSIBLE_ACTION_PLUGINS = {toxinidir}/ansible/action_plugins + ANSIBLE_FILTER_PLUGINS = {toxinidir}/ansible/filter_plugins + ANSIBLE_ROLES_PATH = {toxinidir}/ansible/roles + +deps = + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = + {[testenv:ansible-lint]commands} + +[testenv:ansible-lint] +# Lint only code in ansible/* - ignore various folders used by CI +# TODO(priteau): Ignore YAML linting issues in plugins and figure out why +# idrac-bootstrap.yml fails. +setenv = {[testenv:linters]setenv} +deps = {[testenv:linters]deps} +commands = + ansible-lint -p --exclude etc --exclude kayobe/plugins --exclude playbooks --exclude releasenotes --exclude roles --exclude zuul.d --exclude ansible/idrac-bootstrap.yml [testenv:ansible-syntax] commands =