Daily Archives: 04/09/2019

Ansible: get a target host’s IP

9 April 2019
 

 The task is to get a host’s IP during executing an Ansible task. Below – two examples of how this can be done. Example 1 – hostvars See the documentation here>>>. Code: – name: Test hosts list debug: msg: “{{ hostvars[inventory_hostname][‘ansible_default_ipv4’][‘address’] }}” Run it: [simterm] … TASK [test : Test hosts list] **** ok: [dev.backend-app1-internal.example.com]… Read More »