--
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+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4431f374-65b9-4884-9acb-f709bdd658f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
My job is to find out the hostname which belongs to hostclass ess, which in this case the answer is host002.
hostinfo:
'host001':
ip: 192.168.43.10
hostclass: 'puppet'
'host002':
ip: 192.168.43.11
hostclass: 'ess'
'host003':
ip: 192.168.43.21
hostclass: 'mdb'
i got one solution from some friend in google ansible groups only, but i am unable to fit it my ansible playbook.
- debug:
msg: "{{ hostinfo|dictsort|selectattr('1.hostclass', 'equalto', 'ess')|first|first }}"
The playbook i am writing, which is wrong but i am not able to figure out how to fit the code in my playbook. Can anyone help me in modifying the code of mine.
---
- hosts: somehost
gather_facts: no
vars_files:
file: sometext.yaml
name: sometext
- debug:
msg: "{{ hostinfo|dictsort|selectattr('1.hostclass', 'equalto', 'ess')|first|first }}
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4431f374-65b9-4884-9acb-f709bdd658f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bacee1a5-37a0-423a-9dcf-a8625c361493%40googlegroups.com.
Regards,Biswadip Dutta