+91 88606 33966            edu_sales@siriam.in                   Job Opening : On-site Functional Trainer/Instructor | Supply Chain Management (SCM)
Top 10 Ansible Commands Every Beginner Should Know

Ansible is a powerful automation tool that simplifies IT tasks such as configuration management, application deployment, and orchestration. For beginners, understanding some essential Ansible commands can make it easier to get started and perform day-to-day tasks efficiently. In this blog, we will discuss the top 10 Ansible commands that every beginner should know.

1. ansible –version

The ansible --version command helps you check the installed version of Ansible on your system. It provides useful information such as the Ansible version, Python version, and the configuration file being used.

Example: ansible –version

2. ansible all -m ping

This command verifies connectivity between the Ansible control node and the managed nodes. The ping module checks whether Ansible can connect to the hosts listed in the inventory file.

Example: ansible all -m ping

3. ansible-inventory –list

The ansible-inventory command provides details about the hosts defined in the inventory file. The --list option displays the inventory in JSON format.

Example: ansible-inventory –list

4. ansible all -m setup

The setup module gathers system information about the managed hosts, such as OS details, network configurations, and hardware information.

Example: ansible all -m setup

5. ansible-playbook playbook.yml

This command is used to execute an Ansible playbook, which is a YAML file containing automation tasks.

Example: ansible-playbook playbook.yml

6. ansible all -a “uptime”

The -a flag allows running ad-hoc commands directly on the managed nodes without writing a playbook. For example, the following command checks the system uptime.

Example: ansible all -a “uptime”

7. ansible all -b -m yum -a “name=httpd state=present”

This command installs the Apache HTTP server using the yum module while using privilege escalation (-b for sudo).

Example: ansible all -b -m yum -a “name=httpd state=present”

8. ansible-doc -l

The ansible-doc command provides documentation on available Ansible modules. The -l flag lists all available modules.

Example: ansible-doc -l

9. ansible-vault create secret.yml

Ansible Vault allows you to encrypt sensitive data such as passwords. The following command creates an encrypted file.

Example: ansible-vault create secret.yml

10. ansible-galaxy init my_role

The ansible-galaxy command is used to create reusable roles, which help organize tasks, handlers, and variables efficiently.

Example: ansible-galaxy init my_role


Conclusion

Mastering these basic Ansible commands will help you get comfortable with automation tasks and enhance your productivity. As you continue to explore Ansible, you’ll discover more powerful features that can streamline your IT operations.

Top 10 Ansible Commands Every Beginner Should Know

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top