Devops Lab Manual
Devops Lab Manual
1.2 Creating new repository and commit the codes to newly created repository
1.3 Importing the codebase from different Github account to your Github account
1.2 Creating new repository and commit the codes to newly created repository
1. Sign in github Create a repository (DemoRepo) ,provide a valid name and make public or
private.
Eg: PreethaS25/DemoRepo
2. Create Program files in local Folder Devops Lab (a.html,login.py …)
3. Go inside Local Folder Devops Lab ,Right Click open Git Bash here
4. Automatically will create a git repository locally
git init
5. Configure name and email
git config - -global user.name “PreethaS25”
git config - -global user.email “[email protected]”
1. switch to master branch,merge new branch and push the changes in github
1. Go to Github top corner press +sign .Click import Repository.Paste Old Url,
Give repository details,Begin import
or
2. git clone RemoteRepoPath - obtain a repo from existing URL
Experiment 2
2.0 Using Chef Solo on Linux for AWS 4
Chef solo?
Chef-Solo is an open source tool that runs locally and allows to provision guest machines
using Chef cookbooks without the complication of any Chef client and server configuration.
It helps to execute cookbooks on a self-created server.
2. Install Chef dk
wget https://packages.chef.io/files/stable/chefdk/3.2.30/ubuntu/18.04/chefdk_3.2.30-
1_amd64.deb
For ubuntu
Create a ruby file with file extension .rb – since we are recipe on ruby.
vim hello.rb
file 'HelloChef' do
content 'Hello Ruby'
end
chef-apply hello.rb
Once we run this chef-apply command. We should have a 'HelloChef' file created with
content 'Hello Ruby
3.0 Build your first OpsWorks stack
3.1 Build the infrastructure and automate code deployment for a PHP application with
OpsWorks
3.4 Execute other commands – Undeploy, Rollback, Start Web Server, Stop Web Server,
Restart Web Server
Step3: Click and Add Your FirstStack and select Chef11 stack –provide a Valid name PHPAppServer
Step4: Add a Layer ,choose Opsworks,select Layer Type as PHP App Server and click add layer
Step5: Add a Instance to the layer-choose New instances provide a Hostname php-app1,size t2.micro
then click Add instance.
Step7: Add an application –Click Add app,provide a valid name PHPWEB,Resource Type select as
Git,provide Git URL https://github.com/aws-samples/opsworks-demo-php-simple-app” and Add
App
Step8: Perform the action Deploy ,In deployment page provide the command as Deploy and then
click deploy
Step 9: Once deployment completed .Check the ouput. Go to instance,select the ipaddress ,the
website is deployed successfully.
Step 1: Create a Loadbalancer –Go to Ec2 ,choose Classic Load balancer,create load balancer,
Step4: Select Layer PHP App Server,Select Network ,provide Elastic Load Balancer name as
OpsworksELB,then Click Save
Step 6: So Loadbalancer will take the load and see output ,Click the Url of Loadbalancer(
OpsWorksELB-510716335.us-west-2.elb.amazonaws.com) .It will navigate to the application
website.
Step7: Add one more instance from the layer ,start the instance,make online and check the
application by loadbalancer.Loadbalancer will take care both the application server
Step8: Refresh the web pages request will be taken from php-app1 and php-app2
4.0 Getting Started with Jenkins on Windows (Hyper or Oracle VM box)
Step 4: We should ensure JDK installed, before we install Jenkins on the server.
Install Java:
Since Jenkins is a Java application, the first step is to install Java. Update the package index and
install the Java 8 OpenJDK package with the following commands
sudo apt update
Step 1: Once the Jenkins repository is enabled, update the apt package list and install the latest
version of Jenkins by typing:
Jenkins service will automatically start after the installation process is complete. You can verify it by
printing the service status:
Step2:
By default, Jenkins listen on port 8080. Access this port with your browser to start configuration.
Allowing 8080 port on Firewall By default, 8080 port is not allowed on firewall.
Click on “Description” on AWS instance (where you have created the instance).
Add a new rule with the “Custom TCP rule” and the range “8080”save
Step3 :
Example: 35.153.127.253:8000
Make sure you access the “initialAdminPassword “ file with root permission.
root@ip-172-31-35-128:~# sudo su
root@ip-172-31-35-128:~# cd /var/lib/jenkins/secrets/
Prerequisites
Two or more Ubuntu 18.04 servers. One of these will be used as our Ansible server
Step1 : Set password for root and switch in both the servers.
❖ su root
To get the latest version of Ansible for Ubuntu, you can add the project's PPA (personal
package archive) to your system, you should first ensure that you have the software-
Next, refresh your system's package index once again so that it is aware of the packages available in
the PPA:
❖ sudo apt update
Step 3: Configuring SSH Access to the Ansible Hosts and generate a SSH Key in Server as well as
Hosts
Step 4: Copy the rsa key of server and paste in hosts and vice versa.
nano authorized_keys
nano /etc/ansible/hosts
[test-servers]
172.30.36.39
172.30.36.40
nano conf.yml
Step 2: Execute the playbook
ansible-playbook conf.yml
step3 : Check the files in the host in the location /root/ two files were created a.txt b.txt
ansible-playbook apache.yml
Exp 6
6.0 Linux Command Line Byte Session
6.2
Directory Manipulations commands
6.3 Use common commands for working with files and directories
6.4
Installing Software in Linux CLI
6.5
Sending E-mails
Working commands:-
Who:- used to get information about currently logged in user on the system
cd :-switching directory
6.3) use common commands for working with file and directories
CP
ctrl+d
cat >file2.txt
cp file1.txt file2.txt
example:- cp file1.txt d1
for viewing : cd d1
ls
3) MV
Example:- mv file2.txt d1
For viewing:-
Cd d1
Ls
Example:- mv d1 d2
For viewing:- cd d2
Ls
4) CHANGING DIRECTORY
Cmd: cd directoryname
Example:- mv d1 d2
For viewing:- cd d2
Ls
Rm
1) Remove directory
Rm directory
Non-empty directory
Rm -r directoryname
2) Ls
Description:- list information about the files
Touch
Ex:- touch a.txt b.txt
CAT
Ex:- cat>file1.txt
Content in file:-
A
B
C
D
Ctrl+d
Ex:- vi file1.txt(for opening a file)
3) SEND A EMAIL
Echo “subject:Hello”/sendmail [email protected]
Step1: Create an EC2 Instance, download the latest version of Terraform source
using the following command:
wget
https://releases.hashicorp.com/terraform/1.1.2/terraform_1.1.2
_linux_amd64.zip
Step2:
Once the download is completed, extract the downloaded file using the following
command.
unzip terraform_1.1.2_linux_amd64.zip
Step3:
Copy the Terraform binary from the extracted file to the /usr/bin/ directory:
sudo mv terraform /usr/local/bin/
Step4:
Verify the Terraform version by running the following command:
terraform -v
Copy
provider "aws" {
region = "us-west-2"
access_key = "my-access-key"
secret_key = "my-secret-key"
}
Step3: Set the permissions as Attach Existing policies, Select Administrator Access,Click
Next,Add Tags,Review and Create User.
Step4: User created Successfully. Download csv file ,Accesskey and Secret Key available ,Use
this in the configuration file infra.tf
vi infra.tf
provider "aws" {
region = "us-west-2"
access_key = "AKIAUL3OWSZDHBJ6MQEJ"
secret_key = "oCXXaqHEYKzJqXWILb2ZnHC+WPYPap+QOLfHi1iS"
ami = "ami-0b22b0162cd733db8"
instance_type = "t2.micro"
8.1 Create your first cloud infrastructure using Amazon Cloud Formation
8.3 Create the Stack and choose template for launching instance
Step3: Click Create Template in Designer, From the Resource Types, Drag and drop a resource
Named as S3 –Bucket
Step5: Now Template is ready.Click Next button,Specify the stack Details ,specify a Stack name
S3Stack
Step1: Select Cloud Formation from services-Create Stack, Select with new resources
Step5: DBName,DBPassword,DBRootPassword,DBuser,InstanceType-t2.micro,
Step7:Verify the word press –Goto StackInfo ,Outputs –Click the Wordpress WEB Url
http://ec2-54-92-203-82.compute-1.amazonaws.com/wordpress/wp-admin/index.php
Step9: Once successfully created ,You can able to access WordPress Content Management
Dashboard
EXPERIMENT=9
2: IN TEMPLATE
4. EC2 CONFIGURATION
STEP 3: REVIEW
CLICK CREATE PROJECT.
DEPLOY
STEP 1: CLICK ON PROJECT AND SELECT THE PROJECT WHICH HAS BEEN CREATED.
SELECT PIPELINE.
.
YOU CAN SEE THE DEFAULT NODE.js WEB APPLICATION.
STEP 6: EDIT THE SOURCE CODE AND MAKE CHANGES IN THE CODE COMMIT REPOSTIORY
STEP 7: GO TO SOURCE CONTROL ,SELECT EDITED FILE index.html,RIGHT CLICK SELECT STAGE
CHANGES.
STEP8: COMMIT THE CHANGES BY ENTERING THE MESSAGE AND PRESS CTRL + ENTER
STEP 10: GO TO BASH TERMINAL, SWITCH TO THE PROJECT DIRECTORY cd BMS AND THEN
STEP 13: ONCE DEPLOYED, CLICK VIEW APPLICATION AND SEE THE OUTPUT
OWNER
CONTRIBUTOR
VIWER.
SELECT CONTRIBUTOR.
Experiment – 10
10.3 Use the Amazon ECR images to create ECS task definitions and services
10.4 Implement the services in ECS by using AWS Fargate enjoying the advantages of serverless
10.5 Register ECS tasks with an Application Load Balancer (ALB) target group
Docker Installation
You will get this message, but don’t worry :- To run Docker as a
non-privileged user.
4 :- Check docker is installed or not
Syntax :- docker --version
Latest version will appear :- Docker version 20.10.22,
5 :- check the status of docker image in the system
docker images (No Images have created)
For ex:- REPOSITORY TAG IMAGE ID CREATED SIZE
10.1 Use application source files to create Docker container images and place them in
Amazon ECR
unzip awscliv2.zip
sudo ./aws/install
A repository created.
nano dockerfile
and save
Outpu t of each
1.
2.
3.4.
Step6: Pull the images in the production system and create container
Then execute run command