Repair ansible when calls with jinja2
- adopts official syntax for 'when:' commands - assures we use current linter which spots when errors - reverts temporary linter rule disablement - use parsable output (pep8 like) for ansible-lint Change-Id: I6eb5719841c2f264e1efed4bf38726f71c840e36 Closes-Bug: #1797838
This commit is contained in:
parent
ecd5d0d806
commit
a472345db1
|
@ -10,13 +10,12 @@
|
|||
# ANSIBLE0013: Use Shell only when shell functionality is required
|
||||
# ANSIBLE0016: Tasks that run when changed should likely be handlers
|
||||
# this requires refactoring roles, skipping for now
|
||||
# ANSIBLE0019: This is task ID 102 with '"when" lines should not include Jinja2 variables'
|
||||
SKIPLIST="ANSIBLE0006,ANSIBLE0007,ANSIBLE0010,ANSIBLE0012,ANSIBLE0013,ANSIBLE0016,ANSIBLE0019"
|
||||
SKIPLIST="ANSIBLE0006,ANSIBLE0007,ANSIBLE0010,ANSIBLE0012,ANSIBLE0013,ANSIBLE0016"
|
||||
|
||||
# lint the playbooks separately to avoid linting the roles multiple times
|
||||
pushd playbooks
|
||||
for playbook in `find . -type f -regex '.*\.y[a]?ml'`; do
|
||||
ansible-lint -vvv -x $SKIPLIST -R -r ../ci-scripts/ansible_rules $playbook || lint_error=1
|
||||
ansible-lint -vvv -p -x $SKIPLIST -R -r ../ci-scripts/ansible_rules $playbook || lint_error=1
|
||||
done
|
||||
popd
|
||||
|
||||
|
@ -24,7 +23,7 @@ popd
|
|||
# Due to https://github.com/willthames/ansible-lint/issues/210, the roles
|
||||
# directories need to contain a trailing slash at the end of the path.
|
||||
for rolesdir in `find ./roles -maxdepth 1 -type d`; do
|
||||
ansible-lint -vvv -x $SKIPLIST -R -r ./ci-scripts/ansible_rules $rolesdir/ || lint_error=1
|
||||
ansible-lint -vvv -p -x $SKIPLIST -R -r ./ci-scripts/ansible_rules $rolesdir/ || lint_error=1
|
||||
done
|
||||
|
||||
## exit with 1 if we had a least an error or warning.
|
||||
|
|
|
@ -48,4 +48,4 @@
|
|||
set_fact:
|
||||
to_build: true
|
||||
cacheable: true
|
||||
when: "{{ lookup('env', 'PERIODIC')|default('0')|int == 1 }}"
|
||||
when: lookup('env', 'PERIODIC')|default('0')|int == 1
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
path: "{{ images_working_dir }}"
|
||||
state: absent
|
||||
become: true
|
||||
when: "{{ images_destroy_working_dir }}|bool"
|
||||
when: images_destroy_working_dir | bool
|
||||
|
||||
- name: Create the working directory
|
||||
file:
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
path: '{{ lookup("env", "WORKSPACE") }}/{{ gated_project_name }}'
|
||||
state: absent
|
||||
# do not remove the repo if it was cloned by the jenkins job
|
||||
when: gated_change.project != "{{ lookup('env', 'GERRIT_PROJECT') }}"
|
||||
when: gated_change.project != lookup('env', 'GERRIT_PROJECT')
|
||||
|
||||
- name: Check out the gated change
|
||||
git:
|
||||
|
@ -24,7 +24,7 @@
|
|||
refspec: '{{ gated_change.refspec }}'
|
||||
version: 'FETCH_HEAD'
|
||||
# do not check out the gated change if it was already cloned by the jenkins job
|
||||
when: gated_change.project != "{{ lookup('env', 'GERRIT_PROJECT') }}"
|
||||
when: gated_change.project != lookup('env', 'GERRIT_PROJECT')
|
||||
|
||||
# do this only for the roles
|
||||
- when: gated_change.project != "openstack/tripleo-quickstart"
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
change_id: "{{ lookup('env', 'GERRIT_CHANGE_ID') }}"
|
||||
branch: "{{ lookup('env', 'GERRIT_BRANCH') }}"
|
||||
patchset_rev: "{{ lookup('env', 'GERRIT_PATCHSET_REVISION') }}"
|
||||
when: artg_change_list is not defined and "{{ lookup('env', 'GERRIT_HOST') }}" != ""
|
||||
when:
|
||||
- artg_change_list is not defined
|
||||
- lookup('env', 'GERRIT_HOST') != ""
|
||||
|
||||
- name: Check out the specific changes
|
||||
include: checkout.yml gated_change={{ item }}
|
||||
|
|
|
@ -61,5 +61,6 @@
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Check that post delete node count is correct
|
||||
fail: msg="Overcloud nova list does not show expected number of {{ node_to_scale }} services"
|
||||
when: post_scale_node_count.stdout|int != {{ initial_scale_value | int }}
|
||||
fail:
|
||||
msg: "Overcloud nova list does not show expected number of {{ node_to_scale }} services"
|
||||
when: post_scale_node_count.stdout|int != (initial_scale_value | int)
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
register: post_scale_nova_list
|
||||
|
||||
- name: Display post-scale nova list
|
||||
debug: msg={{ post_scale_nova_list.stdout_lines }}
|
||||
debug:
|
||||
msg: "{{ post_scale_nova_list.stdout_lines }}"
|
||||
when: post_scale_nova_list is defined
|
||||
|
||||
# Verify the scale
|
||||
|
@ -35,5 +36,6 @@
|
|||
register: post_scale_node_count
|
||||
|
||||
- name: Check that post scale node count is correct
|
||||
fail: msg="Overcloud nova list does not show expected number of {{ node_to_scale }} services"
|
||||
when: post_scale_node_count.stdout|int != {{ final_scale_value|int }}
|
||||
fail:
|
||||
msg: "Overcloud nova list does not show expected number of {{ node_to_scale }} services"
|
||||
when: post_scale_node_count.stdout|int != (final_scale_value|int)
|
||||
|
|
|
@ -2,7 +2,7 @@ openstackdocstheme>=1.11.0 # Apache-2.0
|
|||
hacking<0.11,>=0.10
|
||||
|
||||
bashate>=0.2 # Apache-2.0
|
||||
ansible-lint
|
||||
ansible-lint>=3.5.0
|
||||
sphinx>=1.6.2 # BSD
|
||||
reno>=1.8.0 # Apache-2.0
|
||||
jinja2
|
||||
|
|
Loading…
Reference in New Issue