You are on page 1of 6

DAY - 1

ANSIBLE:-

Ansible -> Configuration and Automation Tool

Difference between ANSIBLE & Terraform

Ansible:
------------------
Infrastructure prof
Infrastructure conf
Infrastructure manage
IAAC - infrastructure as a code
Specialist in infra config
programming language using here is yaml {yet another markup language} & Unix
commands via infra configure
Ansible released by REDHAT
ON premisses / Cloud
Matured tool {2006}65%

TERRAFORM:
-------------------------
Specialist in infra provisioning
programming language using here is => Hasicorp Configuration Language {HCL}
it can also do configuration and maintenance
Terraform released by Hasicorp
Cloud
NEW

Define Configuration?
Application Deployment
Tools & software Installation
Doing changes in Existing application
Using Unix/ymal script via doing task like create dir, file trans, permission
change

What is the need of Ansible?


Master - Control node
Slave - Managed nodes
Run time exceptional error will throw when version of software mismatch between the
env's

Ansible Limitations?
Ansible master won't run in Windows server
Single master configuration. single master control multi slave. if master server
spoil means entire project setup will spoil.
Very Easy to Learn and implement
Master and Slave configuration Ansible is also called Agent less Architecture.
In master and slave conf. we do conf / grouping slave server IP ADD in master
server.
In Host Inventory, we create host inventory under the master server.

Two important files inside the ANSIBLE


1,Host Inventory file.
2,Ansible Configuration file.

download "pageant" file from putty organisation. used for .ppk file repo. while
login via pagent

Ansible mechanism -> what ever we need to achive on the slave server we do push
master and it will happens in the slaves server

Replacement for ANSIBLE ->


Chef - pull mechanism,
Puppet - pull mechanism,
salt stack - push & pull mechanism,
ANSIBLE - push mechanism

agent based, agentless

Two ways to install Ansible: 1,pip 2,yum/apt

1, pip{python installation package}:-


Manual installation method
Master -> should be linux env except WINDOWS-> Python, Ansible
Slave -> Python, Platform Independent ie any OS,
while install ansible via pip method Ansible Default file system path
"/etc/ansible" won't create
while path own't create automatic means, ansible default file "Host Inventory,
Ansible Configuration file not available

2, yum/apt
Automatic installation method
while install ansible via yum/apt method Ansible Default file system path
"/etc/ansible" created
while path created automatic means, ansible default file "Host Inventory, Ansible
Configuration file available
Ansible main important Components:-
Adhoc Commands - single task exec commands
Playbooks - muli task
Vault - Security Policy - ie setting password
Roles - Offline Template - we store already used playbooks in ansible galaxy for re
use purpose.

Create one Ansible Master server:


#! /bin/bash
yum update -y
yum install python-pip -y
pip install ansible

Create Two Slave Servers:


#! /bin/bash
yum update -y
yum install python-pip -y

OPEN PAGEANT application and load both master and slave servers key files

open MASTER server by agent forward method


login & check it says login by pvt key
cd .ssh/
ls
cat authorized_keys
cd -
whoami -> ec2-user
pwd -> /home/ec2-user
python --version
ansible --version
cd /etc/ansible -> default file system path. its not available there bcoz.
we install through pip method. host inventory, ansible file are not available. so
we need to create.

vi hosts -> create hosts file -> copy paste slave's pvt IP ADD -> also can
create group different groups [] for slaves to install different softwares

wget https://raw.githubusercontent.com/ansible/ansible/stable-2.11/examples/
ansible.cfg

*****we do ansible in ec2-user onlt. Technically ROOT user we can say Emergency ID.
we can't do proj in root. bcoz cost applicable.
*** read wright execute policy available for homeuser path.
*****open cofiguration file link & choose DEVELOPED VERSION "STABLE 2.11"
******open that window via RAW file and do "wget"
ls -lrth
vi ansible.cfg
---> Host key checking = False ****{make it as command}
****whenever master connect with host it should not ask confirmation. we dissable
host key checking.
ansible all -i hosts -m ping **** ping all the slave servers from master
ansible all -i hosts -a "date"
ansible all -i hosts -a "yum install git -y"
ansible all -i hosts -a "yum install git -y" -b

Atributes used in projects -> ANSIBLE ORGANISATION:-


ANSIBLE ORGANISATION -> INVENTORIES -> HOST INVENTORY, GROUPING
GROUPING:-
[test]
[prod]

ansible prod -i hosts -a "yum install mysql -y" -b

KMS:-
Create IAM Role:
Username -> access key -> AdministratorAccess

KMS Console:
Symetric -> Encrypt and Decrypt
Alias - name
Key Administrator -> {username}

CREATE one EC2 instance


aws configure
accesskey
secret accesskey
aws --version ***aws-cli available
mkdir kms
cd kms/
vi plain.txt {copy paste user name details there}
cat plain.txt
--->copy and run encrypt commands
ls -lrth
cat encrypt.txt
rm -rf plain.txt
ls -lrth
--->copy and run decrypt commands

You might also like