Access Inventory file - Ansible

0 votes

I have my inventory file 

my_host ansible_ssh_host=
my_host2 ansible_ssh_host=

How do I access the alias variable in a playbook/template?

Jan 24 in Ansible by Jalil

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can just use {{ ansible_ssh_host }}


my_host ansible_ssh_host= my_host_alias=my_host


- name: Example
  user: ubuntu
  hosts: all

    - name: whatever
      debug: msg="Myhost is {{ ansible_ssh_host }}"

    - name: whatever
      debug: msg="My host alias is {{ my_host_alias }}"
answered Jan 24 by Akansha

Related Questions In Ansible

0 votes
1 answer
+1 vote
1 answer

Ansible: Deleting matching IPs from hosts file using regex

Ansible notation isn't the same as YAML ...READ MORE

answered Jul 25, 2018 in Ansible by DareDev
• 6,670 points
+1 vote
1 answer

Is it possible to append a large amount of text to a file using Ansible?

Here is concept which you can follow. blockinfile is ...READ MORE

answered Jul 30, 2018 in Ansible by Atul
• 10,220 points
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer

Ansible playbook to wget a file

Hey @Celia, one recommendation, try not using ...READ MORE

answered Jan 16 in Ansible by Vaishu
0 votes
1 answer

Configuring SSH Access to the Ansible Hosts

Hey @Shakira, follow these steps: Execute the following ...READ MORE

answered Jan 17 in Ansible by Sam

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.