ceph: allow curl tasks to run in dry run mode

When running dry-run, --check option is used with Ansible CLI which
means the shell command don't actually run so the curl isn't producting
any change. This patch fixes the tasks that relied on the curl outputs
to only run these tasks when the curl changed and produced something.

Change-Id: I5b722ac111db0a1b6272a95496251107e23dd764
Closes-Bug: #1803986
This commit is contained in:
Emilien Macchi 2018-11-19 08:46:32 -05:00
parent da0f6f98a1
commit 89f276cdab

View File

@ -512,17 +512,22 @@ outputs:
fail:
msg: "Received HTTP: {{curl_get_http_status.stdout}} when attempting to GET from {{swift_get_url}}"
when:
- curl_get_http_status.changed
- curl_get_http_status.stdout != "200" # deployment update
- curl_get_http_status.stdout != "404" # new deployment
- name: unpack downloaded ceph-ansible fetch tarball to fetch directory
# unarchive module hit https://github.com/ansible/ansible/issues/35645
shell: "/usr/bin/gtar --gzip --extract --file /tmp/{{old_ceph_ansible_tarball_name}} -C {{playbook_dir}}/ceph-ansible/fetch_dir"
when: curl_get_http_status.stdout == "200"
when:
- curl_get_http_status.changed
- curl_get_http_status.stdout == "200"
- name: remove downloaded ceph-ansible fetch directory tarball from filesystem
file:
path: "/tmp/{{old_ceph_ansible_tarball_name}}"
state: absent
when: curl_get_http_status.stdout == "200"
when:
- curl_get_http_status.changed
- curl_get_http_status.stdout == "200"
when: local_ceph_ansible_fetch_directory_backup == ""
- name: set ceph-ansible command
set_fact:
@ -570,7 +575,9 @@ outputs:
debug:
var: outputs.stdout_lines | default([]) | union(outputs.stderr_lines | default([]))
failed_when: outputs.rc != 0
when: outputs.rc != 0
when:
- outputs.changed
- outputs.rc != 0
- name: create ceph-ansible fetch directory tarball in local backup
archive:
path: "{{playbook_dir}}/ceph-ansible/fetch_dir"
@ -588,14 +595,15 @@ outputs:
msg: 'Received HTTP: {{curl_put_http_status.stdout}} when attempting to PUT to {{swift_put_url}}'
name: ensure we were able to backup temporary fetch directory to swift
when:
- curl_put_http_status.changed
- curl_put_http_status.stdout != "200"
- curl_put_http_status.stdout != "201"
- name: clean temporary fetch directory after swift backup
file:
path: "/tmp/{{new_ceph_ansible_tarball_name}}"
state: absent
when: (curl_put_http_status.stdout == "200" or
curl_put_http_status.stdout == "201")
when: (curl_put_http_status.changed and (curl_put_http_status.stdout == "200" or
curl_put_http_status.stdout == "201"))
when: local_ceph_ansible_fetch_directory_backup == ""
external_update_tasks:
- when: step|int == 0