Devops Notes
Devops Notes
Script:-
Aws CLI
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.
------------------------------------------------------------------------------------------------
=====================================================================
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.
================================================================================
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.
------------------------------------------------------------------------------
Curl Command :
curl logfile location : it will fetch and give u the content of the log file.
-------------------------------------------------------------------------------
-----------------------------------------------------------------------------
Linux signals:
-----------------------------------------------------------------------------
=========================================================================
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.
------------------------------------------------------------------------------------
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.
==================================================================================
GIT:
• git init
• git add
• git push
• git commit
• git status
• git diff
• git log -> to get the id.
git branch
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 merge the branches
• git merge
• git rebase
• git cherry-pick
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.
================================================================
------------------------------------------
> S3 (Storage)
> IAM
>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.
============================================================================
Ansible Galaxy: Helps to share the modules over ansible using ansible galaxy.
--------------------------------------------
Puppet -> Pull,Master/Slave, Quite tricky with windows and linux, Uses puppet language.
Performance issues.
------------------------------------------------------------------
The protocol which ansible uses for connecting to windows and linux
windows : Win RM
Linux : SSH
====================================================================
step 2: do ssh-keygen
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)
vim ansible-playbook.yml
---
hosts: all
become: root -> only requried when required to install anything using root user.
tasks:
or second method :
apt:
name:ngnix
state: present
service:
name: nginx
state: started
-------------------------------------------------------
To run the anisble playbook command:
-------------------------------------------------------------
ansible roles:
------------------------------------------------
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.