Table of Contents

Middleware

How to Write Ansible Inventory and ansible.cfg



Inventory File

The default file is /etc/ansible/hosts.

[web]
192.168.0.101
192.168.0.102

[db]
192.168.0.100

[production:children]
web
db
[webservers]
web-[1:15].example.com 
[examples]
www.example.com    ansible_user=uer01    ansible_ssh_pass=pass1
192.168.0.100    #test-server-1
192.168.0.101    #test-server-2


Write password to inventory

[all:vars]
ansible_ssh_port=22
ansible_ssh_user=ansible
ansible_ssh_pass=ansible
ansible_sudo_pass=ansible


ansible.cfg

[defaults]
inventory = ./hosts          <-  /home/ansible/hosts   or  /home/ansible/hosts/aaaaa
remote_user = ansible
private_key_file=/home/ansible/.ssh/private_key
ansible-playbook -l all -a "hostname"




Ansible CLI Commands Cheet Sheat and Configuration Examples