Clean up roles data adjustment

1. The python_bin var is unused, so it should be removed.
2. Tasks should be seperated by a newline in order to easily see
   that they are seperate tasks.
3. The return code of 2 was in the wrong place. It should have been
   where the data was changed, as per the changed_when condition.
4. With the return code adjusted, the final task's condition also
   needed adjusting to match.

Related-Bug: #1856865
Change-Id: I916c3ed394f54561fff2a106288a667c0b877360
(cherry picked from commit 967f3805d3)
This commit is contained in:
Jesse Pretorius (odyssey4me) 2019-12-23 10:09:07 +00:00 committed by Jose Luis Franco Arza
parent 614322b9f6
commit 6c5631bb3d
1 changed files with 3 additions and 4 deletions

View File

@ -59,8 +59,6 @@
dest: "{{ roles_data }}.json"
- name: Ensure we set update_serial in roles data
vars:
python_bin: "{{ ansible_python_interpreter | default('python') }}"
shell: |
set -o pipefail
if grep -q OS::TripleO::Services::Pacemaker "{{ roles_data }}.json"; then
@ -68,15 +66,16 @@
jq 'del(.[] | .update_serial ) |
map(. |= (. += {update_serial: 25} )) |
map( if .ServicesDefault | contains (["OS::TripleO::Services::Pacemaker"]) then . += {update_serial: 1} else . += {update_serial: 25} end )'
exit 2
else
echo "No service defined, not modifying the role file"
exit 2
fi
register: modified_roles_data
failed_when: modified_roles_data.rc not in [0,2]
changed_when: modified_roles_data.rc == 2
- name: "Dump the modified roles_data into {{ roles_data }}"
copy:
content: "{{ modified_roles_data.stdout | from_json | to_nice_yaml(indent=2) | trim}}"
dest: "{{ roles_data }}"
when: modified_roles_data.rc == 0
when: modified_roles_data.rc == 2