You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the volume exists, it is correctly deleted, but when it doesn't exist, the task is failed with the following message :
TASK [glusterfs/init/delete/server : delete glusterfs volume] ******************
fatal: [vm_sto1]: FAILED! => {"changed": false, "msg": "volume not found volume1"}
As a consequence, the play stops with FAILURE status.
Expected result:
Task result is "ok", indicating no change happened, and the play continues on.
Workarounds:
Setting ignore_errors to "yes" on the task is not satisfactory because I don't want to ignore errors when actually failing to delete an existing volume, plus I would like the task to have the "ok" status, not "failed but ignored".
I've been playing with failed_when conditions to try and mimic the behaviour I want. I ended up with this :
- name: delete glusterfs volume
gluster_volume:
state: absent
name: "{{ volume.name }}"
run_once: true
register: output
failed_when:
- '"volume not found" not in output.msg'
- not output.changed
but I'm not sure if this is robust and it definitely isn't elegant, so I would like to get rid of it if possible.
The text was updated successfully, but these errors were encountered:
It seems odd to me that a task that has nothing to do should fail. The play might have other tasks to do after this one, so stopping in that case is wrong IMO.
An analogy I can think of is when we want to delete a file using the file module, we specify state=absent and if the file doesn't exist on the machine, the task does nothing and is marked 'ok', and the play continues.
Context:
I have a task that uses the gluster_volume module like this :
Problem:
When the volume exists, it is correctly deleted, but when it doesn't exist, the task is failed with the following message :
As a consequence, the play stops with FAILURE status.
Expected result:
Task result is "ok", indicating no change happened, and the play continues on.
Workarounds:
Setting
ignore_errors
to "yes" on the task is not satisfactory because I don't want to ignore errors when actually failing to delete an existing volume, plus I would like the task to have the "ok" status, not "failed but ignored".I've been playing with
failed_when
conditions to try and mimic the behaviour I want. I ended up with this :but I'm not sure if this is robust and it definitely isn't elegant, so I would like to get rid of it if possible.
The text was updated successfully, but these errors were encountered: