G
G
gremlintv22019-05-24 12:38:29
Ansible
gremlintv2, 2019-05-24 12:38:29

ANSIBLE how to get ip addresses from inventory file group?

I apologize for such a trivial question, but I just can’t find an example for getting IP from the inventory group of a file.
Tried like this:

- name: host
    debug: msg="{{ item }}" 
    with_items:
      - "{{ groups['SYNC-HOSTS'].['ansible_hostname'] }}"

Please share an example

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gremlintv2, 2019-05-24
@gremlintv2

Thanks everyone, issue closed.

- name: host
    debug: msg="{{ hostvars[item]['ansible_host'] }}" 
    with_items:
      - "{{ groups['SYNC-HOSTS'] }}"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question