# Sample Inventory File
# Web Servers
web_node1 ansible_host=web01.xyz.com ansible_connection=winrm ansible_user=administrator ansible_password=Win$Pass
web_node2 ansible_host=web02.xyz.com ansible_connection=winrm ansible_user=administrator ansible_password=Win$Pass
web_node3 ansible_host=web03.xyz.com ansible_connection=winrm ansible_user=administrator ansible_password=Win$Pass
# Database Servers
sql_db1 ansible_host=sql01.xyz.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Lin$Pass
sql_db2 ansible_host=sql02.xyz.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Lin$Pass
# group of nodes
[db_nodes]
sql_db1
sql_db2
[web_nodes]
web_node1
web_node2
web_node3
# group of groups
[us_nodes:children]
boston_nodes
dallas_nodes
Ad-hoc command stracture:
ansible <hosts> -a <command>
ansible <hosts> -m <module> -i <invetroy-file>
ansible all -m ping -i inventory.txt
-
name : Test connectity to target servers
hosts : all
tasks :
- name : Ping test
ping :
ansible-playbook playbook-file.yaml -i invintory-file