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:
@@ -10,13 +10,12 @@
|
|||||||
# ANSIBLE0013: Use Shell only when shell functionality is required
|
# ANSIBLE0013: Use Shell only when shell functionality is required
|
||||||
# ANSIBLE0016: Tasks that run when changed should likely be handlers
|
# ANSIBLE0016: Tasks that run when changed should likely be handlers
|
||||||
# this requires refactoring roles, skipping for now
|
# 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"
|
||||||
SKIPLIST="ANSIBLE0006,ANSIBLE0007,ANSIBLE0010,ANSIBLE0012,ANSIBLE0013,ANSIBLE0016,ANSIBLE0019"
|
|
||||||
|
|
||||||
# lint the playbooks separately to avoid linting the roles multiple times
|
# lint the playbooks separately to avoid linting the roles multiple times
|
||||||
pushd playbooks
|
pushd playbooks
|
||||||
for playbook in `find . -type f -regex '.*\.y[a]?ml'`; do
|
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
|
done
|
||||||
popd
|
popd
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ popd
|
|||||||
# Due to https://github.com/willthames/ansible-lint/issues/210, the roles
|
# 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.
|
# directories need to contain a trailing slash at the end of the path.
|
||||||
for rolesdir in `find ./roles -maxdepth 1 -type d`; do
|
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
|
done
|
||||||
|
|
||||||
## exit with 1 if we had a least an error or warning.
|
## exit with 1 if we had a least an error or warning.
|
||||||
|
@@ -48,4 +48,4 @@
|
|||||||
set_fact:
|
set_fact:
|
||||||
to_build: true
|
to_build: true
|
||||||
cacheable: 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 }}"
|
path: "{{ images_working_dir }}"
|
||||||
state: absent
|
state: absent
|
||||||
become: true
|
become: true
|
||||||
when: "{{ images_destroy_working_dir }}|bool"
|
when: images_destroy_working_dir | bool
|
||||||
|
|
||||||
- name: Create the working directory
|
- name: Create the working directory
|
||||||
file:
|
file:
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
path: '{{ lookup("env", "WORKSPACE") }}/{{ gated_project_name }}'
|
path: '{{ lookup("env", "WORKSPACE") }}/{{ gated_project_name }}'
|
||||||
state: absent
|
state: absent
|
||||||
# do not remove the repo if it was cloned by the jenkins job
|
# 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
|
- name: Check out the gated change
|
||||||
git:
|
git:
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
refspec: '{{ gated_change.refspec }}'
|
refspec: '{{ gated_change.refspec }}'
|
||||||
version: 'FETCH_HEAD'
|
version: 'FETCH_HEAD'
|
||||||
# do not check out the gated change if it was already cloned by the jenkins job
|
# 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
|
# do this only for the roles
|
||||||
- when: gated_change.project != "openstack/tripleo-quickstart"
|
- when: gated_change.project != "openstack/tripleo-quickstart"
|
||||||
|
@@ -7,7 +7,9 @@
|
|||||||
change_id: "{{ lookup('env', 'GERRIT_CHANGE_ID') }}"
|
change_id: "{{ lookup('env', 'GERRIT_CHANGE_ID') }}"
|
||||||
branch: "{{ lookup('env', 'GERRIT_BRANCH') }}"
|
branch: "{{ lookup('env', 'GERRIT_BRANCH') }}"
|
||||||
patchset_rev: "{{ lookup('env', 'GERRIT_PATCHSET_REVISION') }}"
|
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
|
- name: Check out the specific changes
|
||||||
include: checkout.yml gated_change={{ item }}
|
include: checkout.yml gated_change={{ item }}
|
||||||
|
@@ -61,5 +61,6 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Check that post delete node count is correct
|
- name: Check that post delete node count is correct
|
||||||
fail: msg="Overcloud nova list does not show expected number of {{ node_to_scale }} services"
|
fail:
|
||||||
when: post_scale_node_count.stdout|int != {{ initial_scale_value | int }}
|
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
|
register: post_scale_nova_list
|
||||||
|
|
||||||
- name: Display 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
|
when: post_scale_nova_list is defined
|
||||||
|
|
||||||
# Verify the scale
|
# Verify the scale
|
||||||
@@ -35,5 +36,6 @@
|
|||||||
register: post_scale_node_count
|
register: post_scale_node_count
|
||||||
|
|
||||||
- name: Check that post scale node count is correct
|
- name: Check that post scale node count is correct
|
||||||
fail: msg="Overcloud nova list does not show expected number of {{ node_to_scale }} services"
|
fail:
|
||||||
when: post_scale_node_count.stdout|int != {{ final_scale_value|int }}
|
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
|
hacking<0.11,>=0.10
|
||||||
|
|
||||||
bashate>=0.2 # Apache-2.0
|
bashate>=0.2 # Apache-2.0
|
||||||
ansible-lint
|
ansible-lint>=3.5.0
|
||||||
sphinx>=1.6.2 # BSD
|
sphinx>=1.6.2 # BSD
|
||||||
reno>=1.8.0 # Apache-2.0
|
reno>=1.8.0 # Apache-2.0
|
||||||
jinja2
|
jinja2
|
||||||
|
Reference in New Issue
Block a user