Folks,
I’m trying to copy the debug output to a local file for next task.
My host inventory has 2 hosts and I see the local file has only one host output.
is something missing in playbook ? if I have 10 hosts how to get copied all the output to a file.
please help on this,
register: result
-
set_fact:
user: “{{ result.configResolveClass.children|json_query(my_query) }}”
vars:
my_query: “.outConfigs.children.aaaUser.attributes.{id: id, name: name, priv: priv, accountStatus: accountStatus}” -
local_action: copy content=“CIMC IP is {{ inventory_hostname.split() | list | to_yaml }} {{ user | rejectattr(‘accountStatus’, ‘eq’, ‘inactive’)| list | to_yaml }}” dest=/root/user.txt
PLAY [cimc] ********************************************************************************************************************************
TASK [Checking service accounts] *****************************************************************************************************************
ok: [host1]
ok: [host2]
TASK [set_fact] **********************************************************************************************************************************
ok: [host1]
ok: [host2]
TASK [copy] **************************************************************************************************************************************
changed: [host1 → localhost]
changed: [host2 → localhost]
PLAY RECAP ***************************************************************************************************************************************
host1 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
host2 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
cat user.txt
CIMC IP is [host1]
- {accountStatus: active, id: ‘1’, name: admin, priv: admin}
- {accountStatus: active, id: ‘2’, name:account1 , priv: admin}
- {accountStatus: active, id: ‘3’, name:account2, priv: admin}
- {accountStatus: active, id: ‘4’, name:account3 , priv: admin}
- {accountStatus: active, id: ‘5’, name:account4 , priv: admin}
- {accountStatus: active, id: ‘6’, name:account5 , priv: admin}
- {accountStatus: active, id: ‘7’, name:account6 , priv: admin}