Hello, checking if anyone have any insight or pointing me to a solution, about using loops with register and debug:
I’m looking for
a) just debug msg output whenever the mountpoint on remote server is not configured.
b) lesser debug output whenever the mountpoint is not configured, as currently with_items: ‘{{ mount_stat.results }}’ is spitting all the output from the command when the mountpoint is not configured
Not sure
— #
- name : test
hosts: lab1
any_errors_fatal: true
gather_facts: false
ignore_errors: true
tasks:
-
name: check mount point {{ item }}
tags: art
command: “mountpoint {{ item }}”
with_items: -
/opt/mqmm
-
/var/mqm
-
/var/mqm/errors
-
/var/mqm/logs
-
/var/mqm/trace
register: mount_stat -
debug:
msg: ‘The command ({{ item.cmd }}) did not have a 0 return code’
when: item.rc != 0
with_items: ‘{{ mount_stat.results }}’
Here is the example from ansible docs, but i’m not able to get that converted/translated to my requirement
— #
- name :test
hosts: lab1
gather_facts: false
ignore_errors: true
tasks:
-
shell: “echo {{ item }}”
with_items: -
“one”
-
“two”
register: echo -
debug:
msg: ‘The command ({{ item.cmd }}) did not have a 0 return code’
when: item.rc == 0
with_items: ‘{{ echo.results }}’