0

how to make ansible show host names from ec2 dynamic inventory tags or /etc/hosts instead of IPs in PLAY RECAP SUMMARY:

Output:

PLAY RECAP *******************************************************************************************************************
174.129.7.83              : ok=9    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
18.20.83.221              : ok=13   changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Expected:


webserver1 or ec2 name tag              : ok=9    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
webserver2 or ec2 name tag             : ok=13   changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0     

So that I don't have to search for IPs and host names again

Edit 1: Is there any config line for this in ansible.cfg?

2
  • 1
    My ansible shows inventory hostnames as default - you might want to show us what you have set in /etc/ansible/ansible.cfg and other config files
    – Panki
    Jun 19, 2020 at 13:42
  • I am using ec2 dynamic inventory file @Panki
    – Akhil
    Jun 19, 2020 at 13:46

1 Answer 1

0

I found a solution in ec2.ini file

# This allows you to override the inventory_name with an ec2 variable, instead
# of using the destination_variable above. Addressing (aka ansible_ssh_host)
# will still use destination_variable. Tags should be written as 'tag_TAGNAME'.
hostname_variable = tag_Name

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .