Yes, I can get the current target host IP using "inventory_hostname". But the problem is I have to store that IP in a local file in my master machine (ie., where the ansible runs)
On Wednesday, June 26, 2019 at 11:54:53 PM UTC+5:30, Tony Chia wrote: > > You can get the current executing ip addresses in the playbook using the > magic variable inventory_hostname > > You can find more information at > > https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts > > > On Wednesday, June 26, 2019 at 4:05:22 AM UTC-7, Preethi Muruganantham > wrote: >> >> Or is there any way in ansible to fetch the IP of the hosts where the >> playbooks are executed? >> As like .retry file in ansible which holds the IP of failed one, is there >> any ways in ansible which holds the IPs of all executed hosts alone(ie., >> hosts in which the playbook executes) >> >> On Wednesday, June 26, 2019 at 4:32:25 PM UTC+5:30, Preethi Muruganantham >> wrote: >>> >>> Can you give me a suggestion about one more requirement? >>> I need to limit the playbook execution for particular hosts. >>> Eg., From host1 to the host mentioned in site.retry file >>> >>> My inventory file: >>> >>> 192.168.11.1 >>> 192.168.11.2 >>> 192.168.11.3 >>> >>> Playbook name: site.yml >>> Command: ansible-playbook site.yml --limit @~/site.retry) >>> >>> The above command executes the playbook only for the host present in >>> site.retry file. >>> But I need to execute the playbook from host1 until the host present in >>> site.retry file. >>> >>> For eg., if site.retry file contains - 192.168.11.2 >>> I need the playbook to run for 192.168.11.1 and 192.168.11.2 (ie., >>> from the host1 till the one mentioned in site.retry file) >>> >>> Is there any way to achieve this? >>> >> -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ea3b1d9f-b7ba-4ea1-9cfe-715baa748981%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
