#Devops

Опубликовано: 25 Июнь 2026
на канале: Aws tutorial for beginners With Devops
175
5

#Ansible Tutorial #Ansible Ad hoc Commands - Ansible Tutorial

#AnsibleAdhoccommands

#AnsiblePlaybook

Now will do some Ad-hoc commands and Ansible Modules commands...

1.Ad-hoc commands
By using this ad-hoc tasks really quick and one-liner without writing
playbook commands...

We already set hosts in our previous video...no run the below command.

ansible all --list-hosts

Now will run some commands in our hosts without touching them...
ansible demo -a "ls" (if we have all hosts put all,otherwise mention that
group name. Here my hosts group is demo.)

2.See i have accessed my hosts.here one node have file1 let's see that.
one node has that file...

3.Now will create some files and verify in nodes.
ansible demo -a "touch fromserver" (it will create fromserver file in nodes)
ansible demo -a "ls" (by using this will see those files in nodes)

4.Now will install package in nodes.
ansible demo -a "yum install httpd -y" (it will give error.)
ansible demo -b -a "yum install httpd -y" (we have to mention -b to install)

Installed httpd in both nodes...
let's verify it... which httpd

5.Now will Move to ANSIBLE MODULES

To run an arbitary cmd use -a & use -m to run a module.
will check ansible demo -m ping

6.now install/remove a package
ansible demo -b -m yum -a "pkg=httpd state=present"
now remove this
ansible demo -b -m yum -a "pkg=httpd state=absent"
check it in nodes.

7.by default we have commands no need to give state=present.
8.if you want latest version of httpd package
ansible demo -b -m yum -a "pkg=httpd state=latest"
here state=present will install it
state=absent will remove it
state=latest will update it

9.To start / stop a service.

ansible demo -b -m service -a "name=httpd state=started"
it started running now...

To stop the service
ansible demo -b -m service -a "name=httpd state=stopped"

To restart the service use state=restarted.

10.Create / Delete a user account.
ansible demo -b -m user -a "name=ranga"
Verify the user created or not.
cat /etc/passwd

To delete the user account
ansible demo -b -m user -a "name=ranga state=absent"
User ranga was removed.

11.Gathering facts (idempotency)
ansible demo -m setup
ansible demo -m setup -a "filter=*ipv4*"

That's all for this part -2 Video.... Will be back with Playbooks in our
Next Video....

Ansible Gather Facts - Ansible Variable,Loops,When Condition | Ansible Tutorial for Beginners Part-3 HD
#Devops - Ansible Playbook - Ansible Tutorial for Beginners Part-3
#AnsibleTutorial
   • #Devops - Ansible Playbook - Ansible Tutor...  


Ansible Ad hoc Commands - Ansible All Modules | Ansible Package Modules | Ansible Tutorial Part - 2
#Devops #Ansible Ad hoc Commands - Ansible Tutorial Part - 2
#AnsibleTutorial
   • #Devops #Ansible Ad hoc Commands - Ansible...  


How to Install Ansible - Give Sudo Privileges | SSH Connection to Nodes - Ansible Tutorial part - 1
#Devops - Ansible Playbook - Ansible Tutorial for Beginners Part-1
#AnsibleTutorial
   • Ansible Tutorial - Give Sudo Privileges | ...  

Let's subscribe for videos like this and also like,share,comment...
Thank you....