0% found this document useful (0 votes)
8 views11 pages

Devops Notes

The document provides a comprehensive overview of DevOps tools and practices, including AWS services, Linux commands, Git operations, and configuration management with Ansible and Terraform. It details essential shell commands, scripting techniques, and the use of CI/CD pipelines with Jenkins. Additionally, it highlights best practices for infrastructure as code and the differences between various tools and methodologies in DevOps.

Uploaded by

harishtemp23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views11 pages

Devops Notes

The document provides a comprehensive overview of DevOps tools and practices, including AWS services, Linux commands, Git operations, and configuration management with Ansible and Terraform. It details essential shell commands, scripting techniques, and the use of CI/CD pipelines with Jenkins. Additionally, it highlights best practices for infrastructure as code and the differences between various tools and methodologies in DevOps.

Uploaded by

harishtemp23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Devops:

Script:-

Aws CLI

Aws API (Boto 3)

Aws CFT

Terraform

Aws CDK.

-------------------------------------------------------------------------------------

======================

Linux/Shell commands:
======================

.sh : its the extension of the script file used for creating a script file.

• ls : list
• pwd : present working directory
• cd : change directory
• cd.. : go back to directory
• cd ../.. : go back multiple directory
• ls-ltr : it gives the information of files and directory stored.
• touch : create a file.
• vi : create a file and start writing. ( press the esc button and click i to start editing in the file,
to save the content again press the esc button and write :wq!)
• cat: to print the content of file.
• mkdir : to create a directory
• rm : remove a file
• rm-r : to remove a directory.
• free -g: to check the memory of the Linux machine.
• nproc : to check the number of cpu
• df-h : to check the disk size.
• top: to check all the things in one place( cpu, memory,disk).
• man: it just like the help to give u the knowledge whats the use of that command.
• echo: "to print the content."
• history: it gives the list of commands used.
• set-x: prints the heading of the functions.
• pf -ef : gives the details of all the background process running in detail.
• pf-ef | grep "process name" :gives the detail of only that listed process in the list of process.
• date: gives the date.
• awk -f : this command is used to fetech a specific column from the string[ for ex: awk-f" "
'{print $2}']
• set-e: exists the script when ever there is error in the file.(ITS BEST PRACTICE ALWAYS
INCULDE IN THE SCRIPT)
• set -o pipefail: exists the file when there is a pipe fail.
• curl : it is used to fetech the details from the internet and shows.
• wget: its same as curl command but it downloads the logfile and save it and then we can see
it.
• sudo su- : used to switch to root user.
• find : it works with the root user and it is used to find out any file or folder stored in the
system( sudo find / -name nameofthefile.)
• kill : it is used to kill any process
• traceroute: it is the command used to find the hops in the path.
• sort: for sorting
• Logrotate: for roatating and managing the log files.

------------------------------------------------------------------------------------------------

Some important info before writing into the file.


start with Shebang: #!/bin/

• #!/bin/bash ==> most widely used


• #!/bin/ksh ==> Obsoleted.
• #!/bin/sh
• #!/bin/dash

To EXECUTE A FILE IN SHELL:


---------------------------

either write sh or just ./ as a suffix before the name of the file.

=====================================================================

The Use of chmod command


it uses the logic of 421 4-> Read, 2->write, 1->execute.

Using the chmod command it gives the access to 3 people [ The Root, The group, The user].

=============================================================================
THE WAY TO CREATE AND WRITE INTO THE FILE IN SHELL.
---------------------------------------------------

vim filename.sh -> it will create and open the file -> press esc and click i to enter into editing mode ->
write shebang-> #!/bin/bash -> enter the content in the file -> press the esc button -> :wq! -> to save
the file.

now change the permission of the file chmod 777

================================================================================

# used in the file to comment.

pipe command | this command will not work if it is sending the data to "stdin"

for ex : date | echo : this will not work as date will send the data to stdin therefore it wont work.

set-e command only looks for the last line.

------------------------------------------------------------------------------

Curl Command :

curl logfile location : it will fetch and give u the content of the log file.

-------------------------------------------------------------------------------

sudo su- : switch to root user.

-----------------------------------------------------------------------------

Linux signals:

trap: it is used to trap any signal.

-----------------------------------------------------------------------------

for loop, if else loop.

=========================================================================

Cron tab:

it is like a alarm or a function through which if u set any thing at any particular time that will be
exceuted at that time without running the script everytime.

------------------------------------------------------------------------------------

To open a file in read only mode:

vim -r filename.

=========================================================================
Hard link and soft link:

hard link are used as a copy of the file to store a backup of the file and even the original copy is
deleted the backup file is there.

soft link doesn't store the backup of the file and deleting it may delete the file.

==================================================================================

traceroute: it is the command used to find the hops in the path.

GIT:
• git init
• git add
• git push
• git commit
• git status
• git diff
• git log -> to get the id.

how to make branch.

git branch

git checkout -b "name the branch"

to come to the previous version:

git reset --hard (id)

Type of branches:-

