
*Shreyash Bhise | Aspiring Mern Stack Developer and DevOps enthusiast,
1.Pinging All Hosts:
Check connectivity to all hosts in the inventory:
ansible all -m ping2.Copying Files:
Copy a file from the local machine to remote hosts:
ansible target_hosts -m copy -a "src=/path/to/local_file.txt dest=/remote/path/"3.Checking Free Disk Space:
Check free disk space on remote hosts:
ansible target_hosts -m shell -a "df -h"4.Running a Playbook:
- Execute a playbook named
playbook.ymlon thetarget_hostsgroup:
- Execute a playbook named
ansible-playbook -i inventory.ini playbook.yml
5.Running Multiple Playbooks:
Execute multiple playbooks sequentially:
ansible-playbook playbook1.yml playbook2.yml
6.Reboot remote hosts
ansible target_hosts -m reboot7.Check if a service is running
ansible target_hosts -m service -a "name=httpd state=started"8.Check system information
ansible all -m setup9.Check system uptime
ansible target_hosts -m shell -a "uptime"10.Restart a service
ansible target_hosts -m service -a "name=apache2 state=restarted"




