Skip to content
IT related

Inventory

Updated 1 min read Linked from 1 page

Changing the Inventory on Ansible

Find the Inventory file

On Ansible master there will be a file called inventory. Some of the playbooks have their own inventory file, which you can find in the specific playbook's folder.

The main Inventory file is at /root/ansible/inventory. To edit this file you need to open it with the Ansible vault command; ansible-vault edit inventory. In the file you will see the section to add new hosts, make sure to use the same format and add a comment that identifies the host.

At the bottom of the inventory file you will find the 'groups'. You need to put the 'username' of your server (specified in the above section) into each group. Each group corresponds to a playbook, and each playbook will only be run on the hosts that you have put in it's respective group. More info below.

Example of the format

#Karisma test server
TESTSERVER ansible_host=192.168.17.52 ansible_ssh_user="kest" ansible_become_password="changeme"

Breakdown

  1. The comment is at the top, this should describe the server.
  2. First segment is the device 'username'
  3. Second segment is the IP or DNS name
  4. Third segment is the username you login with
  5. Forth segment is the users password.

Example of format used by other playbooks.

192.168.16.12 ansible_ssh_user=fullmetal ansible_ssh_pass="fm" ansible_sudo_pass="fm"

Breakdown

  1. Ip or DNS name of host
  2. SSH user on the host
  3. Password for that user
  4. Password for gaining sudo (likely the same password)
IT related RSS feed Published with Oblish

Keyboard shortcuts

/
Search
[
Previous page
]
Next page
?
Show this list
Esc
Close