![EC2 동적 인벤토리를 사용할 때 재생 요약에 IP 대신 호스트 이름이 표시됩니까?](https://linux55.com/image/175442/EC2%20%EB%8F%99%EC%A0%81%20%EC%9D%B8%EB%B2%A4%ED%86%A0%EB%A6%AC%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%A0%20%EB%95%8C%20%EC%9E%AC%EC%83%9D%20%EC%9A%94%EC%95%BD%EC%97%90%20IP%20%EB%8C%80%EC%8B%A0%20%ED%98%B8%EC%8A%A4%ED%8A%B8%20%EC%9D%B4%EB%A6%84%EC%9D%B4%20%ED%91%9C%EC%8B%9C%EB%90%A9%EB%8B%88%EA%B9%8C%3F.png)
호스트 이름을 표시하는 방법EC2 동적 인벤토리 태그또는 PLAY 검토 요약에서 IP 대신 /etc/hosts:
산출:
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