├── APP-deployment-process-CI_CD-pipeline.txt
├── Ansible-control and slave.docx
├── DOCKER
├── JENKINSFILE
└── Multistage-springboot.txt
├── EMAIL NOTIFICATION CONFIGURATION IN JENKINS.docx
├── HOW TO INTEGRATE GIT WITH JENKINS.docx
├── HOW TO INTEGRATE MAVEN WITH JENKINS.docx
├── How to Upload Artifact to Nexus using Jenkins.docx
├── How to check and list installed packages in CentOS Linux.docx
├── How to integrate Sonarqube with Jenkins.docx
├── How to use Terraform locals.docx
├── How to use Terraform output values.docx
├── INSTALLATION_SCRIPTS
├── How to Install Prometheus and Grafana on Ubuntu.docx
├── JAVA 17
├── Jenkins.sh
├── Portchange-J.sh
├── centos-jenkins.sh
├── certbot.sh
├── nginx-reverse-proxy.txt
├── nginx.sh
└── trivy.sh
├── Interview
└── Docker-task.txt
├── JENKINS
├── Jenkins-backup
└── jenkins-backup.docx
├── Jenkins-playbook.yml
├── KUBERNETES MASTER AND SLAVE SETUP.docx
├── LINUX COMPLETE GUIDE.docx
├── LINUX
├── LS command.txt
└── Send mail using postfix.txt
├── Lamp on ec2
├── PROJECTS
├── DevSecOps-Project
└── PROJECT-DEVSECOPS.docx
├── README.md
├── Reference-file-jenkins-terraform
├── Terraform variable.tf(part-2).docx
├── Terraform variables part-1.docx
├── Terraform
├── Ec2
│ └── Volume.tf
├── How to use Terraform Data sources.docx
├── How to use Terraform Dynamic blocks.docx
├── How to use Terraform locals.docx
├── How to use Terraform output values.docx
├── How to use Workspaces in Terraform.docx
├── IAM
│ ├── Reference.tf
│ └── main.tf
├── JENKINS
│ ├── Amazonlinux-main.tf
│ └── ubuntu.tf
├── Managing Terraform states.docx
├── Terraform variable.tf(part-2).docx
├── Terraform variables part-1.docx
├── Terraform-modules
│ ├── How Terraform modules works.docx
│ ├── Module-1
│ │ ├── main.tf
│ │ └── output.tf
│ ├── Module-2
│ │ ├── main.tf
│ │ └── output.tf
│ ├── VPC-MODULE
│ │ ├── Backend-tf
│ │ └── Reference.tf
│ ├── main.tf
│ └── variable.tf
├── Understanding terraform count.docx
├── VPC
│ ├── Reference.tf
│ ├── main.tf
│ └── variable.tf
└── What is terraform provisioner.docx
├── Tomcat.md
├── Ubuntu-nexsus-22.04.txt
├── Untitled Diagram.drawio
├── V1__rentzone-db.sql
├── Youtube-jenkinsfile1
├── ec2.tf
├── flyway.conf
├── install_jenkins.sh
├── jenkins-ec2-28-sep-2022.txt
├── jenkins-master-slave.xml
├── jfrog-22.04.yaml
├── mysql on Ec1.txt
├── pipeline-yt2.groovy
├── sonarqube.txt
└── vpc workflow complete notes.pdf
/APP-deployment-process-CI_CD-pipeline.txt:
--------------------------------------------------------------------------------
1 | 1. install and running jenkins server and install docker
2 | ==============================================================
3 | sudo apt update
4 | sudo apt install default-jdk -y
5 | wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key |sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg
6 | sudo sh -c 'echo deb [signed-by=/usr/share/keyrings/jenkins.gpg] http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
7 | sudo apt update
8 | sudo apt install jenkins -y
9 | sudo systemctl start jenkins.service
10 | sudo systemctl status jenkins
11 | sudo ufw allow 8080
12 | sudo ufw allow OpenSSH
13 | sudo ufw enable
14 | sudo ufw status
15 | sudo cat /var/lib/jenkins/secrets/initialAdminPassword
16 |
17 | sudo apt install docker.io -y
18 | sudo snap install docker
19 |
20 | Docker pipeline and Kubernetes CLI plug-ins are installed in Jenkins
21 | Add Maven plugin in Global Tool Configuration
22 |
23 | sudo usermod -aG docker jenkins
24 | sudo service jenkins restart
25 | sudo service docker restart
26 | =================================================================
27 | 2. Install awscli, eksctl, kubectl on the jenkins server
28 |
29 |
30 | awscli =>
31 | =========
32 | sudo apt install awscli
33 | aws configure => give the security credentials
34 | eksctl
35 | =======
36 | curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
37 | sudo mv /tmp/eksctl /usr/local/bin
38 | eksctl version
39 | kubectl
40 | =======
41 | sudo curl --silent --location -o /usr/local/bin/kubectl https://s3.us-west-2.amazonaws.com/amazon-eks/1.22.6/2022-03-09/bin/linux/amd64/kubectl
42 | sudo chmod +x /usr/local/bin/kubectl
43 | kubectl version --short --client
44 | =============================================================
45 |
46 | 3.Create IAM Role with Administrator Access
47 |
48 | create a role with adminstrative access policy and then attach to jenkins server
49 |
50 | ==============================================================================================
51 | 4.Switch to Jenkins user and Create a cluster using eksctl
52 |
53 | sudo su - jenkins => we are going to jenkins folder
54 | eksctl create cluster --name nag-eks --region ap-south-1
55 | --nodegroup-name my-nodes --node-type t3.small --managed --nodes 2 => create the cluster in jenkins user only
56 |
57 | aws eks update-kubeconfig --name Aj-eks --region ap-south-1 => update the kubeconfig with correct name of cluster and region
58 |
59 | cat /var/lib/jenkins/.kube/config => save this content of file for further usage.
60 |
61 | Create Credentials for connecting to Kubernetes Cluster using kubeconfig => manage Jenkins->Manage Credentials
62 | ->System->global credentials->add credentails->create new credentials with kind is secret file
63 | -> add file the kubeconfig file before you saved
64 |
65 |
66 |
67 | ==> Jenkins up and running
68 |
69 | ==> Nexus up and running
70 | ---> copy public-ip:8081 #for later use http://3.111.30.182:8081/
71 |
72 | ==> Sonarqube up And running
73 | ---> copy public-ip:9000 #for later use http://13.233.149.23:9000/
74 |
75 | ==> Manage jenkins
76 | ==> configure system
77 | ---> sonarqube servers
78 | ---> in server url paste public ip of sonarqube with 9000 # http://35.154.117.52:9000/
79 |
80 | ==> search for Nexus in configure system
81 | ---> sonatype nexus
82 | ---> in server url paste public ip of nexus repo with 8081 # http://52.66.105.63:8081/
83 |
84 | ===> Apply and save
85 |
86 | ===> In sonarqube Dashboard
87 | ---> Administration
88 | ---> configuration
89 | ---> webhooks
90 | ---> create
91 | ---> give name
92 | ---> Add jenkins url:8080/sonarqube-webhook #http://65.0.85.245:8080/sonarqube-webhook
93 | ---> create # for Qualitygate
94 |
95 | ===> In sonarqube dashboard
96 | ---> Quality gates
97 | ---> create --> Name and save
98 | ---> Add conditions
99 | ---> Bugs less than 2
100 | and coverage lessthan 80
101 | ---> Make it default
102 |
103 | ===> In sonarqube Dashboard
104 | ---> projects
105 | ---> create project (Manually)
106 | ---> give Project display name and set
107 | ---> give a name and generate token and save it in notepad for later purpose
108 | ---> locally
109 | ---> Run analysis select maven
110 | ---> and copy code that generated in run analysis for maven
111 |
112 | ===> In nexus dashboard create repo and user
113 | Create user in nexus
114 |
115 | ==> To create a new user, go to Dashboard
116 | >> Server Administrator and
117 | Configuration
118 | >> User
119 | >> Create user.
120 |
121 | In the Create User page,
122 |
123 | ID: Enter the desired ID; in our case, it is Aj (enter ur ID).
124 | First Name: Enter the desired first name; in our case, it is Ajay (enter ur name).
125 | Last Name: Enter the desired second name; in our case, it is User.
126 | Email: Enter your email address.
127 | Status: Select Active from your drop-down menu.
128 | Roles: Make sure that you grant the nx-admin role to your user.
129 | ===> create user
130 |
131 | Create a Repository in Nexus:
132 | In this step, you are going to create a Maven Hosted repository in Nexus, where your Jenkins is going to upload “build” artifacts.
133 |
134 | Step 1:
135 | Follow the below-mentioned steps to create a hosted repository, name it as (Aj-repo)(user ur name but remember it ), which you are going to use throughout this guide.
136 |
137 | on Repositories select create repository
138 | ==> Select maven2 (hosted) recipe from the list
139 | ==> Step 2:
140 | On the Create Repository page,
141 |
142 | Enter the name as Aj-repo(ur name )
143 | In Version Policy, select the Mixed type of artifacts.
144 | Under the Hosted section, in Deployment policy, select Allow redeploy. It will allow you to deploy an application multiple times.
145 | ==> create
146 |
147 | Install and Configure Nexus Plugins in Jenkins
148 | Here you are going to install and configure a few plugins for Nexus in Jenkins. For this, go to Jenkins and then
149 | ===>Dashboard
150 | >> Manage Jenkins
151 | >> Manage Plugins
152 | >> Available and search and install
153 | 1) Nexus Artifact Uploader,
154 | 2) Pipeline-Utility-Steps,
155 | 3) pipeline maven integration.
156 |
157 | ==> Restart ur jenkins
158 |
159 | ===> In jenkins dashboard
160 | ---> install plugins
161 | ---> Docker
162 | ---> Docker pipeline
163 | ---> kubernetes cli
164 |
165 | ===> Restart jenkins
166 |
167 | ===> Jenkins Dashboard
168 | ---> Manage jenkins
169 | ---> under security Managae credentials for sonarqube
170 | ---> system
171 | ----> global credentials
172 | ----> Add credential
173 | ----> kind ---> SECRET TEXT (select)
174 | ---> paste the token that generated in secret
175 | -----> id
176 | ----> Description
177 | ==> create
178 |
179 | ===> Add Nexus Repository Manager’s user credentials in Jenkins. Go to Dashboard
180 | >>manage Credentials
181 | >> System
182 | >> Global credentials (unrestricted),
183 | add ur credentials
184 | and Remember ur Nexus creds ID
185 |
186 |
187 |
188 | pipeline {
189 | agent any
190 | tools{
191 | maven "maven3" //give ur maven name from GTC
192 | }
193 | environment {
194 | // This can be nexus3 or nexus2 server
195 | NEXUS_VERSION = "nexus3"
196 | // This can be http or https
197 | NEXUS_PROTOCOL = "http"
198 | // Where your Nexus is running
199 | NEXUS_URL = "3.111.30.182:8081" #give ur nexus public ip
200 | // Repository where we will upload the artifact
201 | NEXUS_REPOSITORY= "Aj-repo" # give ur nexus repo name
202 | // Jenkins credential id to authenticate to Nexus OSS
203 | NEXUS_CREDENTIAL_ID = "nexus-id" #jenkins nexus creds id
204 | }
205 | stages {
206 | stage('Git checkout') {
207 | steps {
208 | checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 'Git-creds', url: 'https://github.com/Aj7Ay/amazon-eks-jenkins-terraform-aj7.git']]])
209 | }
210 | }
211 | stage('Build') {
212 | steps {
213 | sh 'mvn -B -DskipTests clean package'
214 | }
215 | }
216 | stage('Test') {
217 | steps {
218 | sh 'mvn test'
219 | }
220 | }
221 | stage('build && SonarQube analysis') {
222 | steps {
223 | withSonarQubeEnv('Aj') { #ur sonarqube env name
224 | // If you have configured more than one global server connection, you can specify its name
225 | // sh "${scannerHome}/bin/sonar-scanner"
226 | sh "mvn clean verify sonar:sonar -Dsonar.projectKey=Youtube -Dsonar.host.url=http://13.233.149.23:9000 -Dsonar.login=squ_a79230438858d9e22bde3a7244757facb1636522" #change ur run analysis code
227 | }
228 | }
229 | }
230 | stage('Quality_Gate') {
231 | steps{
232 | timeout(time: 2, unit: 'MINUTES') {
233 | waitForQualityGate abortPipeline: true
234 | }
235 |
236 | }
237 | }
238 | stage('Build Docker Image') {
239 | steps {
240 | script {
241 | sh 'docker build -t sevenajay/petclinic-1.0 .' #ur docker username
242 | }
243 | }
244 | }
245 | stage('Deploy Docker Image') {
246 | steps {
247 | script {
248 | withCredentials([string(credentialsId: 'docker-secret-text', variable: 'Docker')]) { //give ur docker password as secret text in jenkins creds
249 | sh 'docker login -u sevenajay -p ${Docker}'
250 | }
251 | sh 'docker push sevenajay/petclinic-1.0'
252 | }
253 | }
254 | }
255 | stage ('K8s deploy') {
256 | steps {
257 | withKubeConfig(caCertificate: '', clusterName: '', contextName: '', credentialsId: 'k8s', namespace: '', serverUrl: '') {
258 |
259 | sh "kubectl apply -f kubernetes/petclinic.yaml"
260 | }
261 | }
262 | }
263 | stage("Publish to Nexus Repository Manager") {
264 | steps {
265 | script {
266 | pom = readMavenPom file: "pom.xml";
267 | filesByGlob = findFiles(glob: "target/*.${pom.packaging}");
268 | echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
269 | artifactPath = filesByGlob[0].path;
270 | artifactExists = fileExists artifactPath;
271 | if(artifactExists) {
272 | echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}";
273 | nexusArtifactUploader(
274 | nexusVersion: NEXUS_VERSION,
275 | protocol: NEXUS_PROTOCOL,
276 | nexusUrl: NEXUS_URL,
277 | groupId: pom.groupId,
278 | version: pom.version,
279 | repository: NEXUS_REPOSITORY,
280 | credentialsId: NEXUS_CREDENTIAL_ID,
281 | artifacts: [
282 | [artifactId: pom.artifactId,
283 | classifier: '',
284 | file: artifactPath,
285 | type: pom.packaging],
286 | [artifactId: pom.artifactId,
287 | classifier: '',
288 | file: "pom.xml",
289 | type: "pom"]
290 | ]
291 | );
292 | } else {
293 | error "*** File: ${artifactPath}, could not be found";
294 | }
295 | }
296 | }
297 | }
298 | }
299 | }
300 |
--------------------------------------------------------------------------------
/Ansible-control and slave.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Ansible-control and slave.docx
--------------------------------------------------------------------------------
/DOCKER/JENKINSFILE:
--------------------------------------------------------------------------------
1 | pipeline {
2 | agent {
3 | label "Agent1"
4 | }
5 | tools {
6 | jdk "java17"
7 | maven "M3"
8 | }
9 | environment {
10 | APP_NAME = "complete-production-e2e-ajay"
11 | RELEASE = "1.0.0"
12 | DOCKER_USER = "sevenajay"
13 | DOCKER_PASS = "dockerhub"
14 | IMAGE_NAME = "${DOCKER_USER}" + "/" + "${APP_NAME}"
15 | IMAGE_TAG = "${RELEASE}-${BUILD_NUMBER}"
16 | }
17 | stages {
18 | stage("clean workspace"){
19 | steps {
20 | cleanWs()
21 | }
22 | }
23 | stage("checkout scm"){
24 | steps {
25 | checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/Aj7Ay/complete-prodcution-e2e-pipeline.git']])
26 | }
27 | }
28 | stage("build stage"){
29 | steps {
30 | sh "mvn clean package"
31 | }
32 | }
33 | stage("test code"){
34 | steps {
35 | sh "mvn test"
36 | }
37 | }
38 | stage("sonar checks"){
39 | steps {
40 | script {
41 | withSonarQubeEnv(credentialsId: 'sonar') {
42 | sh "mvn sonar:sonar"
43 | }
44 | }
45 | }
46 | }
47 | stage("quality gate"){
48 | steps {
49 | script {
50 | waitForQualityGate abortPipeline: false, credentialsId: 'sonar'
51 | }
52 | }
53 | }
54 | stage ("docker build") {
55 | steps {
56 | script {
57 | docker.withRegistry('',DOCKER_PASS) {
58 | // Remove old images from docker repository
59 | sh "docker images --format '{{.Repository}}:{{.Tag}}' | grep ${IMAGE_NAME} | grep -v ${RELEASE}-${BUILD_NUMBER} | grep -v latest | xargs -I {} docker rmi {} || true"
60 | docker_image = docker.build "${IMAGE_NAME}"
61 | }
62 | }
63 | }
64 | }
65 | stage ("Trivy image scan") {
66 | steps {
67 | script {
68 | sh "trivy image ${docker_image.id} > trivy.txt"
69 | }
70 | }
71 | }
72 | stage ("PUSH docker image") {
73 | steps {
74 | script {
75 | docker.withRegistry('',DOCKER_PASS) {
76 | docker_image.push("${IMAGE_TAG}")
77 | docker_image.push('latest')
78 | }
79 | }
80 | }
81 | }
82 | }
83 | post {
84 | always {
85 | emailext attachLog: true,
86 | subject: "'${currentBuild.result}'",
87 | body: "Project: ${env.JOB_NAME}
" +
88 | "Build Number: ${env.BUILD_NUMBER}
" +
89 | "URL: ${env.BUILD_URL}
",
90 | to: 'postbox.aj99@gmail.com',
91 | attachmentsPattern: 'trivy.txt'
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/DOCKER/Multistage-springboot.txt:
--------------------------------------------------------------------------------
1 | # Stage 1: Build the application
2 | FROM maven:3.8.1-openjdk-11 AS build
3 |
4 | # Set the working directory inside the container
5 | WORKDIR /app
6 |
7 | # Copy only the POM file to the working directory
8 | COPY pom.xml .
9 |
10 | # Download the project dependencies
11 | RUN mvn dependency:go-offline
12 |
13 | # Copy the source code to the working directory
14 | COPY src ./src
15 |
16 | # Build the application (skipping tests)
17 | RUN mvn package -DskipTests
18 |
19 | # Stage 2: Create the final image
20 | FROM openjdk:11-jre-slim
21 |
22 | # Set the working directory inside the container
23 | WORKDIR /app
24 |
25 | # Copy the built WAR file from the build stage into the 'app' directory in the container
26 | COPY --from=build /app/target/spring-petclinic-2.1.0.war ./app/spring-petclinic-2.1.0.war
27 |
28 | # Expose port 8080 for the Spring Boot application
29 | EXPOSE 8080
30 |
31 | # Set the entrypoint command to run the Spring Boot application
32 | ENTRYPOINT ["java", "-jar", "app/spring-petclinic-2.1.0.war"]
33 |
--------------------------------------------------------------------------------
/EMAIL NOTIFICATION CONFIGURATION IN JENKINS.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/EMAIL NOTIFICATION CONFIGURATION IN JENKINS.docx
--------------------------------------------------------------------------------
/HOW TO INTEGRATE GIT WITH JENKINS.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/HOW TO INTEGRATE GIT WITH JENKINS.docx
--------------------------------------------------------------------------------
/HOW TO INTEGRATE MAVEN WITH JENKINS.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/HOW TO INTEGRATE MAVEN WITH JENKINS.docx
--------------------------------------------------------------------------------
/How to Upload Artifact to Nexus using Jenkins.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/How to Upload Artifact to Nexus using Jenkins.docx
--------------------------------------------------------------------------------
/How to check and list installed packages in CentOS Linux.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/How to check and list installed packages in CentOS Linux.docx
--------------------------------------------------------------------------------
/How to integrate Sonarqube with Jenkins.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/How to integrate Sonarqube with Jenkins.docx
--------------------------------------------------------------------------------
/How to use Terraform locals.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/How to use Terraform locals.docx
--------------------------------------------------------------------------------
/How to use Terraform output values.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/How to use Terraform output values.docx
--------------------------------------------------------------------------------
/INSTALLATION_SCRIPTS/How to Install Prometheus and Grafana on Ubuntu.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/INSTALLATION_SCRIPTS/How to Install Prometheus and Grafana on Ubuntu.docx
--------------------------------------------------------------------------------
/INSTALLATION_SCRIPTS/JAVA 17:
--------------------------------------------------------------------------------
1 | Update the package list:
2 |
3 | sudo apt update
4 |
5 | Install the OpenJDK 17 package:
6 |
7 | sudo apt install openjdk-17-jdk
8 |
9 | Verify the installation by checking the Java version:
10 |
11 | java -version
12 |
13 | This command should display the installed Java version.
14 |
15 | To remove Java 17 and its associated commands, you can use the following steps:
16 | Uninstall the OpenJDK 17 package:
17 |
18 | sudo apt remove openjdk-17-jdk
19 |
20 | Remove any residual configuration files:
21 |
22 | sudo apt purge openjdk-17-jdk
23 |
24 | Additionally, if you no longer need the Java package repository, you can remove it as well:
25 |
26 | sudo apt-add-repository --remove ppa:openjdk-r/ppa
27 |
28 | That's it! Java 17 should now be uninstalled from your Ubuntu 22.04 system, and you won't have access to the Java 17 commands anymore.
29 |
30 | install java 11 and remove on ubuntu 22.04
31 |
32 | To install Java 11 on Ubuntu 22.04, you can follow these steps:
33 | Update the package list:
34 |
35 | sudo apt update
36 |
37 | Install the OpenJDK 11 package:
38 |
39 | sudo apt install openjdk-11-jdk
40 |
41 | sudo apt install default-jre
42 |
43 | Verify the installation by checking the Java version:
44 |
45 | java -version
46 |
47 | This command should display the installed Java version.
48 | To remove Java 11 and its associated commands, you can use the following steps:
49 |
50 | Uninstall the OpenJDK 11 package:
51 |
52 | sudo apt remove openjdk-11-jdk
53 |
54 | Remove any residual configuration files:
55 |
56 | sudo apt purge openjdk-11-jdk
57 |
58 | Additionally, if you no longer need the Java package repository, you can remove it as well:
59 |
60 | sudo apt-add-repository --remove ppa:openjdk-r/ppa
61 |
62 | That's it! Java 11 should now be uninstalled from your Ubuntu 22.04 system, and you won't have access to the Java 11 commands anymore.
63 |
64 |
65 |
66 | Install using the yum Package Manager on Amazon Linux & centos & Amazon 2023
67 | Amazon Corretto 17 has a 'headless' variant available. This variant omits runtime dependencies that are typically associated with GUI applications such as X11 and ALSA and is worth considering for server-oriented workloads. The 'headful' variant adds support for X11 and ALSA. There is also a 'devel' package which contains the JDK development tools, as well as a 'jmods' package that contains the Amazon Corretto 17 JMods used to create custom runtime images.
68 | Option 1: Install the headless Amazon Corretto 17:
69 | sudo yum install java-17-amazon-corretto-headless
70 | Option 2: Install the headful Amazon Corretto 17:
71 | sudo yum install java-17-amazon-corretto
72 | Option 3: Install the JDK for Amazon Corretto 17:
73 | sudo yum install java-17-amazon-corretto-devel
74 | Option 4: Install the JMods for Amazon Corretto 17:
75 | sudo yum install java-17-amazon-corretto-jmods
76 | The installation location is /usr/lib/jvm/java-17-amazon-corretto..
77 | Verify Your Installation
78 | To verify the installation, run java -version in a console. If the version string doesn't mention Corretto, run the following command to change the default java provider.
79 | sudo alternatives --config java
80 | Uninstall Amazon Corretto 17
81 | You can uninstall Amazon Corretto 17 with the following commands.
82 | Uninstall headless:
83 | sudo yum remove java-17-amazon-corretto-headless
84 | Uninstall headful:
85 | sudo yum remove java-17-amazon-corretto
86 | Uninstall devel:
87 | sudo yum remove java-17-amazon-corretto-devel
88 | Uninstall jmods:
89 | sudo yum remove java-17-amazon-corretto-jmods
90 |
91 | sudo yum install java-11-amazon-corretto (Amazon 2023)
92 |
93 | sudo amazon-linux-extras install java-openjdk11 –y (Amazon linu x2)
94 |
--------------------------------------------------------------------------------
/INSTALLATION_SCRIPTS/Jenkins.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | sudo apt update -y
3 | sudo touch /etc/apt/keyrings/adoptium.asc
4 | sudo wget -O /etc/apt/keyrings/adoptium.asc https://packages.adoptium.net/artifactory/api/gpg/key/public
5 | echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
6 | sudo apt update -y
7 | sudo apt install temurin-17-jdk -y
8 | /usr/bin/java --version
9 | curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
10 | /usr/share/keyrings/jenkins-keyring.asc > /dev/null
11 | echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
12 | https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
13 | /etc/apt/sources.list.d/jenkins.list > /dev/null
14 | sudo apt-get update -y
15 | sudo apt-get install jenkins -y
16 | sudo systemctl start jenkins
17 | sudo systemctl status jenkins
18 | sudo cat /var/lib/jenkins/secrets/initialAdminPassword
19 |
--------------------------------------------------------------------------------
/INSTALLATION_SCRIPTS/Portchange-J.sh:
--------------------------------------------------------------------------------
1 | #change Jenkins port
2 | sudo systemctl stop jenkins
3 | sudo systemctl status jenkins
4 | cd /etc/default
5 | sudo vi jenkins #chnage port HTTP_PORT=8090 and save and exit
6 | cd /lib/systemd/system
7 | sudo vi jenkins.service #change Environmenrs="Jenkins_port=8090" save and exit
8 | sudo systemctl daemon-reload
9 | sudo systemctl restart jenkins
10 | sudo systemctl status jenkins
11 |
--------------------------------------------------------------------------------
/INSTALLATION_SCRIPTS/centos-jenkins.sh:
--------------------------------------------------------------------------------
1 | sudo yum update -y
2 | sudo wget -O /etc/yum.repos.d/jenkins.repo \
3 | https://pkg.jenkins.io/redhat-stable/jenkins.repo
4 | sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
5 | sudo yum upgrade
6 | # Add required dependencies for the jenkins package
7 | sudo yum install java-11-openjdk
8 | sudo yum install jenkins
9 | sudo systemctl daemon-reload
10 |
--------------------------------------------------------------------------------
/INSTALLATION_SCRIPTS/certbot.sh:
--------------------------------------------------------------------------------
1 | Step 1 — Installing Certbot
2 | Certbot recommends using their snap package for installation. Snap packages work on nearly all Linux distributions, but they require that you’ve installed snapd first in order to manage snap packages. Ubuntu 22.04 comes with support for snaps out of the box, so you can start by making sure your snapd core is up to date:
3 |
4 | sudo snap install core; sudo snap refresh core
5 | If you’re working on a server that previously had an older version of certbot installed, you should remove it before going any further:
6 |
7 | sudo apt remove certbot
8 | After that, you can install the certbot package:
9 |
10 | sudo snap install --classic certbot
11 | Finally, you can link the certbot command from the snap install directory to your path, so you’ll be able to run it by just typing certbot. This isn’t necessary with all packages, but snaps tend to be less intrusive by default, so they don’t conflict with any other system packages by accident:
12 |
13 | sudo ln -s /snap/bin/certbot /usr/bin/certbot
14 | Now that we have Certbot installed, let’s run it to get our certificate.
15 |
--------------------------------------------------------------------------------
/INSTALLATION_SCRIPTS/nginx-reverse-proxy.txt:
--------------------------------------------------------------------------------
1 | sudo vi /etc/nginx/sites-available/mrcloudbook.online
2 | Paste in the following configuration block, which is similar to the default, but updated for our new directory and domain name:
3 | Paste the below (replace your domain)
4 |
5 | upstream jenkins{
6 | server 127.0.0.1:8080;
7 | }
8 |
9 | server{
10 | listen 80;
11 | server_name ur dns name;
12 |
13 | access_log /var/log/nginx/jenkins.access.log;
14 | error_log /var/log/nginx/jenkins.error.log;
15 |
16 | proxy_buffers 16 64k;
17 | proxy_buffer_size 128k;
18 |
19 | location / {
20 | proxy_pass http://jenkins;
21 | proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
22 | proxy_redirect off;
23 |
24 | proxy_set_header Host $host;
25 | proxy_set_header X-Real-IP $remote_addr;
26 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
27 | proxy_set_header X-Forwarded-Proto https;
28 | }
29 |
30 | }
31 | Next, let’s enable the file by creating a link from it to the sites-enabled directory, which Nginx reads from during startup:
32 | Run from shell prompt (replace your domain)
33 |
34 | sudo ln -s /etc/nginx/sites-available/mrcloudbook.online /etc/nginx/sites-enabled/
35 | Next, test to make sure that there are no syntax errors in any of your Nginx files:
36 | Run from shell prompt
37 |
38 | sudo nginx -t
39 | If there aren’t any problems, restart Nginx to enable your changes:
40 | Run from shell prompt
41 |
42 | sudo systemctl restart nginx
43 | Nginx should now be serving Jenkins from your domain name. You can test this by navigating to http://your_domain
44 |
45 |
46 | sudo certbot --nginx -d mrcloudbook.online
47 |
--------------------------------------------------------------------------------
/INSTALLATION_SCRIPTS/nginx.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | sudo apt update
3 | sudo apt upgrade
4 | sudo apt install nginx -y
5 | sudo systemctl start nginx
6 | sudo systemctl enable nginx
7 | sudo systemctl status nginx
8 |
--------------------------------------------------------------------------------
/INSTALLATION_SCRIPTS/trivy.sh:
--------------------------------------------------------------------------------
1 | sudo apt-get install wget apt-transport-https gnupg lsb-release -y
2 |
3 | wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg > /dev/null
4 |
5 | echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
6 |
7 | sudo apt-get update
8 |
9 | sudo apt-get install trivy -y
10 |
--------------------------------------------------------------------------------
/Interview/Docker-task.txt:
--------------------------------------------------------------------------------
1 | How I Crushed My Interview Task with Oracle VM, Linux and Docker for a Web App
2 |
3 |
4 | 1.Install Oracle VM VirtualBox on your Windows machine by downloading and running the installation file from the official website.
5 |
6 | 2.Create a new Linux virtual machine (VM) within VirtualBox by selecting "New" from the VirtualBox Manager window, giving it a name and selecting "Linux" as the type and "Ubuntu" as the version. Allocate enough resources (RAM, CPU, storage) to the VM to ensure that it can run smoothly.
7 |
8 | 3.Install the Ubuntu Linux operating system on the newly created VM by downloading the ISO file from the official Ubuntu website and selecting it as the boot disk for the VM. Follow the installation prompts to complete the installation.
9 |
10 | 4.Install Docker on the Linux VM by following the official installation guide for Ubuntu. This will involve adding the Docker repository to your package manager, updating it and installing the Docker engine.
11 |
12 | 5.Create a Dockerfile for your web application by creating a new file in your project directory with the name "Dockerfile" (no extension).
13 |
14 | 6.Create three Docker containers from the image you just built by running the "docker run" command with different container names for each instance. Make sure to map the application port to a different port on the host machine for each container to avoid port conflicts.
15 |
16 | 7.Test that your web application is accessible from each container by opening a web browser within each container and navigating to the appropriate URL.
17 |
18 | 8.Use the Docker networking feature to connect it to the three containers running the web application. This will allow you to access all three containers from a single container by referencing their IP addresses or hostnames.
19 |
20 | 9.Access your web application from your Windows laptop, you need to forward the port from your VirtualBox VM to your host machine. To do this, go to the settings for your Linux VM in VirtualBox, select "Network", and then select "Port Forwarding". Add a new rule that maps the container port of your web application to a port on your Windows host machine.
21 |
22 | 10.Once you have forwarded the port, you should be able to access your web application from your Windows laptop by opening a web browser and navigating to the IP address of your Linux VM and the port you forwarded.
23 |
24 | 11.To access your web application from another machine on your network, you need to ensure that your Linux VM is accessible from that machine. This will involve configuring your network settings for the Linux VM to use a bridged adapter or NAT network in VirtualBox. Consult the VirtualBox documentation for instructions on how to do this.
25 |
26 | Once your Linux VM is accessible from another machine, you can access your web application by navigating to the IP address of your Linux VM and the port you forwarded.
27 |
28 | 12.To use a DNS name instead of a port to access your web application, you need to set up a DNS server on your network and configure it to resolve the DNS name you want to use to the IP address of your Linux VM. You can use a free DNS service like No-IP or DynDNS to set up a dynamic DNS name that will automatically update when your IP address changes.
29 |
30 | Once you have set up the DNS name, you can access your web application by navigating to the DNS name instead of the IP address and port.
31 |
32 |
33 |
34 | # Base image
35 | FROM nginx:latest
36 |
37 | # Copy application files to container
38 | COPY index.html /usr/share/nginx/html
39 |
40 | # Expose port 80 for HTTP
41 | EXPOSE 80
42 |
43 | # Start Nginx and serve the HTML file
44 | CMD ["nginx", "-g", "daemon off;"]
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | youtube Allow Fullscreen
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | #!/bin/bash
70 |
71 | # Build the Docker image
72 | docker build -t my-html-app .
73 |
74 | # Run three containers
75 | docker run -d --name container1 -p 8081:80 my-html-app
76 | docker run -d --name container2 -p 8082:80 my-html-app
77 | docker run -d --name container3 -p 8083:80 my-html-app
78 |
79 |
80 | #to give user root permissions
81 | sudo groupadd docker
82 | sudo usermod -aG $user
83 | newgrp docker
84 |
85 |
86 | #To enter into container
87 | docker exec -it bash
88 |
89 |
90 | #To create docker network
91 | docker network create $name
92 | docker network connect $name $container name
93 |
94 | #To see docker networks
95 | docker network ls
96 | #To inspect
97 | docker network inspect $network id
98 |
99 | #to see container id
100 | docker inspect | grep "IPAddress"
101 |
102 |
103 | #to stop containers
104 | docker stop
105 | or
106 | docker stop container name
107 |
108 |
109 | #to delete stopped containers and network at once
110 | docker system prune
111 | y
112 |
113 |
114 | Thanks
115 | Ajay kumar Yegireddi
116 |
117 |
118 |
--------------------------------------------------------------------------------
/JENKINS/Jenkins-backup:
--------------------------------------------------------------------------------
1 | Pre-requisites :
2 | Aws account
3 | Jenkins machine up and running
4 | Aws cli installed on instance
5 | Iam role of s3 full access
6 | S3 bucket
7 |
8 | Disaster Recovery: Backups ensure that you have a copy of your Jenkins configuration and data in case of system failures, hardware crashes, or data corruption. If your Jenkins server goes down, you can restore from a backup to get your system up and running again quickly.
9 |
10 | Configuration Management: Jenkins backups capture the configuration settings, job configurations, plugin configurations, and other customizations you have made to your Jenkins environment. By taking regular backups, you can preserve your Jenkins setup and easily restore it to the desired state.
11 |
12 | Job History and Build Data: Jenkins stores valuable information about past builds, including logs, test results, and build artifacts. Backing up this data ensures that you retain a historical record of your software builds,which can be useful for troubleshooting, auditing, and performance analysis.
13 |
14 | Plugin and Tool Preservation: Jenkins relies on various plugins and tools to extend its functionality.Backing up your Jenkins installation ensures that you have copies of these plugins and tools, making it easier to restore the entire ecosystem in case of a catastrophic event.
15 |
16 | Smooth Migration or Upgrades: Backups are particularly crucial when migrating or upgrading your Jenkins instance. They allow you to transfer your existing configuration and data to the new environment without losing any critical information or customizations.
17 |
18 | Compliance and Security: Some organizations may have compliance requirements that mandate regular backups to ensure data integrity and security. Backing up Jenkins helps meet these requirements and provides an additional layer of protection against data loss or unauthorized access.
19 |
20 |
21 | 0ff217bf9c894f968fad32ea17679aeb
22 |
23 |
24 | pipeline {
25 | agent any
26 | stages {
27 | stage ("cleaningup workspace") {
28 | steps {
29 | cleanWs()
30 | }
31 | }
32 | stage ("checkout scm code") {
33 | steps {
34 | checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/Aj7Ay/complete-prodcution-e2e-pipeline.git']])
35 | }
36 | }
37 | }
38 | }
39 | #!/bin/bash
40 | sudo apt update -y
41 | sudo apt upgrade -y
42 | wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | tee /etc/apt/keyrings/adoptium.asc
43 | echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list
44 | sudo apt update -y
45 | sudo apt install temurin-17-jdk -y
46 | /usr/bin/java --version
47 | curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
48 | /usr/share/keyrings/jenkins-keyring.asc > /dev/null
49 | echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
50 | https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
51 | /etc/apt/sources.list.d/jenkins.list > /dev/null
52 | sudo apt-get update -y
53 | sudo apt-get install jenkins –y
54 | sudo systemctl start jenkins
55 | sudo systemctl status jenkins
56 |
57 | s3fullaccess777
58 |
59 | sudo apt install python3-pip
60 |
61 | sudo pip3 install awscli
62 |
63 | PROCESS :
64 | Log into main Jenkins machine
65 | And attach a s3full access role to it
66 | And connect instance using putty or mobaxtreme
67 | Install awscli
68 | sudo apt install python3-pip
69 | sudo pip3 install awscli
70 | And stop Jenkins machine using below command
71 | sudo su
72 | systemctl stop Jenkins
73 | make Jenkins folder as zip by below command
74 | tar –zcvf /var/lib/jenkins/
75 | copy file to s3 bucket
76 | aws s3 cp s3:///
77 | and delete instance
78 |
79 | START A NEW INSTNACE
80 | Launch Jenkins in it
81 | Add iam role to it
82 | Install aws cli as previous
83 | Stop Jenkins machine
84 | Sudo su
85 | And remove Jenkins folder by below command
86 | rm –rf /var/lib/Jenkins
87 | copy file from s3 bucket to instance
88 | aws s3 cp s3://bucketname/filename filename
89 |
90 | unzip the file
91 | tar –zxvf /
92 | start jenkins
93 |
94 | aws
95 | 2 sudo apt install python3-pip
96 | 3 pip3 install awscli
97 | 4 aws
98 | 5 sudo systemctl status jenkins
99 | 6 systemctl stop jenkins
100 | 7 sudo systemctl status jenkins
101 | 8 cd /var/lib/jenkins/
102 | 9 ls
103 | 10 cd jobs
104 | 11 ls
105 | 12 cd ..
106 | 13 cd /home/ubuntu/
107 | 14 ls
108 | 15 rm -rf /var/lib/jenkins/
109 | 16 aws s3 cp s3://s3fullaccess777/jenkins-backup.tar.gz jenkins-backup.tar.gz (s3 to instance )
110 | Aws s3 cp Jenkins-backup.tar.gz s3://bucketname/filename (instance to s3)
111 | 17 ls
112 | 18 cd /var/lib/
113 | 19 ls
114 | 20 cd /home/ubuntu/
115 | 21 ls
116 | 22 tar -zxvf jenkins-backup.tar.gz -C /
117 | 23 systemctl start jenkins
118 | 24 systemctl status jenkins
119 | 25 history
120 |
--------------------------------------------------------------------------------
/JENKINS/jenkins-backup.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/JENKINS/jenkins-backup.docx
--------------------------------------------------------------------------------
/Jenkins-playbook.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Install jenkins
3 | hosts: Jenkins-server
4 | become: yes
5 | become_user: root
6 |
7 | tasks:
8 | - name: yum update
9 | yum:
10 | name: '*'
11 | state: latest
12 |
13 | - name: add the jenkins repo
14 | get_url:
15 | url: https://pkg.jenkins.io/redhat-stable/jenkins.repo
16 | dest: /etc/yum.repos.d/jenkins.repo
17 |
18 | - name: import a key file from jenkins-ci
19 | ansible.builtin.rpm_key:
20 | state: present
21 | key: https://pkg.jenkins.io/redhat/jenkins.io.key
22 |
23 | - name: yum update
24 | yum:
25 | name: '*'
26 | state: latest
27 |
28 | - name: install java
29 | shell: amazon-linux-extras install java-openjdk11 -y
30 |
31 | - name: Install jenkins
32 | yum:
33 | name: jenkins
34 | state: latest
35 |
36 | - name: Start jenkins
37 | ansible.builtin.systemd:
38 | enabled: yes
39 | name: jenkins
40 | state: started
--------------------------------------------------------------------------------
/KUBERNETES MASTER AND SLAVE SETUP.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/KUBERNETES MASTER AND SLAVE SETUP.docx
--------------------------------------------------------------------------------
/LINUX COMPLETE GUIDE.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/LINUX COMPLETE GUIDE.docx
--------------------------------------------------------------------------------
/LINUX/LS command.txt:
--------------------------------------------------------------------------------
1 | 1. List Files and Directories in Linux
2 | Running ls command with no option list files and directories in a bare format where we won’t be able to view details like file types, size, modified date and time, permission and links, etc.
3 | # ls
4 |
5 | 0001.pcap Desktop Downloads
6 | index.html install.log.syslog Pictures
7 | Templates anaconda-ks.cfg Documents
8 | fbcmd_update.php install.log Music
9 | Public Videos
10 | 2. Long Listing of Files in Linux
11 |
12 | Here, ls -l (-l is a character, not one) shows file or directory, size, modified date and time, file or folder name and owner of the file, and its permission.
13 | # ls -l
14 |
15 | total 176
16 | -rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
17 | -rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg
18 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop
19 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents
20 | drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads
21 | -rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
22 | -rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
23 | -rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
24 | -rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog
25 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Music
26 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Pictures
27 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Public
28 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Templates
29 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Videos
30 | 3. View Hidden Files in Linux
31 | List all files including hidden files starting with ‘.‘.
32 | # ls -a
33 |
34 | . .bashrc Documents .gconfd
35 | install.log .nautilus .pulse-cookie
36 | .. .cache Downloads .gnome2
37 | install.log .netstat.swp .recently-used.xbel
38 | 0001.pcap .config .elinks .gnome2_private
39 | .kde .opera .spice-vdagent
40 | anaconda-ks.cfg .cshrc .esd_auth .gtk-bookmarks
41 | .libreoffice Pictures .tcshrc
42 | .bash_history .dbus .fbcmd .gvfs
43 | .local .pki Templates
44 | .bash_logout Desktop fbcmd_update.php .ICEauthority
45 | .mozilla Public Videos
46 | .bash_profile .digrc .gconf index.html
47 | Music .pulse .wireshark
48 | 4. List Files with Human Readable Format
49 | With a combination of -lh option, shows sizes in a human-readable format.
50 | # ls -lh
51 |
52 | total 176K
53 | -rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
54 | -rw-------. 1 root root 1.6K Jul 31 02:17 anaconda-ks.cfg
55 | drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Desktop
56 | drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Documents
57 | drwxr-xr-x. 4 root root 4.0K Aug 16 02:55 Downloads
58 | -rw-r--r--. 1 root root 21K Aug 12 12:42 fbcmd_update.php
59 | -rw-r--r--. 1 root root 46K Jul 31 09:58 index.html
60 | -rw-r--r--. 1 root root 48K Jul 31 02:17 install.log
61 | -rw-r--r--. 1 root root 12K Jul 31 02:13 install.log.syslog
62 | drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Music
63 | drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Pictures
64 | drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Public
65 | drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Templates
66 | drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Videos
67 | 5. List Files and Directories with ‘/’ Character at the End
68 | Using the -F option with the ls command will add the '/' character at the end of each directory.
69 | # ls -F
70 |
71 | 0001.pcap Desktop/ Downloads/ index.html
72 | install.log.syslog Pictures/ Templates/
73 | anaconda-ks.cfg Documents/ fbcmd_update.php install.log
74 | Music/ Public/ Videos/
75 | 6. List Files in Reverse Order in Linux
76 | The following command with the ls -r option display files and directories in reverse order.
77 | # ls -r
78 |
79 | Videos Public Music install.log
80 | fbcmd_update.php Documents anaconda-ks.cfg
81 | Templates Pictures install.log.syslog index.html
82 | Downloads Desktop 0001.pcap
83 | 7. Recursively list Sub-Directories in Linux
84 | ls -R option will list very long listing directory trees. See an example of the output of the command.
85 | # ls -R
86 |
87 | total 1384
88 | -rw-------. 1 root root 33408 Aug 8 17:25 anaconda.log
89 | -rw-------. 1 root root 30508 Aug 8 17:25 anaconda.program.log
90 |
91 | ./httpd:
92 | total 132
93 | -rw-r--r-- 1 root root 0 Aug 19 03:14 access_log
94 | -rw-r--r--. 1 root root 61916 Aug 10 17:55 access_log-20120812
95 |
96 | ./lighttpd:
97 | total 68
98 | -rw-r--r-- 1 lighttpd lighttpd 7858 Aug 21 15:26 access.log
99 | -rw-r--r--. 1 lighttpd lighttpd 37531 Aug 17 18:21 access.log-20120819
100 |
101 | ./nginx:
102 | total 12
103 | -rw-r--r--. 1 root root 0 Aug 12 03:17 access.log
104 | -rw-r--r--. 1 root root 390 Aug 12 03:17 access.log-20120812.gz
105 | 8. List Files and Directories in Reverse Order in Linux
106 | A combination of -ltr will show the latest modification file or directory date as last.
107 | # ls -ltr
108 |
109 | total 176
110 | -rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog
111 | -rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
112 | -rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg
113 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop
114 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Videos
115 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Templates
116 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Public
117 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Pictures
118 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Music
119 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents
120 | -rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
121 | -rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
122 | drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads
123 | -rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
124 | 9. Sort Files by File Size in Linux
125 | With a combination of -lS displays file size in order, will display big in size first.
126 | # ls -lS
127 |
128 | total 176
129 | -rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
130 | -rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
131 | -rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
132 | -rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog
133 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop
134 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents
135 | drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads
136 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Music
137 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Pictures
138 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Public
139 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Templates
140 | drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Videos
141 | -rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg
142 | -rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
143 | 10. Display Inode number of File or Directory
144 | We can see some numbers printed before the file/directory name. With -i options list file/directory with an inode number.
145 | # ls -i
146 |
147 | 20112 0001.pcap 23610 Documents 23793 index.html
148 | 23611 Music 23597 Templates 23564 anaconda-ks.cfg
149 | 23595 Downloads 22 install.log 23612 Pictures 23613 Videos
150 | 23594 Desktop 23585 fbcmd_update.php 35 install.log.syslog
151 | 23601 Public
152 | 11. Shows Version of ls Command
153 |
154 | Check the version of the ls command.
155 | # ls --version
156 |
157 | ls (GNU coreutils) 8.4
158 | Copyright (C) 2010 Free Software Foundation, Inc.
159 | License GPLv3+: GNU GPL version 3 or later .
160 | This is free software: you are free to change and redistribute it.
161 | There is NO WARRANTY, to the extent permitted by law.
162 | Written by Richard M. Stallman and David MacKenzie.
163 | 12. Show ls Command Help Page
164 | The help page of ls command with their option.
165 | # ls --help
166 |
167 | Usage: ls [OPTION]... [FILE]...
168 | 13. List Directory Information in Linux
169 | With ls -l command list files under directory /tmp. Wherein with -ld parameters displays information of /tmp directory.
170 | # ls -l /tmp
171 | total 408
172 | drwx------. 2 narad narad 4096 Aug 2 02:00 CRX_75DAF8CB7768
173 | -r--------. 1 root root 384683 Aug 4 12:28 htop-1.0.1.tar.gz
174 | drwx------. 2 root root 4096 Aug 4 11:20 keyring-6Mfjnk
175 | drwx------. 2 root root 4096 Aug 16 01:33 keyring-pioZJr
176 | drwx------. 2 gdm gdm 4096 Aug 21 11:26 orbit-gdm
177 | drwx------. 2 root root 4096 Aug 19 08:41 pulse-gl6o4ZdxQVrX
178 | drwx------. 2 narad narad 4096 Aug 4 08:16 pulse-UDH76ExwUVoU
179 | drwx------. 2 gdm gdm 4096 Aug 21 11:26 pulse-wJtcweUCtvhn
180 | -rw-------. 1 root root 300 Aug 16 03:34 yum_save_tx-2012-08-
181 | 16-03-34LJTAa1.yumtx
182 | # ls -ld /tmp/
183 |
184 | drwxrwxrwt. 13 root root 4096 Aug 21 12:48 /tmp/
185 | 14. Display UID and GID of Files
186 | To display UID and GID of files and directories. use option -n with ls command.
187 | # ls -n
188 |
189 | total 36
190 | drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Downloads
191 | drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Music
192 | drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Pictures
193 | -rw-rw-r--. 1 500 500 12 Aug 21 13:06 tmp.txt
194 | drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Videos
195 | 15. ls command and its Aliases
196 | We have made an alias for ls command, when we execute ls command it’ll take the -l option by default and display a long listing as mentioned earlier.
197 | # alias ls="ls -l"
198 | Note: We can see a number of aliases available in your system with the below alias command and the same can be unalias as shown below example.
199 | # alias
200 |
201 | alias cp='cp -i'
202 | alias l.='ls -d .* --color=auto'
203 | alias ll='ls -l --color=auto'
204 | alias ls='ls --color=auto'
205 | alias mv='mv -i'
206 | alias rm='rm -i'
207 | alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
208 | To remove an alias previously defined, just use the unalias command.
209 | # unalias ls
210 |
211 |
--------------------------------------------------------------------------------
/LINUX/Send mail using postfix.txt:
--------------------------------------------------------------------------------
1 | ===> postfix setup amazon linux
2 | ===> Edit configuration for Google smtp
3 | ===> How to send mail
4 | ===> How to attach a file in email
5 |
6 |
7 | firstly launch an ec2 instance
8 |
9 | ----> sudo yum update -yum
10 | ----> sudo yum install postfix -y
11 | ----> sudo yum install mailx -y
12 |
13 | This will install postfix and mailx on the instance
14 |
15 | you can check using below commands
16 |
17 | ---> rpm -qa | grep mailx
18 | ---> rpm -qa | grep postfix
19 |
20 |
21 | lets change postfix configuration in the file #main.cf
22 |
23 | /etc/postfix/main.cf
24 |
25 | ----> cd /etc/postfix # this will change directory from home to /etc/postfix
26 |
27 | you can check the file using
28 |
29 | ----> ls -lrt command
30 |
31 | make an duplicate of configuration file incase of error
32 |
33 | ---> cp main.cf main.cf_bkp #it will create an duplicate file
34 |
35 | lets open the file
36 |
37 | ---> vi main.cf
38 |
39 | ----> use this to search /relayhost
40 |
41 | under
42 | #relayhost = uucphost
43 | #relayhost = [an.ip.add.ress]
44 | add this liness ----->>> underthose
45 |
46 | relayhost = [smtp.gmail.com]:587
47 |
48 | esc and save the file
49 |
50 | sudo hostname new_hostname
51 |
52 | sudo reboot
53 |
54 | ssh again into terminal after one minute
55 |
56 | ---> hostname -f
57 | in case it still ip address
58 |
59 | then chnage directly by going to the file
60 |
61 | ---> sudo vi /etc/hostname
62 | and edit your name #in my case Ajay
63 |
64 | ---> sudo reboot
65 |
66 | and again see ----> hostname -f
67 |
68 | if you see ur name then again go to postfix configuration file
69 |
70 | ---> sudo reboot
71 |
72 | ---> cd /etc/postfix
73 |
74 | ----> vi main.cf
75 |
76 | search using /myhostname
77 |
78 | under #Wmyhostname = virtual.domain.tld
79 |
80 | add this line
81 |
82 | --> myhostname = ur name gave at /etc/hostname
83 |
84 | and at the end of the file add these lines
85 |
86 |
87 | ###############################################
88 | # Location of sasl_passwd we saved
89 | smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
90 |
91 | # Enables SASL authentication for postfix
92 | smtp_sasl_auth_enable = yes
93 | smtp_tls_security_level = encrypt
94 |
95 | # Disallow methods that allow anonymous authentication
96 | smtp_sasl_security_options = noanonymous
97 |
98 |
99 | save and exit main.cf file
100 |
101 |
102 | then ---> mkdir sasl at # /etc/postfix folder
103 |
104 | cd /etc/postfix/sasl
105 |
106 | touch sasl_passwd it creates an empty file
107 |
108 | Then go to your email in browser
109 |
110 | click on your profile
111 | then --> click on manage your google account
112 | security in left side panel clcik it
113 |
114 | make sure enabled two step verfication
115 |
116 | and search option inside search for app
117 |
118 | App passwords select
119 | prompts for email password enter and go inside
120 |
121 | selct app (other custom name )
122 | add name and generate password
123 | you will get password in yellow color background copy it and come back to terminal
124 |
125 | cd /etc/postfix/sasl
126 |
127 | ---> vi sasl_passwd
128 |
129 | enter this
130 |
131 | [smtp.gmail.com]:587 urmail:password that ur copied before
132 |
133 | save and exit from it
134 |
135 |
136 | and change the sasl_passwd file into db file by using this command
137 |
138 | postmap /etc/postfix/sasl/sasl_passwd enter here
139 |
140 | you will generate sasl_passwd.db file
141 |
142 | ls -lrt
143 |
144 | change permission
145 | chmod 600 *
146 |
147 | ls -lrt see rw for only root
148 |
149 | systemctl start postfix.service
150 | systemctl enable postfix.service
151 | systemctl status postfix.service
152 |
153 | active then
154 |
155 | send mail
156 |
157 | ---> echo "Test mail" | mail -s "Ajay Test" urmail and enter
158 |
159 | you will get mail
160 |
161 | and if you want send file also
162 |
163 | vi testfile
164 | enter any text u want save and exit
165 |
166 |
167 | echo "Test mail" | mail -s "Ajay Test" -a testfile urmail and enter
--------------------------------------------------------------------------------
/Lamp on ec2:
--------------------------------------------------------------------------------
1 | 1. Install Apache server on Ubuntu
2 |
3 | sudo apt install apache2
4 |
5 |
6 |
7 | 2. Install php runtime and php mysql connector
8 |
9 | sudo apt install php libapache2-mod-php php-mysql
10 |
11 |
12 |
13 | 3. Install MySQL server
14 |
15 | sudo apt install mysql-server
16 |
17 |
18 |
19 | 4. Login to MySQL server
20 |
21 | sudo mysql -u root
22 |
23 |
24 |
25 | 5. Change authentication plugin to mysql_native_password (change the password to something strong)
26 |
27 | ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'Testpassword@123';
28 |
29 |
30 |
31 | 6. Create a new database user for wordpress (change the password to something strong)
32 |
33 | CREATE USER 'wp_user'@localhost IDENTIFIED BY 'Testpassword@123';
34 |
35 |
36 |
37 | 7. Create a database for wordpress
38 |
39 | CREATE DATABASE wp;
40 |
41 |
42 |
43 | 8. Grant all privilges on the database 'wp' to the newly created user
44 |
45 | GRANT ALL PRIVILEGES ON wp.* TO 'wp_user'@localhost;
46 |
47 |
48 |
49 | 9. Download wordpress
50 |
51 | cd /tmp
52 |
53 | wget https://wordpress.org/latest.tar.gz
54 |
55 |
56 |
57 | 10. Unzip
58 |
59 | tar -xvf latest.tar.gz
60 |
61 | public-ip/wordpress
62 |
63 |
64 |
65 | 11. Move wordpress folder to apache document root
66 |
67 | sudo mv wordpress/ /var/www/html
68 |
69 |
70 |
71 | 12. Command to restart/reload apache server
72 |
73 | sudo systemctl restart apache2
74 |
75 | OR
76 |
77 | sudo systemctl reload apache2
78 |
79 |
80 |
81 | cd /etc/apache2/sites-available/
82 |
83 | Sudo nano 000-default-conf
84 |
85 | Document /var/www/html/wordpress
86 |
87 | sudo systemctl restart apache2
88 |
89 |
90 |
91 | 13. Install certbot
92 |
93 | sudo apt-get update
94 |
95 | sudo apt install certbot python3-certbot-apache
96 |
97 |
98 |
99 | 14. Request and install ssl on your site with certbot
100 |
101 | sudo certbot --apache
102 |
103 |
104 |
--------------------------------------------------------------------------------
/PROJECTS/DevSecOps-Project:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/PROJECTS/PROJECT-DEVSECOPS.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/PROJECTS/PROJECT-DEVSECOPS.docx
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # youtube_notes
2 | Aws devops and linux
3 | use it
4 | let me know if mistakes in the notes or in the youtube videos
5 |
--------------------------------------------------------------------------------
/Reference-file-jenkins-terraform:
--------------------------------------------------------------------------------
1 | # configured aws provider with proper credentials
2 | provider "aws" {
3 | region = "us-east-1"
4 | profile = "mr-cloud-book"
5 | }
6 |
7 |
8 | # create default vpc if one does not exit
9 | resource "aws_default_vpc" "default_vpc" {
10 |
11 | tags = {
12 | Name = "default vpc"
13 | }
14 | }
15 |
16 |
17 | # use data source to get all avalablility zones in region
18 | data "aws_availability_zones" "available_zones" {}
19 |
20 |
21 | # create default subnet if one does not exit
22 | resource "aws_default_subnet" "default_az1" {
23 | availability_zone = data.aws_availability_zones.available_zones.names[0]
24 |
25 | tags = {
26 | Name = "default subnet"
27 | }
28 | }
29 |
30 |
31 | # create security group for the ec2 instance
32 | resource "aws_security_group" "ec2_security_group" {
33 | name = "ec2 security group"
34 | description = "allow access on ports 8080 and 22"
35 | vpc_id =
36 |
37 | # allow access on port 8080
38 | ingress {
39 | description = "http proxy access"
40 | from_port =
41 | to_port =
42 | protocol =
43 | cidr_blocks =
44 | }
45 |
46 | # allow access on port 22
47 | ingress {
48 | description = "ssh access"
49 | from_port =
50 | to_port =
51 | protocol =
52 | cidr_blocks =
53 | }
54 |
55 | egress {
56 | from_port =
57 | to_port =
58 | protocol =
59 | cidr_blocks =
60 | }
61 |
62 | tags = {
63 | Name = "jenkins server security group"
64 | }
65 | }
66 |
67 |
68 | # use data source to get a registered amazon linux 2 ami
69 | data "aws_ami" "amazon_linux_2" {
70 | most_recent = true
71 | owners = ["amazon"]
72 |
73 | filter {
74 | name = "owner-alias"
75 | values = ["amazon"]
76 | }
77 |
78 | filter {
79 | name = "name"
80 | values = ["amzn2-ami-hvm*"]
81 | }
82 | }
83 |
84 |
85 | # launch the ec2 instance and install website
86 | resource "aws_instance" "ec2_instance" {
87 | ami =
88 | instance_type =
89 | subnet_id =
90 | vpc_security_group_ids =
91 | key_name =
92 | # user_data = file("install_jenkins.sh")
93 |
94 | tags = {
95 | Name =
96 | }
97 | }
98 |
99 |
100 | # an empty resource block
101 | resource "null_resource" "name" {
102 |
103 | # ssh into the ec2 instance
104 | connection {
105 | type =
106 | user =
107 | private_key = file()
108 | host =
109 | }
110 |
111 | # copy the install_jenkins.sh file from your computer to the ec2 instance
112 | provisioner "file" {
113 | source =
114 | destination =
115 | }
116 |
117 | # set permissions and run the install_jenkins.sh file
118 | provisioner "remote-exec" {
119 | inline = [
120 | ]
121 | }
122 |
123 | # wait for ec2 to be created
124 | depends_on = []
125 | }
126 |
127 |
128 | # print the url of the jenkins server
129 | output "website_url" {
130 | value = join ("", ["http://", aws_instance.ec2_instance.public_dns, ":", "8080"])
131 | }
132 |
--------------------------------------------------------------------------------
/Terraform variable.tf(part-2).docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform variable.tf(part-2).docx
--------------------------------------------------------------------------------
/Terraform variables part-1.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform variables part-1.docx
--------------------------------------------------------------------------------
/Terraform/Ec2/Volume.tf:
--------------------------------------------------------------------------------
1 | root_block_device {
2 |
3 | volume_size = 16
4 |
5 | volume_type = "gp2"
6 | delete_on_termination = true
7 | }
8 |
9 | # this code also attachs extra volume to ec2 instnace
10 | ebs_block_device {
11 | device_name = "/dev/sdf"
12 | volume_size = 1
13 | volume_type = "gp2"
14 | }
15 |
16 | #second method
17 |
18 | resource "aws_ebs_volume" "ebs-volume-1" {
19 | availability_zone =
20 | size = 10
21 | type = "gp2"
22 | tags {
23 | Name = "Extra volume data"
24 | }
25 | }
26 |
27 | resource "aws_volume_attachment" "ebs-volume-1-attachment" {
28 | device_name = "/dev/xvdh"
29 | volume_id =
30 | instance_id =
31 | }
32 |
33 |
34 | Complete script:
35 |
36 | provider "aws" {
37 | region = "ap-south-2"
38 | profile = "mr-cloud-book"
39 | }
40 | variable "sg_ports" {
41 | type = list(number)
42 | description = "list of ingress ports"
43 | default = [8080, 80, 9000, 22, 443]
44 | }
45 | resource "aws_instance" "ec2_example" {
46 | ami = "ami-09d8b83b58eabf58b"
47 | instance_type = "t3.micro"
48 | key_name = "mr-cloud-book"
49 | vpc_security_group_ids = [aws_security_group.main.id]
50 | #user_data = file("install_website.sh")
51 | root_block_device {
52 | volume_size = 16
53 | volume_type = "gp2"
54 | delete_on_termination = true
55 | }
56 | tags = {
57 | "Name" = "Hyd-Region"
58 | }
59 | }
60 | resource "aws_ebs_volume" "ebs-volume-1" {
61 | availability_zone = aws_instance.ec2_example.availability_zone
62 | size = 20
63 | type = "gp2"
64 | tags = {
65 | Name = "Extra volume data"
66 | }
67 | }
68 |
69 | resource "aws_volume_attachment" "ebs-volume-1-attachment" {
70 | device_name = "/dev/xvdh"
71 | volume_id = aws_ebs_volume.ebs-volume-1.id
72 | instance_id = aws_instance.ec2_example.id
73 | }
74 | resource "aws_security_group" "main" {
75 | dynamic "ingress" {
76 | for_each = var.sg_ports
77 | iterator = port
78 | content {
79 | from_port = port.value
80 | to_port = port.value
81 | protocol = "tcp"
82 | cidr_blocks = ["0.0.0.0/0"]
83 | }
84 | }
85 | egress {
86 | from_port = 0
87 | to_port = 0
88 | protocol = "-1"
89 | cidr_blocks = ["0.0.0.0/0"]
90 | }
91 | }
92 | resource "aws_key_pair" "deployer" {
93 | key_name = "mr-cloud-book"
94 | public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCihDAhkioSWqfTDzJSKag2lqQCPNh/hayPl+3TTogfK2+F8WiWIn3wXeP8F1xT1VzZY/s+nGMvT+zGGtAfNk8WWdw7orLY7LRYP3zYNzlDSc8U3bg+CA3B4POaQvK6ypUAc+SW2zaRMyLYaQpMsF/ZD3h7G6Ptr/7+A8xabEk2Lm4aHgXRLoqDOBnK99W1ri9i8Qc7HK3hgYdD3Bnc917NkNsKh/qaOpKmpslKkRWICrDIR6wFnZYVWTkizr85KAjuC7HKPilCNkntYoYA6HDFhPPPZSb53+E8pFnwxSQjJzks9q1B+viZ0BUUbLSBMYnlR9CFrkAS2JI5BvrtGodV admin@DESKTOP-0S3CU0K"
95 |
96 | }
97 | output "public_ip" {
98 | value = aws_instance.ec2_example.public_ip
99 | }
100 |
101 |
102 | Here's an example of how you could mount an EBS volume to an EC2 instance using a Terraform script: using Remote exec :
103 |
104 | provider "aws" {
105 | region = "us-west-2"
106 | }
107 |
108 | resource "aws_instance" "example" {
109 | ami = "ami-0c55b159cbfafe1f0"
110 | instance_type = "t2.micro"
111 |
112 | root_block_device {
113 | volume_size = "8"
114 | volume_type = "gp2"
115 | }
116 | }
117 |
118 | resource "aws_ebs_volume" "example" {
119 | availability_zone = "us-west-2a"
120 | size = "8"
121 | type = "gp2"
122 |
123 | tags = {
124 | Name = "example-volume"
125 | }
126 | }
127 |
128 | resource "aws_volume_attachment" "example" {
129 | device_name = "/dev/sdf"
130 | volume_id = aws_ebs_volume.example.id
131 | instance_id = aws_instance.example.id
132 | }
133 |
134 | resource "null_resource" "example" {
135 | provisioner "remote-exec" {
136 | inline = [
137 | "sudo mkfs -t ext4 /dev/xvdf",
138 | "sudo mount /dev/xvdf /mnt",
139 | "sudo echo '/dev/xvdf /mnt ext4 defaults 0 0' | sudo tee -a /etc/fstab"
140 | ]
141 |
142 | connection {
143 | type = "ssh"
144 | host = aws_instance.example.public_ip
145 | user = "ubuntu"
146 | private_key = file("~/.ssh/id_rsa")
147 | }
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/Terraform/How to use Terraform Data sources.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform/How to use Terraform Data sources.docx
--------------------------------------------------------------------------------
/Terraform/How to use Terraform Dynamic blocks.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform/How to use Terraform Dynamic blocks.docx
--------------------------------------------------------------------------------
/Terraform/How to use Terraform locals.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform/How to use Terraform locals.docx
--------------------------------------------------------------------------------
/Terraform/How to use Terraform output values.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform/How to use Terraform output values.docx
--------------------------------------------------------------------------------
/Terraform/How to use Workspaces in Terraform.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform/How to use Workspaces in Terraform.docx
--------------------------------------------------------------------------------
/Terraform/IAM/Reference.tf:
--------------------------------------------------------------------------------
1 | # configured aws provider with proper credentials
2 | provider "aws" {
3 | region =
4 | profile =
5 | }
6 |
7 | # create an iam user
8 | resource "aws_iam_user" "iam_user" {
9 | name =
10 | }
11 |
12 | # give the iam user programatic access
13 | resource "aws_iam_access_key" "iam_access_key" {
14 | user =
15 | }
16 |
17 | # create the inline policy
18 | data "aws_iam_policy_document" "s3_get_put_detele_policy_document" {
19 | statement {
20 | actions = [
21 | ]
22 |
23 | resources = [
24 | ]
25 | }
26 | }
27 |
28 | # attach the policy to the user
29 | resource "aws_iam_user_policy" "s3_get_put_detele_policy" {
30 | name =
31 | user =
32 | policy =
33 | }
34 |
--------------------------------------------------------------------------------
/Terraform/IAM/main.tf:
--------------------------------------------------------------------------------
1 | # configured aws provider with proper credentials
2 | provider "aws" {
3 | region = "ap-south-1"
4 | profile = "mr-cloud-book"
5 | }
6 |
7 | # create an iam user
8 | resource "aws_iam_user" "iam_user" {
9 | name = "Ajay-cloud"
10 | }
11 |
12 | # give the iam user programatic access
13 | resource "aws_iam_access_key" "iam_access_key" {
14 | user = aws_iam_user.iam_user.name
15 | }
16 |
17 | # create the inline policy
18 | data "aws_iam_policy_document" "s3_get_put_detele_policy_document" {
19 | statement {
20 | actions = [
21 | "s3:PutObject",
22 | "s3:GetObject",
23 | "s3:DeleteObject"
24 | ]
25 |
26 | resources = [
27 | "arn:aws:s3:::s3fullaccess777/*"
28 | ]
29 | }
30 | }
31 |
32 | # attach the policy to the user
33 | resource "aws_iam_user_policy" "s3_get_put_detele_policy" {
34 | name = "s3-get-put-delete"
35 | user = aws_iam_user.iam_user.name
36 | policy = data.aws_iam_policy_document.s3_get_put_detele_policy_document.json
37 | }
38 |
--------------------------------------------------------------------------------
/Terraform/JENKINS/Amazonlinux-main.tf:
--------------------------------------------------------------------------------
1 | # create security group for the ec2 instance
2 | resource "aws_security_group" "ec2_security_group" {
3 | name = "ec2 security group"
4 | description = "allow access on ports 8080 and 22"
5 |
6 | # allow access on port 8080
7 | ingress {
8 | description = "http proxy access"
9 | from_port = 8080
10 | to_port = 8080
11 | protocol = "tcp"
12 | cidr_blocks = ["0.0.0.0/0"]
13 | }
14 |
15 | # allow access on port 22
16 | ingress {
17 | description = "ssh access"
18 | from_port = 22
19 | to_port = 22
20 | protocol = "tcp"
21 | cidr_blocks = ["0.0.0.0/0"]
22 | }
23 |
24 | egress {
25 | from_port = 0
26 | to_port = 0
27 | protocol = -1
28 | cidr_blocks = ["0.0.0.0/0"]
29 | }
30 |
31 | tags = {
32 | Name = "jenkins server security group"
33 | }
34 | }
35 |
36 | resource "aws_instance" "jenkins" {
37 | ami = "ami-078efad6f7ec18b8a"
38 | instance_type = "t2.micro"
39 | key_name = "MUMBAI"
40 | vpc_security_group_ids = [aws_security_group.ec2_security_group.id]
41 | #associate_public_ip_address = false
42 |
43 | tags = {
44 | Name = "jenkins-instance"
45 | }
46 | user_data = <<-EOF
47 | #!/bin/bash
48 | # Installing Java
49 | sudo yum update -y
50 | sudo amazon-linux-extras install java-openjdk11 -y
51 | java --version
52 |
53 | # Installing wget and necessary packages for HTTP and HTTPS
54 | sudo yum install wget -y
55 | sudo yum install ca-certificates -y
56 | sudo yum install nss -y
57 |
58 | # Downloading Jenkins repository file and importing the key
59 | sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
60 | sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io-2023.key
61 | sudo yum upgrade -y
62 |
63 | # Installing Jenkins
64 | sudo yum install jenkins -y
65 | sudo systemctl start jenkins
66 | sudo systemctl enable jenkins
67 | EOF
68 | }
69 |
--------------------------------------------------------------------------------
/Terraform/JENKINS/ubuntu.tf:
--------------------------------------------------------------------------------
1 | # create security group for the ec2 instance
2 | resource "aws_security_group" "ec2_security_group" {
3 | name = "ec2 security group"
4 | description = "allow access on ports 8080 and 22"
5 |
6 | # allow access on port 8080
7 | ingress {
8 | description = "http proxy access"
9 | from_port = 8080
10 | to_port = 8080
11 | protocol = "tcp"
12 | cidr_blocks = ["0.0.0.0/0"]
13 | }
14 |
15 | # allow access on port 22
16 | ingress {
17 | description = "ssh access"
18 | from_port = 22
19 | to_port = 22
20 | protocol = "tcp"
21 | cidr_blocks = ["0.0.0.0/0"]
22 | }
23 |
24 | egress {
25 | from_port = 0
26 | to_port = 0
27 | protocol = -1
28 | cidr_blocks = ["0.0.0.0/0"]
29 | }
30 |
31 | tags = {
32 | Name = "jenkins server security group"
33 | }
34 | }
35 |
36 | resource "aws_instance" "jenkins" {
37 | ami = "ami-0f5ee92e2d63afc18"
38 | instance_type = "t2.medium"
39 | key_name = "MUMBAI"
40 | vpc_security_group_ids = [aws_security_group.ec2_security_group.id]
41 | associate_public_ip_address = false
42 |
43 | tags = {
44 | Name = "jenkins-instance"
45 | }
46 | user_data = <<-EOF
47 | #!/bin/bash
48 | # Installing Java
49 | apt update -y
50 | apt install openjdk-11-jre -y
51 | java --version
52 |
53 | # Installing Jenkins
54 | curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
55 | /usr/share/keyrings/jenkins-keyring.asc > /dev/null
56 | echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
57 | https://pkg.jenkins.io/debian binary/ | sudo tee \
58 | /etc/apt/sources.list.d/jenkins.list > /dev/null
59 | sudo apt-get update -y
60 | sudo apt-get install jenkins -y
61 | EOF
62 | }
63 |
--------------------------------------------------------------------------------
/Terraform/Managing Terraform states.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform/Managing Terraform states.docx
--------------------------------------------------------------------------------
/Terraform/Terraform variable.tf(part-2).docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform/Terraform variable.tf(part-2).docx
--------------------------------------------------------------------------------
/Terraform/Terraform variables part-1.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform/Terraform variables part-1.docx
--------------------------------------------------------------------------------
/Terraform/Terraform-modules/How Terraform modules works.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform/Terraform-modules/How Terraform modules works.docx
--------------------------------------------------------------------------------
/Terraform/Terraform-modules/Module-1/main.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">=0.12"
3 | }
4 |
5 | resource "aws_instance" "ec2_example" {
6 |
7 | ami = "ami-09d8b83b58eabf58b"
8 | instance_type = "t3.micro"
9 | key_name = "mr-cloud-book"
10 | vpc_security_group_ids = [aws_security_group.main.id]
11 | user_data = <<-EOF
12 | #!/bin/bash
13 | sudo su
14 | yum update -y
15 | yum install -y httpd
16 | cd /var/www/html
17 | wget https://github.com/azeezsalu/techmax/archive/refs/heads/main.zip
18 | unzip main.zip
19 | cp -r techmax-main/* /var/www/html/
20 | rm -rf techmax-main main.zip
21 | systemctl enable httpd
22 | systemctl start httpd
23 | EOF
24 | }
25 |
26 | resource "aws_security_group" "main" {
27 | name = "EC2-webserver-SG-1"
28 | description = "Webserver for EC2 Instances"
29 |
30 | ingress {
31 | from_port = 80
32 | protocol = "TCP"
33 | to_port = 80
34 | cidr_blocks = ["0.0.0.0/0"]
35 | }
36 |
37 | ingress {
38 | from_port = 22
39 | protocol = "TCP"
40 | to_port = 22
41 | cidr_blocks = ["0.0.0.0/0"]
42 | }
43 |
44 | egress {
45 | from_port = 0
46 | protocol = "-1"
47 | to_port = 0
48 | cidr_blocks = ["0.0.0.0/0"]
49 | }
50 | }
51 |
52 | resource "aws_key_pair" "deployer" {
53 | key_name = "mr-cloud-book"
54 | public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCihDAhkioSWqfTDzJSKag2lqQCPNh/hayPl+3TTogfK2+F8WiWIn3wXeP8F1xT1VzZY/s+nGMvT+zGGtAfNk8WWdw7orLY7LRYP3zYNzlDSc8U3bg+CA3B4POaQvK6ypUAc+SW2zaRMyLYaQpMsF/ZD3h7G6Ptr/7+A8xabEk2Lm4aHgXRLoqDOBnK99W1ri9i8Qc7HK3hgYdD3Bnc917NkNsKh/qaOpKmpslKkRWICrDIR6wFnZYVWTkizr85KAjuC7HKPilCNkntYoYA6HDFhPPPZSb53+E8pFnwxSQjJzks9q1B+viZ0BUUbLSBMYnlR9CFrkAS2JI5BvrtGodV admin@DESKTOP-0S3CU0K"
55 | }
56 |
--------------------------------------------------------------------------------
/Terraform/Terraform-modules/Module-1/output.tf:
--------------------------------------------------------------------------------
1 | output "public_ip" {
2 | value = aws_instance.ec2_example.public_ip
3 | }
4 |
--------------------------------------------------------------------------------
/Terraform/Terraform-modules/Module-2/main.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">=0.12"
3 | }
4 | resource "aws_instance" "ec2_example" {
5 | ami = "ami-09d8b83b58eabf58b"
6 | instance_type = "t3.micro"
7 | key_name = "Aj"
8 | vpc_security_group_ids = [aws_security_group.main.id]
9 |
10 | user_data = <<-EOF
11 | #!/bin/bash
12 | sudo su
13 | yum update -y
14 | amazon-linux-extras install nginx1 -y
15 | systemctl enable nginx
16 | systemctl start nginx
17 | systemctl status nginx
18 | sudo echo youtube Allow Fullscreen " > /usr/share/nginx/html/index.html
19 | systemctl restart nginx
20 | EOF
21 | }
22 |
23 | resource "aws_security_group" "main" {
24 | name = "EC2-webserver-SG-2"
25 | description = "Webserver for EC2 Instances"
26 |
27 | ingress {
28 | from_port = 8080
29 | protocol = "TCP"
30 | to_port = 8080
31 | cidr_blocks = ["0.0.0.0/0"]
32 | }
33 | ingress {
34 | from_port = 80
35 | protocol = "TCP"
36 | to_port = 80
37 | cidr_blocks = ["0.0.0.0/0"]
38 | }
39 |
40 | ingress {
41 | from_port = 22
42 | protocol = "TCP"
43 | to_port = 22
44 | cidr_blocks = ["0.0.0.0/0"]
45 | }
46 |
47 | egress {
48 | from_port = 0
49 | protocol = "-1"
50 | to_port = 0
51 | cidr_blocks = ["0.0.0.0/0"]
52 | }
53 | }
54 |
55 | resource "aws_key_pair" "deployer" {
56 | key_name = "Aj"
57 | public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDG8osL7/jMzXeDCqphDwpT6t6j6xWCyWYI6h+uN/FX1OhdhrP8caxHy+dWCyxIceb3dV11ADWzxIZRUCWfkNc3QT2cBnfCerjECATp1/QpfkT9KMBrk4m2iBKBQ4y9pUesALQyWFI4TAWsiV4a1iJR6CmBO85wa+d9cMd70PmHZJLRe5LaAK5IaRK/eta5Zo9lgpP7ujTO+nRigWd1fTZiS3Hu8qyzr8lRm0khDqHK7+8jl2uKznFvr06f9XR9g/LaNQ9Gavmo4rcE493uzxKwz7HhIXx5W1MMOVgisaEI/XWtjAjRjOE1zAtyF8YcNFqC032nHQUaw4w6Xk8tZTvKWtE+JwFQQ9Zs8Y6B0HrBq9o6wWYBNWDvgOWeMtjJnI2rzVyBGMrD5Pna5V92jPczjGKShpo3QOeC1If36jcEUuhQcdRsOp2zh7u2R/uUukh2nulqXILYOGIG2uN2xzo5hnzCkCUVkuCxDE2pFHbOM2nVn25rc1U70RRz7TksmW8= admin@DESKTOP-0S3CU0K"
58 | }
59 |
--------------------------------------------------------------------------------
/Terraform/Terraform-modules/Module-2/output.tf:
--------------------------------------------------------------------------------
1 | output "public_dns" {
2 | value = aws_instance.ec2_example.public_dns
3 | }
4 |
--------------------------------------------------------------------------------
/Terraform/Terraform-modules/VPC-MODULE/Backend-tf:
--------------------------------------------------------------------------------
1 | # store the terraform state file in s3
2 | terraform {
3 | backend "s3" {
4 | bucket =
5 | key =
6 | region =
7 | profile =
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Terraform/Terraform-modules/VPC-MODULE/Reference.tf:
--------------------------------------------------------------------------------
1 | # create vpc
2 | resource "aws_vpc" "vpc" {
3 | cidr_block =
4 | instance_tenancy =
5 | enable_dns_hostnames = true
6 |
7 | tags = {
8 | Name = "${}-vpc"
9 | }
10 | }
11 |
12 | # create internet gateway and attach it to vpc
13 | resource "aws_internet_gateway" "internet_gateway" {
14 | vpc_id =
15 |
16 | tags = {
17 | Name = "${}-igw"
18 | }
19 | }
20 |
21 | # use data source to get all avalablility zones in region
22 | data "aws_availability_zones" "available_zones" {}
23 |
24 | # create public subnet az1
25 | resource "aws_subnet" "public_subnet_az1" {
26 | vpc_id =
27 | cidr_block =
28 | availability_zone =
29 | map_public_ip_on_launch =
30 |
31 | tags = {
32 | Name =
33 | }
34 | }
35 |
36 | # create public subnet az2
37 | resource "aws_subnet" "public_subnet_az2" {
38 | vpc_id =
39 | cidr_block =
40 | availability_zone =
41 | map_public_ip_on_launch =
42 |
43 | tags = {
44 | Name =
45 | }
46 | }
47 |
48 | # create route table and add public route
49 | resource "aws_route_table" "public_route_table" {
50 | vpc_id =
51 |
52 | route {
53 | cidr_block =
54 | gateway_id =
55 | }
56 |
57 | tags = {
58 | Name =
59 | }
60 | }
61 |
62 | # associate public subnet az1 to "public route table"
63 | resource "aws_route_table_association" "public_subnet_az1_route_table_association" {
64 | subnet_id =
65 | route_table_id =
66 | }
67 |
68 | # associate public subnet az2 to "public route table"
69 | resource "aws_route_table_association" "public_subnet_az2_route_table_association" {
70 | subnet_id =
71 | route_table_id =
72 | }
73 |
74 | # create private app subnet az1
75 | resource "aws_subnet" "private_app_subnet_az1" {
76 | vpc_id =
77 | cidr_block =
78 | availability_zone =
79 | map_public_ip_on_launch =
80 |
81 | tags = {
82 | Name =
83 | }
84 | }
85 |
86 | # create private app subnet az2
87 | resource "aws_subnet" "private_app_subnet_az2" {
88 | vpc_id =
89 | cidr_block =
90 | availability_zone =
91 | map_public_ip_on_launch =
92 |
93 | tags = {
94 | Name =
95 | }
96 | }
97 |
98 | # create private data subnet az1
99 | resource "aws_subnet" "private_data_subnet_az1" {
100 | vpc_id =
101 | cidr_block =
102 | availability_zone =
103 | map_public_ip_on_launch =
104 |
105 | tags = {
106 | Name =
107 | }
108 | }
109 |
110 | # create private data subnet az2
111 | resource "aws_subnet" "private_data_subnet_az2" {
112 | vpc_id =
113 | cidr_block =
114 | availability_zone =
115 | map_public_ip_on_launch =
116 |
117 | tags = {
118 | Name =
119 | }
120 |
--------------------------------------------------------------------------------
/Terraform/Terraform-modules/main.tf:
--------------------------------------------------------------------------------
1 | provider "aws" {
2 | region = var.region
3 | profile = var.profile
4 | }
5 |
6 | module "webserver-1" {
7 | source = ".//module-1"
8 | }
9 |
10 | module "webserver-2" {
11 | source = ".//module-2"
12 | }
13 |
--------------------------------------------------------------------------------
/Terraform/Terraform-modules/variable.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "ap-south-2"
3 | }
4 | variable "profile" {
5 | default = "mr-cloud-book"
6 | }
7 |
--------------------------------------------------------------------------------
/Terraform/Understanding terraform count.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform/Understanding terraform count.docx
--------------------------------------------------------------------------------
/Terraform/VPC/Reference.tf:
--------------------------------------------------------------------------------
1 | # create vpc
2 | # terraform aws create vpc
3 | resource "aws_vpc" "vpc" {
4 | cidr_block =
5 | instance_tenancy =
6 | enable_dns_hostnames =
7 |
8 | tags = {
9 | Name =
10 | }
11 | }
12 |
13 | # create internet gateway and attach it to vpc
14 | # terraform aws create internet gateway
15 | resource "aws_internet_gateway" "internet_gateway" {
16 | vpc_id =
17 |
18 | tags = {
19 | Name =
20 | }
21 | }
22 |
23 | # create public subnet az1
24 | # terraform aws create subnet
25 | resource "aws_subnet" "public_subnet_az1" {
26 | vpc_id =
27 | cidr_block =
28 | availability_zone =
29 | map_public_ip_on_launch =
30 |
31 | tags = {
32 | Name =
33 | }
34 | }
35 |
36 | # create public subnet az2
37 | # terraform aws create subnet
38 | resource "aws_subnet" "public_subnet_az2" {
39 | vpc_id =
40 | cidr_block =
41 | availability_zone =
42 | map_public_ip_on_launch =
43 |
44 | tags = {
45 | Name =
46 | }
47 | }
48 |
49 | # create route table and add public route
50 | # terraform aws create route table
51 | resource "aws_route_table" "public_route_table" {
52 | vpc_id =
53 |
54 | route {
55 | cidr_block =
56 | gateway_id =
57 | }
58 |
59 | tags = {
60 | Name =
61 | }
62 | }
63 |
64 | # associate public subnet az1 to "public route table"
65 | # terraform aws associate subnet with route table
66 | resource "aws_route_table_association" "public_subnet_az1_route_table_association" {
67 | subnet_id =
68 | route_table_id =
69 | }
70 |
71 | # associate public subnet az2 to "public route table"
72 | # terraform aws associate subnet with route table
73 | resource "aws_route_table_association" "public_subnet_2_route_table_association" {
74 | subnet_id =
75 | route_table_id =
76 | }
77 |
78 | # create private app subnet az1
79 | # terraform aws create subnet
80 | resource "aws_subnet" "private_app_subnet_az1" {
81 | vpc_id =
82 | cidr_block =
83 | availability_zone =
84 | map_public_ip_on_launch =
85 |
86 | tags = {
87 | Name =
88 | }
89 | }
90 |
91 | # create private app subnet az2
92 | # terraform aws create subnet
93 | resource "aws_subnet" "private_app_subnet_az2" {
94 | vpc_id =
95 | cidr_block =
96 | availability_zone =
97 | map_public_ip_on_launch =
98 |
99 | tags = {
100 | Name =
101 | }
102 | }
103 |
104 | # create private data subnet az1
105 | # terraform aws create subnet
106 | resource "aws_subnet" "private_data_subnet_az1" {
107 | vpc_id =
108 | cidr_block =
109 | availability_zone =
110 | map_public_ip_on_launch =
111 |
112 | tags = {
113 | Name =
114 | }
115 | }
116 |
117 | # create private data subnet az2
118 | # terraform aws create subnet
119 | resource "aws_subnet" "private_data_subnet_az2" {
120 | vpc_id =
121 | cidr_block =
122 | availability_zone =
123 | map_public_ip_on_launch =
124 |
125 | tags = {
126 | Name =
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/Terraform/VPC/main.tf:
--------------------------------------------------------------------------------
1 | # create vpc
2 | # terraform aws create vpc
3 | resource "aws_vpc" "vpc" {
4 | cidr_block = var.vpc_cidr
5 | instance_tenancy = "default"
6 | enable_dns_hostnames = true
7 |
8 | tags = {
9 | Name = " cloud vpc"
10 | }
11 | }
12 |
13 | # create internet gateway and attach it to vpc
14 | # terraform aws create internet gateway
15 | resource "aws_internet_gateway" "internet_gateway" {
16 | vpc_id = aws_vpc.vpc.id
17 |
18 | tags = {
19 | Name = " Cloud internet gateway"
20 | }
21 | }
22 |
23 | # create public subnet az1
24 | # terraform aws create subnet
25 | resource "aws_subnet" "public_subnet_az1" {
26 | vpc_id = aws_vpc.vpc.id
27 | cidr_block = var.public_subnet_az1_cidr
28 | availability_zone = "ap-south-1a"
29 | map_public_ip_on_launch = true
30 |
31 | tags = {
32 | Name = "Public subnet az1"
33 | }
34 | }
35 |
36 | # create public subnet az2
37 | # terraform aws create subnet
38 | resource "aws_subnet" "public_subnet_az2" {
39 | vpc_id = aws_vpc.vpc.id
40 | cidr_block = var.public_subnet_az2_cidr
41 | availability_zone = "ap-south-1b"
42 | map_public_ip_on_launch = true
43 |
44 | tags = {
45 | Name = "Public subnet az2"
46 | }
47 | }
48 |
49 | # create route table and add public route
50 | # terraform aws create route table
51 | resource "aws_route_table" "public_route_table" {
52 | vpc_id = aws_vpc.vpc.id
53 |
54 | route {
55 | cidr_block = "0.0.0.0/0"
56 | gateway_id = aws_internet_gateway.internet_gateway.id
57 | }
58 |
59 | tags = {
60 | Name = "Route table for public subnets"
61 | }
62 | }
63 |
64 | # associate public subnet az1 to "public route table"
65 | # terraform aws associate subnet with route table
66 | resource "aws_route_table_association" "public_subnet_az1_route_table_association" {
67 | subnet_id = aws_subnet.public_subnet_az1.id
68 | route_table_id = aws_route_table.public_route_table.id
69 | }
70 |
71 | # associate public subnet az2 to "public route table"
72 | # terraform aws associate subnet with route table
73 | resource "aws_route_table_association" "public_subnet_2_route_table_association" {
74 | subnet_id = aws_subnet.public_subnet_az2.id
75 | route_table_id = aws_route_table.public_route_table.id
76 | }
77 |
78 | # create private app subnet az1
79 | # terraform aws create subnet
80 | resource "aws_subnet" "private_app_subnet_az1" {
81 | vpc_id = aws_vpc.vpc.id
82 | cidr_block = var.private_app_subnet_az1_cidr
83 | availability_zone = "ap-south-1a"
84 | map_public_ip_on_launch = false
85 |
86 | tags = {
87 | Name = "Private app subnet az1"
88 | }
89 | }
90 |
91 | # create private app subnet az2
92 | # terraform aws create subnet
93 | resource "aws_subnet" "private_app_subnet_az2" {
94 | vpc_id = aws_vpc.vpc.id
95 | cidr_block = var.private_app_subnet_az2_cidr
96 | availability_zone = "ap-south-1b"
97 | map_public_ip_on_launch = false
98 |
99 | tags = {
100 | Name = "private app subnet az2"
101 | }
102 | }
103 |
104 | # create private data subnet az1
105 | # terraform aws create subnet
106 | resource "aws_subnet" "private_data_subnet_az1" {
107 | vpc_id = aws_vpc.vpc.id
108 | cidr_block = var.private_data_subnet_az1_cidr
109 | availability_zone = "ap-south-1a"
110 | map_public_ip_on_launch = false
111 |
112 | tags = {
113 | Name = "Private data subnet az1"
114 | }
115 | }
116 |
117 | # create private data subnet az2
118 | # terraform aws create subnet
119 | resource "aws_subnet" "private_data_subnet_az2" {
120 | vpc_id = aws_vpc.vpc.id
121 | cidr_block = var.private_data_subnet_az2_cidr
122 | availability_zone = "ap-south-1b"
123 | map_public_ip_on_launch = false
124 |
125 | tags = {
126 | Name = "private data subnet az2"
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/Terraform/VPC/variable.tf:
--------------------------------------------------------------------------------
1 | # create vpc cidr blocks
2 |
3 | variable "vpc_cidr" {
4 | description = "VPc cidr block"
5 | type = string
6 | default = "10.0.0.0/16"
7 | }
8 |
9 | variable "public_subnet_az1_cidr" {
10 | description = "public subnet az1 cidr"
11 | type = string
12 | default = "10.0.0.0/24"
13 | }
14 |
15 | variable "public_subnet_az2_cidr" {
16 | description = "public subnet az2 cidr"
17 | type = string
18 | default = "10.0.1.0/24"
19 | }
20 |
21 | variable "private_app_subnet_az1_cidr" {
22 | description = "private app subnet az1"
23 | type = string
24 | default = "10.0.2.0/24"
25 | }
26 |
27 | variable "private_app_subnet_az2_cidr" {
28 | description = "private app subnet az2"
29 | type = string
30 | default = "10.0.3.0/24"
31 | }
32 |
33 | variable "private_data_subnet_az1_cidr" {
34 | description = "private data subnet az1"
35 | type = string
36 | default = "10.0.4.0/24"
37 | }
38 |
39 | variable "private_data_subnet_az2_cidr" {
40 | description = "private data subnet az2"
41 | type = string
42 | default = "10.0.5.0/24"
43 | }
44 |
--------------------------------------------------------------------------------
/Terraform/What is terraform provisioner.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/Terraform/What is terraform provisioner.docx
--------------------------------------------------------------------------------
/Tomcat.md:
--------------------------------------------------------------------------------
1 | ##################----INSTALL TOMCAT----##################
2 |
3 | --> change to opt directory
4 |
5 | cd /opt
6 |
7 | --> Download tomcat file using wget command
8 |
9 | sudo wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.65/bin/apache-tomcat-9.0.65.tar.gz
10 |
11 | sudo wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.80/bin/apache-tomcat-9.0.80.tar.gz (Another link )
12 |
13 | --> Unzip tar file
14 |
15 | sudo tar -xvf apache-tomcat-9.0.65.tar.gz
16 |
17 | --> move to conf directory and change port in tomcat server to another port from default port
18 |
19 | vi server.xml
20 |
21 | --> update tomcat users xml file for manager app login.
22 |
23 | cd /opt/apache-tomcat-9.0.65/conf
24 |
25 | sudo vi tomcat-users.xml
26 |
27 | # ---add-below-line at the end (2nd-last line)----
28 |
29 |
30 |
31 | --> create a symbolic links for direct start and stop of tomcat
32 |
33 | sudo ln -s /opt/apache-tomcat-9.0.65/bin/startup.sh /usr/bin/startTomcat
34 |
35 | sudo ln -s /opt/apache-tomcat-9.0.65/bin/shutdown.sh /usr/bin/stopTomcat
36 |
37 | sudo vi /opt/apache-tomcat-9.0.65/webapps/manager/META-INF/context.xml
38 |
39 | comment:
40 |
41 | Valve className="org.apache.catalina.valves.RemoteAddrValve"
42 |
43 | allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
44 |
45 | sudo vi /opt/apache-tomcat-9.0.65/webapps/host-manager/META-INF/context.xml
46 |
47 | comment:
48 |
49 | Valve className="org.apache.catalina.valves.RemoteAddrValve"
50 |
51 | allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
52 |
53 | sudo stopTomcat
54 |
55 | sudo startTomcat
56 |
--------------------------------------------------------------------------------
/Ubuntu-nexsus-22.04.txt:
--------------------------------------------------------------------------------
1 | Prequesites :
2 | 4 cpus max and min used 2 in this video
3 | 20 gb storage
4 | java 8
5 | Aws account
6 |
7 | ==> sudo apt update #update packages
8 |
9 | Now, install the Java OpenJDK 8 via the apt command below. Input Y when asked to confirm the installation and press ENTER to proceed.
10 | ==> sudo apt install openjdk-8-jdk # install java8
11 |
12 | Once Java is installed, verify the Java version on your system using the following command.
13 | ==> java -version
14 |
15 | To install Nexus, you will need to create a new dedicated Linux user with a valid shell and
16 | also need to set up the max open files for both hard and soft limits to '65536'.
17 |
18 | Run the following command to create a new dedicated user for the Nexus with the name 'nexus'
19 | ==> sudo useradd -d /opt/nexus -s /bin/bash nexus
20 | ==> sudo passwd nexus
21 | Add password
22 |
23 | Next, set the ulimit to '65536' using the below command. This will only affect the system on the current system temporarily.
24 | To make it permanent, you can create a new config file that you will do in the next step.
25 |
26 | ==> ulimit -n 65536
27 |
28 | TO set up ulimit permanently, create a new config file '/etc/security/limits.d/nexus.conf' using nano editor.
29 | ==> sudo nano /etc/security/limits.d/nexus.conf
30 | nexus - nofile 65536
31 |
32 | ==> ulimit -a
33 |
34 | Download the Nexus Repository Manager package via the wget command as below. If the download process is finished,
35 | you will see the file 'nexus-3.41.1-01-unix.tar.gz' on your current working directory.
36 |
37 | ==> wget https://download.sonatype.com/nexus/3/nexus-3.41.1-01-unix.tar.gz
38 |
39 | Now extract the file 'nexus-3.41.1-01-unix.tar.gz' via the tar command below. And you should get two directories, the 'nexus-3.41.1-01' and 'sonatype-work'.
40 |
41 | The directory 'nexus-3.41.1-01' is the main directory for the Nexus package, and the directory 'sonatype-work' is the main working directory for Nexus.
42 |
43 | ==> tar xzf nexus-3.41.1-01-unix.tar.gz
44 |
45 | Next, move those extracted directories to '/opt' using the following command.
46 | The Nexus package directory will be '/opt/nexus' and the Nexus working directory will be '/opt/sonatype-work'.
47 |
48 | ==> sudo mv nexus-3.41.1-01 /opt/nexus
49 | ==> sudo mv sonatype-work /opt/
50 |
51 | Lastly, change the ownership of both directories to the user and group 'nexus' via the chown command below.
52 |
53 | ==> sudo chown -R nexus:nexus /opt/nexus /opt/sonatype-work
54 |
55 | Next, you will set up your Nexus installation by editing some of the Nexus configuration files.
56 |
57 | Open the file '/opt/nexus/bin/nexus.rc' using nano editor.
58 |
59 | ==> sudo nano /opt/nexus/bin/nexus.rc
60 |
61 | Uncomment the option 'run_as_user' and change the value to 'nexus'. With this configuration, you will be running the Nexus application as the system user 'nexus'.
62 |
63 | ==> run_as_user='nexus'
64 |
65 | Save the file and exit the editor when you are done.
66 |
67 | Next, open the config file '/etc/nexus/bin/nexus.vmoptions' using the nano editor to set up the max heap memory for Nexus.
68 | ***********************************************************************************************
69 | ==> sudo vi /opt/nexus/bin/nexus.vmoptions
70 |
71 | -Xms1024m
72 | -Xmx1024m
73 | -XX:MaxDirectMemorySize=1024m
74 |
75 | -XX:LogFile=./sonatype-work/nexus3/log/jvm.log
76 | -XX:-OmitStackTraceInFastThrow
77 | -Djava.net.preferIPv4Stack=true
78 | -Dkaraf.home=.
79 | -Dkaraf.base=.
80 | -Dkaraf.etc=etc/karaf
81 | -Djava.util.logging.config.file=/etc/karaf/java.util.logging.properties
82 | -Dkaraf.data=./sonatype-work/nexus3
83 | -Dkaraf.log=./sonatype-work/nexus3/log
84 | -Djava.io.tmpdir=./sonatype-work/nexus3/tmp
85 | ************************************************************************************************
86 |
87 | To run nexus as service using Systemd
88 |
89 | ==> sudo nano /etc/systemd/system/nexus.service
90 | ************************************************************************************************
91 | [Unit]
92 | Description=nexus service
93 | After=network.target
94 |
95 | [Service]
96 | Type=forking
97 | LimitNOFILE=65536
98 | ExecStart=/opt/nexus/bin/nexus start
99 | ExecStop=/opt/nexus/bin/nexus stop
100 | User=nexus
101 | Restart=on-abort
102 |
103 | [Install]
104 | WantedBy=multi-user.target
105 | ***********************************************************************************************
106 |
107 | ==> sudo systemctl daemon-reload
108 | ==> sudo systemctl start nexus.service
109 | ==> sudo systemctl enable nexus.service
110 | ==> sudo systemctl status nexus.service
111 |
112 | if the nexus service is not started, you can the nexus logs using below command
113 |
114 | ==> tail -f /opt/sonatype-work/nexus3/log/nexus.log
115 |
116 | in ec2 instance add 8081 port for Nexus
117 |
118 | sudo cat /opt/nexus/sonatype-work/nexus3/admin.password
119 |
120 |
121 | ###########################################################################################################################################################
122 |
123 |
--------------------------------------------------------------------------------
/Untitled Diagram.drawio:
--------------------------------------------------------------------------------
1 | UzV2zq1wL0osyPDNT0nNUTV2VTV2LsrPL4GwciucU3NyVI0MMlNUjV1UjYwMgFjVyA2HrCFY1qAgsSg1rwSLBiADYTaQg2Y1AA==
--------------------------------------------------------------------------------
/Youtube-jenkinsfile1:
--------------------------------------------------------------------------------
1 | pipeline{
2 | agent any
3 | parameters {
4 | string (name: "NAME" , description : 'please tell me your name?')
5 | text (name: "DESC", description: "Describe about the job details")
6 | booleanParam(name:'SKIP_TEST', description: 'want to skip running test cases?')
7 | choice(name:'BRANCH', choices:['master', 'dev'], description: 'choose branch')
8 | password(name: 'Git_passwd', description: 'Enter password')
9 | }
10 | tools{
11 | maven "maven3"
12 | }
13 | stages {
14 | stage("Printing params") {
15 | steps {
16 | echo "Hello ${params.NAME}"
17 | echo "Job Details: ${params.DESC}"
18 | echo "skip Running Test case ?: ${params.SKIP_TEST}"
19 | echo "Branch Choice: ${params.BRANCH}"
20 | echo "Git_passwd : ${params.Git_passwd}"
21 | }
22 | }
23 | stage ("GIT CHECKOUT") {
24 | steps {
25 | echo "GIT CHECKOUT "
26 | git credentialsId: 'Git-creds', url: 'https://github.com/Aj7Ay/sparkjava-war-example.git'
27 | }
28 | }
29 | stage ("BUILD") {
30 | steps {
31 | script {
32 | sh "mvn clean install package "
33 | }
34 | }
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/ec2.tf:
--------------------------------------------------------------------------------
1 | # configured aws provider with proper credentials
2 | provider "aws" {
3 | region = "ap-south-1"
4 | profile = "mr-cloud-book"
5 | }
6 |
7 |
8 | # create default vpc if one does not exit
9 | resource "aws_default_vpc" "default_vpc" {
10 |
11 | tags = {
12 | Name = "default vpc"
13 | }
14 | }
15 |
16 |
17 | # use data source to get all avalablility zones in region
18 | data "aws_availability_zones" "available_zones" {}
19 |
20 |
21 | # create default subnet if one does not exit
22 | resource "aws_default_subnet" "default_az1" {
23 | availability_zone = data.aws_availability_zones.available_zones.names[0]
24 |
25 | tags = {
26 | Name = "default subnet"
27 | }
28 | }
29 |
30 |
31 | # create security group for the ec2 instance
32 | resource "aws_security_group" "ec2_security_group" {
33 | name = "ec2 security group"
34 | description = "allow access on ports 8080 and 22"
35 | vpc_id = aws_default_vpc.default_vpc.id
36 |
37 | # allow access on port 8080
38 | ingress {
39 | description = "http proxy access"
40 | from_port = 8080
41 | to_port = 8080
42 | protocol = "tcp"
43 | cidr_blocks = ["0.0.0.0/0"]
44 | }
45 |
46 | # allow access on port 22
47 | ingress {
48 | description = "ssh access"
49 | from_port = 22
50 | to_port = 22
51 | protocol = "tcp"
52 | cidr_blocks = ["0.0.0.0/0"]
53 | }
54 |
55 | egress {
56 | from_port = 0
57 | to_port = 0
58 | protocol = -1
59 | cidr_blocks = ["0.0.0.0/0"]
60 | }
61 |
62 | tags = {
63 | Name = "jenkins server security group"
64 | }
65 | }
66 |
67 |
68 | # use data source to get a registered amazon linux 2 ami
69 | data "aws_ami" "amazon_linux_2" {
70 | most_recent = true
71 | owners = ["amazon"]
72 |
73 | filter {
74 | name = "owner-alias"
75 | values = ["amazon"]
76 | }
77 |
78 | filter {
79 | name = "name"
80 | values = ["amzn2-ami-hvm*"]
81 | }
82 | }
83 |
84 |
85 | # launch the ec2 instance and install website
86 | resource "aws_instance" "ec2_instance" {
87 | ami = data.aws_ami.amazon_linux_2.id
88 | instance_type = "t2.micro"
89 | subnet_id = aws_default_subnet.default_az1.id
90 | vpc_security_group_ids = [aws_security_group.ec2_security_group.id]
91 | key_name = "mumbai"
92 | # user_data = file("install_jenkins.sh")
93 |
94 | tags = {
95 | Name = "Jenkins serrver"
96 | }
97 | }
98 |
99 |
100 | # an empty resource block
101 | resource "null_resource" "name" {
102 |
103 | # ssh into the ec2 instance
104 | connection {
105 | type = "ssh"
106 | user = "ec2-user"
107 | private_key = file("~/Downloads/mumbai.pem")
108 | host = aws_instance.ec2_instance.public_ip
109 | }
110 |
111 | # copy the install_jenkins.sh file from your computer to the ec2 instance
112 | provisioner "file" {
113 | source = "install_jenkins.sh"
114 | destination = "/tmp/install_jenkins.sh"
115 | }
116 |
117 | # set permissions and run the install_jenkins.sh file
118 | provisioner "remote-exec" {
119 | inline = [
120 | "sudo chmod +x /tmp/install_jenkins.sh",
121 | "sh /tmp/install_jenkins.sh",
122 | ]
123 | }
124 |
125 | # wait for ec2 to be created
126 | depends_on = [aws_instance.ec2_instance]
127 | }
128 |
129 |
130 | # print the url of the jenkins server
131 | output "website_url" {
132 | value = join("", ["http://", aws_instance.ec2_instance.public_dns, ":", "8080"])
133 | }
134 |
--------------------------------------------------------------------------------
/flyway.conf:
--------------------------------------------------------------------------------
1 | flyway.url=jdbc:mysql://localhost:3306/
2 | flyway.user=
3 | flyway.password=
4 | flyway.locations=filesystem:sql
5 | flyway.cleanDisabled=false
6 |
7 |
8 | ssh -i ec2-user@ -L 3306::3306 -N ( command for ssh into ec2 to rds )
9 |
--------------------------------------------------------------------------------
/install_jenkins.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | sudo yum update –y
3 | sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
4 | sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
5 | sudo yum upgrade
6 | sudo amazon-linux-extras install java-openjdk11 -y
7 | sudo yum install jenkins -y
8 | sudo systemctl enable jenkins
9 | sudo systemctl start jenkins
10 | sudo systemctl status jenkins
11 | sudo cat /var/lib/jenkins/secrets/initialAdminPassword
--------------------------------------------------------------------------------
/jenkins-ec2-28-sep-2022.txt:
--------------------------------------------------------------------------------
1 | ################ JENKINS ON EC2-UBUNTU COMMANDS ########################
2 |
3 | ---> sudo apt-get update -y #updates ubuntu server
4 |
5 | ---> wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add - #adds repository key
6 |
7 | ---> sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' #add package repository
8 |
9 | ---> sudo apt update #update
10 |
11 | ---> sudo apt install default-jre #installs java dependency
12 |
13 | ---> sudo apt install jenkins -y #install jenkins
14 |
15 | ---> sudo systemctl start jenkins
16 | ---> sudo systemctl status jenkins #starts jenkins service
17 |
18 | ---> sudo ufw allow 8080 #allows jenkins port
19 |
20 | ---> sudo ufw status # to check status
21 |
22 | ---> sudo ufw allow OpenSSH sudo ufw enable
23 | ---> sudo ufw enable #if ubuntu firewall is inactive use this commands
24 |
25 | ---> sudo cat /var/lib/jenkins/secrets/initialAdminPassword #for jenkins initialAdminPassword
26 |
27 | ---> enable security group open 8080 in console
28 |
29 |
30 |
31 | ################## AMAZON EC2-LINUX ################################3333
32 |
33 | Ensure that your software packages are up to date on your instance by uing the following command to perform a quick software update:
34 |
35 | ---> sudo yum update –y
36 |
37 | Add the Jenkins repo using the following command:
38 |
39 | ---> sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
40 |
41 | Import a key file from Jenkins-CI to enable installation from the package:
42 |
43 | ---> sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
44 | ---> sudo yum upgrade
45 |
46 | Install Java:
47 |
48 | ---> sudo amazon-linux-extras install java-openjdk11 -y
49 |
50 | Install Jenkins:
51 |
52 | ---> sudo yum install jenkins -y
53 |
54 | Enable the Jenkins service to start at boot:
55 |
56 | ---> sudo systemctl enable jenkins
57 |
58 | Start Jenkins as a service:
59 |
60 | ---> sudo systemctl start jenkins
61 |
62 | ---> sudo cat /var/lib/jenkins/secrets/initialAdminPassword #initialAdminPassword
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/jenkins-master-slave.xml:
--------------------------------------------------------------------------------
1 | ################ JENKINS ON EC2-UBUNTU COMMANDS ########################
2 |
3 | ---> sudo apt-get update -y #updates ubuntu server
4 |
5 | ---> wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add - #adds repository key
6 |
7 | ---> sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' #add package repository
8 |
9 | ---> sudo apt update #update
10 |
11 | ---> sudo apt install default-jre #installs java dependency
12 |
13 | ---> sudo apt install jenkins -y #install jenkins
14 |
15 | ---> sudo systemctl start jenkins
16 | ---> sudo systemctl status jenkins #starts jenkins service
17 |
18 | ---> sudo ufw allow 8080 #allows jenkins port
19 |
20 | ---> sudo ufw status # to check status
21 |
22 | ---> sudo ufw allow OpenSSH sudo ufw enable
23 | ---> sudo ufw enable #if ubuntu firewall is inactive use this commands
24 |
25 | ---> sudo cat /var/lib/jenkins/secrets/initialAdminPassword #for jenkins initialAdminPassword
26 |
27 | ---> enable security group open 8080 in console
28 |
29 |
30 |
31 | ################## AMAZON EC2-LINUX ################################3333
32 |
33 | Ensure that your software packages are up to date on your instance by uing the following command to perform a quick software update:
34 |
35 | ---> sudo yum update
36 |
37 | Add the Jenkins repo using the following command:
38 |
39 | ---> sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
40 |
41 | Import a key file from Jenkins-CI to enable installation from the package:
42 |
43 | ---> sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
44 | ---> sudo yum upgrade
45 |
46 | Install Java:
47 |
48 | ---> sudo amazon-linux-extras install java-openjdk11 -y
49 |
50 | Install Jenkins:
51 |
52 | ---> sudo yum install jenkins -y
53 |
54 | Enable the Jenkins service to start at boot:
55 |
56 | ---> sudo systemctl enable jenkins
57 |
58 | Start Jenkins as a service:
59 |
60 | ---> sudo systemctl start jenkins
61 |
62 | ---> sudo cat /var/lib/jenkins/secrets/initialAdminPassword #initialAdminPassword
63 |
64 |
65 |
66 | ################## MASTER -SLAVE SETUP ###############################
67 |
68 | create an ec2-instance ubuntu 22.04
69 | --> connect slave node using putty or Gitbash
70 |
71 | ---> sudo apt-get update
72 | ---> sudo apt-get install default-jre -y
73 | ---> java -version
74 | ---> pwd
75 | ---> mkdir jenkins
76 | ---> sudo chmod 777 jenkins
77 | ---> pwd #copy path
78 |
79 | ############## generate key on master #############
80 |
81 | ---> ssh-keygen -t rsa
82 | ---> cd .ssh
83 | ---> sudo cat id_rsa.pub and copy the code
84 |
85 | ############## on slave nodes ###############
86 | ---> cd .ssh
87 | ---> sudo vi authorized_keys
88 | ---> paste the copied code
89 | ##################################
90 |
91 | ##### GUI
92 | ---> manage jenkins
93 | ---> manage nodes and clouds
94 | ---> + NEW NODE
95 | ==> Name
96 | ==> description
97 | ==> executions
98 | ==> /home/ubuntu/jenkins #copied path
99 | ==> label
100 | ==> use node as much as possible
101 | ==> launch method
102 | ---> via OpenSSH
103 | ==> host
104 | ---> jenkins slave public Ip
105 | ==> credentials
106 | ---> Add jenkins
107 | ----> username ssh with private key
108 | ---> id jenkins slave
109 | ---> description
110 | ---> username ubuntu
111 | ---> enter directory
112 | ---> Add slave pem file
113 | ==>add
114 | ---> select ubuntu created credentails
115 | ==> trusted manage key
116 | ==> Availability
117 | ===> save
118 |
119 |
120 |
121 | ############# JENKINS MASTER SLAVE PROCESS 2 ########################
122 | --> sudo su #master
123 | --> sudo apt-get update
124 | --> sudo hostname jenkins-master #master
125 | --> cd /etc/apt/ #master
126 | --> ls #master
127 | --> cd sources.list.d #master
128 | --> ls -a #master
129 | --> cd .. #master
130 | --> vim sources.list #master
131 | --> sudo apt install default-jre -y #master
132 | --> sudo apt-get install jenkins -y #master
133 |
134 | ============================= server node =====================
135 | --> sudo su
136 | --> sudo apt-get update
137 | --> sudo hostname jenkins-slave
138 | --> exec bash
139 | --> sudo apt-get install default-jre
140 | --> y
141 |
142 |
143 |
144 | ================================set up process ================================
145 |
146 | --> ps fax | grep jenkins #master
147 | --> ps faxu | grep jenkins #master
148 | --> su - jenkins #master
149 | --> pwd #master
150 | --> ssh-keygen -t rsa #master
151 | --> enter 3 timess #master
152 | --> cat /var/lib/jenkins/.ssh/id_rsa.pub #master
153 | --> copy public key
154 | --> adduser jenkins #slave node
155 | --> give password
156 | enter and last y
157 | --> su - jenkins #slave node
158 | --> ls -la #slave node
159 | --> ssh jenkins@localhost #slave node #when u cant find .ssh use this
160 | --> yes
161 | --> cd .ssh #slave node
162 | --> sudo vi authorized_keys #slave node
163 | --> paste the public key that copied in master jenkins
164 | --> ip r #get ip address #slave node #copy ip
165 | --> ssh jenkins@ip and yes #master
166 | --> ip r and logout #master
167 | --> ssh jenkins@ip #master
168 | ###############################################################################
169 | jenkins master slave setup
170 | ###############################################################################
171 |
172 | --> manage jenkins
173 | --> manage nodes and clouds
174 | --> New node
175 | --> Name and permanent
176 | --> name
177 | --> description
178 | --> of executors #5
179 | --> remote root directory /home/jenkins
180 | --> labels
181 | --> usage as much as possible
182 | --> launch method #use launch agent via execution master command
183 | --> launch command # ssh hostname java -jar ~/bin/agent.jar #jenkins@ip address slave private in place hostname
184 | --> ssh jenkins@172.31.34.74 java -jar /home/jenkins/agent.jar #on launch command #use slave private ip
185 | --> agent.jar downloaded here click it and
186 | --> wget that link in slave node
187 | --> Availability
188 | --> save
189 | -->execute shell build in gui
190 | --> pwd date cal
--------------------------------------------------------------------------------
/jfrog-22.04.yaml:
--------------------------------------------------------------------------------
1 | prerequisites for JFrog
2 |
3 | small or medium instance t2 ytpe
4 | 2cpus
5 | 8081 and 8082 and ssh ports
6 | openjdk 11
7 |
8 | ==> $ sudo apt update
9 | First of all add the GPG key by entering the following command.
10 | ==> sudo apt install default-jre
11 |
12 | ==> $ wget -qO - https://api.bintray.com/orgs/jfrog/keys/gpg/public.key | sudo apt-key add -
13 | Add jfrog repository in your apt list. Just copy and paste the following command in your terminal.
14 |
15 | ==> $ echo "deb https://jfrog.bintray.com/artifactory-debs bionic main" | sudo tee /etc/apt/sources.list.d/jfrog.list
16 | Let’s then update apt index,
17 |
18 | ==> $ sudo apt update
19 | Now, you can install using jfrog service by entering the following command.
20 |
21 | ==> $ sudo apt install jfrog-artifactory-oss
22 | Start the service,
23 |
24 | ==> $ sudo systemctl start artifactory.service
25 | Enable the service,
26 |
27 |
28 | ==> $ sudo systemctl enable artifactory.service
29 | Check the status of service
30 |
31 | ==> $ systemctl status artifactory.service
32 |
33 | Access Jfrog UI
34 | Open your browser and enter http://IP_or DOMAIN-NAME:8081/artifactory
35 |
36 | Use default username and password to loging.
37 | admin
38 | password
39 |
40 | You need to reset the admin password.
41 |
42 | Setup the base URL, like your domain name to access the JFrog artifactory web UI. You can skip if you don’t have any.
43 |
44 | Now, the next step is to configure the default proxy. If your enterprise has a proxy gateway for accessing the server, use it otherwise skip it.
45 |
46 | Now your installation and basic configuration is finished. You can start creating a repository based on your project.
47 |
--------------------------------------------------------------------------------
/mysql on Ec1.txt:
--------------------------------------------------------------------------------
1 | Commands used to host MySql Server on AWS EC2 Instance
2 | Step 1: Update the system
3 | sudo apt update
4 |
5 | Step 2: Install MySql
6 | sudo apt install mysql-server
7 |
8 | Step 3: Check the Status of MySql (Active or Inactive)
9 | sudo systemctl status mysql
10 |
11 | Step 4: Login to MySql as a root
12 | sudo mysql
13 |
14 | Step 5: Update the password for the MySql Server
15 | ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'place-your-password-here';
16 |
17 | FLUSH PRIVILEGES;
18 |
19 | Step 6: Test the MySql server if it is working by running sample sql queries
20 | CREATE DATABASE mysql_test;
21 |
22 | USE mysql_test;
23 |
24 | CREATE TABLE table1 (id INT, name VARCHAR(45));
25 |
26 | INSERT INTO table1 VALUES(1, 'Virat'), (2, 'Sachin'), (3, 'Dhoni'), (4, 'ABD'), (5,'Ajay');
27 |
28 | SELECT * FROM table1;
29 |
--------------------------------------------------------------------------------
/pipeline-yt2.groovy:
--------------------------------------------------------------------------------
1 | pipeline{
2 | agent any
3 | parameters {
4 | string (name: "NAME" , description : 'please tell me your name?')
5 | choice (name: "GENDER", choices: ['Male','Female'], description: 'choose gender')
6 | }
7 | tools{
8 | maven "maven3"
9 | }
10 | stages {
11 | stage ('printing name') {
12 | steps {
13 | script {
14 | def name = "${params.NAME}"
15 | def gender = "${params.GENDER}"
16 | if (gender == "Male") {
17 | echo "Mr.$name"
18 | } else {
19 | echo "Mrs.$name"
20 | }
21 | }
22 | }
23 | }
24 | stage ("GIT CHECKOUT") {
25 | steps {
26 | echo "GIT CHECKOUT "
27 | git credentialsId: 'Git-creds', url: 'https://github.com/Aj7Ay/sparkjava-war-example.git'
28 | }
29 | }
30 | stage ("BUILD") {
31 | steps {
32 | script {
33 | sh "mvn clean install package "
34 | }
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/sonarqube.txt:
--------------------------------------------------------------------------------
1 |
2 | 1. Install OpenJDK 11
3 | SSH to your Ubuntu server as a non-root user with sudo access.
4 | Install OpenJDK 11.
5 |
6 | $ sudo apt-get install openjdk-11-jdk -y
7 |
8 | ----------------------------------------------------------------------------------------
9 |
10 | 2. Install and Configure PostgreSQL
11 | Add the PostgreSQL repository.
12 |
13 | $ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" /etc/apt/sources.list.d/pgdg.list'
14 | Add the PostgreSQL signing key.
15 |
16 | $ wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
17 |
18 | Install PostgreSQL.
19 |
20 | $ sudo apt install postgresql postgresql-contrib -y
21 |
22 | Enable the database server to start automatically on reboot.
23 |
24 | $ sudo systemctl enable postgresql
25 |
26 | Start the database server.
27 |
28 | $ sudo systemctl start postgresql
29 |
30 | Change the default PostgreSQL password.
31 |
32 | $ sudo passwd postgres
33 |
34 | Switch to the postgres user.
35 |
36 | $ su - postgres
37 |
38 | Create a user named sonar.
39 |
40 | $ createuser sonar
41 |
42 | Log in to PostgreSQL.
43 |
44 | $ psql
45 |
46 | Set a password for the sonar user. Use a strong password in place of my_strong_password.
47 |
48 | ALTER USER sonar WITH ENCRYPTED password 'my_strong_password';
49 |
50 | Create a sonarqube database and set the owner to sonar.
51 |
52 | CREATE DATABASE sonarqube OWNER sonar;
53 |
54 | Grant all the privileges on the sonarqube database to the sonar user.
55 |
56 | GRANT ALL PRIVILEGES ON DATABASE sonarqube to sonar;
57 |
58 | Exit PostgreSQL.
59 |
60 | \q
61 |
62 | Return to your non-root sudo user account.
63 |
64 | $ exit
65 |
66 |
67 | ---------------------------------------------------------------------------------------
68 |
69 |
70 | 3. Download and Install SonarQube
71 | Install the zip utility, which is needed to unzip the SonarQube files.
72 |
73 | $ sudo apt-get install zip -y
74 | Locate the latest download URL from the SonarQube official download page.
75 |
76 | Download the SonarQube distribution files.
77 |
78 | $ sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.6.1.59531.zip
79 |
80 | Unzip the downloaded file.
81 |
82 |
83 | sudo unzip sonarqube-9.6.1.59531.zip
84 |
85 |
86 | Move the unzipped files to /opt/sonarqube directory
87 |
88 | sudo mv sonarqube-9.6.1.59531 sonarqube
89 | sudo mv sonarqube /opt/
90 |
91 |
92 | 4. Add SonarQube Group and User
93 | Create a dedicated user and group for SonarQube, which can not run as the root user.
94 |
95 | Create a sonar group.
96 |
97 | $ sudo groupadd sonar
98 | Create a sonar user and set /opt/sonarqube as the home directory.
99 |
100 | $ sudo useradd -d /opt/sonarqube -g sonar sonar
101 | Grant the sonar user access to the /opt/sonarqube directory.
102 |
103 | $ sudo chown sonar:sonar /opt/sonarqube -R
104 |
105 |
106 | ---------------------------------------------------------------------------------------
107 |
108 |
109 | 5. Configure SonarQube
110 | Edit the SonarQube configuration file.
111 |
112 | $ sudo nano /opt/sonarqube/conf/sonar.properties
113 | Find the following lines:
114 |
115 | #sonar.jdbc.username=
116 | #sonar.jdbc.password=
117 | Uncomment the lines, and add the database user and password you created in Step 2.
118 |
119 | sonar.jdbc.username=sonar
120 | sonar.jdbc.password=my_strong_password
121 | Below those two lines, add the sonar.jdbc.url.
122 |
123 | sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube
124 | Save and exit the file.
125 |
126 |
127 | Edit the sonar script file.
128 |
129 | $ sudo nano /opt/sonarqube/bin/linux-x86-64/sonar.sh
130 | About 50 lines down, locate this line:
131 |
132 | #RUN_AS_USER=
133 | Uncomment the line and change it to:
134 |
135 |
136 |
137 | Save and exit the file.
138 |
139 |
140 | ---------------------------------------------------------------------------------------
141 |
142 | 6. Setup Systemd service
143 | Create a systemd service file to start SonarQube at system boot.
144 |
145 | $ sudo nano /etc/systemd/system/sonar.service
146 | Paste the following lines to the file.
147 |
148 | [Unit]
149 | Description=SonarQube service
150 | After=syslog.target network.target
151 |
152 | [Service]
153 | Type=forking
154 |
155 | ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
156 | ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
157 |
158 | User=sonar
159 | Group=sonar
160 | Restart=always
161 |
162 | LimitNOFILE=65536
163 | LimitNPROC=4096
164 |
165 | [Install]
166 | WantedBy=multi-user.target
167 | Save and exit the file.
168 |
169 | Enable the SonarQube service to run at system startup.
170 |
171 | $ sudo systemctl enable sonar
172 | Start the SonarQube service.
173 |
174 | $ sudo systemctl start sonar
175 | Check the service status.
176 |
177 | $ sudo systemctl status sonar
178 |
179 |
180 | ---------------------------------------------------------------------------------------
181 |
182 |
183 | 7. Modify Kernel System Limits
184 | SonarQube uses Elasticsearch to store its indices in an MMap FS directory. It requires some changes to the system defaults.
185 |
186 | Edit the sysctl configuration file.
187 |
188 | $ sudo nano /etc/sysctl.conf
189 | Add the following lines.
190 |
191 | vm.max_map_count=262144
192 | fs.file-max=65536
193 | ulimit -n 65536
194 | ulimit -u 4096
195 | Save and exit the file.
196 |
197 | Reboot the system to apply the changes.
198 |
199 | $ sudo reboot
200 |
201 | $ sudo systemctl stop ufw
202 | ---------------------------------------------------------------------------------------
203 |
204 | 8. Access SonarQube Web Interface
205 | Access SonarQube in a web browser at your server's IP address on port 9000. For example:
206 |
207 | http://IP:9000
208 | Log in with username admin and password admin. SonarQube will prompt you to change your password.
209 |
210 |
211 |
212 | pipeline {
213 | agent any
214 | tools{
215 | maven "maven3"
216 | }
217 | stages {
218 | stage('SCM') {
219 | steps {
220 | git url: 'https://github.com/spring-projects/spring-petclinic.git'
221 | }
222 | }
223 | stage('build && SonarQube analysis') {
224 | steps {
225 | withSonarQubeEnv('Aj') {
226 | // If you have configured more than one global server connection, you can specify its name
227 | // sh "${scannerHome}/bin/sonar-scanner"
228 | sh "mvn clean verify sonar:sonar -Dsonar.projectKey=Aj -Dsonar.host.url=http://43.205.215.66:9000 -Dsonar.login=sqp_13d65c5a6adf9bc4e36258e2f69cb40cced15f2b"
229 | }
230 | }
231 | }
232 | stage("Quality Gate") {
233 | steps {
234 | timeout(time: 1, unit: 'HOURS') {
235 | // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails
236 | // true = set pipeline to UNSTABLE, false = don't
237 | waitForQualityGate abortPipeline: true
238 | }
239 | }
240 | }
241 | }
242 | }
243 |
--------------------------------------------------------------------------------
/vpc workflow complete notes.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aj7Ay/youtube_notes/477d73e75ec9a48856eac6f5dca263cf0c3a70ea/vpc workflow complete notes.pdf
--------------------------------------------------------------------------------