0

I got the inventory file with content of ip addresses,

192.168.1.1
192.168.1.2
192.168.1.3

I want to capture the ip address especially when it's passing to the tasks and looping it. If use the variables on ansible facts, I'm afraid I might use other/wrong ip address.

So is it possible to grab the input from the inventory?

Thanks.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Ricky Vene
  • 105
  • 1
  • 11
  • @techraf The `ipv4` address is what's wanted, not the hostname – OneCricketeer May 08 '18 at 21:25
  • https://stackoverflow.com/a/23257539/2308683 – OneCricketeer May 08 '18 at 21:26
  • @cricket_007 With the host file OP posted in the question, `inventory_hostname` will contain the IP address for each host. ・ And OP explicitly mentioned they **do not want** to rely on facts, so why do you post a link to an answer suggesting exactly that? – techraf May 08 '18 at 21:38
  • @techraf They said they are afraid facts would be wrong. Which I don't understand that myself. Plus, adding `debug` would show if it's correct or not before applying it – OneCricketeer May 08 '18 at 22:50

0 Answers0