같은 인벤토리 파일 갖는Ansible - 액세스 재고 별명
[my_hosts]
my_host ansible_ssh_host=123.123.123.123
my_host2 ansible_ssh_host=234.234.234.234
내가 내 템플릿의 일부 디버그 정보를 수집하고자합니다.
플레이 북/템플릿의 별칭 변수에 어떻게 액세스합니까? 즉이 :
debug: msg=Myhost is {{ ansible_host_alias }} # Myhost is my_host # Myhost is myhost2
나는 ansible -m setup my_host
를 사용하여 사실을 수집하기 위해 노력했다. ansible_hostname
, HOSTNAME
및 HOST
변수에는 컴퓨터의 호스트 이름 (예 : echo $HOSTNAME
)이 내 어시스턴트와 다릅니다.
이 ansible_ssh_host'가 2.0에서 ansible_host' '에 찬성 중지되었습니다'주의하십시오. ([docs] (http://docs.ansible.com/ansible/intro_inventory.html#hosts-and-groups)). 마찬가지로 ansible_ssh_user와 ansible_ssh_port는 ansible_user와 ansible_port가됩니다. 이러한 짧은 변수는 이전 버전의 Ansible에서 경고없이 무시됩니다. – Kyr