Ansible Adhoc Commands Practical example and Benefits | Best Practice | EP -4 | Ansible Tutorial

Опубликовано: 12 Август 2024
на канале: DevOps Vijay
329
9

An Ansible ad hoc command uses the /usr/bin/ansible command-line tool to automate a single task on one or more managed nodes. ad hoc commands are quick and easy, but they are not reusable.

So why learn about ad hoc commands? ad hoc commands demonstrate the simplicity and power of Ansible. The concepts you learn here will port over directly to the playbook language. Before reading and executing these examples,

Benefits and Advantages of ansible ad hoc Commands:

1. Speed and Ease of Use: They require minimal setup and can be executed with a single command line. This is ideal for one-off tasks or situations where you need a fast response.
2. Simple Tasks Made Automatic: Automating even basic tasks saves time and reduces errors. Ad hoc commands let you automate simple actions like restarting services, checking system info, or copying files across multiple servers.
3. Parallel Execution: Manage multiple systems efficiently. Ansible can run ad hoc commands on a group of servers simultaneously, saving you significant time compared to manually performing the task on each machine.

4. Testing and Development: Use ad hoc commands as a testing ground for your automation. Before diving into complex playbooks, you can test modules, arguments, and target systems with ad hoc commands to refine your automation logic.
5. Flexibility: Ad hoc commands offer a wide range of possibilities. you can leverage various Ansible modules to interact with your systems in diverse ways, making them adaptable to various automation needs.

Official documentation url:
https://docs.ansible.com/ansible/late...

Example/Sample commands:
ansible [pattern] -m [module] -a "[module options]"

ansible webservers -m ansible.builtin.file -a "dest=/path/to/c mode=755 owner=mdehaan group=mdehaan state=directory"
ansible webservers -m ansible.builtin.yum -a "name=acme-1.5 state=present"
ansible webservers -m ansible.builtin.yum -a "name=acme state=absent"


Introduction of objective topics to be covered : 00:10
Introduction to ad hoc commands: 00:40
Benefits of adhoc commands: 02:40
Live Practical Example of Adhoc commands: 04:35
ping Command in Linux : 05:11
uptime Command in Linux : 06:50
copy Command in Linux : 08:10
File Command in Linux : 10:31
yum Command in Linux : 12:00
service Command in Linux : 14:00

*************************************************************
Jenkins tutorial complete step by step guide :
How to install jenkins in windows:    • How to  Install Jenkins on Windows ? ...  
How to create first sample job in jenkins:    • How to Create First Freestyle Project...  
Poll scm jenkins :    • Jenkins Poll SCM GitHub | BUILD Trigg...  
How to install plugin in jenkins:    • Jenkins Plugins installation | EP 04 ...  
How to create pipeline in jenkins:    • Creating First Pipeline in Jenkins | ...  
Configure Slave agent in jenkins:    • Maven Installation & Jenkins Slave Ag...  
SSH-KEYS setup :    • SSH Key Based Password Less Authentic...  
Maven installation:    • Maven Installation on Windows | EP 01...  
Configure Maven with Nexus:    • Installation of Nexus Repository in w...  

*************************************************************
Ubuntu on Virtualbox:    • Need UBUNTU on Windows Operating Syst...  
Install Guest additions in oracle vm:    • Full screen issue ? | Install GUEST A...  
Install Tomcat on Ubuntu:    • How to Install  and configure Tomcat ...  

****************************************************
Devops interview questions:    • Test your DevOps skills and knowledge...  
Devops java project sample:    • Create Java Project in Maven | Folder...  
*****************************************************
Ansible tutorial
***********************************************
Introduction to ansible:    • Introduction to Ansible Architecture ...  
Ansible installation on linux:    • Ansible Installation on Linux | Ansib...  
Best practice for ansible folder structure:    • Ansible Directory Layout: Organize Yo...  


devops tutorial for beginners
devops full course
devops interview questions
jenkins tutorial

#tutorial #devops #jenkins #jenkinstutorial #jenkinspipeline #learning #career #interview #question #jenkins #cicd #linux #devopsvijay #devopsproject #devopstraining #devopstrainingvideos #cicd #bashscripting #shellscripting #ansible #ansibletutorial #ansibletraining