Ansible tool can be used either manually ( adhoc command) or automatically ( playbook)
let say we want to configure http server
either you do manually . But it takes lot of time in typing these command manually. In server lots of computer and we have to install and do all things in it which is not possible manually
so we want to configure the web server automation
it mostly depend on how you manage the configuration
Two way of configeration
manual
adhoc
if you say you are learning the ansible due to their automation but automation is provided by tons of platforms.
what ansible provides is configuration management with intelligence.
as we know to start the service we use
a) In Redhat 5-6 we use service
command
b) In Redhat 7 we use systemctl
command
now we migrate to redhat version 9.
so if we try to run the same shell script of redhat 5-6 that we are using from last couple of year with redhat 7 then it fails because it support different prompt and command.
To run this script they have to do some changes.
In future we have so many migration so every time we stuck so we want solution which could run on different version .
let say in this I have to install httpd in all with same script. it will not done in same script because we know what to do that is install but have to tell how to do. we have to write both in script.
we want to setup our webservers so we can't use to scripting. as we have to tell both the answer what and how to do.
what ansible will give:-
a) code(don't bother about programming language
b) configure management
c) Declarative management
d) what to do and i don't want to know how to do
e) Intelligence
f) provisioning
g) networking
h) security automation and so on.
whenever you want to automate the things you have to write the code .
In Ansible world anyone can write the code without knowing Programming language.
Ansible program file is called as ansible playbook.
lets launch the instance in AWS cloud on the top of redhat AMI
now download the putty.exe then
then go to auth section on left bottom side and browse your private key
then click open
then click accept
yum install ansible-core
and now ansible is install so now any configure management we do with the help of ansible.
lets do ansible manually that is adhoc command
for example in this os i want to install a software but i dont know how to install the software .
through ansible i want to install of package name dialog
we have to specify whether the particular is a file or package name these are the keywords called module
for example while install
-m package
m for module and keyword to install is package
command to install the package
>>ansible localhost -m package -a "name=dialog state=present"
here -m (module) and keyword tell what it is whether it is package , firewall
command to uninstall the package
>>ansible localhost -m package -a "name=dialog state=absent"
interesting thing we don't have to use yum or rpm command to install it .
same thing we can do in ubuntu also let see
we see that package dialog is not installed in it
firstly we have to install ansible in it
those who use ubuntu can use
apt-get update
then
apt-get install ansible -y
see we run same thing here and get the success this is the power of ansible don't matter know to command and script of that os. same ad-hoc command will run on all os .
My Contact Info:
๐ฉEmail:- mayank07082001@gmail.com
LinkedIn:-linkedin.com/in/mayank-sharma-devops