如何让ansible显示主机名EC2动态库存标签或 /etc/hosts 而不是 PLAY 中的 IP 回顾摘要:
输出:
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
预期的:
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
这样我就不用再搜索IP和主机名了
编辑1:ansible.cfg 中是否有任何配置行?
答案1
ec2.ini
我在文件中找到了解决方案
# 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