N
N
nano_e_t_42020-04-18 20:32:37
Ansible
nano_e_t_4, 2020-04-18 20:32:37

How to iterate over inventory variables?

Hello everyone
Remind pliz how to iterate over variable inventories?
right now I'm doing like this on this inventory

{% for host in groups['all'] %}
      - targets: ['{{ host }}:9273']
        labels:
          stage_name: "{{ host }}"


[linux-servers]
awesome1 ansible_host=8.8.8.8 ansible_private_ip=10.0.0.0
awesome2 ansible_host=8.8.8.8 ansible_private_ip=10.0.0.0
awesome3 ansible_host=8.8.8.8 ansible_private_ip=10.0.0.0


but it displays hostnames (awesome) and I need ansible_private_ip,

I don’t remember how this is done, remind me pliz, who knows

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nano_e_t_4, 2020-04-18
@nano_e_t_4

out of date, found
- targets: ['{{ hostvars[host].ansible_private_ip }}:9273']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question