Day 56: Understanding Ad-hoc commands in Ansible

Day 56: Understanding Ad-hoc commands in Ansible

Ansible ad hoc commands are one-liners designed to achieve a very specific task they are like quick snippets and your compact swiss army knife when you want to do a quick task across multiple machines.

To put simply, Ansible ad hoc commands are one-liner Linux shell commands and playbooks are like a shell script, a collective of many commands with logic.

Ansible ad hoc commands come handy when you want to perform a quick task.

Task-01

  • write an ansible ad hoc ping command to ping 3 servers from inventory file

  • Write an ansible ad hoc command to check uptime

happy Learning :)

  1. Create 1 master server and 3 servers and note down public ip and enter in /etc/ansible/hosts file

ad hoc ping command to ping 3 servers from inventory file

ansible all -m ping -u ubuntu

Display all filesystems and their disk usage in human-readable form: df -h.

ansible all -a "df -h" -u ubuntu

Write an ansible ad hoc command to check uptime

ansible servers -a "uptime" -u ubuntu

ansible ad hoc command to check listening ports

ansible all -m listen_ports_facts

Happy Learning..!!

Thank you for reading!! Hope you find this helpful.

#day56#90aysofdevops#devopscommunity#

Always open for suggestions..!!

Thank you Shubham Londhe !