Reputation: 1
I have a inventory within the hosts file called [WEB], it consists of the servers below.
[WEB] WEB01 WEB02 WEB03
When I declare hosts: WEB, it will iterate through each server and run locally on that respective server to do what it needs.
How can I take the same inventory but run what I want to do on the local Ansible server when running ansible-playbook FILE.YML? For example, I want to run a URI command that has the web server name as a parameter but as said, run it on the local Ansible server to POST to a external website. This doesn't need to run on the web servers themselves but I want to take the webserver names (WEB01, WEB02, WEB03) and run the URI module to post to a site.
Thanks!
Upvotes: 0
Views: 391
Reputation: 2823
You can loop through the host name vars using with items and delegate that to local host .
OR
If you don't want to perform any action on the hosts in the web group then you can define that in a variable in the inventory then apply with items. specify hosts as hosts: localhost
Upvotes: 1