Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!
We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!
Learn from Guru Rajesh Kumar and double your salary in just one year.
Day1
Day 2
Step 1 - Create a VMs
- Laptop
- AWS
- Azure
Step 2 - Install Docker
https://www.devopsschool.com/blog/docker-installation-and-configurations/#Docker_install_in_Ubuntu
Step 3 - D
651 docker ps
652 docker images
653 docker pull httpd
654 clear
655 ls
656 docker images
657 docker create httpd
658 docker ps -a
659 docker create httpd
660 docker ps -a
661 docker start 727efa0171e8
662 docker ps -a
663 docker start 2aa155db6eea
664 docker ps -a
665 docker stop 727efa0171e8
666 docker ps -a
667 docker start 727efa0171e8
668 docker ps -a
669 docker restart 2aa155db6eea
670 docker ps -a
671 docker pause 727efa0171e8
672 docker ps -a
673 docker unpause 727efa0171e8
674 docker ps -a
675 docker kill 727efa0171e8
676 docker ps -a
677 dockerrm 727efa0171e8
678 docker rm 727efa0171e8
679 docker ps -a
680 clear
681 ls
682 docker ps -a
683 docker inspect 2aa155db6eea
684 curl http://172.17.0.3
685 clear
686 ls
687 docker ps -a
688 docker exec -it 2aa155db6eea /bin/bash
29 Nov 2023 – Ansible 1st Session
What is Ansible?
=====================
Config mgmt tool
---------------------
Server(S) config mgt
python
release
ansible - cmd - free
tower - GUI paid
awx - UI - free
From Redhat
tool
save time -- Deployng something in 1000s of server parr
save cost -
imp quality
Agent lesss
Whats there in server == resources
-----------------------------
file
dir
package
services
user
groups
cmd
apt
yum
ps
==========================================================
Why Ansible?
If you want to Configure 100s of server parr - u can use Ansible
Other tools?
Chef puppet salt cfengine
How it works?
HUMAN ---> Ansible Control Server(ACS) ----> Ansible remote server(ARS) (S)
ACS ARS
=====================================
Linux ANY
Ansible NA
--------------> Windows (Winrm)
---------------> Linux (SSH)
Python Linux - python
windows - dotnet - ps
Component of Ansible in (ACS)
==================================
Ansible
Executables
Modules - Python code - RUN IN ARS - a code which u want to do in ARS.
https://docs.ansible.com/ansible/2.9/modules/list_of_all_modules.html
https://docs.ansible.com/ansible/2.8/modules/modules_by_category.html
plugins - Python code - RUN IN ACS -- feature of ansible
Configfile -- https://github.com/ansible/ansible/blob/stable-2.9/examples/ansible.cfg
Playbook
Yaml file whcih contains Module which to be run In ARS
Inventory
a file which has list of IP addre of ARS
30 Nov 2023 – Ansible Adhoc Commands
What is Project?
----------------------
Setup a webserver.
Psucode
-----------------
Step 1 - Install webserver apt
Step 2 - Copy index.html to /var/www/html copy
Step 3 - Start a service service
============================================
ansible localhost -m apt -a"name=apache2 state=latest"
ansible localhost -m copy -a"src=index.html dest=/var/www/html/index.html"
ansible localhost -m service -a"name=apache2 state=started"
inventory
LIST OF IP ADDRESS oF ARS
CMD | file | SCRIPT
ansible all -i 172.22.240.232, -m apt -a"name=apache2 state=latest" -u rajesh -k
ansible all -i 172.22.240.232, -m copy -a"src=index.html dest=/var/www/html/index.html" -u ubuntu -k
ansible all -i 172.22.240.232, -m service -a"name=apache2 state=started" -u ubuntu -k
ansible all -i 132.148.28.255,5.6.6.7, -m apt -a"name=apache2 state=latest" -u root -k
ansible all -i 132.148.28.255,,5.6.6.7, -m copy -a"src=index.html dest=/var/www/html/index.html" -u root -k
ansible all -i 132.148.28.255,,5.6.6.7, -m service -a"name=apache2 state=started" -u root -k
ansible all -i 172.22.240.232, -m apt -a"name=apache2 state=latest" -u rajesh -k -b -K
ansible all -i 172.22.240.232, -m copy -a"src=index.html dest=/var/www/html/index.html" -u rajesh -k -b -K
ansible all -i 172.22.240.232, -m service -a"name=apache2 state=started" -u rajesh -k -b -K
inventory
172.22.240.232
172.22.240.233
172.22.240.234
ansible all -i inventory -m apt -a"name=apache2 state=latest" -u rajesh -k -b -K
ansible all -i inventory -m copy -a"src=index.html dest=/var/www/html/index.html" -u rajesh -k -b -K
ansible all -i inventory -m service -a"name=apache2 state=started" -u rajesh -k -b -K
inventory
[web]
172.22.240.232
172.22.240.233
172.22.240.234
[db]
172.22.240.235
172.22.240.236
ansible web -i inventory -m apt -a"name=apache2 state=latest" -u rajesh -k -b -K
ansible web -i inventory -m copy -a"src=index.html dest=/var/www/html/index.html" -u rajesh -k -b -K
ansible web -i inventory -m service -a"name=apache2 state=started" -u rajesh -k -b -K
5 Dec 2023
Ansible Playbook?
===========================
What is Playbook?
----------------------
Yaml file
Contains
Hosts: localhost | groupname | all
Task(S):
- Task1 == module and its param
- task2 == module and its param
- Task3 == module and its param
Why we need playbook?
================================
To have all the modules in one file
Paramterized -
Easy to share
ansible web -i inventory -m apt -a"name=apache2 state=latest" -u rajesh -k -b -K
ansible web -i inventory -m copy -a"src=index.html dest=/var/www/html/index.html" -u rajesh -k -b -K
ansible web -i inventory -m service -a"name=apache2 state=started" -u rajesh -k -b -K
---
- name: Update web servers
hosts: web
tasks:
- name: Install apache httpd (state=present is optional)
ansible.builtin.apt:
name: apache2
state: present
- name: Copy file with owner and permissions
ansible.builtin.copy:
src: index.html
dest: /var/www/html/index.html
- name: Start service httpd, if not started
ansible.builtin.service:
name: apache2
state: started
ansible-playbook -i inventory web.yaml -u rajesh -k -b -K
===================================================
variables in Ansible Playbook?
=========================================
https://www.devopsschool.com/blog/example-code-of-ansible-variable-with-playbook/
---
- name: Update web servers
hosts: web
vars:
myname: "Rajeshkumar"
age: "18"
packagename: "apache2"
servicename: "apache2"
vars_files:
- "vars.yaml"
vars_prompt:
- name: "version"
prompt: "Which version Do you want to install?"
private: no
tasks:
- name: Install Apache in ubuntu
ansible.builtin.apt:
name: "{{ packagename }}"
state: latest
- name: Copy index.html
ansible.builtin.copy:
src: index.html
dest: /var/www/html/index.html
- name: Starting a Apache Server
ansible.builtin.service:
name: "{{ servicename }}"
state: started
- name: Print return information from the previous task
ansible.builtin.debug:
var: myname
- name: include default step variables
include_vars: tasks_var.yaml
- name: Print return information from the previous task
ansible.builtin.debug:
msg: "My Name is {{ myname }} and My age is {{ age }}"
- name: Print return information from the previous task
ansible.builtin.debug:
var: version
- name: Ansible register variable basic example
shell: "find *.txt"
args:
chdir: "/root/ansible"
register: find_output
- debug:
var: find_output
- debug:
var: find_output.stdout_lines
- debug:
var: find_output.stdout_lines[0]
ansible-playbook -i inventory web.yaml -u rajesh -k -b -K
==============================
How to set condition in Ansible Playbook?
https://www.devopsschool.com/blog/how-to-set-condition-module-executations-in-ansible-with-example/
How to do looping in Ansible Playbook?
https://www.devopsschool.com/blog/how-to-loop-and-iteration-executations-in-ansible-playbook-with-example/
Fact Vars
=============================================
==============================================
Template
Handlers
Roles
6 Dec 2023
---
- name: Update web servers
hosts: web
vars:
myname: "Rajeshkumar"
age: "18"
packagename: "apache2"
servicename: "apache2"
port: "80"
tasks:
- name: Install Apache in ubuntu
ansible.builtin.apt:
name: "{{ packagename }}"
state: latest
- name: Copy index.html
ansible.builtin.copy:
src: index.html
dest: /var/www/html/index.html
- name: Print return information from the previous task
ansible.builtin.debug:
msg: "My Name is {{ myname }} and My age is {{ age }}"
- name: Template index.html
template:
src: index.html.j2
dest: /var/www/html/index-template.html
- name: Template index.html
template:
src: ports.conf.j2
dest: /etc/apache2/ports.conf
notify:
- ReStarting a Apache Server
- name: Starting a Apache Server
ansible.builtin.service:
name: "{{ servicename }}"
state: started
handlers:
- name: ReStarting a Apache Server
ansible.builtin.service:
name: apache2
state: restarted
ansible-playbook -i inventory temp.yaml -u rajesh -k -b -K
Template
https://www.devopsschool.com/blog/ansible-template-and-handlers-explained-with-example/
Handlers
Roles
=========================================
Fixed Dir strcuture
How to manage
vars
files used in play
template
handlers
AND
Share with otthers
├── web
│ ├── README.md
│ ├── defaults VARS DONE
│ │ └── main.yml
│ ├── files files used in play
│ ├── handlers handlers tasks DONE
│ │ └── main.yml
│ ├── meta info about roles
│ │ └── main.yml
│ ├── tasks tasks
│ │ └── main.yml
│ ├── templates .j2 files
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars VARS DONE
│ └── main.yml
└── web.yaml
---
- name: Update web servers
hosts: web
roles:
- web
ansible-playbook -i inventory site.yaml -u rajesh -k -b -K
==============================================
Terraform Session
What is Terraform?
======================
IAAC
Codeing for infra automation
Code for Tools in Infra
=========================
Whats in Infra?
---------------------
TOOLS - PLATFORM - Supported by API
From Hashicorp
Release
cmd - free
ent - paid - GUI
cloud - paid - GUI
in GO
https://registry.terraform.io/browse/providers
==================================================
10 I + 10 EBS + 10 SG + 2 LB + 1 RB +1 VP + S3 + efs + ====
===================
CloudFormation
terraform
====================================
How to install it?
Download
save
set in path
https://www.devopsschool.com/blog/terraform-install-configurations/
How terraform works?
-----------------------
RULES
-------------------------
all the code must be stored .tf file
one dir ---
1. tf
multiple tfs file
===================
ONE PROJECT
How to get started?
===========================================
How to write a code?
============================
Collection of Resources and their attributes
----------------------------
resource "aws_instance" "web" {
ami =
instance_type = "t3.micro"
tags = {
Name = "HelloWorld"
}
}
resource "s3" "web" {
} }
resources1
att1
att2
resources2
att1
att2
resources3
att1
att2
resources4
att1
att2
resources5
att1
att2
C:\Users\Rajesh Kumar\Desktop\prj>doskey /h
terraform plan
terraform apply
terraform showq
cls
terraform show
terraform destroy
doskey /h