DevOps===Devlopment + Operational
Continous Integration & Continous Deployment
SDLC
Waterfall
agile
agile + devops
poc---code---build----test----release----deploy--operate---monitor
GIT-->Version Handle
Local Version Control System
Centralized Version Control System--svn
Distributed Version Control System--git
working dir-------->stage area------------>local repo----------->remote repo
yum install git -y
git init
git config -l
git --version
git add . git add filename git add --all
git status--red/green
git commit -m "msg"
git status
git push <remoterepourl> branchname
git remote add variablename remoterepourl
git push variablename branchname
(git push origin master)
git branch branchname--create a feature branch and also replicates all the commits
from the sourcebranch
git branch---it will show your standing branch
git switch/checkout for switch between branches
git blame filename---similar to cat only viewer it show the content but cant edit
the content
git merge/rebase--for incoperating all the commits
master---m1 m2 m3
feature---m1 m2 f1 f2
merge--m1 m2 f1 f2 m3
rebase---m1 m2 m3 f1 f2
:dffig BA/RE--feature/LO-master
git cherry-pick--picks the specific commit
vi [Link]
git stash---temp location
git stash list
git stash pop----cut and paste/apply---copy and paste
git stash drop--deletes only one stash at a time /apply--deletes only entire stash
at a time
git clone---clones the entire repo into your local
git fork---clones the entire repo from one account to another account
Jenkins---Conitnous Integration
java
Build Triggers
Remote Trigger
build periodically cront tab
user management---roles authorization strategy
Manage roles
global role
item role
node role
manage users
master slave---> to split the workloads
/var/lib/jenkins/workspace
/etc/default/jenkins--config of jenkins in ubuntu
/etc/sysconfig/jenkins--config of jenkins in linux
systemctl edit jenkins--port no
def port no of jenkins:8080
key pair---public key--aws stores inside the servers
private key--we need to store inside our local
ssh username@remoteip
pipelines
build pipeline
delivery pipeline
build monitor
blue ocean pipeline
parametrized job
parameters--variable name---variable value
pkg=httpd
yum install $pkg
autodeployment
.[Link]
wget -O/curl -L -o
o-save as
tar -xvzf .[Link]
cd /opt/tomcat/bin
./[Link]
cd /opt/tomcat/logs/[Link]
tail -100f [Link]
ps -ef | grep tomcat
tomcat port no:8080
imp dir in tomcat
/opt/tomcat/bin/executables
/opt/tomcat/conf/[Link]---> tomcat port no
/opt/tomcat/logs/[Link]
/opt/tomcat/webapps---root dir of tomacat where you place your code
how to check if jenkins is installed?
ps -ef | grep jenkins
systemctl status jenkins
systemctl enable jenkins--->symlink will be created
service jenkins status
jenkins --version
to automate dployment---deploy to container plugin should be installed in jenkins
Groovy Scripting
Ansible--Configuration Management tool--idempotent---commands wont run until it is
needed
chec/puppet/saltstack
ansible--agentless--agent needn't to be installed on slave-push
chef/puppet--agentbased----agent has to be installed on slave-pull
saltstack--both
windows cant be an master
ansible shouldnt be exuted as root
saltstack should be executed as root
ansible--adhoc commands
playbook--set of adhoc commands
written in yaml saved with the extension .yaml/yml
ansible-playbook [Link]
roles--set of playbook
saltstack--adhoc commands
state file--adhoc commands
state file written in yaml saved with the extension .sls
salt '*' [Link] filename
top file--set of sls
pre-requsite--python
adhoc---ansible all -i [Link] -m yum "name=httpd state=httpd" -b
- hosts: all
remote_user: ec2-user
become: yes
tasks:
- name: description
yum:
name: httpd
state: present
handlers
line in file
notify
loop
template--.j2
yum repo
started=start
stopped=stop
restart=restarted
install=present/latest
uninstall=absent
/etc/ansible/host--inventory file
/etc/ansible/[Link]--ansible cfg file
ansible-galaxy init rolename
roles:
- apache
- jenkins
ansible vault
ansible-vault encrypt/decrypt/view/edit/rekey [Link]
ansible-playbook [Link] --ask-vault-pass
docker---containerzation
physical servers----virtual servers---containers
docker file------build--------docker image--------run--------docker container
docker hub---docker images
docker file--txt file
vi Dockerfile
vi [Link]---set of dockerfile similar to playbook
docker-compose up -d --- spin up the containers
docker-compose down---spin down and also removes the containers
types of docker network
bridge--multiple containers with same port no can run on same machine--multiple app
can be deployed
host--only one container with same port no can run on same machine--single app can
be deployed
Terraform--iaac
HCL--Hashicorp Configuration Lang---this is an blend of json and yaml
extension--- .tf
terraform init
terraform plan
terraform apply
terraform destroy
terraform is an cloud agnositc tool--which means same code can be run in diff cloud
providers with only few mods
saltmaster: masterip
id: minion1
mandatory restart has to be done if we change the config file
salt-key--will list all the minions which are requesting
salt-key -a minionid---to accept minion req
salt-key -d minionid---to deletes the accepted minion req
salt '*' minionid sys.list_functions---to see all the functions which are avaialble
in salt for that particular server
g for g--grains for gathering--pull concept---it will pull all the static inform
the slave
targetting can be done in 2 ways
Compound matching -C 'L@s1,s2'
pcre--pearl compatible regular expressions--- --pcre or -E
components of an state file
id decalaration:
state declaration:
funtion declaration
salt-call [Link]--top file will get executed
splunk---monitoring
monitor---events--logs, metrics---cpu utlization,memory utl
splunk:8000--console page---index--tomcatlogs splunk forwarder
splunk enable listen 9997 splunk add forward-server
masterip:9997
splunk list forward-
server
splunk add monitor
/opt/tomcat/[Link] -index tomcatlogs
splunk min 15gb storage has to be allocated