Browse Source

Enable ansible-lint

- enable run of ansible-lint, with a temporary set of excludes
- fixes two problems reported by ansible-linter

Change-Id: Ibbe23db8fd5ac1008109f50f514df96686b0fa19
Bug: #1921409
changes/99/782999/8
Sorin Sbarnea 7 months ago
parent
commit
a013f42e36
  1. 3
      .gitignore
  2. 20
      common/deploy-steps-playbooks-common.yaml
  3. 1
      deployment/haproxy/haproxy-container-puppet.yaml
  4. 1
      test-requirements.txt
  5. 1
      tox.ini
  6. 3
      tripleo_heat_templates/tests/test_tht_ansible_syntax.yml

3
.gitignore

@ -179,3 +179,6 @@ tripleo_heat_templates/tests/tripleo-ansible
# Files created by releasenotes build
releasenotes/build
.cache
tripleo_heat_templates/tests/ansible-pacemaker
tripleo_heat_templates/tests/tripleo-ansible

20
common/deploy-steps-playbooks-common.yaml

@ -5,6 +5,18 @@
# So we don't break the MaxFailPercentage feature since these plays can't use
# Ansible strategies.
- hosts: localhost
name: Check if required variables are defined
tasks:
- fail:
msg: deploy_source_host variable is not defined
when: deploy_source_host is not defined
- fail:
msg: deploy_target_host variable is not defined
when: deploy_target_host is not defined
# Keep in mind that you will still need to use defaults in order to be
# able to pass Ansible own syntax check for blocks like 'hosts'.
- hosts: all
name: Clear cached facts
# We don't want to gather facts, just clear them
@ -14,7 +26,7 @@
tags:
- facts
- hosts: "{{ deploy_source_host }}:{{ deploy_target_host }}"
- hosts: "{{ deploy_source_host | default([]) }}:{{ deploy_target_host | default([]) }}"
name: Gather facts
strategy: tripleo_free
gather_facts: true
@ -35,12 +47,12 @@
any_errors_fatal: false
ignore_unreachable: true
tasks:
- include_vars: global_vars.yaml
- include_vars: global_vars.yaml # noqa: missing-import
no_log: true
tags:
- always
- hosts: "{{ deploy_target_host }}"
- hosts: "{{ deploy_target_host | default([]) }}"
name: Render all_nodes data as group_vars for overcloud
gather_facts: "{{ gather_facts | default(false) }}"
# we don't skip errors or ignore unreachable on this one because it's
@ -57,7 +69,7 @@
- facts
- always
- hosts: "{{ deploy_target_host }}"
- hosts: "{{ deploy_target_host | default([]) }}"
name: Set all_nodes data as group_vars for overcloud
gather_facts: "{{ gather_facts | default(false) }}"
any_errors_fatal: false

1
deployment/haproxy/haproxy-container-puppet.yaml

@ -324,7 +324,6 @@ outputs:
shell: |
puppet apply {{ (puppet_debug|bool) | ternary('--debug --verbose', '') }} --detailed-exitcodes --summarize --color=false \
--modulepath '{{ puppet_modulepath }}' --tags '{{ puppet_tags }}' -e '{{ puppet_execute }}'
register: puppet_host_outputs
changed_when: puppet_host_outputs.rc == 2
failed_when: false
vars:

1
test-requirements.txt

@ -14,3 +14,4 @@ testtools>=2.2.0 # MIT
oslotest>=3.2.0 # Apache-2.0
yaql>=1.1.3 # Apache 2.0 License
ansible-runner>=1.4.2 # Apache
ansible-lint[core,yamllint]>=5.0.5 # MIT/GPL

1
tox.ini

@ -28,6 +28,7 @@ commands =
bash -c ./tools/roles-data-validation.sh
bash -c ./tools/check-up-to-date.sh
flake8
ansible-lint -v
[flake8]
# E125 is deliberately excluded. See

3
tripleo_heat_templates/tests/test_tht_ansible_syntax.yml

@ -15,9 +15,8 @@
# under the License.
- name: Run check
- name: Render Ansible tasks for roles templates
hosts: localhost
name: Render Ansible tasks for roles templates
vars:
# This variable is set to 9999, so we will not execute actually
# any task. Still, the Ansible interpreter will check for syntax

Loading…
Cancel
Save