Wednesday, 19 August 2020

Ansible abcd for Infrastructure automations

 yum install ansible

create server inventory file with all server names which you want to manage certain tasks

eg:

mongodb01.abc.com

mongodb02.abc.com

mongodb03.abc.com


or you can create groups within the inventory 

eg:

db-servers

mongodb01.abc.com

mongodb02.abc.com

mongodb03.abc.com

web-servers

apache01.abc.com

apache02.abc.com

apache03.abc.com


How to run the ansible ad-hoc tasks for the entire inventory file?

ansible -i /opt/scripts/inventory  -m shell  -a "uptime"


How to run the ansible ad-hoc tasks for the only one group of servers in the inventory file?

ansible -i /opt/scripts/inventory db-servers -m -a "uptime"


No comments:

Post a Comment