Merge "Enable ansible-lint"

This commit is contained in:
Zuul 2021-04-13 19:06:05 +00:00 committed by Gerrit Code Review
commit 6233d5f758
6 changed files with 22 additions and 7 deletions

3
.gitignore vendored
View File

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

View File

@ -5,6 +5,18 @@
# So we don't break the MaxFailPercentage feature since these plays can't use # So we don't break the MaxFailPercentage feature since these plays can't use
# Ansible strategies. # 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 - hosts: all
name: Clear cached facts name: Clear cached facts
# We don't want to gather facts, just clear them # We don't want to gather facts, just clear them
@ -14,7 +26,7 @@
tags: tags:
- facts - facts
- hosts: "{{ deploy_source_host }}:{{ deploy_target_host }}" - hosts: "{{ deploy_source_host | default([]) }}:{{ deploy_target_host | default([]) }}"
name: Gather facts name: Gather facts
strategy: tripleo_free strategy: tripleo_free
gather_facts: true gather_facts: true
@ -35,12 +47,12 @@
any_errors_fatal: false any_errors_fatal: false
ignore_unreachable: true ignore_unreachable: true
tasks: tasks:
- include_vars: global_vars.yaml - include_vars: global_vars.yaml # noqa: missing-import
no_log: true no_log: true
tags: tags:
- always - always
- hosts: "{{ deploy_target_host }}" - hosts: "{{ deploy_target_host | default([]) }}"
name: Render all_nodes data as group_vars for overcloud name: Render all_nodes data as group_vars for overcloud
gather_facts: "{{ gather_facts | default(false) }}" gather_facts: "{{ gather_facts | default(false) }}"
# we don't skip errors or ignore unreachable on this one because it's # we don't skip errors or ignore unreachable on this one because it's
@ -57,7 +69,7 @@
- facts - facts
- always - always
- hosts: "{{ deploy_target_host }}" - hosts: "{{ deploy_target_host | default([]) }}"
name: Set all_nodes data as group_vars for overcloud name: Set all_nodes data as group_vars for overcloud
gather_facts: "{{ gather_facts | default(false) }}" gather_facts: "{{ gather_facts | default(false) }}"
any_errors_fatal: false any_errors_fatal: false

View File

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

View File

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

View File

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

View File

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