0% found this document useful (0 votes)
6 views1 page

Invetory File 3

The document outlines the structure of an Ansible inventory file, defining three groups: a single host with specific credentials, a group of multiple hosts sharing the same credentials, and a combined group of all hosts. It provides instructions on how to modify the inventory file as needed and how to use it in an Ansible playbook with the -i option. Example entries for the groups and their respective configurations are also included.

Uploaded by

afba2331
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Invetory File 3

The document outlines the structure of an Ansible inventory file, defining three groups: a single host with specific credentials, a group of multiple hosts sharing the same credentials, and a combined group of all hosts. It provides instructions on how to modify the inventory file as needed and how to use it in an Ansible playbook with the -i option. Example entries for the groups and their respective configurations are also included.

Uploaded by

afba2331
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

'''

In this example, we have defined three groups:

[single_host]: Contains a single host with IP 192.168.1.10, username user1, and


password pass1.
[group_of_hosts]: Contains multiple hosts (192.168.1.20, 192.168.1.30,
192.168.1.40) with the same username user2 and password pass2.
[all_hosts:children]: Combines all the hosts from the single_host and
group_of_hosts groups.
You can modify the inventory file by adding or removing hosts as needed, along with
their respective usernames and passwords.

Now you can use this inventory file in your Ansible playbook by specifying the path
to the inventory file using the -i option:

bash
Copy code
ansible-playbook -i path/to/inventory.ini playbook.yml
Replace path/to/inventory.ini with the path to your inventory file.
'''
[single_host]
192.168.1.10 ansible_user=user1 ansible_password=pass1

[group_of_hosts]
192.168.1.20 ansible_user=user2 ansible_password=pass2
192.168.1.30 ansible_user=user2 ansible_password=pass2
192.168.1.40 ansible_user=user2 ansible_password=pass2

[all_hosts:children]
single_host
group_of_hosts

You might also like