Open robin-checkmk opened 2 weeks ago
Curious. The failed_when
directive should make the task not fail, if the rc
is 0
or 1
, as the latter means an absent file, which is fine. Let me double-check this.
- name: "{{ ansible_system }}: Read Updater State."
become: true
ansible.builtin.command: cat /var/lib/check_mk_agent/cache/plugins_cmk-update-agent.cache
register: __checkmk_agent_updater_state
changed_when: false
failed_when: |
not __checkmk_agent_updater_state.rc == 0
and not __checkmk_agent_updater_state.rc == 1
@mueller-ma I cannot reproduce this issue. For me the failed_when
logic works just fine. No matter if the file exists or not, the task is fine. Can you double-check on your end? Do you have any non-default Ansible configuration on place?
There're two tasks using cat
, but only one of them catches failure code == 1
: https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/roles/agent/tasks/Linux.yml#L90-L103
You successfully confused me with the two different problems in this one issue! :grin:
I just pushed a fix, which will be released with the next release.
Also the role crashes when a file doesn't exist:
I noticed this issue on Rapberry Pis, so maybe the path is different on arm?
Originally posted by @mueller-ma in https://github.com/Checkmk/ansible-collection-checkmk.general/issues/631#issuecomment-2203366127