From 2b21dac369a6fb36db0611ffdf50366ab7ee73ca Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 26 Jun 2019 18:05:08 +0000 Subject: [PATCH] Be consistent about spaces before and after vars With the arrival of ansible-lint 4, Jinja2 variable expansions must include spaces before and after the variable name inside the brackets. Adjust the new violations accordingly and remove the rule 206 exclusion. For special cases we can have use inline excludes. Change-Id: Ib3ff7b0233a5d5cf99772f9c2adc81861cf34ffa --- roles/bindep/tasks/packages.yaml | 2 +- roles/build-python-release/tasks/main.yaml | 2 +- roles/multi-node-bridge/tasks/peer.yaml | 2 +- roles/multi-node-firewall/tasks/main.yaml | 4 ++-- roles/upload-pypi/tasks/main.yaml | 4 ++-- test-requirements.txt | 2 +- tox.ini | 5 ++--- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/roles/bindep/tasks/packages.yaml b/roles/bindep/tasks/packages.yaml index f0982aef5..bd3d1555d 100644 --- a/roles/bindep/tasks/packages.yaml +++ b/roles/bindep/tasks/packages.yaml @@ -18,5 +18,5 @@ - name: Fail if we cannot install all packages fail: - msg: "bindep failed to install from {{ bindep_file}} - {{ bindep_final_check.stdout }}" + msg: "bindep failed to install from {{ bindep_file }} - {{ bindep_final_check.stdout }}" when: bindep_final_check is failed diff --git a/roles/build-python-release/tasks/main.yaml b/roles/build-python-release/tasks/main.yaml index fe8369e56..fd7b7084d 100644 --- a/roles/build-python-release/tasks/main.yaml +++ b/roles/build-python-release/tasks/main.yaml @@ -1,4 +1,4 @@ - name: Build a tarball and wheel - command: "{{release_python}} setup.py sdist bdist_wheel {{bdist_wheel_xargs}}" + command: "{{ release_python }} setup.py sdist bdist_wheel {{ bdist_wheel_xargs }}" args: chdir: "{{ zuul_work_dir }}" diff --git a/roles/multi-node-bridge/tasks/peer.yaml b/roles/multi-node-bridge/tasks/peer.yaml index 8eeba1213..c1dea7d1f 100644 --- a/roles/multi-node-bridge/tasks/peer.yaml +++ b/roles/multi-node-bridge/tasks/peer.yaml @@ -29,7 +29,7 @@ command: >- ovs-vsctl --may-exist add-port {{ bridge_name }} {{ bridge_name }}_{{ nodepool_ip }} - -- set interface {{ bridge_name }}_{{ nodepool_ip}} + -- set interface {{ bridge_name }}_{{ nodepool_ip }} type=vxlan options:remote_ip={{ nodepool_ip }} options:key={{ vni }} options:local_ip={{ switch_ip }} delegate_to: "{{ switch }}" diff --git a/roles/multi-node-firewall/tasks/main.yaml b/roles/multi-node-firewall/tasks/main.yaml index 3a43b0a09..64871e736 100644 --- a/roles/multi-node-firewall/tasks/main.yaml +++ b/roles/multi-node-firewall/tasks/main.yaml @@ -5,7 +5,7 @@ - name: Set up the host ip addresses set_fact: - ipv4_addresses: > + ipv4_addresses: > # noqa 206 {% set hosts = [] -%} {% for host, vars in hostvars.items() -%} {% if vars['nodepool']['private_ipv4'] -%} @@ -16,7 +16,7 @@ {% endif -%} {% endfor -%} {{- hosts | sort | unique -}} - ipv6_addresses: > + ipv6_addresses: > # noqa 206 {% set hosts = [] -%} {% for host, vars in hostvars.items() -%} {% if vars['nodepool']['public_ipv6'] -%} diff --git a/roles/upload-pypi/tasks/main.yaml b/roles/upload-pypi/tasks/main.yaml index 5a32bcb23..671daeac7 100644 --- a/roles/upload-pypi/tasks/main.yaml +++ b/roles/upload-pypi/tasks/main.yaml @@ -18,7 +18,7 @@ - name: Report no wheels to be uploaded debug: - msg: "Found no wheels to upload: {{found_wheels.msg}}" + msg: "Found no wheels to upload: {{ found_wheels.msg }}" when: found_wheels.files == [] - name: Register packages on the PyPI server (via wheels) @@ -38,7 +38,7 @@ - name: Report no tarballs to be uploaded debug: - msg: "Found no tarballs to upload: {{found_tarballs.msg}}" + msg: "Found no tarballs to upload: {{ found_tarballs.msg }}" when: found_tarballs.files == [] - name: Register packages on the PyPI server (via tarballs) diff --git a/test-requirements.txt b/test-requirements.txt index 0a19d62d6..6f062bf44 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -15,7 +15,7 @@ zuul ansible>=2.5.1,<2.6 # https://review.openstack.org/567007 # Don't automatically switch to ansible-lint 5 when it becomes # available, so that it can be evaluated for an orderly transition. -ansible-lint<5 +ansible-lint>=4.1.1a0,<5 bashate>=0.2 stestr>=1.0.0 # Apache-2.0 # For upload-logs-swift: diff --git a/tox.ini b/tox.ini index 6d5ede496..757c0a7f2 100644 --- a/tox.ini +++ b/tox.ini @@ -43,11 +43,10 @@ commands = # Ansible lint # [ANSIBLE0012] Commands should not change things if nothing needs doing # [204] Lines should be no longer than 160 chars - # [206] Variables should have spaces before and after: {{ var_name }} bash -c "find playbooks -type f -regex '.*.ya?ml' -print0 | \ - xargs -t -n1 -0 ansible-lint -xANSIBLE0012,204,206" + xargs -t -n1 -0 ansible-lint -xANSIBLE0012,204" bash -c 'find roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | \ - xargs -t -n1 ansible-lint -xANSIBLE0012,204,206' + xargs -t -n1 ansible-lint -xANSIBLE0012,204' # Ansible Syntax Check bash -c "find playbooks -type f -regex '.*.ya?ml' -exec \ ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null"