Now my task is to find out the hostname of the system belong to hostclass ‘ess’ , which in this case the answer in host002. I have to write an ansible script to find out the result. Can anyone help me in finding out, or any idea to approach for the problem.
Issue Type:: Finding a phrase through ansible
Ansible Version:: Ansible 2.4.0
Component Name:: It looks similar to json type file.
That takes the hostinfo dict, turns it into a list of tuples, selects where hostclass equals ess, gets the first result (there should only be one here), and then gets the first element.
If you don’t have jinja2 version with the equalto test, you can replace that with search or match
I am glad you replied so fast, but sorry to say i am not an ansible expert . I am just a beginner . I just typed the code. Can you help me in understanding where i am not correct.
@Matt Martz : I am sorry to ask silly questions, regarding ansible as by seeing the small piece of code, i can understand you must be an ansible expert. If possible you can help me in my problem explanation a bit.
And any such links for learning you want to refer, please refer me. As i googled selectattr but first|first parameter which you have passed i am not getting any good document. If you can help me in referring such, it would be of very nice help.
Hi, thanks for sharing the docs link. In the meanwhile i am not able to go in the right direction of solving the problem. so far what i have done is ::
converted the text file to json through python.
write some ansible codes, which in return it is dumping the contents but i am not able to get the thing i want.