• Master/Main/Trunk
• Feature -> This branch is used to add new feature to the product.
• Release -> This branch is used for release and deliver the product to the customer.
• Hot-fix. -> This branch is used when ever any urgent issues comes from the customer we
open this branch and resloved the issue and afterwards merge this branch with the all the
other branch.

============================================================================

How to push the code to git hub

firstly connect with the remote

git remote add "location/reponame"

===================================================
How to merge the branches

there are three ways to do so -:

• git merge
• git rebase
• git cherry-pick

How to use git cherry-pick

step1: make the branch using git checkout -b command

step2: copy the ID of the new branch using LOG command

step3: using git cherry-pick ID of the branch, thereafter the head is successfully shifted to the main
branch and the new branch is successfully added to the Header.

================================================================

AWS SERVICES REQUIRED FOR DEVOPS ENGINEER:-

------------------------------------------

** ECS vs EKS (Important for interview)

> EC2 (Live Project)

> VPC (Private)

> EBS (Volume)

> S3 (Storage)

> IAM

> Cloud Watch (Monitoring)

> LAMBDA (Serverless Compute)

> Cloud Build Services:-

- Aws Code Pipeline

-Aws Code Build

-Aws Code Deploy.

> AWS Configuration :(just like monitoring)

>Billing & Costing

>AWS KMS(key management service) : used for security purpose.

>Cloud Trail: Used to store log files and helps in retreving the log files using api.

>AWS EKS
>Far Gate, ECS

> ELK (Elastic Search): used for storing login information and perform action to find out errors.

============================================================================

CONFIGURATION MANAGEMENT USING ANSIBLE:

Ansible Galaxy: Helps to share the modules over ansible using ansible galaxy.

Diff btw Ansible and Puppet

--------------------------------------------

Ansible -> Push, Agentless (Inventory, Dynamic Inventory),Passwordless autentication, Managing


Windows and Linux are pretty easy, simple to understand, Uses Yaml language(Global)

Puppet -> Pull,Master/Slave, Quite tricky with windows and linux, Uses puppet language.

Issues with Ansible

Advances modules of windows are diffcult

Debbugging logs are not easy to understand

Performance issues.

------------------------------------------------------------------

Interview Q's (Ansible)

The protocol which ansible uses for connecting to windows and linux

windows : Win RM

Linux : SSH

====================================================================

ANSIBLE (Configuration Management):

To get started we need to do the passwordless authentication first

step 1: in your ubuntu download ansible-> sudo apt install ansible

step 2: do ssh-keygen

step 3: ls to get the public key .pub

step 4: copy the public key

step 5: now open the target ubuntu follow the process till step 2

step 6: ls in the target ubuntu you will the file name as authorized keys open the file and paste the
public key copied from the first ubuntu vm in that
step7 : all done now from the main ubuntu do ssh(private id) and u will login successfully into the
target ubuntu.

=============================================================================

Ansible playbook(code)

It is written in yaml format

save the file with .yml

vim ansible-playbook.yml

THE FORMAT: (with example to install and start nignix)

---

- name: Install and start nginx

hosts: all

become: root -> only requried when required to install anything using root user.

tasks:

-name: Install ngix

shell: apt install ngnix

or second method :

-name: Install ngnix

apt:

name:ngnix

state: present

-name: Start ngnix

service:

name: nginx

state: started

-------------------------------------------------------
To run the anisble playbook command:

ansible-playbook -i inventory (name of the file)

-------------------------------------------------------------

ansible roles:

ansible-galaxy role init (name of the role)

------------------------------------------------

TERRAFORM (Infrastructure as a Code)

Its based on the concept of API of Code and developed by hashicorp.

Life Cycle->

Write->Plan->Apply

Commands:

Terraform init

Terraform plan

Terraform apply

Terraform destroy
Good Practices:

Always keep the tf file in Github and keep the state file of the terraform in s3 bucket.

Keeping dynamo db is good practice as its help in locking the state file while parallel execution of the
of the enviorment using terraform.

CICD (Continuous Integration| Continuous Delivery)


Some basis steps followed are:

• Unit Testing → Basically its manual testing


• Static Code Analysis → To check the indentation and syntax
• Code Quality/ Vulnerability → to check security vulnerability
• Automation → Its type of functional testing
• Reports → Reports of every test performed.
• Deployment → Deploy the product to the customer.

How does the CICD pipeline works:


Developer after wriritng its first code and submitting in the github (any version control) and
there after we install a cicd tool in this case its Jenkins and the Jenkins has the task to tell us
when ever any user push or commit anything in the particular repository onto the specific
branch of the github attached with the Jenkins thereafter will work as a pipeline and the
user will install some particular tools for performing the above listed tasks that’s help in
deployment of the product to the customer in a fast way therefore the name CICD.

How Jenkins work :


Jenkins automatically divides the development process in these steps as listed above and has the
feature that when the Jenkins looks that the feature is ready to be moved in the next environment it
automatically move it to the next environment and with change in environment it also have some
increase in the cpu and RAM for better management. With change in the environment master slave
number increases
In dev we have 1 master slave

In Stage we may have 3 master 5 slave

In Production we may have 3 master 30 slave.

You might also like