can someone help me on how to remove *inactive user *from the below debug output,
TASK [debug] ************************************************************************************************************************************* ok: [host1] => {} MSG: - {accountStatus: active, id: '1', name: admin, priv: admin} - {accountStatus: active, id: '2', name: VIDEO, priv: admin} - {accountStatus: active, id: '3', name: CDVR, priv: admin} - {accountStatus: active, id: '4', name: VIP, priv: admin} - {accountStatus: active, id: '5', name: vie, priv: admin} - {accountStatus: active, id: '6', name: op5, priv: admin} - {accountStatus: active, id: '7', name: DEU, priv: admin} - {accountStatus: active, id: '8', name: syn, priv: admin} - {accountStatus: inactive, id: '9', name: '', priv: ''} - {accountStatus: inactive, id: '10', name: '', priv: ''} - {accountStatus: inactive, id: '11', name: '', priv: ''} - {accountStatus: inactive, id: '12', name: '', priv: ''} - {accountStatus: inactive, id: '13', name: '', priv: ''} - {accountStatus: inactive, id: '14', name: '', priv: ''} - {accountStatus: inactive, id: '15', name: '', priv: ''} Playbook: 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}" - debug: msg: "{{ user | to_yaml }}" On Thursday, 31 December 2020 at 17:58:21 UTC-5 dick....@geant.org wrote: > > https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#formatting-data-yaml-and-json > > > On Thu, 31 Dec 2020 at 22:54, Ramesh AR <rames...@gmail.com> wrote: > >> 1. how to exclude the below from json queries or is it possible to filter >> in debug . I tried but couldn't sorted out . >> +++++++++++++++++++++++++++++++++++++ >> for example, I don't want to be displayed the below output. The below one >> doesn't have any value like that I'm getting so many .. so how to rid of it >> from Json query . >> >> { >> "accountStatus": "inactive", >> "id": "15", >> "name": "", >> "priv": "" >> } >> +++++++++++++++++++++++++++++++++++++ >> 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}" >> - debug: msg="{{ user |join (" ") }}" >> +++++++++++++++++++++++++++++++++++++ >> 2. is there a way to align debug o/p ? >> >> MSG: >> >> {'id': '1', 'name': 'xxx', 'priv': 'admin'} {'id': '2', 'name': 'xxx', >> 'priv': 'admin'} {'id': '3', 'name': 'xxxx', 'priv': 'admin'} {'id': '4', >> 'name': 'xxxx', 'priv': 'admin'} {'id': '5', 'name': 'xxxx', 'priv': >> 'admin'} {'id': '6', 'name': 'xxxxx', 'priv': 'admin'} {'id': '7', 'name': >> 'xxxxx', 'priv': 'admin'} >> >> expected o/p: >> >> {'id': '1', 'name': 'xxx', 'priv': 'admin'} >> {'id': '2', 'name': 'xxx', 'priv': 'admin'} >> {'id': '3', 'name': 'xxxx', 'priv': 'admin'} >> {'id': '4', 'name': 'xxxx', 'priv': 'admin'} >> {'id': '5', 'name': 'xxxx', 'priv': 'admin'} >> {'id': '6', 'name': 'xxxxx', 'priv': 'admin'} >> {'id': '7', 'name': 'xxxxx', 'priv': 'admin'} >> >> Thanks , >> Ramesh >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to ansible-proje...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/bba3fe2f-ebfd-4fe1-9249-08810f3ef0c1n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ansible-project/bba3fe2f-ebfd-4fe1-9249-08810f3ef0c1n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > Sent from a mobile device - please excuse the brevity, spelling and > punctuation. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b515aa63-22d7-4b27-8136-2a2559794fd9n%40googlegroups.com.