Ansible Ad Hoc Commands | Ansible Modules : File, Ping, Copy, Yum, User, Service, Shell |Thetips4you



Ansible Ad Hoc Commands | Ansible Modules : File, Ping, Copy, Yum, User, Service, Shell |Thetips4you

Ansible Ad Hoc Commands | Ansible Modules : File, Ping, Copy, Yum, User, Service, Shell |Thetips4you

#Ansible, #AnsibleTutorial,#AnsibleCommands Hello Friends, Welcome back to my channel. In Today’s tutorial we are going to see more about Ansible. In our last video we have seen how to install Ansible on Centos and Ubuntu machine. Let us see how we can make use of Ad-hoc ansible commands in this lecture. Ad-hoc commands are great for tasks which are not repeated and done very rarely. We will see about how to run the commands in Ansible and make use of different modules in this video.

—————————————————————————————–
Ansible setup on Centos or Ubuntu:
https://youtu.be/tgVdbF4nmyI
————————————————————————————
———————————————————————————–
Adhoc Command Git:
https://github.com/shazforiot/Ansible-Adhoc-Commands.git
———————————————————————————–
———————————————————————————–
Install Ansible:
——————-

sudo yum install epel-release

sudo yum install python-pip

yum install ansible

Create SSH Connection:
————————

ssh-keygen

Press enter for all questions. The public and private key will be created in the location : /root/.ssh/id_rsa

Run the below command to copy the key to other machines.

ssh-copy-id user@ip

eg: ssh-copy-id [email protected]

Ansible Modules:
————————-

Ping Module:
ansible testservers -m ping

File module: Creating and deleting directory

ansible testservers -m file -a “dest=/root/file state=directory”
ansible testservers -m file -a “dest=/root/file mode=755 owner=root group=root state=directory”
ansible testservers -m file -a “dest=/root/file state=absent”

Copy Module:

ansible testservers -m copy -a “src=/root/file/text.txt dest=/root/”

Shell Module:

ansible testservers -m shell -a “mkdir test”

Yum Module:

ansible testservers -m yum -a “name=wget state=present”
ansible testservers -m yum -a “name=httpd state=present”

Service Module:

ansible testservers -m service -a “name=httpd state=restarted”
ansible testservers -m service -a “name=httpd state=started”
ansible testservers -m service -a “name=httpd state=stopped”

Restarting the servers:

ansible testservers -a “/sbin/reboot”
——————————————————————————————–
==========================================
Follow me @:
https://www.instagram.com/thetips4you
https://www.youtube.com/channel/UCoOq-DtESvayx5yJE5H6-qQ
https://www.facebook.com/thetipsforyou
http://www.thetips4you.com
===========================================
Music credit: “Royalty Free Music from Bensound”

Comments are closed.