EC2 ダイナミックインベントリを使用する場合、再生サマリーに IP の代わりにホスト名が表示されますか?

EC2 ダイナミックインベントリを使用する場合、再生サマリーに IP の代わりにホスト名が表示されますか?

ホスト名を表示する方法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

おすすめ記事