From 8c60e096fab6c07a736f584ca86db75e3bd25687 Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 10:50:44 +0800 Subject: [PATCH 001/135] readme linux command --- 1-Linux_Tutorial/History.txt | 32 +++++++++ 1-Linux_Tutorial/README.md | 132 +++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 1-Linux_Tutorial/History.txt create mode 100644 1-Linux_Tutorial/README.md diff --git a/1-Linux_Tutorial/History.txt b/1-Linux_Tutorial/History.txt new file mode 100644 index 0000000..92667c7 --- /dev/null +++ b/1-Linux_Tutorial/History.txt @@ -0,0 +1,32 @@ +# Linux tutorial + +## Basic Commands: + +``` + +s +ls -l +clear +pwd +ls +cd Desktop/ +ls +ll +pwd +cd /home/varunmanikoutlo/ +pwd +ll +ls -l +ll +ls -la +ls -lar +ls -lart +ls -larth +cd /home/varunmanikoutlo/ +pwd +cd Desktop/ +cd ../ +history +history | cut -c 8- + +``` diff --git a/1-Linux_Tutorial/README.md b/1-Linux_Tutorial/README.md new file mode 100644 index 0000000..8be9b7d --- /dev/null +++ b/1-Linux_Tutorial/README.md @@ -0,0 +1,132 @@ +# Linux Basic Commands + +This README file provides a brief introduction to some essential Linux commands for beginners. + +## Table of Contents +1. [Navigating the File System](#navigating-the-file-system) +2. [File Management](#file-management) +3. [Directory Management](#directory-management) +4. [Permissions](#permissions) +5. [Viewing File Contents](#viewing-file-contents) +6. [System Information](#system-information) + +### Navigating the File System + +- To print the current working directory: + + ``` + pwd + ``` + +- To change the current working directory: + + ``` + cd [directory] + ``` + +- To list the contents of a directory: + + ``` + ls [options] [directory] + ``` + +### File Management + +- To create a new file: + + ``` + touch [file] + ``` + +- To copy a file: + + ``` + cp [source] [destination] + ``` + +- To move a file: + + ``` + mv [source] [destination] + ``` + +- To remove a file: + + ``` + rm [file] + ``` + +### Directory Management + +- To create a new directory: + + ``` + mkdir [directory] + ``` + +- To remove an empty directory: + + ``` + rmdir [directory] + ``` + +- To remove a non-empty directory: + + ``` + rm -r [directory] + ``` + +### Permissions + +- To change file or directory permissions: + + ``` + chmod [permissions] [file or directory] + ``` + +- To change file or directory ownership: + + ``` + chown [owner] [file or directory] + ``` + +### Viewing File Contents + +- To display the contents of a file: + + ``` + cat [file] + ``` + +- To display the first few lines of a file: + + ``` + head [file] + ``` + +- To display the last few lines of a file: + + ``` + tail [file] + ``` + +### System Information + +- To display system information: + + ``` + uname -a + ``` + +- To display disk usage: + + ``` + df -h + ``` + +- To display memory usage: + + ``` + free -h + ``` +``` From a014164166719d0ce25a2f60759b9a92c337a909 Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 10:59:30 +0800 Subject: [PATCH 002/135] readme linux command --- 1-Linux_Tutorial/README.md | 131 +++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/1-Linux_Tutorial/README.md b/1-Linux_Tutorial/README.md index 8be9b7d..4e7d4b7 100644 --- a/1-Linux_Tutorial/README.md +++ b/1-Linux_Tutorial/README.md @@ -130,3 +130,134 @@ This README file provides a brief introduction to some essential Linux commands free -h ``` ``` + +```markdown +# Linux Basic Commands - chmod and chown + +This section provides an in-depth explanation of the `chmod` and `chown` commands, including examples. + +## chmod - Change File and Directory Permissions + +### Symbolic Mode + +| Operator | Description | +| -------- | ----------- | +| `u` | User | +| `g` | Group | +| `o` | Others | +| `a` | All (User, Group, and Others) | + +| Permission | Description | +| ---------- | ----------- | +| `r` | Read | +| `w` | Write | +| `x` | Execute | + +| Action | Description | +| ------ | ----------- | +| `+` | Add permission | +| `-` | Remove permission | +| `=` | Set permission | + +### Example + +To add execute permission for the user: + +### Example + +To add execute permission for the user: + +chmod u+x [file or directory] + +arduino +Copy code + +To remove write permission for the group and others: + +chmod go-w [file or directory] + +Copy code +vbnet +Copy code + +Here's the third part of the requested content within a single Markdown code block for your README.md file: + +markdown +Copy code +To set read and execute permissions for the user, and read permission for the group and others: + +chmod u=rw,g=r,o=r [file or directory] + +perl +Copy code + +## Octal Mode + +| Octal Value | Permission | +| ----------- | ------------------- | +| `0` | No permission | +| `1` | Execute | +| `2` | Write | +| `3` | Write and Execute | +| `4` | Read | +| `5` | Read and Execute | +| `6` | Read and Write | +| `7` | Read, Write, Execute| + +### Example + +To set read, write, and execute permissions for the user, read and write permissions for the group, and read permission for others: + +chmod 764 [file or directory] + +Here's the continuation of the content within a single Markdown code block for your README.md file, following the line "chmod 764 [file or directory]": + +```markdown + +## chown - Change File and Directory Ownership + +### Syntax + +chown [owner]:[group] [file or directory] + + +### Example + +To change the owner of a file or directory to `newuser` and the group to `newgroup`: + +chown newuser:newgroup [file or directory] + + +To change only the owner to `newuser`: + +chown newuser [file or directory] + + +To change only the group to `newgroup`: + +chown :newgroup [file or directory] + +## Additional Notes + +- The `chmod` and `chown` commands can be used recursively with the `-R` option to change permissions or ownership for a directory and its contents: + +chmod -R [permissions] [directory] +chown -R [owner]:[group] [directory] + +bash +Copy code + +- You can use the `umask` command to set default file permissions for newly created files: + +umask [octal value] + + +- You can use the `id` command to display information about the current user and group: + +id + +For more information and examples, consult the `man` pages for each command: +``` +man chmod +man chown +``` \ No newline at end of file From 7e8878a6007d7274b17517f8f388b08ef1ce4310 Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 11:00:31 +0800 Subject: [PATCH 003/135] readme linux command --- 1-Linux_Tutorial/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/1-Linux_Tutorial/README.md b/1-Linux_Tutorial/README.md index 4e7d4b7..e5493cf 100644 --- a/1-Linux_Tutorial/README.md +++ b/1-Linux_Tutorial/README.md @@ -131,7 +131,6 @@ This README file provides a brief introduction to some essential Linux commands ``` ``` -```markdown # Linux Basic Commands - chmod and chown This section provides an in-depth explanation of the `chmod` and `chown` commands, including examples. From 940233223319e05bdfb2431d0eb9c65f68959dab Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 11:00:40 +0800 Subject: [PATCH 004/135] readme linux command --- 1-Linux_Tutorial/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-Linux_Tutorial/README.md b/1-Linux_Tutorial/README.md index e5493cf..8f9de38 100644 --- a/1-Linux_Tutorial/README.md +++ b/1-Linux_Tutorial/README.md @@ -129,7 +129,7 @@ This README file provides a brief introduction to some essential Linux commands ``` free -h ``` -``` + # Linux Basic Commands - chmod and chown From 38921041dabbc2f03dfb9bb98003181a24c9f8f1 Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 11:02:47 +0800 Subject: [PATCH 005/135] readme linux command --- 1-Linux_Tutorial/README.md | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/1-Linux_Tutorial/README.md b/1-Linux_Tutorial/README.md index 8f9de38..aeaecef 100644 --- a/1-Linux_Tutorial/README.md +++ b/1-Linux_Tutorial/README.md @@ -166,29 +166,23 @@ To add execute permission for the user: To add execute permission for the user: +``` chmod u+x [file or directory] - -arduino -Copy code +``` To remove write permission for the group and others: +``` chmod go-w [file or directory] +``` -Copy code -vbnet -Copy code - -Here's the third part of the requested content within a single Markdown code block for your README.md file: -markdown -Copy code To set read and execute permissions for the user, and read permission for the group and others: -chmod u=rw,g=r,o=r [file or directory] -perl -Copy code +``` +chmod u=rw,g=r,o=r [file or directory] +``` ## Octal Mode @@ -207,54 +201,60 @@ Copy code To set read, write, and execute permissions for the user, read and write permissions for the group, and read permission for others: +``` chmod 764 [file or directory] +``` -Here's the continuation of the content within a single Markdown code block for your README.md file, following the line "chmod 764 [file or directory]": - -```markdown ## chown - Change File and Directory Ownership ### Syntax +``` chown [owner]:[group] [file or directory] - +``` ### Example To change the owner of a file or directory to `newuser` and the group to `newgroup`: +``` chown newuser:newgroup [file or directory] - +``` To change only the owner to `newuser`: +``` chown newuser [file or directory] - +``` To change only the group to `newgroup`: +``` chown :newgroup [file or directory] - +``` ## Additional Notes - The `chmod` and `chown` commands can be used recursively with the `-R` option to change permissions or ownership for a directory and its contents: + +``` chmod -R [permissions] [directory] chown -R [owner]:[group] [directory] +``` -bash -Copy code - You can use the `umask` command to set default file permissions for newly created files: +``` umask [octal value] - +``` - You can use the `id` command to display information about the current user and group: +``` id - +``` For more information and examples, consult the `man` pages for each command: ``` man chmod From b1f29b9d157a0562025ac0a6b6b07c950afca41c Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 11:04:13 +0800 Subject: [PATCH 006/135] readme linux command --- 1-Linux_Tutorial/README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/1-Linux_Tutorial/README.md b/1-Linux_Tutorial/README.md index aeaecef..c812287 100644 --- a/1-Linux_Tutorial/README.md +++ b/1-Linux_Tutorial/README.md @@ -162,9 +162,6 @@ This section provides an in-depth explanation of the `chmod` and `chown` command To add execute permission for the user: -### Example - -To add execute permission for the user: ``` chmod u+x [file or directory] From 30547e23fb1a2a02095442220bc7795a6dcc36c4 Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 11:10:21 +0800 Subject: [PATCH 007/135] readme linux command --- 1-Linux_Tutorial/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/1-Linux_Tutorial/README.md b/1-Linux_Tutorial/README.md index c812287..14b2d17 100644 --- a/1-Linux_Tutorial/README.md +++ b/1-Linux_Tutorial/README.md @@ -230,6 +230,32 @@ To change only the group to `newgroup`: ``` chown :newgroup [file or directory] ``` + +## chmod Examples for Different File Types + +1. Set read-only permission for a `.pem` file: + +``` +chmod 400 private_key.pem +``` +This restricts the `.pem` file to be readable only by the owner, ensuring the private key remains secure. + +2. Set read, write, and execute permissions for the owner, and read and execute permissions for the group and others on a `script.sh` file: + +``` +chmod 755 script.sh + +``` +This allows the owner to read, write, and execute the script, while others can only read and execute it. + +3. Set read, write, and execute permissions for the owner, group, and others on a `script.sh` file: + +``` +chmod 777 script.sh +``` + +This allows everyone to read, write, and execute the script, which can be a security risk and is generally not recommended. + ## Additional Notes - The `chmod` and `chown` commands can be used recursively with the `-R` option to change permissions or ownership for a directory and its contents: From 909a46904a62f8fa61dcb2c1d6fd02090b59a41b Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 11:14:16 +0800 Subject: [PATCH 008/135] readme linux command --- 1-Linux_Tutorial/README.md | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/1-Linux_Tutorial/README.md b/1-Linux_Tutorial/README.md index 14b2d17..f6432d8 100644 --- a/1-Linux_Tutorial/README.md +++ b/1-Linux_Tutorial/README.md @@ -194,6 +194,53 @@ chmod u=rw,g=r,o=r [file or directory] | `6` | Read and Write | | `7` | Read, Write, Execute| + +## Octal Permissions and Examples + +| Octal Value | Permission | Description | Example | +| ----------- | ------------------- | ---------------------------------------- | ---------------------------- | +| `0` | No permission | No permissions are granted | `chmod 000 file.txt` | +| `1` | Execute | Execute permission only | `chmod 111 script.sh` | +| `2` | Write | Write permission only | `chmod 222 file.txt` | +| `3` | Write and Execute | Write and execute permissions | `chmod 333 script.sh` | +| `4` | Read | Read permission only | `chmod 444 file.txt` | +| `5` | Read and Execute | Read and execute permissions | `chmod 555 script.sh` | +| `6` | Read and Write | Read and write permissions | `chmod 666 file.txt` | +| `7` | Read, Write, Execute| All permissions (read, write, and execute)| `chmod 777 script.sh` | + +To set permissions using octal values, use the `chmod` command followed by the octal value for user, group, and others: +``` +chmod [user][group][others] [file or directory] +``` +Example: + +To set read, write, and execute permissions for the user, read and execute permissions for the group, and read permissions for others: +``` +chmod 754 script.sh +``` +## Combining Octal Permissions + +You can combine octal permissions to create custom permission sets for your files and directories. Each digit in the octal value represents the permissions for the user, group, and others, respectively. + +### Examples + +1. To set read and write permissions for the user, and read permissions for the group and others: + +``` +chmod 644 file.txt +``` + +2. To set read, write, and execute permissions for the user, and read permissions for the group and others: +``` +chmod 744 script.sh +``` + +3. To set read and execute permissions for the user, group, and others: +``` +chmod 555 script.sh +``` + +Remember to carefully choose permissions based on the security requirements ### Example To set read, write, and execute permissions for the user, read and write permissions for the group, and read permission for others: From e3f3e108891aa33f8295584e4c69c6f9c4cf8a9b Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 11:22:58 +0800 Subject: [PATCH 009/135] readme linux command --- 2-Git/README.md | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 2-Git/README.md diff --git a/2-Git/README.md b/2-Git/README.md new file mode 100644 index 0000000..e55ec84 --- /dev/null +++ b/2-Git/README.md @@ -0,0 +1,104 @@ +# Version Control System + +## Introduction + +Version control systems (VCS) are essential tools for tracking changes in software projects, allowing you to maintain a complete history of modifications made to your codebase. This enables developers to easily collaborate, track progress, and revert changes if needed. + +## Working with Git + +Git is a popular distributed version control system designed for handling projects of all sizes with speed and efficiency. It is widely used by developers around the world and has become the de facto standard for version control. + +### Unassisted Practice: Install Git on Linux + +To install Git on a Linux system, follow these steps: + +1. Open a terminal. +2. Update the package list by running: + +``` +sudo apt update +``` +3. Install Git with the following command: + + +``` +sudo apt install git +``` + +4. Verify the installation by checking the Git version: + +``` +git --version + +``` + +5. Configure your Git username and email: + +``` +git config --global user.name "Your Name" + +git config --global user.email "youremail@example.com" + +``` + +You have now successfully installed Git on your Linux system. + +# Part 2 + +## GitHub as an SCM Tool + +GitHub is a web-based platform for version control and collaboration using Git. It provides a simple and user-friendly interface for managing and collaborating on software projects. + +### Assisted Practice: Create and Clone a GitHub Repository + +1. Sign up for a GitHub account or sign in to your existing account. +2. Click on the "+" icon in the upper-right corner, and select "New repository." +3. Enter a repository name, add an optional description, choose visibility (public or private), and click "Create repository." +4. Copy the repository URL from the "Quick setup" section. +5. On your local machine, open a terminal and navigate to the directory where you want to clone the repository. +6. Run the following command to clone the repository: + +``` +git clone [repository URL] +``` + +You have now created a GitHub repository and cloned it to your local machine. + +## Fork, Push, and Pull in Git + +### Assisted Practice: Create a Pull Request in Git + +1. Fork a repository on GitHub by clicking the "Fork" button at the top right corner of the repository page. + +2. Clone the forked repository to your local machine: + +``` +git clone [forked repository URL] +``` + +3. Create a new branch for your changes: + +``` +git checkout -b [new branch name] +``` + +4. Make changes to the files and commit them: + +``` +git add . +git commit -m "Your commit message" +``` + +5. Push your changes to your forked repository: + +``` +git push origin [new branch name] +``` + +6. Go to the original repository on GitHub, and click on the "Pull Requests" tab. + +7. Click on the "New Pull Request" button, and choose the branch you just pushed from your forked repository. + +8. Review your changes and click "Create Pull Request." + +You have now created a pull request in Git. From de518e358eeb5a0f2f8afd39242053edb0ecc27c Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 11:30:56 +0800 Subject: [PATCH 010/135] readme linux command --- 2-Git/README.md | 144 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/2-Git/README.md b/2-Git/README.md index e55ec84..0070a72 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -102,3 +102,147 @@ git push origin [new branch name] 8. Review your changes and click "Create Pull Request." You have now created a pull request in Git. + + +# Part 3 + +### Assisted Practice: Push file to GitHub Repository + +1. Navigate to your local repository in the terminal. +2. Create or modify a file in the repository. +3. Stage the changes using: + +``` +git add [file name] +``` +To stage all changes in the repository, use: +``` +git add . + +``` + +4. Commit the changes with a meaningful commit message: + +``` +git commit -m "Your commit message" +``` + +5. Push the changes to the remote repository on GitHub: + +``` +git push origin [branch name] +``` + +Your changes are now pushed to the GitHub repository. + +## Branching in Git + +Branching allows you to create a separate line of development within a repository, enabling you to work on features or fixes independently from the main branch. This makes it easier to manage and maintain code, especially in large projects with multiple contributors. + +### Assisted Practice: Create a Branch in Git + +1. Navigate to your local repository in the terminal. +2. Create a new branch with a descriptive name: + +``` +git checkout -b [new branch name] +``` + +3. Verify that you have switched to the new branch: + +``` +git branch +``` + +You have now created a new branch in Git. + +## Switching Branches in Git + +Switching branches allows you to move between different lines of development in your repository. + +### Assisted Practice: Switching Branches in Git + +1. List all branches in your local repository: + +``` +git branch +``` + +2. Switch to an existing branch: + +``` +git checkout [existing branch name] +``` + +3. Verify that you have switched to the desired branch: + +``` +git branch +``` + +You have now successfully switched branches in Git. + +## Merging Branches in Git + +Merging branches in Git is the process of combining changes from one branch into another. This is commonly done when a feature or fix is completed and ready to be integrated into the main branch. + +### Assisted Practice: Merging Branches in Git + +1. Ensure that you have committed all changes in the branch you want to merge. +2. Switch to the target branch: + +``` +git checkout [target branch name] +``` + +3. Merge the changes from the source branch into the target branch: + +``` +git merge [source branch name] +``` + +4. Resolve any merge conflicts if they occur, and commit the changes. +5. Push the updated target branch to the remote repository: + +``` +git push origin [target branch name] +``` + +You have now successfully merged branches in Git. + +This completes the content for your README.md file on version control systems, Git, and GitHub. + + +## Using "git switch" Command + +The "git switch" command is an alternative way to switch branches in Git, introduced in Git version 2.23.0. It provides a more straightforward and user-friendly method for switching branches compared to the "git checkout" command. + +### Assisted Practice: Switching Branches Using "git switch" + +1. List all branches in your local repository: + +``` +git branch +``` + +2. Switch to an existing branch using the "git switch" command: + +``` +git switch [existing branch name] +``` + + +3. Verify that you have switched to the desired branch: +``` +git branch +``` + +You have now successfully switched branches using the "git switch" command. + +### Creating a New Branch with "git switch" + +You can also create a new branch and switch to it using the "git switch" command in a single step: +``` +git switch -c [new branch name] +``` +This command will create a new branch with the specified name and switch \ No newline at end of file From 8734527c480b342a9a2dd4abff4fadd6ae702ce2 Mon Sep 17 00:00:00 2001 From: varun-sl Date: Sun, 23 Apr 2023 04:47:26 +0000 Subject: [PATCH 011/135] uploading history commands --- 2-Git/history.txt | 145 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 2-Git/history.txt diff --git a/2-Git/history.txt b/2-Git/history.txt new file mode 100644 index 0000000..3b3b7d8 --- /dev/null +++ b/2-Git/history.txt @@ -0,0 +1,145 @@ +ls +ls -l +clear +pwd +ls +cd Desktop/ +ls +ll +pwd +cd /home/varunmanikoutlo/ +pwd +ll +ls -l +ll +ls -la +ls -lar +ls -lart +ls -larth +cd /home/varunmanikoutlo/ +pwd +cd Desktop/ +cd ../ +history +history | cut -c 8- +history +history | cut -c 8- +man cut +man +man ls +man cut +ll +mkdir varun +ll +mkdir -p /opt/one/two/tree/four +mkdir -p ./one/two/tree/four +ll +ll one/ +ll one/two/ +ll one/two/tree/ +tree +apt install tree +sudo -i +sudo su +sudo apt install tree +htop +sudo apt install elinks +apt install elinks +sudo apt install elinks +sudo visudo +touch one/one.txt +tree one/ +tree one/two/index.html +touch one/two/index.html +tree one/two/index.html +tree one/ +cd one/ +touch a.txt b.txt c.txt d.log +ll +vim a.txt +ll +echo "hi this is for file b.txt" +echo "hi this is for file b.txt" > b.txt +cat b.txt +cat a.txt +history +history > history.txt +ll +cat history.txt +ll +rm a.txt +ll +rm *.txt +ll +tree +rm two/ +rmdir two/ +rmdir two/ -r +rmdir two/ -f +rmdir two +rmdir -f two +rmdir -rf two +rm -rf two +tree +ls +cd .. +ll +rm -rf one/ +history +history | cut -c 8- +ehoc "hi" > index.html +echo "hi" > index.html +cat index.html +echo "hi i am good " >> index.html +cat index.html +echo "hi i am good. How are you ? " >> index.html +cat index.html +ll +touch varun/a.txt +uname -a +date +cat /etc/issue +apt install git +sudo apt install git +cat /etc/os-release +cd varun/ +git clone https://github.com/manikcloud/java-calculator-delete.git +ll +cd java-calculator-delete/ +ll +vim README.md +git add README.md +git commit -am"first upload" +git push +cd .. +rm -rf java-calculator-delete/ +ll +git clone git@github.com:manikcloud/java-calculator-delete.git +ssh-keygen +cd ~/.ssh/ +ll +cat id_rsa +cat id_rsa.pub +llcd - +cd - +git clone git@github.com:manikcloud/java-calculator-delete.git +ll +cd java-calculator-delete/ +vim README.md +git add . +git push +git config --global user.email varunmanik1@gmail.com +git config --global user.name varun-sl +git push +git status +git commit -am"hi" +gitpush +git push +cd .. +git clone git@github.com:manikcloud/DevOps-Tutorial.git +ll +cd DevOps-Tutorial/ +ll +cd 2-Git/ +history +history | cut -c 8- > history.txt From 18a78a08a176e26a921c7585515d46770c51007d Mon Sep 17 00:00:00 2001 From: VARUN KUMAR MANIK Date: Sun, 23 Apr 2023 12:49:41 +0800 Subject: [PATCH 012/135] ssh command details --- 2-Git/ssh-command-details | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 2-Git/ssh-command-details diff --git a/2-Git/ssh-command-details b/2-Git/ssh-command-details new file mode 100644 index 0000000..884f802 --- /dev/null +++ b/2-Git/ssh-command-details @@ -0,0 +1,28 @@ +ssh-keygen +cd ~/.ssh/ +ll +cat id_rsa +cat id_rsa.pub +llcd - +cd - +git clone git@github.com:manikcloud/java-calculator-delete.git +ll +cd java-calculator-delete/ +vim README.md +git add . +git push +git config --global user.email varunmanik1@gmail.com +git config --global user.name varun-sl +git push +git status +git commit -am"hi" +gitpush +git push +cd .. +git clone git@github.com:manikcloud/DevOps-Tutorial.git +ll +cd DevOps-Tutorial/ +ll +cd 2-Git/ +history +history | cut -c 8- > history.txt From 7e0986ba6476ca71bf16c3742d7b7340f3965191 Mon Sep 17 00:00:00 2001 From: varun-sl Date: Sun, 23 Apr 2023 04:51:20 +0000 Subject: [PATCH 013/135] uploading history commands --- 2-Git/ssh-command-details | 2 -- 1 file changed, 2 deletions(-) diff --git a/2-Git/ssh-command-details b/2-Git/ssh-command-details index 884f802..d0eb36d 100644 --- a/2-Git/ssh-command-details +++ b/2-Git/ssh-command-details @@ -1,9 +1,7 @@ ssh-keygen cd ~/.ssh/ ll -cat id_rsa cat id_rsa.pub -llcd - cd - git clone git@github.com:manikcloud/java-calculator-delete.git ll From f7207dc1b46c6b91fcd05cb6240457def3b874b0 Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 13:40:43 +0800 Subject: [PATCH 014/135] readme linux command --- 2-Git/README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/2-Git/README.md b/2-Git/README.md index 0070a72..98f302f 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -245,4 +245,28 @@ You can also create a new branch and switch to it using the "git switch" command ``` git switch -c [new branch name] ``` -This command will create a new branch with the specified name and switch \ No newline at end of file +This command will create a new branch with the specified name and switch + + +# SSH Connectivity to your Simplilearn lab VM + +- Step 1 - Loging to github +- Step 2: Create a Repo +- Step 3 : Click on your user profile and clicl on stetting +- step 4: Click on ssh key +- step copy and paste your pub key +- Step 6: Click OK +- Step 7: Clon your repo + +## create ssh key in your lab vm + +- Step 1: Login to lab VM and open terminal +- Step 2: runthe following command + +``` +ssh-keygen +``` +Enter three time to create the public & private key + +- Step 3 : copy the content of you `id_rs.pub` key +- Step 4 : Paste the content in privious step 6 From d682f671df67621dd873fcc1ff8135cb0d58834b Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 13:43:35 +0800 Subject: [PATCH 015/135] readme linux command --- 2-Git/README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/2-Git/README.md b/2-Git/README.md index 98f302f..588c22a 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -254,9 +254,9 @@ This command will create a new branch with the specified name and switch - Step 2: Create a Repo - Step 3 : Click on your user profile and clicl on stetting - step 4: Click on ssh key -- step copy and paste your pub key +- step 4.: Copy and paste your pub key - Step 6: Click OK -- Step 7: Clon your repo +- Step 7: Clone your repo ## create ssh key in your lab vm @@ -268,5 +268,9 @@ ssh-keygen ``` Enter three time to create the public & private key -- Step 3 : copy the content of you `id_rs.pub` key +- Step 3 : copy the content of you `id_rsa.pub` key + +``` +cat ~/.id_ras.pub +``` - Step 4 : Paste the content in privious step 6 From eb89ebe00f80afb68f7bb32c9b53a30003c29b99 Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 13:49:52 +0800 Subject: [PATCH 016/135] readme linux command --- 2-Git/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-Git/README.md b/2-Git/README.md index 588c22a..80e5152 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -271,6 +271,6 @@ Enter three time to create the public & private key - Step 3 : copy the content of you `id_rsa.pub` key ``` -cat ~/.id_ras.pub +cat ~/.ssh/id_rsa.pub ``` - Step 4 : Paste the content in privious step 6 From 2b6694628a978196d461b6a0bc61cd31e9b65854 Mon Sep 17 00:00:00 2001 From: Varun-lab Date: Sun, 23 Apr 2023 06:26:38 +0000 Subject: [PATCH 017/135] index.html basic code --- index.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..00c372a --- /dev/null +++ b/index.html @@ -0,0 +1,23 @@ + + + + + + +Page Title + + + + + + + +

This is a Heading

+ +

This is a paragraph.

+ + + + + + From 1b0e3e7b86e3cd1ce01655d2af570cf77b7ba427 Mon Sep 17 00:00:00 2001 From: Varun-lab Date: Sun, 23 Apr 2023 06:39:04 +0000 Subject: [PATCH 018/135] adding a ne branch: Dev --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 00c372a..34796c1 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@

This is a Heading

-

This is a paragraph.

+

This is a paragraph in Dev Branch

From 42a0b8bdb50e0ea90ec90cb19beffed7430bc1a4 Mon Sep 17 00:00:00 2001 From: Varun-lab Date: Sun, 23 Apr 2023 06:41:20 +0000 Subject: [PATCH 019/135] delete --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 34796c1..b241a6d 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@

This is a Heading

-

This is a paragraph in Dev Branch

+

This is a paragraph in Dev Branch in main

From 13c709fca7966b7bb76d5e475bac80821261c16f Mon Sep 17 00:00:00 2001 From: Varun-lab Date: Sun, 23 Apr 2023 06:51:58 +0000 Subject: [PATCH 020/135] hi --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index b241a6d..82e5bd6 100644 --- a/index.html +++ b/index.html @@ -21,3 +21,4 @@

This is a Heading

+hi From b94dfb64b46d5eca2ac49f2fad131b0a9ee4724b Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 23 Apr 2023 18:32:42 +0800 Subject: [PATCH 021/135] readme linux command --- 2-Git/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/2-Git/README.md b/2-Git/README.md index 80e5152..c4ac27c 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -274,3 +274,29 @@ Enter three time to create the public & private key cat ~/.ssh/id_rsa.pub ``` - Step 4 : Paste the content in privious step 6 + + +# Common error while stting the above steps + +``` +git clone git@github.com:sindhugowda1991/java.calculatore-delete.git +Cloning into 'java.calculatore-delete'... +The authenticity of host 'github.com (140.82.114.4)' can't be established. +ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM. +Are you sure you want to continue connecting (yes/no/[fingerprint])? y +Please type 'yes', 'no' or the fingerprint: y +Please type 'yes', 'no' or the fingerprint: y +Please type 'yes', 'no' or the fingerprint: n +Please type 'yes', 'no' or the fingerprint: y +Please type 'yes', 'no' or the fingerprint: y +Please type 'yes', 'no' or the fingerprint: y +Please type 'yes', 'no' or the fingerprint: y +Please type 'yes', 'no' or the fingerprint: y +Please type 'yes', 'no' or the fingerprint: yes +Warning: Permanently added 'github.com,140.82.114.4' (ECDSA) to the list of known hosts. +git@github.com: Permission denied (publickey). +fatal: Could not read from remote repository. + +Please make sure you have the correct access rights +and the repository exists. +``` \ No newline at end of file From 9c9d4d1b71289689e6f05147447ce614f73cc7d4 Mon Sep 17 00:00:00 2001 From: Varunmanik2 <103329447+Varunmanik2@users.noreply.github.com> Date: Sat, 29 Apr 2023 10:31:17 +0800 Subject: [PATCH 022/135] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d75f935..b0e9b76 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # DevOps-Tutorial -DevOps-Tutorial +DevOps-Tutorial By Varun Kumar Manik. # Caltech-DevOps Simplilearn PG Program This repository contains course materials for the Caltech-DevOps Simplilearn Postgraduate Program. From 1b858bd530094df7fcfb7f7a8cc6d67d9cf0cf94 Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 10:49:53 +0800 Subject: [PATCH 023/135] readme --- 2-Git/README.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/2-Git/README.md b/2-Git/README.md index c4ac27c..55e7119 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -299,4 +299,69 @@ fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. -``` \ No newline at end of file +``` + + + +# Git Branch Guide + +This is a step-by-step guide to help you understand and work with Git branches. Branches are a fundamental feature of Git that allows developers to work on multiple tasks simultaneously without interfering with each other. + +## Table of Contents + +1. [Purpose of Git Branches](#purpose-of-git-branches) +2. [Creating a Branch](#creating-a-branch) +3. [Switching Between Branches](#switching-between-branches) +4. [Merging Branches](#merging-branches) +5. [Deleting a Branch](#deleting-a-branch) + +## Purpose of Git Branches + +Git branches allow you to separate different features or bug fixes into their own isolated environments. This makes it easier to manage, test, and collaborate on code without causing conflicts. + +## Creating a Branch + +To create a new branch, use the following command: + +``` +git checkout -b +``` + +This will create a new branch and switch to it. + +## Switching Between Branches + +To switch between branches, use the following command: + +``` +git checkout +``` + +This will switch to the specified branch. + +## Merging Branches + +To merge one branch into another, first switch to the branch you want to merge into: + +``` +git checkout +``` + +Then, use the following command to merge the other branch: + +``` +git merge +``` + +This will merge the changes from the source branch into the target branch. + +## Deleting a Branch + +To delete a branch, use the following command: + +``` +git branch -d +``` + +This will delete the specified branch. + From 13576df629855475fa590e8b3eb99e809c163507 Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 10:51:41 +0800 Subject: [PATCH 024/135] readme --- 2-Git/README.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/2-Git/README.md b/2-Git/README.md index 55e7119..5d66b9b 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -365,3 +365,71 @@ git branch -d This will delete the specified branch. +## Git Merge, Reset, and Rebase + +These operations are used to manipulate the commit history and combine changes from different branches. + +### Git Merge + +Git merge combines the changes from one branch into another. To perform a merge, follow these steps: + +1. Switch to the target branch: + + \```bash + git checkout + \``` + +2. Merge the source branch into the target branch: + + \```bash + git merge + \``` + +### Git Reset + +Git reset is used to undo commits or move the branch pointer to a different commit. There are three modes: soft, mixed (default), and hard. + +1. Soft reset: + + \```bash + git reset --soft + \``` + + This will move the branch pointer to the specified commit, but keep the changes in the staging area. + +2. Mixed reset (default): + + \```bash + git reset + \``` + + This will move the branch pointer to the specified commit and unstage the changes. + +3. Hard reset: + + \```bash + git reset --hard + \``` + + This will move the branch pointer to the specified commit and discard all changes. + +### Git Rebase + +Git rebase is used to apply a series of commits from one branch onto another, creating a linear history. To perform a rebase, follow these steps: + +1. Switch to the branch that has the commits you want to apply: + + \```bash + git checkout + \``` + +2. Rebase the source branch onto the target branch: + + \```bash + git rebase + \``` + + This will apply the commits from the source branch on top of the target branch. + +Note: Be cautious when using `git rebase` as it can rewrite the commit history. It's recommended to use it only on local branches that haven't been pushed to a remote repository. + From 7e4bea6926a1f1361dc76e1c6d3df4ae091712cb Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 10:52:14 +0800 Subject: [PATCH 025/135] readme --- 2-Git/README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/2-Git/README.md b/2-Git/README.md index 5d66b9b..44a0646 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -375,15 +375,15 @@ Git merge combines the changes from one branch into another. To perform a merge, 1. Switch to the target branch: - \```bash + ``` git checkout - \``` + ``` 2. Merge the source branch into the target branch: - \```bash + ``` git merge - \``` + ``` ### Git Reset @@ -391,25 +391,25 @@ Git reset is used to undo commits or move the branch pointer to a different comm 1. Soft reset: - \```bash + ``` git reset --soft - \``` + ``` This will move the branch pointer to the specified commit, but keep the changes in the staging area. 2. Mixed reset (default): - \```bash + ``` git reset - \``` + ``` This will move the branch pointer to the specified commit and unstage the changes. 3. Hard reset: - \```bash + ``` git reset --hard - \``` + ``` This will move the branch pointer to the specified commit and discard all changes. @@ -419,15 +419,15 @@ Git rebase is used to apply a series of commits from one branch onto another, cr 1. Switch to the branch that has the commits you want to apply: - \```bash + ``` git checkout - \``` + ``` 2. Rebase the source branch onto the target branch: - \```bash + ``` git rebase - \``` + ``` This will apply the commits from the source branch on top of the target branch. From a942aeb20b42de1f24b38738133bc1f9e4b6e667 Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 10:52:49 +0800 Subject: [PATCH 026/135] readme --- 2-Git/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/2-Git/README.md b/2-Git/README.md index 44a0646..dfa6701 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -433,3 +433,10 @@ Git rebase is used to apply a series of commits from one branch onto another, cr Note: Be cautious when using `git rebase` as it can rewrite the commit history. It's recommended to use it only on local branches that haven't been pushed to a remote repository. +| Operation | Description | Usage | +|-----------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------| +| Revert | Creates a new commit that undoes the changes made in a specific commit. | ```bash | +| | | git revert | +| | | ``` | +| Reset | Moves the branch pointer to a specified commit. Can be used in soft, mixed (default), or hard mode. | Soft reset: | +| | From 95e324994066f692b52a74bcd8adf595056182ff Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 10:53:27 +0800 Subject: [PATCH 027/135] readme --- 2-Git/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-Git/README.md b/2-Git/README.md index dfa6701..9033e7b 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -435,7 +435,7 @@ Note: Be cautious when using `git rebase` as it can rewrite the commit history. | Operation | Description | Usage | |-----------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------| -| Revert | Creates a new commit that undoes the changes made in a specific commit. | ```bash | +| Revert | Creates a new commit that undoes the changes made in a specific commit. | ``` | | | | git revert | | | | ``` | | Reset | Moves the branch pointer to a specified commit. Can be used in soft, mixed (default), or hard mode. | Soft reset: | From f281eda6d0ae276cd85015bde591842a86e562e3 Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 10:54:56 +0800 Subject: [PATCH 028/135] readme --- 2-Git/README.md | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/2-Git/README.md b/2-Git/README.md index 9033e7b..39d69c9 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -433,10 +433,26 @@ Git rebase is used to apply a series of commits from one branch onto another, cr Note: Be cautious when using `git rebase` as it can rewrite the commit history. It's recommended to use it only on local branches that haven't been pushed to a remote repository. -| Operation | Description | Usage | -|-----------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------| -| Revert | Creates a new commit that undoes the changes made in a specific commit. | ``` | -| | | git revert | -| | | ``` | -| Reset | Moves the branch pointer to a specified commit. Can be used in soft, mixed (default), or hard mode. | Soft reset: | -| | + +| Operation | Description | Usage | +|-----------------|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| **Git Revert** | Creates a new commit that undoes the changes made in a specific commit. | ``` | +| | | git revert | +| | | ``` | +| **Git Reset** | Moves the branch pointer to a specified commit. Soft, mixed (default), or hard mode. | Soft reset: | +| | | ``` | +| | | git reset --soft | +| | | ``` | +| | | Mixed reset (default): | +| | | ``` | +| | | git reset | +| | | ``` | +| | | Hard reset: | +| | | ``` | +| | | git reset --hard | +| | | ``` | +| **Git Rebase** | Applies a series of commits from one branch onto another, creating a linear history. | ``` | +| | | git checkout | +| | | git rebase | +| | | ``` | + From 486b19cbcbc3bb5572fa6aa75bd9b58b615b6e2e Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 10:59:17 +0800 Subject: [PATCH 029/135] readme for this branch string --- 2-Git/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/2-Git/README.md b/2-Git/README.md index 39d69c9..eaca117 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -247,6 +247,21 @@ git switch -c [new branch name] ``` This command will create a new branch with the specified name and switch +# Git Switch vs git Checkout + +| Operation | Description | Usage | +|------------------|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| +| **Git Switch** | Switches to a different branch or commit, creating a new branch if needed. | ``` | +| | | git switch | +| | | git switch -c | +| | | git switch --detach | +| | | ``` | +| **Git Checkout** | Switches to a different branch or commit, creating a new branch if needed. | ``` | +| | | git checkout | +| | | git checkout -b | +| | | git checkout | +| | | ``` | + # SSH Connectivity to your Simplilearn lab VM From 7370e52fd33e6f4a6cc9d7640d3f4df4593e7e77 Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 11:02:51 +0800 Subject: [PATCH 030/135] readme for this branch string --- 2-Git/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/2-Git/README.md b/2-Git/README.md index eaca117..b96608c 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -32,13 +32,16 @@ git --version ``` -5. Configure your Git username and email: +5. Configure your Git username, email & Editor: ``` git config --global user.name "Your Name" git config --global user.email "youremail@example.com" +git config --global core.editor "code --wait" + + ``` You have now successfully installed Git on your Linux system. From dac09317ea041531540da18f60f3fd9e72e583a4 Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 11:08:39 +0800 Subject: [PATCH 031/135] readme for this branch string --- 2-Git/README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/2-Git/README.md b/2-Git/README.md index b96608c..25d5d61 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -306,11 +306,6 @@ Please type 'yes', 'no' or the fingerprint: y Please type 'yes', 'no' or the fingerprint: y Please type 'yes', 'no' or the fingerprint: n Please type 'yes', 'no' or the fingerprint: y -Please type 'yes', 'no' or the fingerprint: y -Please type 'yes', 'no' or the fingerprint: y -Please type 'yes', 'no' or the fingerprint: y -Please type 'yes', 'no' or the fingerprint: y -Please type 'yes', 'no' or the fingerprint: yes Warning: Permanently added 'github.com,140.82.114.4' (ECDSA) to the list of known hosts. git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. @@ -318,7 +313,16 @@ fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` +## Solution +1. Open the `known_hosts` file using a text editor like `nano` or `vim`: + + ``` + nano ~/.ssh/known_hosts + ``` + +2. Locate the entry for the host you want to delete. The entry will start with the hostname (e.g., `github.com`) or the IP address, followed by the public key and some other information. Delete the entire line containing the entry, save the changes, and close the text editor. +----------------------------------------------------------------------------------------------------------- # Git Branch Guide From 8e1e2ca37dc8d58ca1ecf38975dcc0aa5392ac3d Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 11:10:09 +0800 Subject: [PATCH 032/135] readme for this branch string --- 2-Git/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2-Git/README.md b/2-Git/README.md index 25d5d61..5bf05a4 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -254,11 +254,11 @@ This command will create a new branch with the specified name and switch | Operation | Description | Usage | |------------------|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| -| **Git Switch** | Switches to a different branch or commit, creating a new branch if needed. | ``` | +| **Git Switch** | Switches to a different branch or commit, creating a new branch if needed. | | | | | git switch | | | | git switch -c | | | | git switch --detach | -| | | ``` | +| | | | | **Git Checkout** | Switches to a different branch or commit, creating a new branch if needed. | ``` | | | | git checkout | | | | git checkout -b | From 90cb67d40d53a3d678381ae235e533c83972d5f9 Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 11:10:37 +0800 Subject: [PATCH 033/135] readme for this branch string --- 2-Git/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-Git/README.md b/2-Git/README.md index 5bf05a4..13b01b6 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -254,7 +254,7 @@ This command will create a new branch with the specified name and switch | Operation | Description | Usage | |------------------|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| -| **Git Switch** | Switches to a different branch or commit, creating a new branch if needed. | | +| **Git Switch** | Switches to a different branch or commit, creating a new branch if needed. | | | git switch | | | | git switch -c | | | | git switch --detach | From af0cbc8e12d26e9850a662caecce1386d169a401 Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 11:11:08 +0800 Subject: [PATCH 034/135] readme for this branch string --- 2-Git/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-Git/README.md b/2-Git/README.md index 13b01b6..1ca1095 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -255,7 +255,7 @@ This command will create a new branch with the specified name and switch | Operation | Description | Usage | |------------------|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| | **Git Switch** | Switches to a different branch or commit, creating a new branch if needed. -| | | git switch | +git switch | | | | git switch -c | | | | git switch --detach | | | | | From 6f1679ec3e45895b322c70a33a865dee6bf3d116 Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 11:11:29 +0800 Subject: [PATCH 035/135] readme for this branch string --- 2-Git/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-Git/README.md b/2-Git/README.md index 1ca1095..13b01b6 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -255,7 +255,7 @@ This command will create a new branch with the specified name and switch | Operation | Description | Usage | |------------------|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| | **Git Switch** | Switches to a different branch or commit, creating a new branch if needed. -git switch | +| | | git switch | | | | git switch -c | | | | git switch --detach | | | | | From 7ab7b32ef1d6725f83313977b0b0c0462fb6c61c Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 11:16:44 +0800 Subject: [PATCH 036/135] readme for this branch string --- 2-Git/README.md | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/2-Git/README.md b/2-Git/README.md index 13b01b6..1d37792 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -478,3 +478,113 @@ Note: Be cautious when using `git rebase` as it can rewrite the commit history. | | | git rebase | | | | ``` | +## Components of the .git Folder + +The `.git` folder is the heart of a Git repository, and it contains all the metadata and objects required for version control. Here's an overview of its components: + +### HEAD + +\```bash +.git/HEAD +\``` + +The `HEAD` file is a reference to the currently checked-out commit. It usually points to the tip of the current branch. + +### config + +\```bash +.git/config +\``` + +The `config` file contains repository-specific configuration settings. These settings override global and system-wide settings. + +### description + +\```bash +.git/description +\``` + +The `description` file contains a brief text description of the repository. This file is used primarily by the GitWeb program and is not essential for Git functionality. + +### hooks + +\```bash +.git/hooks +\``` + +The `hooks` directory contains script files that can be executed automatically when certain Git events occur, such as pre-commit, post-commit, or pre-receive. These scripts can be used to enforce coding standards, send notifications, or perform other custom tasks. + +### info + +\```bash +.git/info +\``` + +The `info` directory contains additional metadata about the repository. The `exclude` file within this directory allows you to specify files or patterns to be ignored by Git, similar to a `.gitignore` file. + +### objects + +\```bash +.git/objects +\``` + +The `objects` directory stores all the data for your Git repository in a compressed format. It includes commits, trees, and blobs. + +### refs + +\```bash +.git/refs +\``` + +The `refs` directory contains pointers to commits. It includes references to branches (under `refs/heads`) and tags (under `refs/tags`). + +### branches, index, and logs (optional) + +\```bash +.git/branches +.git/index +.git/logs +\``` + +- The `branches` directory is used for storing legacy branch references and is rarely used in modern Git workflows. +- The `index` file contains staging area information, which is used to build the next commit. +- The `logs` directory contains a record of all updates made to the refs. + +## Table +| Component | Description | +|----------------|-----------------------------------------------------------------------------------------------------------------------------------| +| **HEAD** | A reference to the currently checked-out commit, usually pointing to the tip of the current branch. | +| **config** | Contains repository-specific configuration settings that override global and system-wide settings. | +| **description**| Contains a brief text description of the repository, primarily used by the GitWeb program. | +| **hooks** | A directory with script files that can be executed automatically when certain Git events occur, such as pre-commit or post-commit.| +| **info** | Contains additional metadata about the repository. The `exclude` file within allows specifying files or patterns to be ignored. | +| **objects** | Stores all the data for your Git repository in a compressed format, including commits, trees, and blobs. | +| **refs** | Contains pointers to commits, including references to branches (under `refs/heads`) and tags (under `refs/tags`). | +| **branches** | Used for storing legacy branch references, rarely used in modern Git workflows. | +| **index** | Contains staging area information, used to build the next commit. | +| **logs** | Contains a record of all updates made to the refs. | + + + +# Disclaimer +
+ +Please note that the entire repository is owned and maintained by [Varun Kumar Manik](https://www.linkedin.com/in/vkmanik/). While every effort has been made to ensure the accuracy and reliability of the information and resources provided in this repository, Varun Kumar Manik takes full responsibility for any errors or inaccuracies that may be present. + +Simplilearn is not responsible for the content or materials provided in this repository and disclaims all liability for any issues, misunderstandings, or claims that may arise from the use of the information or materials provided. By using this repository, you acknowledge that Varun Kumar Manik is solely accountable for its content, and you agree to hold Simplilearn harmless from any claims or liabilities that may arise as a result of your use or reliance on the information provided herein. + +It is important to understand that this repository contains educational materials for a training course, and users are expected to apply their own judgment and discretion when utilizing the provided resources. Neither Varun Kumar Manik nor Simplilearn can guarantee specific results or outcomes from following the materials in this repository. + +
+ +## Connect & Follow + +For more info, please connect and follow me: + +- Github: [https://github.com/manikcloud](https://github.com/manikcloud) +- LinkedIn: [https://www.linkedin.com/in/vkmanik/](https://www.linkedin.com/in/vkmanik/) +- Email: [varunmanik1@gmail.com](mailto:varunmanik1@gmail.com) +- Facebook: [https://www.facebook.com/cloudvirtualization/](https://www.facebook.com/cloudvirtualization/) +- YouTube: [https://bit.ly/32fknRN](https://bit.ly/32fknRN) +- Twitter: [https://twitter.com/varunkmanik](https://twitter.com/varunkmanik) + From aefc9a9c3d766a5381bc6ec7198cf1bc1b938901 Mon Sep 17 00:00:00 2001 From: varun Date: Sat, 29 Apr 2023 11:17:15 +0800 Subject: [PATCH 037/135] readme for this branch string --- 2-Git/README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/2-Git/README.md b/2-Git/README.md index 1d37792..3e9dad2 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -484,67 +484,67 @@ The `.git` folder is the heart of a Git repository, and it contains all the meta ### HEAD -\```bash +``` .git/HEAD -\``` +``` The `HEAD` file is a reference to the currently checked-out commit. It usually points to the tip of the current branch. ### config -\```bash +``` .git/config -\``` +``` The `config` file contains repository-specific configuration settings. These settings override global and system-wide settings. ### description -\```bash +``` .git/description -\``` +``` The `description` file contains a brief text description of the repository. This file is used primarily by the GitWeb program and is not essential for Git functionality. ### hooks -\```bash +``` .git/hooks -\``` +``` The `hooks` directory contains script files that can be executed automatically when certain Git events occur, such as pre-commit, post-commit, or pre-receive. These scripts can be used to enforce coding standards, send notifications, or perform other custom tasks. ### info -\```bash +``` .git/info -\``` +``` The `info` directory contains additional metadata about the repository. The `exclude` file within this directory allows you to specify files or patterns to be ignored by Git, similar to a `.gitignore` file. ### objects -\```bash +``` .git/objects -\``` +``` The `objects` directory stores all the data for your Git repository in a compressed format. It includes commits, trees, and blobs. ### refs -\```bash +``` .git/refs -\``` +``` The `refs` directory contains pointers to commits. It includes references to branches (under `refs/heads`) and tags (under `refs/tags`). ### branches, index, and logs (optional) -\```bash +``` .git/branches .git/index .git/logs -\``` +``` - The `branches` directory is used for storing legacy branch references and is rarely used in modern Git workflows. - The `index` file contains staging area information, which is used to build the next commit. From 7e647a6573db79d9c979e51f971c279e70c32690 Mon Sep 17 00:00:00 2001 From: Varunmanik2 <103329447+Varunmanik2@users.noreply.github.com> Date: Sat, 29 Apr 2023 12:00:47 +0800 Subject: [PATCH 038/135] Update README.md add space and add one more line --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b0e9b76..8c74258 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # DevOps-Tutorial -DevOps-Tutorial By Varun Kumar Manik. + +- DevOps-Tutorial By Varun Kumar Manik. +- Sending from User. # Caltech-DevOps Simplilearn PG Program This repository contains course materials for the Caltech-DevOps Simplilearn Postgraduate Program. From 7358b776cb84ba8af6638b721e667e322d12eef5 Mon Sep 17 00:00:00 2001 From: Varun manik Date: Sat, 29 Apr 2023 04:33:03 +0000 Subject: [PATCH 039/135] adding installlation file --- vs-code-installation.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 vs-code-installation.sh diff --git a/vs-code-installation.sh b/vs-code-installation.sh new file mode 100755 index 0000000..9085f13 --- /dev/null +++ b/vs-code-installation.sh @@ -0,0 +1,6 @@ +#!/bin/bash +sudo apt update +sudo apt install software-properties-common apt-transport-https wget +wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - +sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" +sudo apt install code \ No newline at end of file From 11e0e33d7beb15d934e885811e00673dd40da359 Mon Sep 17 00:00:00 2001 From: Varun manik Date: Sat, 29 Apr 2023 05:02:52 +0000 Subject: [PATCH 040/135] adding todays history --- history-apr-29-2023.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 history-apr-29-2023.txt diff --git a/history-apr-29-2023.txt b/history-apr-29-2023.txt new file mode 100644 index 0000000..a3825ec --- /dev/null +++ b/history-apr-29-2023.txt @@ -0,0 +1,19 @@ +git clone git@github.com:manikcloud/DevOps-Tutorial.git +ll +git branch +git branch -a +git checkout -b dev1 +git branch -a +git checkout -b dev-4567 +git branch -a +git switch -c uat-123 +git branch -a +git switch dev +git switch dev1 +git switch - +git branch -a +git switch main +git switch dev-4567 +history +history | cut -c 8- +history | cut -c 8- > history-apr-29-2023.txt From d926187fbd14b3b8bca18fe653681ca16c1cf561 Mon Sep 17 00:00:00 2001 From: Varun manik Date: Sat, 29 Apr 2023 05:34:50 +0000 Subject: [PATCH 041/135] few changes in index file --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 82e5bd6..db9cc0a 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ -Page Title +XYZ-company/title> </head> @@ -12,7 +12,7 @@ -<h1>This is a Heading</h1> +<h1>This is Giops Class going on. </h1> <p>This is a paragraph in Dev Branch in main </p> From 49573e2822dc471d212b1c965ace5d74e67d4a7d Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 29 Apr 2023 05:38:08 +0000 Subject: [PATCH 042/135] few changes in index file --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index db9cc0a..61ee027 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ -<h1>This is Giops Class going on. </h1> +<h1>This is GitOps Class going on. </h1> <p>This is a paragraph in Dev Branch in main </p> From 8229988a72d61e5d705bce8e23b6b3ad02c51c3c Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 29 Apr 2023 05:44:34 +0000 Subject: [PATCH 043/135] adding one more para --- index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 61ee027..4ba7365 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,9 @@ <h1>This is GitOps Class going on. </h1> -<p>This is a paragraph in Dev Branch in main </p> +<p>This is a paragraph in Dev Branch. </p> + +<p>we are learning about git Merge </p> From 5c3800b7d4f0e9b488814d721a97e6bd68a8ddf4 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 29 Apr 2023 05:49:47 +0000 Subject: [PATCH 044/135] add number --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 4ba7365..aec3c1a 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ -<h1>This is GitOps Class going on. </h1> +<h1>This is GitOps Class going on. 1 </h1> <p>This is a paragraph in Dev Branch. </p> From 67ab1c33906db603d0f284f9706f245a24787713 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 29 Apr 2023 06:07:37 +0000 Subject: [PATCH 045/135] hi --- hi.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 hi.txt diff --git a/hi.txt b/hi.txt new file mode 100644 index 0000000..45b983b --- /dev/null +++ b/hi.txt @@ -0,0 +1 @@ +hi From 1f72a2bb384aae2d19247cbf74a14b4b1c38cd4e Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 29 Apr 2023 06:12:38 +0000 Subject: [PATCH 046/135] Revert "add number" This reverts commit 5c3800b7d4f0e9b488814d721a97e6bd68a8ddf4. --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index aec3c1a..4ba7365 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ -<h1>This is GitOps Class going on. 1 </h1> +<h1>This is GitOps Class going on. </h1> <p>This is a paragraph in Dev Branch. </p> From 8d4065cdb654bc50ecff392ee642be7b9f7574ee Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 09:15:01 +0800 Subject: [PATCH 047/135] ansible -readme --- 6-ansible/README.md | 48 +++++++++++++++++++++++++++++++++++++++++++++ 6-ansible/node.yml | 19 ++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 6-ansible/README.md create mode 100644 6-ansible/node.yml diff --git a/6-ansible/README.md b/6-ansible/README.md new file mode 100644 index 0000000..fbfd0f6 --- /dev/null +++ b/6-ansible/README.md @@ -0,0 +1,48 @@ +# Lesson 06 Demo 2 +## Demonstrate YAML Scripting + +Steps to be performed: +1. Create a playbook +2. Add YAML script to the playbook to install node +3. Run Ansible YAML script + +## Step 1: Create a playbook +1.1 Use the below command to create a node.yml file + sudo vi node.yml +1.2 Establish SSH key pair in the Linux system to have SSH connectivity with localhost using the following commands: + ssh-keygen -t rsa (Press Enter when asked for File and Paraphrase details) + cat .ssh/id_rsa.pub >> .ssh/authorized_keys + ssh localhost -p 42006 (Type yes when prompted) +1.3 Now, add the host localhost in the Ansible host file /etc/ansible/hosts + sudo vi /etc/ansible/hosts +1.4 When the file opens, add the below two lines of the code at the end of the file: + [webservers] + localhost:42006 + +## Step 2: Add YAML script to the playbook to install node +2.1 Open the node.yaml file by using the below command and then add the following code + sudo vi node.yml +2.2 Copy and paste the below code into the node.yml file: + + ``` + --- + - hosts: webservers + become: true + tasks: + - name: add apt key for nodesource + become: true + apt_key: url=https://deb.nodesource.com/gpgkey/nodesource.gpg.key + - name: add repo for nodesource + become: true + apt_repository: + repo: 'deb https://deb.nodesource.com/node_0.10 {{ ansible_distribution_release }} main' + update_cache: no + - name: install nodejs + become: true + apt: name=nodejs +``` +2.3 Save the file and exit using shift+esc+: and then type wq + +## Step 3: Run Ansible YAML script +3.1 Run apache.yaml file using the below command: + ansible-playbook node.yml diff --git a/6-ansible/node.yml b/6-ansible/node.yml new file mode 100644 index 0000000..8fdf448 --- /dev/null +++ b/6-ansible/node.yml @@ -0,0 +1,19 @@ +--- +- hosts: webservers + become: true + tasks: + - name: add apt key for nodesource + become: true + apt_key: + url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key + + - name: add repo for nodesource + become: true + apt_repository: + repo: 'deb https://deb.nodesource.com/node_0.10 {{ ansible_distribution_release }} main' + update_cache: no + + - name: install nodejs + become: true + apt: + name: nodejs From 836b1ce20b323d35dc32a86085527aeeb60c9bd8 Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 09:24:15 +0800 Subject: [PATCH 048/135] ansible -readme --- 6-ansible/{ => 6.2-yaml-script}/node.yml | 0 6-ansible/6.3-apache-ansible-playbook/apache.yaml | 13 +++++++++++++ 2 files changed, 13 insertions(+) rename 6-ansible/{ => 6.2-yaml-script}/node.yml (100%) create mode 100644 6-ansible/6.3-apache-ansible-playbook/apache.yaml diff --git a/6-ansible/node.yml b/6-ansible/6.2-yaml-script/node.yml similarity index 100% rename from 6-ansible/node.yml rename to 6-ansible/6.2-yaml-script/node.yml diff --git a/6-ansible/6.3-apache-ansible-playbook/apache.yaml b/6-ansible/6.3-apache-ansible-playbook/apache.yaml new file mode 100644 index 0000000..fe5703d --- /dev/null +++ b/6-ansible/6.3-apache-ansible-playbook/apache.yaml @@ -0,0 +1,13 @@ +hosts: webservers +become: true +tasks: + - name: install apache2 + apt: name=apache2 update_cache=no state=latest + - name: enabled mod_rewrite + apache2_module: name=rewrite state=present + notify: + - restart apache2 + +handlers: + - name: restart apache2 + service: name=apache2 state=restarted From 1babe2f524553953356e998810352112076614a5 Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 09:25:16 +0800 Subject: [PATCH 049/135] ansible -readme --- 6-ansible/{6.2-yaml-script => 6.2-node-ansible-playbook}/node.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 6-ansible/{6.2-yaml-script => 6.2-node-ansible-playbook}/node.yml (100%) diff --git a/6-ansible/6.2-yaml-script/node.yml b/6-ansible/6.2-node-ansible-playbook/node.yml similarity index 100% rename from 6-ansible/6.2-yaml-script/node.yml rename to 6-ansible/6.2-node-ansible-playbook/node.yml From a4c460c7bbbe17d2cd6fa97b7c4d06e122bf308c Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 09:29:06 +0800 Subject: [PATCH 050/135] ansible -readme --- 6-ansible/6.4-ansible-module/README.md | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 6-ansible/6.4-ansible-module/README.md diff --git a/6-ansible/6.4-ansible-module/README.md b/6-ansible/6.4-ansible-module/README.md new file mode 100644 index 0000000..2f6e507 --- /dev/null +++ b/6-ansible/6.4-ansible-module/README.md @@ -0,0 +1,30 @@ +# README + +## Lesson 06 Demo 4 - Ansible Modules + +This document provides the steps to execute Ansible modules on a local server. + +### Steps to be performed: + +1. Execute Ansible modules on a local server. + +#### Step 1: Executing Ansible modules with local server + +1.1 Run the below commands in the given sequence to execute different Ansible modules. + +``` +ansible -m setup webservers +ansible webservers -m shell -a 'hostname' +ansible webservers -m apt -a 'name=git state=present' --become +ansible webservers -m file -a 'dest=/root/sample.txt state=touch mode=600 owner=root group=root' --become +``` + +## description of the commands used in the README: + +- ansible -m setup webservers: This command uses the setup module to gather facts about the remote hosts listed under the [webservers] group in the Ansible inventory file. The setup module collects a wide range of system information such as OS version, IP addresses, disk space, memory usage, etc. + +- ansible webservers -m shell -a 'hostname': This command uses the shell module to execute the hostname command on the remote hosts listed under the [webservers] group in the Ansible inventory file. The shell module allows running shell commands on the remote hosts. + +- ansible webservers -m apt -a 'name=git state=present' --become: This command uses the apt module to install the git package on the remote hosts listed under the [webservers] group in the Ansible inventory file. The apt module provides a way to manage packages on Debian-based systems. The --become flag is used to elevate privileges and run the command as the root user. + +- ansible webservers -m file -a 'dest=/root/sample.txt state=touch mode=600 owner=root group=root' --become: This command uses the file module to create a new file named sample.txt with root as the owner and group, and the file mode set to 600 on the remote hosts listed under the [webservers] group in the Ansible inventory file. The file module provides a way to manage files and directories on remote hosts. The --become flag is used to elevate privileges and run the command as the root user. \ No newline at end of file From c26f9cf940ab656b3a04fb8cec0ab6ce14bef6a9 Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 09:38:48 +0800 Subject: [PATCH 051/135] ansible -readme --- 6-ansible/6.5-ansible-role/README.md | 181 +++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 6-ansible/6.5-ansible-role/README.md diff --git a/6-ansible/6.5-ansible-role/README.md b/6-ansible/6.5-ansible-role/README.md new file mode 100644 index 0000000..f832661 --- /dev/null +++ b/6-ansible/6.5-ansible-role/README.md @@ -0,0 +1,181 @@ +## Lesson 06 Demo 5 - Creating and Working with Ansible Roles + +This document provides the steps to create and work with Ansible roles. + +### Steps to be performed: + +1. Install Ansible on Ubuntu, and establish connectivity between Ansible controller and node machine (You can skip this step in case Ansible is already installed) +2. Create Ansible Role +3. Create Ansible tasks +4. Create Ansible template +5. Create Ansible variable +6. Remove unwanted directory +7. Create Ansible role playbook +8. Deploy Ansible role playbook + +## Step 1: Install Ansible on Ubuntu, and establish connectivity between Ansible controller and node machine + +If Ansible is not installed on the Ubuntu system, use the following commands to install Ansible: + +``` +sudo apt-get install -f +sudo apt-get install software-properties-common +sudo apt-add-repository ppa:ansible/ansible +sudo apt-get update +sudo apt-get install ansible +``` + +## Step 2: Create Ansible Role + 2.1 Once we have our Ansible environment ready, create a new project directory. I will create a new project named base to demonstrate Ansible roles example: + + + +``` + +mkdir base +cd base +``` + +2.2 To create an Ansible role, use ansible-galaxy init <role_name> to create the role directory structure: + +``` + +cd roles +ansible-galaxy init demor +cd demor +``` + + +2.3 You can use the ls command to list the Ansible role directory structure. + +## Step 3: Create Ansible Tasks +3.1 Now update the /etc/motd file using Ansible playbook roles. Create tasks to use the main.yml file present inside the tasks folder. + + +``` + + +cd tasks +ls +vi main.yml +``` + +3.2 Enter the following code: + + +# tasks file for demor +``` + +- name: copy demor file + template: + src: templates/demor.j2 + dest: /etc/demor + owner: root + group: root + mode: 0444 +``` + +## Step 4: Create Ansible Template +4.1 Create the template content which will be used to update /etc/motd in our Ansible roles examples. Create a new template file under the templates directory using some variables. + + + +``` + +cd .. +cd templates +vi demor.j2 +``` + +4.2 Enter the following details: + + +``` + +Welcome to {{ ansible_hostname }} + +This file was created on {{ ansible_date_time.date }} +Go away if you have no business being here + +Contact {{ system_manager }} if anything is wrong +``` + +## Step 5: Create Ansible Variable +5.1 We will use the defaults folder to define custom variables which are used in our template file templates/demor.j2. + + + +``` + +cd .. +cd defaults +ls +vi main.yml +``` + +5.2 Enter the following details in the file: + +``` +# defaults file for demor +system_manager: admin@golinuxcloud.com +``` + +## Step 6: Remove unwanted directories (Optional) +6.1 This step is completely optional. In this Ansible roles example, we will not use other directories so we are deleting them. After deleting the additional directories you can use the tree command to list the directory structure of motd roles. + + +``` + + +cd .. +rm -rf handlers tests vars +Step 7: Create an Ansible Role Play +``` + + + + + + +## Step 7: Create an Ansible Role Playbook + +7.1 Now after you create an Ansible role structure, we need a playbook file that will deploy the role to our managed hosts. I will create my playbook file `demor-role.yml` under the `base` project directory. + +``` +cd .. +cd .. +sudo vi demor-role.yml +``` + + +7.2 Enter the following code in the file: + +``` + + +--- +- name: use demor role playbook + hosts: webservers + user: ansible + become: true + + roles: + - role: demor + system_manager: admin@golinuxcloud.com +``` + +## Step 8: Deploy Ansible Role Playbook +8.1 Execute the following command: + + +``` + + +ansible-playbook demor-role.yml +``` + +Note: In case you get an error asking you to install sshpass program, execute the command: sudo apt install sshpass and then run the ansible-playbook demor-role.yml command. + + + + From 71203e70f9edb8fbfaab165664148be11f8531c9 Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 09:40:41 +0800 Subject: [PATCH 052/135] ansible -readme --- 6-ansible/6.5-ansible-role/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/6-ansible/6.5-ansible-role/README.md b/6-ansible/6.5-ansible-role/README.md index f832661..83ce99c 100644 --- a/6-ansible/6.5-ansible-role/README.md +++ b/6-ansible/6.5-ansible-role/README.md @@ -129,14 +129,9 @@ system_manager: admin@golinuxcloud.com cd .. rm -rf handlers tests vars -Step 7: Create an Ansible Role Play ``` - - - - ## Step 7: Create an Ansible Role Playbook 7.1 Now after you create an Ansible role structure, we need a playbook file that will deploy the role to our managed hosts. I will create my playbook file `demor-role.yml` under the `base` project directory. From d8cd7c5ca7ae6e26b34dab557a48497cd98151bb Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 09:46:06 +0800 Subject: [PATCH 053/135] ansible -readme --- 6-ansible/6.7-setup-terraform/README.md | 0 .../6.7-setup-terraform/tf-installation.sh | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 6-ansible/6.7-setup-terraform/README.md create mode 100644 6-ansible/6.7-setup-terraform/tf-installation.sh diff --git a/6-ansible/6.7-setup-terraform/README.md b/6-ansible/6.7-setup-terraform/README.md new file mode 100644 index 0000000..e69de29 diff --git a/6-ansible/6.7-setup-terraform/tf-installation.sh b/6-ansible/6.7-setup-terraform/tf-installation.sh new file mode 100644 index 0000000..eab8818 --- /dev/null +++ b/6-ansible/6.7-setup-terraform/tf-installation.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Set the desired Terraform version +TERRAFORM_VERSION="1.4.5" + +# Download Terraform +wget "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" + +# Install unzip if not installed +sudo apt-get update +sudo apt-get install -y unzip + +# Unzip the Terraform package +unzip "terraform_${TERRAFORM_VERSION}_linux_amd64.zip" + +# Move the Terraform binary to the /usr/local/bin folder +sudo cp terraform /usr/local/bin/ +sudo mv terraform /usr/bin/ + +# Clean up the downloaded zip file +rm "terraform_${TERRAFORM_VERSION}_linux_amd64.zip" + +# Verify the installation +terraform --version \ No newline at end of file From a6f6220498aefd9111ef872849386f7bae94e54f Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 09:53:42 +0800 Subject: [PATCH 054/135] ansible -readme --- 6-ansible/6.6-setup-terraform/README.md | 14 +++ .../tf-installation.sh | 0 .../6.7-S3-Bucket-Using-Terraform/README.md | 115 ++++++++++++++++++ 6-ansible/6.7-setup-terraform/README.md | 0 4 files changed, 129 insertions(+) create mode 100644 6-ansible/6.6-setup-terraform/README.md rename 6-ansible/{6.7-setup-terraform => 6.6-setup-terraform}/tf-installation.sh (100%) create mode 100644 6-ansible/6.7-S3-Bucket-Using-Terraform/README.md delete mode 100644 6-ansible/6.7-setup-terraform/README.md diff --git a/6-ansible/6.6-setup-terraform/README.md b/6-ansible/6.6-setup-terraform/README.md new file mode 100644 index 0000000..aea0586 --- /dev/null +++ b/6-ansible/6.6-setup-terraform/README.md @@ -0,0 +1,14 @@ + +# Lesson 06 Demo 6 +## Set up Terraform + +Steps to be performed: +1. Download the appropriate package +2. Add the binary file to the bin directory + +### Step 1: Run the below commands + +``` +chmod 755 tf-installation.sh +sh tf-installation.sh +``` \ No newline at end of file diff --git a/6-ansible/6.7-setup-terraform/tf-installation.sh b/6-ansible/6.6-setup-terraform/tf-installation.sh similarity index 100% rename from 6-ansible/6.7-setup-terraform/tf-installation.sh rename to 6-ansible/6.6-setup-terraform/tf-installation.sh diff --git a/6-ansible/6.7-S3-Bucket-Using-Terraform/README.md b/6-ansible/6.7-S3-Bucket-Using-Terraform/README.md new file mode 100644 index 0000000..bfbace2 --- /dev/null +++ b/6-ansible/6.7-S3-Bucket-Using-Terraform/README.md @@ -0,0 +1,115 @@ +# Lesson 06 Demo 7 - Create an S3 Bucket Using Terraform + +This document provides the steps to create an S3 bucket using Terraform. + +## Steps to be performed + +1. Set up Terraform components +2. Create Terraform execution plan + +## Step 1: Set up Terraform components + +1.1 Run the following commands in the given sequence to set up the Terraform component: + +``` +pip install awscli +sudo apt-get update +``` + +1.2 Create a new file to execute this project. + + + +``` + +mkdir s3back +cd s3back +``` + +## Step 2: Create a Terraform execution plan +2.1 Create creds.tf under s3back and add the following code: + + + +``` + +nano creds.tf +``` + +2.2 Paste the following code: + + +``` + + +provider "aws" { + access_key = "" + secret_key = "" + token = "" + region = "us-east-1" +} +``` + +Note: Use the AWS access credentials provided in the AWS API Access tab in your LMS in your PRACTICE LAB tab as shown in the screenshot. + +2.3 Create main.tf under s3back and run the following code: + + + +``` + +nano main.tf +``` + +2.4 Paste the following code: + + + +``` + +resource "aws_s3_bucket" "b" { + bucket = "my-tf-test-bucket" + acl = "private" + + tags = { + Name = "My bucket" + Environment = "Dev" + } +} + +``` + +Note: Bucket name (here my-tf-test-bucket) entered here should be unique globally otherwise it may throw an error while executing the script. + +2.5 Run the following commands in the given sequence to add the AWS providers: + + + +``` + +terraform init +``` + +2.6 Run the following command to commit TF state: + + + +``` + +terraform plan +``` + +2.7 Run the following command to create the S3 bucket: + + + +``` + +terraform apply +``` + +**Enter a value: Yes** + +2.8 Verify the creation of S3 bucket in the AWS Management console. + + diff --git a/6-ansible/6.7-setup-terraform/README.md b/6-ansible/6.7-setup-terraform/README.md deleted file mode 100644 index e69de29..0000000 From 12901808fa0e85bd61ef263a770729a5942ba55c Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 10:12:36 +0800 Subject: [PATCH 055/135] ansible -readme --- 5-jenkins/README.md | 121 +++++++ 6-ansible/6.6-setup-terraform/README.md | 39 ++- 6-ansible/6.8-tf-ec2-provisioning/README.md | 310 ++++++++++++++++++ 6-ansible/6.8-tf-ec2-provisioning/deployer | 38 +++ .../6.8-tf-ec2-provisioning/deployer.pub | 1 + 6-ansible/6.8-tf-ec2-provisioning/main.tf | 110 +++++++ 6-ansible/6.8-tf-ec2-provisioning/slave-vm.tf | 93 ++++++ .../6.8-tf-ec2-provisioning/ubuntu-vm.tf | 88 +++++ 8 files changed, 794 insertions(+), 6 deletions(-) create mode 100644 5-jenkins/README.md create mode 100644 6-ansible/6.8-tf-ec2-provisioning/README.md create mode 100644 6-ansible/6.8-tf-ec2-provisioning/deployer create mode 100644 6-ansible/6.8-tf-ec2-provisioning/deployer.pub create mode 100644 6-ansible/6.8-tf-ec2-provisioning/main.tf create mode 100644 6-ansible/6.8-tf-ec2-provisioning/slave-vm.tf create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf diff --git a/5-jenkins/README.md b/5-jenkins/README.md new file mode 100644 index 0000000..d75f935 --- /dev/null +++ b/5-jenkins/README.md @@ -0,0 +1,121 @@ +# DevOps-Tutorial +DevOps-Tutorial +# Caltech-DevOps Simplilearn PG Program + +This repository contains course materials for the Caltech-DevOps Simplilearn Postgraduate Program. + +## Course Contents + +1. **Course Introduction** + - Overview of the program + - Objectives and outcomes + +2. **Basic Linux** + - Introduction to Linux + - File system and basic commands + - Shell scripting + +3. **Introduction to DevOps** + - DevOps concepts and principles + - DevOps practices and tools + +4. **Version Control System** + - Introduction to Git + - Git workflow + - Branching and merging strategies + +5. **CI/CD Pipeline with Jenkins** + - Introduction to Jenkins + - Configuring and managing Jenkins + - Building and deploying pipelines + +6. **Configuration Management with Ansible** + - Introduction to Ansible + - Writing Ansible playbooks + - Ansible roles and best practices + +7. **Infrastructure as Code with Terraform** + - Introduction to Terraform + - Writing Terraform configurations + - Terraform modules and best practices + +8. **Containerization with Docker** + - Introduction to Docker + - Dockerfile and Docker Compose + - Docker networking and storage + +9. **Container Orchestration with Kubernetes** + - Introduction to Kubernetes + - Kubernetes objects and resources + - Kubernetes networking and storage + +10. **Continuous Monitoring** + - Introduction to monitoring + - Monitoring tools and techniques + - Integrating monitoring with CI/CD pipelines + +11. **Centralized Notification System** + - Introduction to centralized notifications + - Notification tools and techniques + - Integrating notifications with CI/CD pipelines + +12. **AWS Cloud** + - Introduction to AWS + - AWS services and best practices + - Deploying and managing applications on AWS + +13. **Real-Time Project** + - Working with Java, Maven, and Tomcat + - Building a complete CI/CD pipeline + - Applying DevOps principles and practices + +--------------------------------------------------------------------------------------------------- +## How to Use This Repository + +This repository contains course materials, example projects, and code snippets. Use it as a reference while working through the Caltech-DevOps Simplilearn Postgraduate Program. + + + +# Getting Started + +To get started, you will need to clone the repository to your local machine. Follow the instructions below: + +1. Open a terminal or Git Bash. +2. Navigate to the directory where you want to clone the repository. +3. Run the following command to clone the repository: + +``` +git clone git@github.com:manikcloud/devops-project.git +``` + +4. Change into the cloned repository directory: +``` +cd devops-project +``` + + +You have now successfully cloned the repository to your local machine. You can start working on the project and use Git to track your changes. + +## Contributing to the Project + +Before making any changes, create a new branch based on the master branch. This will help keep the master branch clean and make it easier to collaborate with others. + +1. Ensure you are in the `devops-project` directory. +2. Run the following command to create a new branch: + +``` +git checkout -b your_branch_name +``` +3. Make your changes, commit them, and push them to the remote repository: +``` +git add . +git commit -m "Your commit message" +git push origin your_branch_name +``` + + +When you are ready to merge your changes with the master branch, create a pull request on GitHub. This will allow others to review your changes before merging them. + +Remember to always keep your local repository up to date by fetching and merging changes from the remote repository. + +Happy coding! diff --git a/6-ansible/6.6-setup-terraform/README.md b/6-ansible/6.6-setup-terraform/README.md index aea0586..afac4ab 100644 --- a/6-ansible/6.6-setup-terraform/README.md +++ b/6-ansible/6.6-setup-terraform/README.md @@ -3,12 +3,39 @@ ## Set up Terraform Steps to be performed: -1. Download the appropriate package -2. Add the binary file to the bin directory -### Step 1: Run the below commands +## Install Terraform from SH Script ``` -chmod 755 tf-installation.sh -sh tf-installation.sh -``` \ No newline at end of file +sudo cchmod 755 tf-installation.sh +sudo sh tf-installation.sh + +``` + + +## Create an AWS Account + +1. Go to the AWS website and click on the "Create an AWS Account" button. +2. Follow the on-screen instructions to create your account. +3. Once your account is created, log in to the AWS Management Console. + +### Create Access Keys in IAM + +1. In the AWS Management Console, navigate to the IAM service. +2. Click on "Users" in the left sidebar, and then click on the "Add User" button. +3. Enter a user name and select "Programmatic Access" as the access type. +4. Click on the "Next: Permissions" button. +5. Choose the appropriate permissions for your user, or attach an existing policy. +6. Click on the "Next: Tags" button. +7. Add any tags (optional) and click on the "Next: Review" button. +8. Review your settings and click on the "Create User" button. +9. Once the user is created, take note of the access key ID and secret access key. You will need these later to configure the AWS CLI. + +### Install AWS CLI and Configure it + +1. Install AWS CLI using the following command: +``` +sudo apt-get install awscli +``` +2. Run the command `aws configure` to configure your access key ID, secret access key, default region, and output format. + diff --git a/6-ansible/6.8-tf-ec2-provisioning/README.md b/6-ansible/6.8-tf-ec2-provisioning/README.md new file mode 100644 index 0000000..49f69a6 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/README.md @@ -0,0 +1,310 @@ +# Create EC2 instances with Terraform + +This branch contains Terraform code to create EC2 instances in AWS. + +## Related Blog Posts By Author: + +- [DevSecOps CI/CD Java Tomcat Project](https://varunmanik1.medium.com/devsecops-cicd-java-tomcat-project-141d6b73e436) +- [DevOps Jenkins AWS Series Part 1: How to Install Jenkins on AWS Ubuntu 22.04](https://varunmanik1.medium.com/devops-jenkins-aws-series-part-1-how-to-install-jenkins-on-aws-ubuntu-22-04-cb0c3cdb055) +- [DevOps Jenkins AWS Series Part 2: Setup AWS CloudShell, Install Terraform in Persistent](https://varunmanik1.medium.com/devops-jenkins-aws-series-part-2-setup-aws-cloudshell-install-terraform-in-persistent-425dc0537cf5) + + +## Prerequisites + +Before you start, make sure you have the following: + +- An AWS account, with ec2 full access permission +- And Linux Terminal, wher you can run all these commands + +## Files + +- `README.md`: This file, providing an overview of the branch. +- `deployer` and `deployer.pub`: SSH keys for accessing the EC2 instances. +- `history.txt`: A text file with a record of changes to this project. +- `jenkins-installation-ubuntu.sh`: A shell script to install Jenkins on the EC2 instance. +- `main.tf`: The main Terraform configuration file that creates the AWS resources. +- `slave-vm.tf`: A Terraform configuration file that creates a Jenkins slave instance. +- `tf-cli-installation.sh`: A shell script to install the Terraform CLI on the EC2 instance. +- `ubuntu-vm.tf`: A Terraform configuration file that creates an Ubuntu EC2 instance. + +## Usage + +To create EC2 instances with Terraform, follow these steps: + +1. Clone this repository to your local machine by running the command: `git clone https://github.com/manikcloud/Jenkins-cicd.git`. +2. Switch to the `0.1_create_ec2_tf` branch by running the command: `git checkout 0.1_create_ec2_tf`. +3. Navigate to the `terraform` directory by running the command: `cd terraform`. +4. Initialize Terraform by running the command: `terraform init`. +5. Create an execution plan by running the command: `terraform plan`. +6. Apply the execution plan by running the command: `terraform apply`. + +You will be prompted to enter values for the variables defined in the `variables.tf` file. + + +Create an AWS Account + +1. Go to the AWS website and click on the "Create an AWS Account" button. +2. Follow the on-screen instructions to create your account. +3. Once your account is created, log in to the AWS Management Console. + +### Create Access Keys in IAM + +1. In the AWS Management Console, navigate to the IAM service. +2. Click on "Users" in the left sidebar, and then click on the "Add User" button. +3. Enter a user name and select "Programmatic Access" as the access type. +4. Click on the "Next: Permissions" button. +5. Choose the appropriate permissions for your user, or attach an existing policy. +6. Click on the "Next: Tags" button. +7. Add any tags (optional) and click on the "Next: Review" button. +8. Review your settings and click on the "Create User" button. +9. Once the user is created, take note of the access key ID and secret access key. You will need these later to configure the AWS CLI. + +### Install AWS CLI and Configure it + +1. Install AWS CLI using the following command: +``` +sudo apt-get install awscli +``` +2. Run the command `aws configure` to configure your access key ID, secret access key, default region, and output format. + +## Install Terraform from SH Script + +``` +sudo chmod 755 chmod 755 tf-cli-installation.sh +sudo sh chmod 755 tf-cli-installation.sh + +``` +# OR + +## Install Terraform Manual +1. Set the desired Terraform version: `TERRAFORM_VERSION="1.4.5"` +2. Download Terraform: +``` +wget "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" +``` +3. Install unzip if not installed: +``` +sudo apt-get update && sudo apt-get install -y unzip +``` +4. Unzip the Terraform package: +``` +unzip "terraform_${TERRAFORM_VERSION}_linux_amd64.zip" +``` +5. Move the Terraform binary to the /usr/local/bin folder: +``` +sudo cp terraform /usr/local/bin/ && sudo mv terraform /usr/bin/ +``` +6. Clean up the downloaded zip file: +``` +rm "terraform_${TERRAFORM_VERSION}_linux_amd64.zip" +``` +7. Verify the installation: +``` +terraform --version +``` +That's it! With an AWS account, access keys, AWS CLI, and Terraform installed and configured, you're ready to use Terraform to create AWS resources. + + +After the Terraform code has finished executing, you can choose one of the following options to install Jenkins: + +### Option 1.1 : Install Jenkins by SH Script + +``` +chmod 755 jenkins-installation-ubuntu.sh +sudo sh jenkins-installation-ubuntu.sh +``` + +### Option 1.2 : Manually Install Jenkins + +To manually install Jenkins, follow these steps: + +1. SSH into the Ubuntu EC2 instance created by Terraform by running the command: + `ssh -i deployer ubuntu@<public-ip-of-instance>`. + +2. Install Java by running the command: + `sudo apt-get update && sudo apt-get install default-jdk`. + +3. Add the Jenkins repository key by running the command: + +4. Add the Jenkins repository by running the command: + +``` + +sudo mkdir -p /usr/share/keyrings + +sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null + +sudo echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null + +``` +5. Update the package list by running the command, + +6. Install Jenkins by running the command: + +``` +sudo apt-get update +sudo apt-get install jenkins + ``` +### Option 2: Use Terraform to Install Jenkins + +To use Terraform to install Jenkins, follow these steps: + +1. SSH into the Ubuntu EC2 instance created by Terraform by running the command: +`ssh -i deployer ubuntu@<public-ip-of-instance>`. + +2. Run the Jenkins installation script by running the command: +`sudo sh /home/ubuntu/jenkins-installation-ubuntu.sh`. + +3. The script will install Jenkins and its dependencies. Once the installation is complete, Jenkins will be running on the EC2 instance. + +## Clean Up + +To destroy the EC2 instances and associated resources, run the command: `terraform destroy` + +Note: This will delete all resources created by Terraform in this branch. + + +## For More info on lab machine plz expend below: + +<details> +# Jenkins-cicd +PG DO - CI/CD Pipeline with Jenkins Simplilearn + +# AWS Ubuntu VM Provisioning steps +- Step 1: Click on Launch Instance +- Step 2 : Click on Software Image (AMI) +- Select Ubuntu +- Step 4: Key pair name – required +- Click on Create new key pair +- Put key pair name Jenkins-sl +- & Download it +- Step 5 : Click on Launch Instance +- Step 6 : Select your VM and Click connect +- Step 7 : You can see the terminal +- Step: Showing Github example + +# Git Status +``` +git --version +``` +## cretae Dir +``` +mkdir demo +cd demo +``` +## GIT & Ubuntu SSH connection +``` +ssh-keygen + +"Hit enter button 3 time" + +cat ~/.ssh/id_rsa.pub +git clone git@github.com:manikcloud/Jenkins-cicd.git +history +history | cut -c 8- +``` + +# Jenkins installation on UBUNTU 18.04 & Ubuntu 22.04 + +### Step 1 +``` +sudo apt-get update -y && sudo apt install openjdk-8-jdk -y +``` +### Step 2: Downloading Key +``` +sudo wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add +``` + +### Step 3: Adding Key +``` +sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' +``` + +### Step 4: Jenkins Package installation +``` +sudo apt-get update -y && sudo apt install jenkins -y +sudo /etc/init.d/jenkins start +sudo service jenkins status +``` +### Step 5: Jenkins default password +``` +sudo cat /home/labsuser/jenkins/secrets/initialAdminPassword +``` +### Step 6: History command + +``` +history | cut -c 8- + +``` +# Jenkins URL with port 8080 +- http://x.x.x.x:8080/ + +Replace x with your ip + +# Change Security group rule for Jenkins +``` +- Select your instance +- Down below select your security tab +- Click on the Security groups sg-0c51908b5fa4abf75 (launch-wizard-2) +- Click on the action +- Click on EDIT INBOUND RULE +- Select custom TCP and put port 8080 +- Custom ip should be 0.0.0.0/0 +- Click on Save the rule +``` + +# Common error + +``` +getting "E: Unable to locate package openjdk-8-jdk" message on java update +``` + +# Resolution +Run this command + +``` +sudo apt update -y +``` +# Plugin Installation +dashboard>manage>jenkins>manage plugins>maven integration + + + +# Jenkins Setting + +``` +Java_Home +/usr/lib/jvm/java-8-openjdk-amd64/ +``` + +# Post Build Step + +``` +java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App + +``` + +# This project is parameterized +``` +echo "User First name is : $First_Name" +echo "User Last name is : $Last_Name" +echo "User Gender is : $Sex" + +``` +</details> + +# References: +1. https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html +2. https://maven.apache.org/download.cgi + +## Connect & Follow + +For more info, please connect and follow me: + +- Github: [https://github.com/manikcloud](https://github.com/manikcloud) +- LinkedIn: [https://www.linkedin.com/in/vkmanik/](https://www.linkedin.com/in/vkmanik/) +- Email: [varunmanik1@gmail.com](mailto:varunmanik1@gmail.com) +- Facebook: [https://www.facebook.com/cloudvirtualization/](https://www.facebook.com/cloudvirtualization/) +- YouTube: [https://bit.ly/32fknRN](https://bit.ly/32fknRN) +- Twitter: [https://twitter.com/varunkmanik](https://twitter.com/varunkmanik) + diff --git a/6-ansible/6.8-tf-ec2-provisioning/deployer b/6-ansible/6.8-tf-ec2-provisioning/deployer new file mode 100644 index 0000000..2b6525d --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/deployer @@ -0,0 +1,38 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn +NhAAAAAwEAAQAAAYEAw/IExD9MHaiZx5FQ3OyDMxcoKbIm03pmcpWb5OIHBommvmF/P1aV +BMjq6mDoP/DqzgLHUAqT3HPCdwIVAUr4I3inO7CWdDfL/gDip1UA54v8vvZlg+qBjrM8x+ +g1X6BzstR0WQGxep/sRZJNA3orEidxbBlUCvyea2IF1QgSYot+Ji9PgzgaIMS72vLQ3C4F +i8/qsbPEHB+IYKx5HU/MIQSnynMqSAhkuFP1oFxVuTN6TeDsp0s3qifYF59BW6udCf7egq +Z6+sKpc0c6HADF55YK3IWGVmSYEy91vM64NRce0Qct3wGxMlqMq5AfXBSD0pJolGRvcVIY +qyODG3YB1TZZKe8VNFeinwkZUzRPsc1pWz0oGu5I5aoos4w6Ee8RMSjS2zbYQep5TSBMF/ +hZY7YK06jFdsOpPB98X64XRtPfdxJzDMHT1ZpbRIyXmfpdwRE1HImyhhRXOYskffVuzSoa +4h+Xejr213r+yZm6rF68J/K57t2rgxibO2GiMM5pAAAFmKv3VXqr91V6AAAAB3NzaC1yc2 +EAAAGBAMPyBMQ/TB2omceRUNzsgzMXKCmyJtN6ZnKVm+TiBwaJpr5hfz9WlQTI6upg6D/w +6s4Cx1AKk9xzwncCFQFK+CN4pzuwlnQ3y/4A4qdVAOeL/L72ZYPqgY6zPMfoNV+gc7LUdF +kBsXqf7EWSTQN6KxIncWwZVAr8nmtiBdUIEmKLfiYvT4M4GiDEu9ry0NwuBYvP6rGzxBwf +iGCseR1PzCEEp8pzKkgIZLhT9aBcVbkzek3g7KdLN6on2BefQVurnQn+3oKmevrCqXNHOh +wAxeeWCtyFhlZkmBMvdbzOuDUXHtEHLd8BsTJajKuQH1wUg9KSaJRkb3FSGKsjgxt2AdU2 +WSnvFTRXop8JGVM0T7HNaVs9KBruSOWqKLOMOhHvETEo0ts22EHqeU0gTBf4WWO2CtOoxX +bDqTwffF+uF0bT33cScwzB09WaW0SMl5n6XcERNRyJsoYUVzmLJH31bs0qGuIfl3o69td6 +/smZuqxevCfyue7dq4MYmzthojDOaQAAAAMBAAEAAAGBAIVNW7LKwRSYQ+4BzTpO6L7ULS +2YllNevN2NLF5c6pym/rocB/5l/8EekrparQX69zKpr0CjwY3DbvOZhgK4JvGyvkqcSu7L +msq1fXyLFq9vi8W6SLuiyPr0sw/oyI7C0JNDd9epkD01GP8Hlb8c2Lpj/QSmgodq7rdtGz +yfXiqObYa6vuQtQZEzZf2BHVf9Mya3jxnPi0X6qcPi8g5f4CZCTYgsKwKQOz0vWTX8OxFg +lP7wWu9A+6CVtKv1WvhrWZy0g68CaMsBRZ2weZ1K4ScqbZvJdvWPfJzY0rJgJk7wNPA5Ak +QEG+IaMtmFQ5phGEcxqXkoGcSlLEW7P8XMwLHTWdlFAgVwrWsvmU8dzZ+tOa82ZY8tIF+B +wzzYgFZoO3H4fFXd3sXx7f/ME5a1NTTiEU/8I16omN8xdrDSVHbJd4stljpUGda6iTgF2s +khXmZ7dxCq/ZDlbCQwsumzbmPz+ass13/bP/PG7e92CRhwxrRELQij0DWpRiLPc13c0QAA +AMEAg+5tOG/WZA1P8KfeDmZXImTWOuTnaOZzYRI9ZXFpF9gUa+zYO/0l5br4I0/SKQJs0Y +C+XIamiN7HoOjH4MDkqTHrmkliGsJ0Z5Ag/u6eEEvXqMqkdJ8dbhP9aHVUhPUJ9AuJ7Bsf +Jgy/hgjkntf165K83Gkrgmcql+iPOxA9EjrWFRuWdTrMFRJgqTirtwMPI7ywKXkXKB5tX+ +AqgpPb2s7cj00B4pQku9RA0apE0UOcRzEiAMUpP9egTHBIN1XzAAAAwQDnJbhvuZkZxKjD +KMJsta1nom0+TLNxix7y/oOaX+YRmYY+6vS7WHCY5qg/7wUNd6npTS/QU1FoL0HsQalVwy +YDYoUAbmfdT2xQEUesO6cKpFNfI+ToolsZppp+Nuqi60FEFE+S/pV/4gMxQnt0DcQ/Wumu +R/eBTBdjbFh4ZkedPIulue6XxtBmhfzor8IGNklChWrKib47D0/LN5AJA62uriQmo23yKG +AVDYuhSnEOt4yPZgW5e0tVrajkUti0cpUAAADBANkDXzsfmG1GyF9I68NdLhDfU0huxRWs +8bVPX92eKI2HKZ/ZzHx9s3gwkz/nj2iCmIKOEI0S7qNkGGjt+vQ+qH7oxWhjW4t8S7b/pe +JBVDvRUGNk2XIYk5Jdcgv+VPJDrfe51IV6cXxxkmOU5asMgvlsMue8pKuiBw/HgdmNOQBp +9Y/NSXLTUDh0jOwFyryYZKDZPSaP/iWN38Y3v6UHwa9wz0AnL1Iv1sT12sui9dEQ9hdTDd +thvT0LVaxmsBlrhQAAACB2YXJ1bm1hbmlrb3V0bG9AaXAtMTcyLTMxLTE3LTIwNgE= +-----END OPENSSH PRIVATE KEY----- diff --git a/6-ansible/6.8-tf-ec2-provisioning/deployer.pub b/6-ansible/6.8-tf-ec2-provisioning/deployer.pub new file mode 100644 index 0000000..d149548 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/deployer.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDD8gTEP0wdqJnHkVDc7IMzFygpsibTemZylZvk4gcGiaa+YX8/VpUEyOrqYOg/8OrOAsdQCpPcc8J3AhUBSvgjeKc7sJZ0N8v+AOKnVQDni/y+9mWD6oGOszzH6DVfoHOy1HRZAbF6n+xFkk0DeisSJ3FsGVQK/J5rYgXVCBJii34mL0+DOBogxLva8tDcLgWLz+qxs8QcH4hgrHkdT8whBKfKcypICGS4U/WgXFW5M3pN4OynSzeqJ9gXn0Fbq50J/t6Cpnr6wqlzRzocAMXnlgrchYZWZJgTL3W8zrg1Fx7RBy3fAbEyWoyrkB9cFIPSkmiUZG9xUhirI4MbdgHVNlkp7xU0V6KfCRlTNE+xzWlbPSga7kjlqiizjDoR7xExKNLbNthB6nlNIEwX+FljtgrTqMV2w6k8H3xfrhdG0993EnMMwdPVmltEjJeZ+l3BETUcibKGFFc5iyR99W7NKhriH5d6OvbXev7JmbqsXrwn8rnu3auDGJs7YaIwzmk= varunmanikoutlo@ip-172-31-17-206 diff --git a/6-ansible/6.8-tf-ec2-provisioning/main.tf b/6-ansible/6.8-tf-ec2-provisioning/main.tf new file mode 100644 index 0000000..cd9a076 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/main.tf @@ -0,0 +1,110 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.27" + } + } + + required_version = ">= 0.14.9" +} + +provider "aws" { + profile = "default" + region = "us-east-1" +} + + +# resource "aws_security_group" "allow_SSH" { +# name = "allow_SSH" +# description = "Allow SSH inbound traffic" +# # vpc_id = aws_vpc.main.id + + +# ingress { +# from_port = 0 +# to_port = 0 +# protocol = "-1" +# cidr_blocks = ["0.0.0.0/0"] +# ipv6_cidr_blocks = ["::/0"] +# # description = "SSH from VPC" +# # from_port = 22 +# # to_port = 22 +# # protocol = "tcp" +# # cidr_blocks = ["61.6.14.46/32"] +# # # ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block] +# } + +# egress { +# from_port = 0 +# to_port = 0 +# protocol = "-1" +# cidr_blocks = ["0.0.0.0/0"] +# ipv6_cidr_blocks = ["::/0"] +# } +# } + +# resource "aws_key_pair" "deployer1" { +# key_name = "deployer-key1" +# public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDD8gTEP0wdqJnHkVDc7IMzFygpsibTemZylZvk4gcGiaa+YX8/VpUEyOrqYOg/8OrOAsdQCpPcc8J3AhUBSvgjeKc7sJZ0N8v+AOKnVQDni/y+9mWD6oGOszzH6DVfoHOy1HRZAbF6n+xFkk0DeisSJ3FsGVQK/J5rYgXVCBJii34mL0+DOBogxLva8tDcLgWLz+qxs8QcH4hgrHkdT8whBKfKcypICGS4U/WgXFW5M3pN4OynSzeqJ9gXn0Fbq50J/t6Cpnr6wqlzRzocAMXnlgrchYZWZJgTL3W8zrg1Fx7RBy3fAbEyWoyrkB9cFIPSkmiUZG9xUhirI4MbdgHVNlkp7xU0V6KfCRlTNE+xzWlbPSga7kjlqiizjDoR7xExKNLbNthB6nlNIEwX+FljtgrTqMV2w6k8H3xfrhdG0993EnMMwdPVmltEjJeZ+l3BETUcibKGFFc5iyR99W7NKhriH5d6OvbXev7JmbqsXrwn8rnu3auDGJs7YaIwzmk= varunmanikoutlo@ip-172-31-17-206" +# } + +# # resource "aws_instance" "linux" { +# # ami = "ami-0c02fb55956c7d316" +# # instance_type = "t2.micro" +# # key_name = aws_key_pair.deployer1.key_name +# # # count = 1 +# # vpc_security_group_ids = ["${aws_security_group.allow_SSH.id}"] +# # tags = { +# # "Name" = "Linux-Node" +# # "ENV" = "Dev" +# # } + +# # depends_on = [aws_key_pair.deployer1] + +# # } + +# ####### Ubuntu VM ##### + + +# resource "aws_instance" "ubuntu" { +# ami = "ami-04505e74c0741db8d" +# instance_type = "t2.micro" +# key_name = aws_key_pair.deployer1.key_name +# vpc_security_group_ids = ["${aws_security_group.allow_SSH.id}"] +# tags = { +# "Name" = "UBUNTU-sl-1" +# "ENV" = "Dev" +# } + +# # Type of connection to be established +# connection { +# type = "ssh" +# user = "ubuntu" +# private_key = file("./deployer") +# host = self.public_ip +# } +# # Remotely execute commands to install Java, Python, Jenkins +# provisioner "remote-exec" { +# inline = [ +# "sudo apt update && upgrade", +# "sudo apt install -y python3.8", +# "wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -", +# "sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'", +# "sudo apt-get update", +# "sudo apt-get install default-jdk -y", +# "sudo apt-get install -y jenkins", +# "systemctl status jenkins --no-pager -l", +# "sudo systemctl enable --now jenkins", +# "sudo cat /var/lib/jenkins/secrets/initialAdminPassword", +# ] +# } + +# depends_on = [aws_key_pair.deployer1] + +# } + +# output "ubuntu" { +# value = aws_instance.ubuntu.public_ip +# description = "description" +# } diff --git a/6-ansible/6.8-tf-ec2-provisioning/slave-vm.tf b/6-ansible/6.8-tf-ec2-provisioning/slave-vm.tf new file mode 100644 index 0000000..3f56aed --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/slave-vm.tf @@ -0,0 +1,93 @@ + +# resource "aws_security_group" "allow_SSH_Slave" { +# name = "allow_SSH_Slave" +# description = "Allow SSH inbound traffic" +# # vpc_id = aws_vpc.main.id + + +# ingress { +# from_port = 0 +# to_port = 0 +# protocol = "-1" +# cidr_blocks = ["0.0.0.0/0"] +# ipv6_cidr_blocks = ["::/0"] +# # description = "SSH from VPC" +# # from_port = 22 +# # to_port = 22 +# # protocol = "tcp" +# # cidr_blocks = ["61.6.14.46/32"] +# # # ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block] +# } + +# egress { +# from_port = 0 +# to_port = 0 +# protocol = "-1" +# cidr_blocks = ["0.0.0.0/0"] +# ipv6_cidr_blocks = ["::/0"] +# } +# } + +# resource "aws_key_pair" "deployer3" { +# key_name = "deployer-key3" +# public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDD8gTEP0wdqJnHkVDc7IMzFygpsibTemZylZvk4gcGiaa+YX8/VpUEyOrqYOg/8OrOAsdQCpPcc8J3AhUBSvgjeKc7sJZ0N8v+AOKnVQDni/y+9mWD6oGOszzH6DVfoHOy1HRZAbF6n+xFkk0DeisSJ3FsGVQK/J5rYgXVCBJii34mL0+DOBogxLva8tDcLgWLz+qxs8QcH4hgrHkdT8whBKfKcypICGS4U/WgXFW5M3pN4OynSzeqJ9gXn0Fbq50J/t6Cpnr6wqlzRzocAMXnlgrchYZWZJgTL3W8zrg1Fx7RBy3fAbEyWoyrkB9cFIPSkmiUZG9xUhirI4MbdgHVNlkp7xU0V6KfCRlTNE+xzWlbPSga7kjlqiizjDoR7xExKNLbNthB6nlNIEwX+FljtgrTqMV2w6k8H3xfrhdG0993EnMMwdPVmltEjJeZ+l3BETUcibKGFFc5iyR99W7NKhriH5d6OvbXev7JmbqsXrwn8rnu3auDGJs7YaIwzmk= varunmanikoutlo@ip-172-31-17-206" +# } + +# resource "aws_instance" "linux" { +# ami = "ami-0c02fb55956c7d316" +# instance_type = "t2.micro" +# key_name = aws_key_pair.deployer3.key_name +# # count = 1 +# vpc_security_group_ids = ["${aws_security_group.allow_SSH_Slave.id}"] +# tags = { +# "Name" = "Linux-Node" +# "ENV" = "Dev" +# } + +# depends_on = [aws_key_pair.deployer3] + +# } + +# ####### Ubuntu VM ##### + + +# resource "aws_instance" "ubuntu" { +# ami = "ami-04505e74c0741db8d" +# instance_type = "t2.micro" +# key_name = aws_key_pair.deployer3.key_name +# vpc_security_group_ids = ["${aws_security_group.allow_SSH_Slave.id}"] +# tags = { +# "Name" = "UBUNTU-sl-1" +# "ENV" = "Dev" +# } + +# # Type of connection to be established +# connection { +# type = "ssh" +# user = "ubuntu" +# private_key = file("./deployer") +# host = self.public_ip +# } +# # Remotely execute commands to install Java, Python, Jenkins +# provisioner "remote-exec" { +# inline = [ +# "sudo apt update && upgrade", +# "sudo apt-get install -y python3.8 default-jdk mvn git", +# "echo 62c3f6eefeab36fe989cd376360e04baa0de08c325b93de880693a6e2af67298 > secret-file", +# "curl -sO http://54.160.148.48:8080/jnlpJars/agent.jar", +# "java -jar agent.jar -jnlpUrl http://54.160.148.48:8080/manage/computer/ubuntu/jenkins-agent.jnlp -secret @secret-file -workDir '/home/ubuntu/'", +# ] +# } + +# depends_on = [aws_key_pair.deployer3] + +# } + +# output "ubuntu" { +# value = aws_instance.ubuntu.public_ip +# description = "description" +# } +# output "linux" { +# value = aws_instance.linux.public_ip +# description = "description" +# } diff --git a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf new file mode 100644 index 0000000..ef59856 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf @@ -0,0 +1,88 @@ +# variable "jenkins_admin_user" { +# description = "The admin username for Jenkins" +# default = "admin" +# } + +# variable "jenkins_admin_password" { +# description = "The admin password for Jenkins" +# default = "Admin@456" +# } + +resource "aws_security_group" "allow_SSH_ubuntu" { + name = "allow_SSH_ubuntu" + description = "Allow SSH inbound traffic" + # vpc_id = aws_vpc.main.id + + + ingress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + } +} + +resource "aws_key_pair" "deployer" { + key_name = "deployer-key" + public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDD8gTEP0wdqJnHkVDc7IMzFygpsibTemZylZvk4gcGiaa+YX8/VpUEyOrqYOg/8OrOAsdQCpPcc8J3AhUBSvgjeKc7sJZ0N8v+AOKnVQDni/y+9mWD6oGOszzH6DVfoHOy1HRZAbF6n+xFkk0DeisSJ3FsGVQK/J5rYgXVCBJii34mL0+DOBogxLva8tDcLgWLz+qxs8QcH4hgrHkdT8whBKfKcypICGS4U/WgXFW5M3pN4OynSzeqJ9gXn0Fbq50J/t6Cpnr6wqlzRzocAMXnlgrchYZWZJgTL3W8zrg1Fx7RBy3fAbEyWoyrkB9cFIPSkmiUZG9xUhirI4MbdgHVNlkp7xU0V6KfCRlTNE+xzWlbPSga7kjlqiizjDoR7xExKNLbNthB6nlNIEwX+FljtgrTqMV2w6k8H3xfrhdG0993EnMMwdPVmltEjJeZ+l3BETUcibKGFFc5iyR99W7NKhriH5d6OvbXev7JmbqsXrwn8rnu3auDGJs7YaIwzmk= varunmanikoutlo@ip-172-31-17-206" +} + +####### Ubuntu VM ##### + + +resource "aws_instance" "ubuntu" { + ami = "ami-007855ac798b5175e" + instance_type = "t2.medium" + key_name = aws_key_pair.deployer.key_name + vpc_security_group_ids = ["${aws_security_group.allow_SSH_ubuntu.id}"] + tags = { + "Name" = "Jenkins-UBUNTU-22-04" + "ENV" = "Dev" + } + # metadata_options { + # http_endpoint = "disabled" + # } + # Type of connection to be established + connection { + type = "ssh" + user = "ubuntu" + private_key = file("./deployer") + host = self.public_ip + timeout = "10m" + } + + associate_public_ip_address = true + + # Remotely execute commands to install Java, Python, Jenkins + provisioner "remote-exec" { + inline = [ + "sudo apt update ", + "sudo apt install -y default-jdk ", + "sudo mkdir -p /usr/share/keyrings/", + "sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null", + "sudo echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null", + "sudo apt update", + "sudo apt install -y jenkins", + "sudo systemctl start jenkins --no-pager -l", + "sudo systemctl enable --now jenkins", + "sudo cat /var/lib/jenkins/secrets/initialAdminPassword", + ] + } + + depends_on = [aws_key_pair.deployer] + +} + +output "ubuntu" { + value = aws_instance.ubuntu.public_ip + description = "description" +} From bc112db485b58142de1d74ac75a764ec3718866b Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 10:20:14 +0800 Subject: [PATCH 056/135] ansible -readme --- 6-ansible/6.2-node-ansible-playbook/README.md | 310 ++++++++++++++++++ 6-ansible/README.md | 94 +++--- 2 files changed, 358 insertions(+), 46 deletions(-) create mode 100644 6-ansible/6.2-node-ansible-playbook/README.md diff --git a/6-ansible/6.2-node-ansible-playbook/README.md b/6-ansible/6.2-node-ansible-playbook/README.md new file mode 100644 index 0000000..49f69a6 --- /dev/null +++ b/6-ansible/6.2-node-ansible-playbook/README.md @@ -0,0 +1,310 @@ +# Create EC2 instances with Terraform + +This branch contains Terraform code to create EC2 instances in AWS. + +## Related Blog Posts By Author: + +- [DevSecOps CI/CD Java Tomcat Project](https://varunmanik1.medium.com/devsecops-cicd-java-tomcat-project-141d6b73e436) +- [DevOps Jenkins AWS Series Part 1: How to Install Jenkins on AWS Ubuntu 22.04](https://varunmanik1.medium.com/devops-jenkins-aws-series-part-1-how-to-install-jenkins-on-aws-ubuntu-22-04-cb0c3cdb055) +- [DevOps Jenkins AWS Series Part 2: Setup AWS CloudShell, Install Terraform in Persistent](https://varunmanik1.medium.com/devops-jenkins-aws-series-part-2-setup-aws-cloudshell-install-terraform-in-persistent-425dc0537cf5) + + +## Prerequisites + +Before you start, make sure you have the following: + +- An AWS account, with ec2 full access permission +- And Linux Terminal, wher you can run all these commands + +## Files + +- `README.md`: This file, providing an overview of the branch. +- `deployer` and `deployer.pub`: SSH keys for accessing the EC2 instances. +- `history.txt`: A text file with a record of changes to this project. +- `jenkins-installation-ubuntu.sh`: A shell script to install Jenkins on the EC2 instance. +- `main.tf`: The main Terraform configuration file that creates the AWS resources. +- `slave-vm.tf`: A Terraform configuration file that creates a Jenkins slave instance. +- `tf-cli-installation.sh`: A shell script to install the Terraform CLI on the EC2 instance. +- `ubuntu-vm.tf`: A Terraform configuration file that creates an Ubuntu EC2 instance. + +## Usage + +To create EC2 instances with Terraform, follow these steps: + +1. Clone this repository to your local machine by running the command: `git clone https://github.com/manikcloud/Jenkins-cicd.git`. +2. Switch to the `0.1_create_ec2_tf` branch by running the command: `git checkout 0.1_create_ec2_tf`. +3. Navigate to the `terraform` directory by running the command: `cd terraform`. +4. Initialize Terraform by running the command: `terraform init`. +5. Create an execution plan by running the command: `terraform plan`. +6. Apply the execution plan by running the command: `terraform apply`. + +You will be prompted to enter values for the variables defined in the `variables.tf` file. + + +Create an AWS Account + +1. Go to the AWS website and click on the "Create an AWS Account" button. +2. Follow the on-screen instructions to create your account. +3. Once your account is created, log in to the AWS Management Console. + +### Create Access Keys in IAM + +1. In the AWS Management Console, navigate to the IAM service. +2. Click on "Users" in the left sidebar, and then click on the "Add User" button. +3. Enter a user name and select "Programmatic Access" as the access type. +4. Click on the "Next: Permissions" button. +5. Choose the appropriate permissions for your user, or attach an existing policy. +6. Click on the "Next: Tags" button. +7. Add any tags (optional) and click on the "Next: Review" button. +8. Review your settings and click on the "Create User" button. +9. Once the user is created, take note of the access key ID and secret access key. You will need these later to configure the AWS CLI. + +### Install AWS CLI and Configure it + +1. Install AWS CLI using the following command: +``` +sudo apt-get install awscli +``` +2. Run the command `aws configure` to configure your access key ID, secret access key, default region, and output format. + +## Install Terraform from SH Script + +``` +sudo chmod 755 chmod 755 tf-cli-installation.sh +sudo sh chmod 755 tf-cli-installation.sh + +``` +# OR + +## Install Terraform Manual +1. Set the desired Terraform version: `TERRAFORM_VERSION="1.4.5"` +2. Download Terraform: +``` +wget "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" +``` +3. Install unzip if not installed: +``` +sudo apt-get update && sudo apt-get install -y unzip +``` +4. Unzip the Terraform package: +``` +unzip "terraform_${TERRAFORM_VERSION}_linux_amd64.zip" +``` +5. Move the Terraform binary to the /usr/local/bin folder: +``` +sudo cp terraform /usr/local/bin/ && sudo mv terraform /usr/bin/ +``` +6. Clean up the downloaded zip file: +``` +rm "terraform_${TERRAFORM_VERSION}_linux_amd64.zip" +``` +7. Verify the installation: +``` +terraform --version +``` +That's it! With an AWS account, access keys, AWS CLI, and Terraform installed and configured, you're ready to use Terraform to create AWS resources. + + +After the Terraform code has finished executing, you can choose one of the following options to install Jenkins: + +### Option 1.1 : Install Jenkins by SH Script + +``` +chmod 755 jenkins-installation-ubuntu.sh +sudo sh jenkins-installation-ubuntu.sh +``` + +### Option 1.2 : Manually Install Jenkins + +To manually install Jenkins, follow these steps: + +1. SSH into the Ubuntu EC2 instance created by Terraform by running the command: + `ssh -i deployer ubuntu@<public-ip-of-instance>`. + +2. Install Java by running the command: + `sudo apt-get update && sudo apt-get install default-jdk`. + +3. Add the Jenkins repository key by running the command: + +4. Add the Jenkins repository by running the command: + +``` + +sudo mkdir -p /usr/share/keyrings + +sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null + +sudo echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null + +``` +5. Update the package list by running the command, + +6. Install Jenkins by running the command: + +``` +sudo apt-get update +sudo apt-get install jenkins + ``` +### Option 2: Use Terraform to Install Jenkins + +To use Terraform to install Jenkins, follow these steps: + +1. SSH into the Ubuntu EC2 instance created by Terraform by running the command: +`ssh -i deployer ubuntu@<public-ip-of-instance>`. + +2. Run the Jenkins installation script by running the command: +`sudo sh /home/ubuntu/jenkins-installation-ubuntu.sh`. + +3. The script will install Jenkins and its dependencies. Once the installation is complete, Jenkins will be running on the EC2 instance. + +## Clean Up + +To destroy the EC2 instances and associated resources, run the command: `terraform destroy` + +Note: This will delete all resources created by Terraform in this branch. + + +## For More info on lab machine plz expend below: + +<details> +# Jenkins-cicd +PG DO - CI/CD Pipeline with Jenkins Simplilearn + +# AWS Ubuntu VM Provisioning steps +- Step 1: Click on Launch Instance +- Step 2 : Click on Software Image (AMI) +- Select Ubuntu +- Step 4: Key pair name – required +- Click on Create new key pair +- Put key pair name Jenkins-sl +- & Download it +- Step 5 : Click on Launch Instance +- Step 6 : Select your VM and Click connect +- Step 7 : You can see the terminal +- Step: Showing Github example + +# Git Status +``` +git --version +``` +## cretae Dir +``` +mkdir demo +cd demo +``` +## GIT & Ubuntu SSH connection +``` +ssh-keygen + +"Hit enter button 3 time" + +cat ~/.ssh/id_rsa.pub +git clone git@github.com:manikcloud/Jenkins-cicd.git +history +history | cut -c 8- +``` + +# Jenkins installation on UBUNTU 18.04 & Ubuntu 22.04 + +### Step 1 +``` +sudo apt-get update -y && sudo apt install openjdk-8-jdk -y +``` +### Step 2: Downloading Key +``` +sudo wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add +``` + +### Step 3: Adding Key +``` +sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' +``` + +### Step 4: Jenkins Package installation +``` +sudo apt-get update -y && sudo apt install jenkins -y +sudo /etc/init.d/jenkins start +sudo service jenkins status +``` +### Step 5: Jenkins default password +``` +sudo cat /home/labsuser/jenkins/secrets/initialAdminPassword +``` +### Step 6: History command + +``` +history | cut -c 8- + +``` +# Jenkins URL with port 8080 +- http://x.x.x.x:8080/ + +Replace x with your ip + +# Change Security group rule for Jenkins +``` +- Select your instance +- Down below select your security tab +- Click on the Security groups sg-0c51908b5fa4abf75 (launch-wizard-2) +- Click on the action +- Click on EDIT INBOUND RULE +- Select custom TCP and put port 8080 +- Custom ip should be 0.0.0.0/0 +- Click on Save the rule +``` + +# Common error + +``` +getting "E: Unable to locate package openjdk-8-jdk" message on java update +``` + +# Resolution +Run this command + +``` +sudo apt update -y +``` +# Plugin Installation +dashboard>manage>jenkins>manage plugins>maven integration + + + +# Jenkins Setting + +``` +Java_Home +/usr/lib/jvm/java-8-openjdk-amd64/ +``` + +# Post Build Step + +``` +java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App + +``` + +# This project is parameterized +``` +echo "User First name is : $First_Name" +echo "User Last name is : $Last_Name" +echo "User Gender is : $Sex" + +``` +</details> + +# References: +1. https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html +2. https://maven.apache.org/download.cgi + +## Connect & Follow + +For more info, please connect and follow me: + +- Github: [https://github.com/manikcloud](https://github.com/manikcloud) +- LinkedIn: [https://www.linkedin.com/in/vkmanik/](https://www.linkedin.com/in/vkmanik/) +- Email: [varunmanik1@gmail.com](mailto:varunmanik1@gmail.com) +- Facebook: [https://www.facebook.com/cloudvirtualization/](https://www.facebook.com/cloudvirtualization/) +- YouTube: [https://bit.ly/32fknRN](https://bit.ly/32fknRN) +- Twitter: [https://twitter.com/varunkmanik](https://twitter.com/varunkmanik) + diff --git a/6-ansible/README.md b/6-ansible/README.md index fbfd0f6..c0ec667 100644 --- a/6-ansible/README.md +++ b/6-ansible/README.md @@ -1,48 +1,50 @@ -# Lesson 06 Demo 2 -## Demonstrate YAML Scripting - -Steps to be performed: -1. Create a playbook -2. Add YAML script to the playbook to install node -3. Run Ansible YAML script - -## Step 1: Create a playbook -1.1 Use the below command to create a node.yml file - sudo vi node.yml -1.2 Establish SSH key pair in the Linux system to have SSH connectivity with localhost using the following commands: - ssh-keygen -t rsa (Press Enter when asked for File and Paraphrase details) - cat .ssh/id_rsa.pub >> .ssh/authorized_keys - ssh localhost -p 42006 (Type yes when prompted) -1.3 Now, add the host localhost in the Ansible host file /etc/ansible/hosts - sudo vi /etc/ansible/hosts -1.4 When the file opens, add the below two lines of the code at the end of the file: - [webservers] - localhost:42006 - -## Step 2: Add YAML script to the playbook to install node -2.1 Open the node.yaml file by using the below command and then add the following code - sudo vi node.yml -2.2 Copy and paste the below code into the node.yml file: - - ``` - --- - - hosts: webservers - become: true - tasks: - - name: add apt key for nodesource - become: true - apt_key: url=https://deb.nodesource.com/gpgkey/nodesource.gpg.key - - name: add repo for nodesource - become: true - apt_repository: - repo: 'deb https://deb.nodesource.com/node_0.10 {{ ansible_distribution_release }} main' - update_cache: no - - name: install nodejs - become: true - apt: name=nodejs +# Course Content + +This repository contains various resources and scripts used for the course, focusing on Ansible and Terraform. + +## Directory Structure + +- **6-ansible** + - **6.2-node-ansible-playbook**: Ansible playbook for installing Node.js. + - node.yml + - **6.3-apache-ansible-playbook**: Ansible playbook for installing Apache. + - apache.yaml + - **6.4-ansible-module**: Documentation on how to use Ansible modules. + - README.md + - **6.5-ansible-role**: Documentation on how to create and use Ansible roles. + - README.md + - **6.6-setup-terraform**: Scripts and instructions for setting up Terraform. + - README.md + - tf-installation.sh + - **6.7-S3-Bucket-Using-Terraform**: Instructions on how to create an S3 bucket using Terraform. + - README.md + - **6.8-tf-ec2-provisioning**: Terraform scripts for provisioning EC2 instances. + - README.md + - deployer + - deployer.pub + - main.tf + - slave-vm.tf + - ubuntu-vm.tf + +## Prerequisites + +Before using the resources in this repository, make sure you have the following prerequisites installed: + +- Ansible +- Terraform +- Git + +## How to Clone and Change Directory + +To clone the repository and change the directory, follow these steps: + +1. Open your terminal or command prompt. +2. Run the following command to clone the repository: + +``` +git clone https://github.com/manikcloud/DevOps-Tutorial.git ``` -2.3 Save the file and exit using shift+esc+: and then type wq +## Features +This repository provides resources and scripts to help you learn and practice Ansible and Terraform. It includes Ansible playbooks for installing Node.js and Apache, documentation on how to use Ansible modules and roles, and Terraform scripts for setting up infrastructure and provisioning EC2 instances. -## Step 3: Run Ansible YAML script -3.1 Run apache.yaml file using the below command: - ansible-playbook node.yml +Feel free to explore the repository and use the provided resources to enhance your learning experience. \ No newline at end of file From 58fc1545bac756e7e1050a793c3bb930a107e46c Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 10:33:45 +0800 Subject: [PATCH 057/135] ansible -readme --- .../6.7-S3-Bucket-Using-Terraform/.gitignore | 29 +++++++++++++++++++ 6-ansible/6.8-tf-ec2-provisioning/.gitignore | 29 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 6-ansible/6.7-S3-Bucket-Using-Terraform/.gitignore create mode 100644 6-ansible/6.8-tf-ec2-provisioning/.gitignore diff --git a/6-ansible/6.7-S3-Bucket-Using-Terraform/.gitignore b/6-ansible/6.7-S3-Bucket-Using-Terraform/.gitignore new file mode 100644 index 0000000..7a3e2fd --- /dev/null +++ b/6-ansible/6.7-S3-Bucket-Using-Terraform/.gitignore @@ -0,0 +1,29 @@ +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log + +# Ignore any .tfvars files that are generated automatically for each Terraform run. Most +# .tfvars files are managed as part of configuration and so should be included in +# version control. +# +# example.tfvars + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* diff --git a/6-ansible/6.8-tf-ec2-provisioning/.gitignore b/6-ansible/6.8-tf-ec2-provisioning/.gitignore new file mode 100644 index 0000000..7a3e2fd --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/.gitignore @@ -0,0 +1,29 @@ +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log + +# Ignore any .tfvars files that are generated automatically for each Terraform run. Most +# .tfvars files are managed as part of configuration and so should be included in +# version control. +# +# example.tfvars + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* From ebe8b5f1da2f87026f7d765c06b70affe8b8e89c Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 6 May 2023 02:38:55 +0000 Subject: [PATCH 058/135] uploading readme --- .gitignore | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.gitignore b/.gitignore index 524f096..bd3d9f4 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,32 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* replay_pid* +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log + +# Ignore any .tfvars files that are generated automatically for each Terraform run. Most +# .tfvars files are managed as part of configuration and so should be included in +# version control. +# +# example.tfvars + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* From 4a6404be29ff0a4f0eab4ea4f4f0cf7a1dfa17cc Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 6 May 2023 02:47:50 +0000 Subject: [PATCH 059/135] uploading readme --- .../.terraform.lock.hcl | 25 ++++++++++++++++ .../{slave-vm.tf => amazon-linux-vm.tf} | 0 .../6.8-tf-ec2-provisioning/ubuntu-vm.tf | 29 ++----------------- 3 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 6-ansible/6.8-tf-ec2-provisioning/.terraform.lock.hcl rename 6-ansible/6.8-tf-ec2-provisioning/{slave-vm.tf => amazon-linux-vm.tf} (100%) diff --git a/6-ansible/6.8-tf-ec2-provisioning/.terraform.lock.hcl b/6-ansible/6.8-tf-ec2-provisioning/.terraform.lock.hcl new file mode 100644 index 0000000..7864285 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/.terraform.lock.hcl @@ -0,0 +1,25 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "3.76.1" + constraints = "~> 3.27" + hashes = [ + "h1:5WSHHV9CgBvZ0rDDDxLnNHsjDfm4knb7ihJ2AIGB58A=", + "zh:1cf933104a641ffdb64d71a76806f4df35d19101b47e0eb02c9c36bd64bfdd2d", + "zh:273afaf908775ade6c9d32462938e7739ee8b00a0de2ef3cdddc5bc115bb1d4f", + "zh:2bc24ae989e38f575de034083082c69b41c54b8df69d35728853257c400ce0f4", + "zh:53ba88dbdaf9f818d35001c3d519a787f457283d9341f562dc3d0af51fd9606e", + "zh:5cdac7afea68bbd89d3bdb345d99470226482eff41f375f220fe338d2e5808da", + "zh:63127808890ac4be6cff6554985510b15ac715df698d550a3e722722dc56523c", + "zh:97a1237791f15373743189b078a0e0f2fa4dd7d7474077423376cd186312dc55", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:a4f625e97e5f25073c08080e4a619f959bc0149fc853a6b1b49ab41d58b59665", + "zh:b56cca54019237941f7614e8d2712586a6ab3092e8e9492c70f06563259171e9", + "zh:d4bc33bfd6ac78fb61e6d48a61c179907dfdbdf149b89fb97272c663989a7fcd", + "zh:e0089d73fa56d128c574601305634a774eebacf4a84babba71da10040cecf99a", + "zh:e957531f1d92a6474c9b02bd9200da91b99ba07a0ab761c8e3176400dd41721c", + "zh:eceb85818d57d8270db4df7564cf4ed51b5c650a361aaa017c42227158e1946b", + "zh:f565e5caa1b349ec404c6d03d01c68b02233f5485ed038d0aab810dd4023a880", + ] +} diff --git a/6-ansible/6.8-tf-ec2-provisioning/slave-vm.tf b/6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/slave-vm.tf rename to 6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf diff --git a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf index ef59856..925bf01 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf +++ b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf @@ -1,12 +1,4 @@ -# variable "jenkins_admin_user" { -# description = "The admin username for Jenkins" -# default = "admin" -# } -# variable "jenkins_admin_password" { -# description = "The admin password for Jenkins" -# default = "Admin@456" -# } resource "aws_security_group" "allow_SSH_ubuntu" { name = "allow_SSH_ubuntu" @@ -41,11 +33,11 @@ resource "aws_key_pair" "deployer" { resource "aws_instance" "ubuntu" { ami = "ami-007855ac798b5175e" - instance_type = "t2.medium" + instance_type = "t2.micro" key_name = aws_key_pair.deployer.key_name vpc_security_group_ids = ["${aws_security_group.allow_SSH_ubuntu.id}"] tags = { - "Name" = "Jenkins-UBUNTU-22-04" + "Name" = "UBUNTU-22-04" "ENV" = "Dev" } # metadata_options { @@ -60,23 +52,8 @@ resource "aws_instance" "ubuntu" { timeout = "10m" } - associate_public_ip_address = true + associate_public_ip_address = true - # Remotely execute commands to install Java, Python, Jenkins - provisioner "remote-exec" { - inline = [ - "sudo apt update ", - "sudo apt install -y default-jdk ", - "sudo mkdir -p /usr/share/keyrings/", - "sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null", - "sudo echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null", - "sudo apt update", - "sudo apt install -y jenkins", - "sudo systemctl start jenkins --no-pager -l", - "sudo systemctl enable --now jenkins", - "sudo cat /var/lib/jenkins/secrets/initialAdminPassword", - ] - } depends_on = [aws_key_pair.deployer] From e7a9ad992c99aa7b9ad2bed9df97cc341fdb0618 Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 10:49:15 +0800 Subject: [PATCH 060/135] ansible -readme --- .../ansible/ansible.cfg | 6 ++ .../ansible/host_vars.yml | 3 + .../ansible/inventory.ini | 2 + .../ansible/jenkins.yaml | 66 +++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yml create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg b/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg new file mode 100644 index 0000000..3f2db16 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg @@ -0,0 +1,6 @@ +[defaults] +inventory = inventory.ini +remote_user = ubuntu +private_key_file = ../deployer +host_key_checking = False +retry_files_enabled = False diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yml new file mode 100644 index 0000000..58a3d6d --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yml @@ -0,0 +1,3 @@ +--- +ansible_user: ubuntu +ansible_ssh_private_key_file: ../deployer diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini new file mode 100644 index 0000000..a6bc262 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini @@ -0,0 +1,2 @@ +[my_servers] +my_server ansible_host=X.X.X.X \ No newline at end of file diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins.yaml b/6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins.yaml new file mode 100644 index 0000000..a3e7136 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins.yaml @@ -0,0 +1,66 @@ +--- +- name: Install Jenkins on Ubuntu + hosts: all + become: yes + gather_facts: yes + + tasks: + - name: Update and upgrade apt packages + apt: + update_cache: yes + upgrade: yes + + - name: Install default JDK + apt: + name: default-jdk + state: present + + - name: Check Java version + command: java -version + register: java_version + changed_when: False + + - name: Create keyrings directory + file: + path: /usr/share/keyrings + state: directory + + - name: Add Jenkins key + ansible.builtin.get_url: + url: https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key + dest: /usr/share/keyrings/jenkins-keyring.asc + + - name: Add Jenkins repository + ansible.builtin.apt_repository: + repo: deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ + state: present + + - name: Update apt cache + apt: + update_cache: yes + + - name: Install Jenkins + apt: + name: jenkins + state: present + + - name: Check Jenkins status + command: systemctl status jenkins --no-pager -l + register: jenkins_status + changed_when: False + + - name: Enable and start Jenkins service + ansible.builtin.systemd: + name: jenkins + enabled: yes + state: started + + - name: Get Jenkins initial admin password + slurp: + src: /var/lib/jenkins/secrets/initialAdminPassword + register: jenkins_initial_admin_password + changed_when: False + + - name: Display Jenkins initial admin password + debug: + msg: "Initial Jenkins admin password: {{ jenkins_initial_admin_password['content'] | b64decode }}" From d521d040a8f5bbaeb5c14adefc562090b5fcab08 Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sat, 6 May 2023 10:57:10 +0800 Subject: [PATCH 061/135] ansible -readme --- .../ansible/jenkins-installation-ubuntu.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins-installation-ubuntu.sh diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins-installation-ubuntu.sh b/6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins-installation-ubuntu.sh new file mode 100644 index 0000000..9e165cd --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins-installation-ubuntu.sh @@ -0,0 +1,16 @@ +#!/bin/bash +sudo apt update && sudo apt upgrade -y + +sudo apt install default-jdk -y + +sudo java -version +sudo mkdir -p /usr/share/keyrings + +sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null +sudo echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null + +sudo apt update -y +sudo apt install jenkins -y +systemctl status jenkins --no-pager -l +sudo systemctl enable --now jenkins +sudo cat /var/lib/jenkins/secrets/initialAdminPassword From 8228279ed90d8fbc78865fd7afeb2b83d7ed671c Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 6 May 2023 04:04:18 +0000 Subject: [PATCH 062/135] making change to trigger the jenkins --- 5-jenkins/README.md | 2 +- 6-ansible/6.4-ansible-module/README.md | 4 +- .../ansible/apache.yaml | 15 ++++++ .../ansible/base/demor/.travis.yml | 29 +++++++++++ .../ansible/base/demor/README.md | 38 ++++++++++++++ .../ansible/base/demor/defaults/main.yml | 2 + .../ansible/base/demor/handlers/main.yml | 2 + .../ansible/base/demor/meta/main.yml | 52 +++++++++++++++++++ .../ansible/base/demor/tasks/main.yml | 7 +++ .../ansible/base/demor/tests/inventory | 2 + .../ansible/base/demor/tests/test.yml | 5 ++ .../ansible/base/demor/vars/main.yml | 2 + .../ansible/inventory.ini | 3 +- .../6.8-tf-ec2-provisioning/ansible/node.yml | 19 +++++++ 14 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/apache.yaml create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/.travis.yml create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/README.md create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/defaults/main.yml create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/handlers/main.yml create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/meta/main.yml create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tasks/main.yml create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/inventory create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/test.yml create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/vars/main.yml create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/node.yml diff --git a/5-jenkins/README.md b/5-jenkins/README.md index d75f935..9465e01 100644 --- a/5-jenkins/README.md +++ b/5-jenkins/README.md @@ -1,4 +1,4 @@ -# DevOps-Tutorial +# DevOps-Tutorial for Jenkins DevOps-Tutorial # Caltech-DevOps Simplilearn PG Program diff --git a/6-ansible/6.4-ansible-module/README.md b/6-ansible/6.4-ansible-module/README.md index 2f6e507..2b2dba9 100644 --- a/6-ansible/6.4-ansible-module/README.md +++ b/6-ansible/6.4-ansible-module/README.md @@ -13,8 +13,8 @@ This document provides the steps to execute Ansible modules on a local server. 1.1 Run the below commands in the given sequence to execute different Ansible modules. ``` -ansible -m setup webservers -ansible webservers -m shell -a 'hostname' +ansible -m setup all +ansible all -m shell -a 'hostname' ansible webservers -m apt -a 'name=git state=present' --become ansible webservers -m file -a 'dest=/root/sample.txt state=touch mode=600 owner=root group=root' --become ``` diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/apache.yaml b/6-ansible/6.8-tf-ec2-provisioning/ansible/apache.yaml new file mode 100644 index 0000000..ac3bdbf --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/apache.yaml @@ -0,0 +1,15 @@ +--- +- hosts: all + become: true + + tasks: + - name: install apache2 + apt: name=apache2 update_cache=no state=latest + - name: enabled mod_rewrite + apache2_module: name=rewrite state=present + notify: + - restart apache2 + + handlers: + - name: restart apache2 + service: name=apache2 state=restarted diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/.travis.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/README.md b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/defaults/main.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/defaults/main.yml new file mode 100644 index 0000000..cec8c67 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for demor diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/handlers/main.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/handlers/main.yml new file mode 100644 index 0000000..4a4338f --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for demor diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/meta/main.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tasks/main.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tasks/main.yml new file mode 100644 index 0000000..51d3dcc --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tasks/main.yml @@ -0,0 +1,7 @@ +- name: copy demor file + template: + src: templates/demor.j2 + dest: /etc/demor + owner: root + group: root + mode: 0444 \ No newline at end of file diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/inventory b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/test.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/test.yml new file mode 100644 index 0000000..c591e98 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - demor diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/vars/main.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/vars/main.yml new file mode 100644 index 0000000..8ba34b8 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for demor diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini index a6bc262..9a16b57 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini @@ -1,2 +1,3 @@ [my_servers] -my_server ansible_host=X.X.X.X \ No newline at end of file +my_server ansible_host=50.17.108.50 + diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/node.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/node.yml new file mode 100644 index 0000000..079e9bc --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/node.yml @@ -0,0 +1,19 @@ +--- +- hosts: all + become: true + tasks: + - name: add apt key for nodesource + become: true + apt_key: + url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key + + - name: add repo for nodesource + become: true + apt_repository: + repo: 'deb https://deb.nodesource.com/node_0.10 {{ ansible_distribution_release }} main' + update_cache: no + + - name: install nodejs + become: true + apt: + name: nodejs From 141315d7dbd41508190f70c0682553c63a46ec60 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 6 May 2023 04:06:42 +0000 Subject: [PATCH 063/135] making change to trigger the jenkins --- 5-jenkins/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5-jenkins/README.md b/5-jenkins/README.md index 9465e01..8e3b6ad 100644 --- a/5-jenkins/README.md +++ b/5-jenkins/README.md @@ -1,4 +1,4 @@ -# DevOps-Tutorial for Jenkins +# DevOps-Tutorial for Jenkins 1 DevOps-Tutorial # Caltech-DevOps Simplilearn PG Program From 5cf1550bd3f4852e5ac19c5133b7f5880c2ffff2 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 6 May 2023 04:17:46 +0000 Subject: [PATCH 064/135] adding simple java program --- 5-jenkins/5.2-simple-java-program/HelloWorld.java | 5 +++++ 5-jenkins/5.2-simple-java-program/README.md | 0 2 files changed, 5 insertions(+) create mode 100644 5-jenkins/5.2-simple-java-program/HelloWorld.java create mode 100644 5-jenkins/5.2-simple-java-program/README.md diff --git a/5-jenkins/5.2-simple-java-program/HelloWorld.java b/5-jenkins/5.2-simple-java-program/HelloWorld.java new file mode 100644 index 0000000..bbff415 --- /dev/null +++ b/5-jenkins/5.2-simple-java-program/HelloWorld.java @@ -0,0 +1,5 @@ +public class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello, World From Varun Manik on date May 6 2023"); + } +} \ No newline at end of file diff --git a/5-jenkins/5.2-simple-java-program/README.md b/5-jenkins/5.2-simple-java-program/README.md new file mode 100644 index 0000000..e69de29 From d72cf25a66976b85c93aea6a50cc2da5661e8633 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 6 May 2023 04:27:01 +0000 Subject: [PATCH 065/135] making change to trigger the jenkins --- 5-jenkins/5.2-simple-java-program/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/5-jenkins/5.2-simple-java-program/README.md b/5-jenkins/5.2-simple-java-program/README.md index e69de29..fb3bfdc 100644 --- a/5-jenkins/5.2-simple-java-program/README.md +++ b/5-jenkins/5.2-simple-java-program/README.md @@ -0,0 +1,16 @@ + + + +## opy paste this commands in ur jenkins execute shell + +``` +cd 5-jenkins/5.2-simple-java-program + +ls -l + +javac HelloWorld.java + + +java HelloWorld + +``` \ No newline at end of file From 0abf75d8662d1ed81a34185a320bcd033a3a4954 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 6 May 2023 04:27:58 +0000 Subject: [PATCH 066/135] making change to trigger the jenkins --- 5-jenkins/5.2-simple-java-program/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5-jenkins/5.2-simple-java-program/README.md b/5-jenkins/5.2-simple-java-program/README.md index fb3bfdc..0e859ec 100644 --- a/5-jenkins/5.2-simple-java-program/README.md +++ b/5-jenkins/5.2-simple-java-program/README.md @@ -1,7 +1,7 @@ -## opy paste this commands in ur jenkins execute shell +## Copy & paste this commands in your Jenkins, build option, execute shell ``` cd 5-jenkins/5.2-simple-java-program From fbb5d13c718e7b00b91263bf2634fa9fec05efdd Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 6 May 2023 04:51:35 +0000 Subject: [PATCH 067/135] adding mvn java program --- 5-jenkins/5.3-maven-project/my-app/pom.xml | 83 +++++++++++++++++++ .../src/main/java/com/mycompany/app/App.java | 13 +++ .../test/java/com/mycompany/app/AppTest.java | 20 +++++ .../target/maven-archiver/pom.properties | 4 + .../compile/default-compile/createdFiles.lst | 1 + .../compile/default-compile/inputFiles.lst | 1 + .../default-testCompile/createdFiles.lst | 1 + .../default-testCompile/inputFiles.lst | 1 + .../TEST-com.mycompany.app.AppTest.xml | 59 +++++++++++++ .../com.mycompany.app.AppTest.txt | 4 + 10 files changed, 187 insertions(+) create mode 100644 5-jenkins/5.3-maven-project/my-app/pom.xml create mode 100644 5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java create mode 100644 5-jenkins/5.3-maven-project/my-app/src/test/java/com/mycompany/app/AppTest.java create mode 100644 5-jenkins/5.3-maven-project/my-app/target/maven-archiver/pom.properties create mode 100644 5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst create mode 100644 5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst create mode 100644 5-jenkins/5.3-maven-project/my-app/target/surefire-reports/TEST-com.mycompany.app.AppTest.xml create mode 100644 5-jenkins/5.3-maven-project/my-app/target/surefire-reports/com.mycompany.app.AppTest.txt diff --git a/5-jenkins/5.3-maven-project/my-app/pom.xml b/5-jenkins/5.3-maven-project/my-app/pom.xml new file mode 100644 index 0000000..9da641f --- /dev/null +++ b/5-jenkins/5.3-maven-project/my-app/pom.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.mycompany.app</groupId> + <artifactId>my-app</artifactId> + <version>1.0-SNAPSHOT</version> + + <name>my-app</name> + <!-- FIXME change it to the project's website --> + <url>http://www.example.com</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + <maven.compiler.release>11</maven.compiler.release> + </properties> + + + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.11</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.1</version> + </plugin> + <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <version>3.1.0</version> + </plugin> + <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>3.0.2</version> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.0</version> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.22.1</version> + </plugin> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <version>3.0.2</version> + </plugin> + <plugin> + <artifactId>maven-install-plugin</artifactId> + <version>2.5.2</version> + </plugin> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <version>2.8.2</version> + </plugin> + <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <version>3.7.1</version> + </plugin> + <plugin> + <artifactId>maven-project-info-reports-plugin</artifactId> + <version>3.0.0</version> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> diff --git a/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java b/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java new file mode 100644 index 0000000..32e3060 --- /dev/null +++ b/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java @@ -0,0 +1,13 @@ +package com.mycompany.app; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World! From Varun Manik in Simplilearn class" ); + } +} diff --git a/5-jenkins/5.3-maven-project/my-app/src/test/java/com/mycompany/app/AppTest.java b/5-jenkins/5.3-maven-project/my-app/src/test/java/com/mycompany/app/AppTest.java new file mode 100644 index 0000000..81ac345 --- /dev/null +++ b/5-jenkins/5.3-maven-project/my-app/src/test/java/com/mycompany/app/AppTest.java @@ -0,0 +1,20 @@ +package com.mycompany.app; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest +{ + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() + { + assertTrue( true ); + } +} diff --git a/5-jenkins/5.3-maven-project/my-app/target/maven-archiver/pom.properties b/5-jenkins/5.3-maven-project/my-app/target/maven-archiver/pom.properties new file mode 100644 index 0000000..d6071b5 --- /dev/null +++ b/5-jenkins/5.3-maven-project/my-app/target/maven-archiver/pom.properties @@ -0,0 +1,4 @@ +#Created by Apache Maven 3.6.3 +groupId=com.mycompany.app +artifactId=my-app +version=1.0-SNAPSHOT diff --git a/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..de9dba0 --- /dev/null +++ b/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +com/mycompany/app/App.class diff --git a/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..384d5a8 --- /dev/null +++ b/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +/home/varunmanikoutlo/varun/DevOps-Tutorial/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java diff --git a/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..6348184 --- /dev/null +++ b/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1 @@ +com/mycompany/app/AppTest.class diff --git a/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..9ff666c --- /dev/null +++ b/5-jenkins/5.3-maven-project/my-app/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/home/varunmanikoutlo/varun/DevOps-Tutorial/5-jenkins/5.3-maven-project/my-app/src/test/java/com/mycompany/app/AppTest.java diff --git a/5-jenkins/5.3-maven-project/my-app/target/surefire-reports/TEST-com.mycompany.app.AppTest.xml b/5-jenkins/5.3-maven-project/my-app/target/surefire-reports/TEST-com.mycompany.app.AppTest.xml new file mode 100644 index 0000000..dac6ed8 --- /dev/null +++ b/5-jenkins/5.3-maven-project/my-app/target/surefire-reports/TEST-com.mycompany.app.AppTest.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="com.mycompany.app.AppTest" time="0.042" tests="1" errors="0" skipped="0" failures="0"> + <properties> + <property name="awt.toolkit" value="sun.awt.X11.XToolkit"/> + <property name="java.specification.version" value="11"/> + <property name="sun.cpu.isalist" value=""/> + <property name="sun.jnu.encoding" value="UTF-8"/> + <property name="java.class.path" value="/home/varunmanikoutlo/varun/DevOps-Tutorial/5-jenkins/5.3-maven-project/my-app/target/test-classes:/home/varunmanikoutlo/varun/DevOps-Tutorial/5-jenkins/5.3-maven-project/my-app/target/classes:/home/varunmanikoutlo/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/varunmanikoutlo/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/> + <property name="java.vm.vendor" value="Ubuntu"/> + <property name="sun.arch.data.model" value="64"/> + <property name="java.vendor.url" value="https://ubuntu.com/"/> + <property name="user.timezone" value=""/> + <property name="java.vm.specification.version" value="11"/> + <property name="os.name" value="Linux"/> + <property name="sun.java.launcher" value="SUN_STANDARD"/> + <property name="sun.boot.library.path" value="/usr/lib/jvm/java-11-openjdk-amd64/lib"/> + <property name="sun.java.command" value="/home/varunmanikoutlo/varun/DevOps-Tutorial/5-jenkins/5.3-maven-project/my-app/target/surefire/surefirebooter7833339953640500318.jar /home/varunmanikoutlo/varun/DevOps-Tutorial/5-jenkins/5.3-maven-project/my-app/target/surefire 2023-05-06T04-50-04_163-jvmRun1 surefire4344132283997186016tmp surefire_013108013248152437099tmp"/> + <property name="jdk.debug" value="release"/> + <property name="surefire.test.class.path" value="/home/varunmanikoutlo/varun/DevOps-Tutorial/5-jenkins/5.3-maven-project/my-app/target/test-classes:/home/varunmanikoutlo/varun/DevOps-Tutorial/5-jenkins/5.3-maven-project/my-app/target/classes:/home/varunmanikoutlo/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/varunmanikoutlo/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/> + <property name="sun.cpu.endian" value="little"/> + <property name="user.home" value="/home/varunmanikoutlo"/> + <property name="user.language" value="en"/> + <property name="java.specification.vendor" value="Oracle Corporation"/> + <property name="java.version.date" value="2023-01-17"/> + <property name="java.home" value="/usr/lib/jvm/java-11-openjdk-amd64"/> + <property name="file.separator" value="/"/> + <property name="basedir" value="/home/varunmanikoutlo/varun/DevOps-Tutorial/5-jenkins/5.3-maven-project/my-app"/> + <property name="java.vm.compressedOopsMode" value="Zero based"/> + <property name="line.separator" value=" "/> + <property name="java.specification.name" value="Java Platform API Specification"/> + <property name="java.vm.specification.vendor" value="Oracle Corporation"/> + <property name="java.awt.graphicsenv" value="sun.awt.X11GraphicsEnvironment"/> + <property name="surefire.real.class.path" value="/home/varunmanikoutlo/varun/DevOps-Tutorial/5-jenkins/5.3-maven-project/my-app/target/surefire/surefirebooter7833339953640500318.jar"/> + <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/> + <property name="java.runtime.version" value="11.0.18+10-post-Ubuntu-0ubuntu120.04.1"/> + <property name="user.name" value="varunmanikoutlo"/> + <property name="path.separator" value=":"/> + <property name="os.version" value="5.15.0-1035-aws"/> + <property name="java.runtime.name" value="OpenJDK Runtime Environment"/> + <property name="file.encoding" value="UTF-8"/> + <property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/> + <property name="localRepository" value="/home/varunmanikoutlo/.m2/repository"/> + <property name="java.vendor.url.bug" value="https://bugs.launchpad.net/ubuntu/+source/openjdk-lts"/> + <property name="java.io.tmpdir" value="/tmp"/> + <property name="java.version" value="11.0.18"/> + <property name="user.dir" value="/home/varunmanikoutlo/varun/DevOps-Tutorial/5-jenkins/5.3-maven-project/my-app"/> + <property name="os.arch" value="amd64"/> + <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/> + <property name="java.awt.printerjob" value="sun.print.PSPrinterJob"/> + <property name="sun.os.patch.level" value="unknown"/> + <property name="java.library.path" value="/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib"/> + <property name="java.vm.info" value="mixed mode, sharing"/> + <property name="java.vendor" value="Ubuntu"/> + <property name="java.vm.version" value="11.0.18+10-post-Ubuntu-0ubuntu120.04.1"/> + <property name="sun.io.unicode.encoding" value="UnicodeLittle"/> + <property name="java.class.version" value="55.0"/> + </properties> + <testcase name="shouldAnswerWithTrue" classname="com.mycompany.app.AppTest" time="0.002"/> +</testsuite> \ No newline at end of file diff --git a/5-jenkins/5.3-maven-project/my-app/target/surefire-reports/com.mycompany.app.AppTest.txt b/5-jenkins/5.3-maven-project/my-app/target/surefire-reports/com.mycompany.app.AppTest.txt new file mode 100644 index 0000000..efc88dd --- /dev/null +++ b/5-jenkins/5.3-maven-project/my-app/target/surefire-reports/com.mycompany.app.AppTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: com.mycompany.app.AppTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.042 s - in com.mycompany.app.AppTest From 716035b29cf124f997b65514b2b40788292f2125 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 6 May 2023 05:03:06 +0000 Subject: [PATCH 068/135] adding mvn java program --- 5-jenkins/5.3-maven-project/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 5-jenkins/5.3-maven-project/README.md diff --git a/5-jenkins/5.3-maven-project/README.md b/5-jenkins/5.3-maven-project/README.md new file mode 100644 index 0000000..94df37e --- /dev/null +++ b/5-jenkins/5.3-maven-project/README.md @@ -0,0 +1,15 @@ + + + +## Copy & paste this commands in your Jenkins, build option, execute shell + +``` +cd 5-jenkins/5.3-maven-project/my-app + +mvn clean install + +tree + +java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App + +``` \ No newline at end of file From 77a3ea723735a0263dca4b1655a1c83382e2291d Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 6 May 2023 07:22:16 +0000 Subject: [PATCH 069/135] terrafrom install --- 6-ansible/6.6-setup-terraform/README.md | 2 +- 6-ansible/6.6-setup-terraform/tf-installation.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 6-ansible/6.6-setup-terraform/tf-installation.sh diff --git a/6-ansible/6.6-setup-terraform/README.md b/6-ansible/6.6-setup-terraform/README.md index afac4ab..f90c90b 100644 --- a/6-ansible/6.6-setup-terraform/README.md +++ b/6-ansible/6.6-setup-terraform/README.md @@ -7,7 +7,7 @@ Steps to be performed: ## Install Terraform from SH Script ``` -sudo cchmod 755 tf-installation.sh +sudo chmod 755 tf-installation.sh sudo sh tf-installation.sh ``` diff --git a/6-ansible/6.6-setup-terraform/tf-installation.sh b/6-ansible/6.6-setup-terraform/tf-installation.sh old mode 100644 new mode 100755 index eab8818..835ee3b --- a/6-ansible/6.6-setup-terraform/tf-installation.sh +++ b/6-ansible/6.6-setup-terraform/tf-installation.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash # Set the desired Terraform version TERRAFORM_VERSION="1.4.5" From 32d5cc7e4305fd00ea0dd4d3134d5312901abc91 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 6 May 2023 07:38:59 +0000 Subject: [PATCH 070/135] terrafrom install --- .../.terraform.lock.hcl | 24 +++++++++++++++++++ .../6.7-S3-Bucket-Using-Terraform/main.tf | 13 ++++++++++ 2 files changed, 37 insertions(+) create mode 100644 6-ansible/6.7-S3-Bucket-Using-Terraform/.terraform.lock.hcl create mode 100644 6-ansible/6.7-S3-Bucket-Using-Terraform/main.tf diff --git a/6-ansible/6.7-S3-Bucket-Using-Terraform/.terraform.lock.hcl b/6-ansible/6.7-S3-Bucket-Using-Terraform/.terraform.lock.hcl new file mode 100644 index 0000000..e747866 --- /dev/null +++ b/6-ansible/6.7-S3-Bucket-Using-Terraform/.terraform.lock.hcl @@ -0,0 +1,24 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "4.66.1" + hashes = [ + "h1:D/qzK7fE3pgdg25W1u5GqI+VILy8UmhzXruz6c8rJ7g=", + "zh:001c707174b7d6bf89a96cf806f925bb852d1a285fb80b81222cbeb4743bcb79", + "zh:19bc6ac0a7fd1c564fd56c536f1743f71a5e7ca724e21ea51a6a79218939733d", + "zh:3dac5c27f40b511239e9fe6f97dc0b6c95f630ba328001820ddc764e766a5ca2", + "zh:49092c92e2565db4cd4c98ec6878386e6957525d3392b63f0d5df4c48a7c1913", + "zh:4f9e2e1d0c5365a4e6689096cc91ba88ca9c0dc7c633377ba674c1dd856b6a9f", + "zh:57e32bb454f2dc17d5631a9559e36188761d8ae95a452478f81f41bb568a3a42", + "zh:678b78ba629dd833f0705ac90630969f514a54013ab9713ce7ceda55fc5ea138", + "zh:8aab1d76348cf2a685f72382cb838a910b77353179e81ab5794b9c45c8fb36a3", + "zh:8b6791bf0948aa8b49258863992a8ad7e7332dcae1a889e86da0e5ab778dc3b6", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:a36f2777452c2cebdaa8a27378416d512ead367acc078a671bb12276dd4bc9dd", + "zh:c492e6f685882fad6481f4793e696d9e1b01aaae419225c2db0a484b632d1cac", + "zh:d4418e0d1d18e321db364a91d7a768e274bb0fb46df9f3cb5b9debb2bb6917b9", + "zh:d5b4310ef2b2ec22ae14cf909deb1231b56bdd79dc2b51e5db4e46a05e0110c4", + "zh:dedfb01e26b34fb61a52b7e953b8bf5d7a69971187e91697b67221298bbed377", + ] +} diff --git a/6-ansible/6.7-S3-Bucket-Using-Terraform/main.tf b/6-ansible/6.7-S3-Bucket-Using-Terraform/main.tf new file mode 100644 index 0000000..5f4318e --- /dev/null +++ b/6-ansible/6.7-S3-Bucket-Using-Terraform/main.tf @@ -0,0 +1,13 @@ +provider "aws" { + + region = "us-east-1" +} +resource "aws_s3_bucket" "b" { + bucket = "my-tf-test-bucket-34561" + acl = "private" + + tags = { + Name = "My bucket" + Environment = "Dev" + } +} From 493f3167097326748e1fd80a8a65a63f00bee637 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sun, 7 May 2023 02:21:58 +0000 Subject: [PATCH 071/135] ansible readme --- .../ansible/inventory.ini | 3 +- .../ansible/jenkins-installation-ubuntu.sh | 16 ------- 6-ansible/README.md | 47 ++++++++++++++++++- 3 files changed, 48 insertions(+), 18 deletions(-) delete mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins-installation-ubuntu.sh diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini index 9a16b57..83727e2 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini @@ -1,3 +1,4 @@ [my_servers] -my_server ansible_host=50.17.108.50 +my_server ansible_host=18.209.59.137 +#ansible all -i '18.209.59.137,' --private-key=path/to/deployer -m ping \ No newline at end of file diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins-installation-ubuntu.sh b/6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins-installation-ubuntu.sh deleted file mode 100644 index 9e165cd..0000000 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins-installation-ubuntu.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -sudo apt update && sudo apt upgrade -y - -sudo apt install default-jdk -y - -sudo java -version -sudo mkdir -p /usr/share/keyrings - -sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null -sudo echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null - -sudo apt update -y -sudo apt install jenkins -y -systemctl status jenkins --no-pager -l -sudo systemctl enable --now jenkins -sudo cat /var/lib/jenkins/secrets/initialAdminPassword diff --git a/6-ansible/README.md b/6-ansible/README.md index c0ec667..e1e8b2f 100644 --- a/6-ansible/README.md +++ b/6-ansible/README.md @@ -1,3 +1,4 @@ + # Course Content This repository contains various resources and scripts used for the course, focusing on Ansible and Terraform. @@ -47,4 +48,48 @@ git clone https://github.com/manikcloud/DevOps-Tutorial.git ## Features This repository provides resources and scripts to help you learn and practice Ansible and Terraform. It includes Ansible playbooks for installing Node.js and Apache, documentation on how to use Ansible modules and roles, and Terraform scripts for setting up infrastructure and provisioning EC2 instances. -Feel free to explore the repository and use the provided resources to enhance your learning experience. \ No newline at end of file +Feel free to explore the repository and use the provided resources to enhance your learning experience. + +# Ansible Setup on Ubuntu + +This guide will help you set up Ansible on an Ubuntu system. + +## Prerequisites + +- An Ubuntu system +- SSH access to a remote server + +## Steps + +1. Install Ansible on the Ubuntu system: + +``` +sudo apt update +sudo apt install -y ansible +``` + +2. Create an inventory file, for example, `inventory.ini`, and add your server details: + +```ini +[my_servers] +my_server ansible_host=18.209.59.137 +``` + +3. Create an Ansible configuration file, `ansible.cfg`, and add the following content: + +```ini +[defaults] +inventory = inventory.ini +remote_user = ubuntu +private_key_file = ../deployer +host_key_checking = False +retry_files_enabled = False +``` + +4. Test the Ansible connection to the remote server with the following command: + +``` +ansible my_servers -m ping +``` + +Replace 'my_servers' with the appropriate group name from your inventory file. From a3f68c5797baa4d3a2b84547d53d9c31b76af40a Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sun, 7 May 2023 02:30:55 +0000 Subject: [PATCH 072/135] ansible readme --- .../ansible/base/demor/.travis.yml | 29 ----------- .../ansible/base/demor/README.md | 38 -------------- .../ansible/base/demor/defaults/main.yml | 2 - .../ansible/base/demor/handlers/main.yml | 2 - .../ansible/base/demor/meta/main.yml | 52 ------------------- .../ansible/base/demor/tasks/main.yml | 7 --- .../ansible/base/demor/tests/inventory | 2 - .../ansible/base/demor/tests/test.yml | 5 -- .../ansible/base/demor/vars/main.yml | 2 - 6-ansible/README.md | 44 ++++++++++++++-- 10 files changed, 40 insertions(+), 143 deletions(-) delete mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/.travis.yml delete mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/README.md delete mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/defaults/main.yml delete mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/handlers/main.yml delete mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/meta/main.yml delete mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tasks/main.yml delete mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/inventory delete mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/test.yml delete mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/vars/main.yml diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/.travis.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/.travis.yml deleted file mode 100644 index 36bbf62..0000000 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -language: python -python: "2.7" - -# Use the new container infrastructure -sudo: false - -# Install ansible -addons: - apt: - packages: - - python-pip - -install: - # Install ansible - - pip install ansible - - # Check ansible version - - ansible --version - - # Create ansible.cfg with correct roles_path - - printf '[defaults]\nroles_path=../' >ansible.cfg - -script: - # Basic role syntax check - - ansible-playbook tests/test.yml -i tests/inventory --syntax-check - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/README.md b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/README.md deleted file mode 100644 index 225dd44..0000000 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/README.md +++ /dev/null @@ -1,38 +0,0 @@ -Role Name -========= - -A brief description of the role goes here. - -Requirements ------------- - -Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. - -Role Variables --------------- - -A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. - -Dependencies ------------- - -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: servers - roles: - - { role: username.rolename, x: 42 } - -License -------- - -BSD - -Author Information ------------------- - -An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/defaults/main.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/defaults/main.yml deleted file mode 100644 index cec8c67..0000000 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# defaults file for demor diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/handlers/main.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/handlers/main.yml deleted file mode 100644 index 4a4338f..0000000 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# handlers file for demor diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/meta/main.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/meta/main.yml deleted file mode 100644 index c572acc..0000000 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/meta/main.yml +++ /dev/null @@ -1,52 +0,0 @@ -galaxy_info: - author: your name - description: your role description - company: your company (optional) - - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value - # issue_tracker_url: http://example.com/issue/tracker - - # Choose a valid license ID from https://spdx.org - some suggested licenses: - # - BSD-3-Clause (default) - # - MIT - # - GPL-2.0-or-later - # - GPL-3.0-only - # - Apache-2.0 - # - CC-BY-4.0 - license: license (GPL-2.0-or-later, MIT, etc) - - min_ansible_version: 2.1 - - # If this a Container Enabled role, provide the minimum Ansible Container version. - # min_ansible_container_version: - - # - # Provide a list of supported platforms, and for each platform a list of versions. - # If you don't wish to enumerate all versions for a particular platform, use 'all'. - # To view available platforms and versions (or releases), visit: - # https://galaxy.ansible.com/api/v1/platforms/ - # - # platforms: - # - name: Fedora - # versions: - # - all - # - 25 - # - name: SomePlatform - # versions: - # - all - # - 1.0 - # - 7 - # - 99.99 - - galaxy_tags: [] - # List tags for your role here, one per line. A tag is a keyword that describes - # and categorizes the role. Users find roles by searching for tags. Be sure to - # remove the '[]' above, if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of alphanumeric characters. - # Maximum 20 tags per role. - -dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tasks/main.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tasks/main.yml deleted file mode 100644 index 51d3dcc..0000000 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tasks/main.yml +++ /dev/null @@ -1,7 +0,0 @@ -- name: copy demor file - template: - src: templates/demor.j2 - dest: /etc/demor - owner: root - group: root - mode: 0444 \ No newline at end of file diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/inventory b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/inventory deleted file mode 100644 index 878877b..0000000 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/inventory +++ /dev/null @@ -1,2 +0,0 @@ -localhost - diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/test.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/test.yml deleted file mode 100644 index c591e98..0000000 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - demor diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/vars/main.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/vars/main.yml deleted file mode 100644 index 8ba34b8..0000000 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/base/demor/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# vars file for demor diff --git a/6-ansible/README.md b/6-ansible/README.md index e1e8b2f..9b4cf6f 100644 --- a/6-ansible/README.md +++ b/6-ansible/README.md @@ -1,4 +1,3 @@ - # Course Content This repository contains various resources and scripts used for the course, focusing on Ansible and Terraform. @@ -19,13 +18,20 @@ This repository contains various resources and scripts used for the course, focu - tf-installation.sh - **6.7-S3-Bucket-Using-Terraform**: Instructions on how to create an S3 bucket using Terraform. - README.md - - **6.8-tf-ec2-provisioning**: Terraform scripts for provisioning EC2 instances. + - **6.8-tf-ec2-provisioning**: Terraform scripts for provisioning EC2 instances and additional Ansible files. - README.md - deployer - deployer.pub - main.tf - slave-vm.tf - ubuntu-vm.tf + - ansible.cfg: Ansible configuration file. + - apache.yaml: Ansible playbook for installing Apache. + - host_vars.yml: Host variables file for Ansible configuration. + - inventory.ini: Ansible inventory file with server details. + - jenkins.yaml: Ansible playbook for installing Jenkins. + - node.yml: Ansible playbook for installing Node.js. + - **host_vars.yaml**: Host variables file for Ansible configuration. ## Prerequisites @@ -45,8 +51,10 @@ To clone the repository and change the directory, follow these steps: ``` git clone https://github.com/manikcloud/DevOps-Tutorial.git ``` + ## Features -This repository provides resources and scripts to help you learn and practice Ansible and Terraform. It includes Ansible playbooks for installing Node.js and Apache, documentation on how to use Ansible modules and roles, and Terraform scripts for setting up infrastructure and provisioning EC2 instances. + +This repository provides resources and scripts to help you learn and practice Ansible and Terraform. It includes Ansible playbooks for installing Node.js, Apache, and Jenkins, documentation on how to use Ansible modules and roles, and Terraform scripts for setting up infrastructure and provisioning EC2 instances. Feel free to explore the repository and use the provided resources to enhance your learning experience. @@ -92,4 +100,32 @@ retry_files_enabled = False ansible my_servers -m ping ``` -Replace 'my_servers' with the appropriate group name from your inventory file. +Replace 'my_servers' with the appropriate group name + + +from your inventory file. + +# Additional Ansible Files in 6.8 Directory + +Below is a brief explanation of the additional Ansible files found in the `6.8` directory: + +- **ansible.cfg**: This is the Ansible configuration file that contains settings such as the inventory file path, remote user, private key file, host key checking, and retry file settings. +- **apache.yaml**: This Ansible playbook installs the Apache web server on the target machines. To run the playbook, use the following command: + +``` +ansible-playbook apache.yaml +``` + +- **host_vars.yml**: This file contains host-specific variables for Ansible configuration. It allows you to define variables for each host in your inventory. +- **inventory.ini**: This is the Ansible inventory file that contains the server details, such as the server's hostname and IP address. +- **jenkins.yaml**: This Ansible playbook installs Jenkins on the target machines. To run the playbook, use the following command: + +``` +ansible-playbook jenkins.yaml +``` + +- **node.yml**: This Ansible playbook installs Node.js on the target machines. To run the playbook, use the following command: + +``` +ansible-playbook node.yml +``` From 2d0f018fafee641c60b7c36e5731845be55a841d Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sun, 7 May 2023 02:32:35 +0000 Subject: [PATCH 073/135] ansible readme --- .../6.8-tf-ec2-provisioning/ansible/README.md | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/README.md diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/README.md b/6-ansible/6.8-tf-ec2-provisioning/ansible/README.md new file mode 100644 index 0000000..035e329 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/README.md @@ -0,0 +1,111 @@ +# Course Content + +This repository contains various resources and scripts used for the course, focusing on Ansible and Terraform. + +## Directory Structure + + - **6.8-tf-ec2-provisioning**: Terraform scripts for provisioning EC2 instances and additional Ansible files. + - README.md + - deployer + - deployer.pub + - main.tf + - slave-vm.tf + - ubuntu-vm.tf + - ansible.cfg: Ansible configuration file. + - apache.yaml: Ansible playbook for installing Apache. + - host_vars.yml: Host variables file for Ansible configuration. + - inventory.ini: Ansible inventory file with server details. + - jenkins.yaml: Ansible playbook for installing Jenkins. + - node.yml: Ansible playbook for installing Node.js. + - **host_vars.yaml**: Host variables file for Ansible configuration. + +## Prerequisites + +Before using the resources in this repository, make sure you have the following prerequisites installed: + +- Ansible +- Terraform +- Git + +## How to Clone and Change Directory + +To clone the repository and change the directory, follow these steps: + +1. Open your terminal or command prompt. +2. Run the following command to clone the repository: + +``` +git clone https://github.com/manikcloud/DevOps-Tutorial.git +``` + +# Ansible Setup on Ubuntu + +This guide will help you set up Ansible on an Ubuntu system. + +## Prerequisites + +- An Ubuntu system +- SSH access to a remote server + +## Steps + +1. Install Ansible on the Ubuntu system: + +``` +sudo apt update +sudo apt install -y ansible +``` + +2. Create an inventory file, for example, `inventory.ini`, and add your server details: + +```ini +[my_servers] +my_server ansible_host=18.209.59.137 +``` + +3. Create an Ansible configuration file, `ansible.cfg`, and add the following content: + +```ini +[defaults] +inventory = inventory.ini +remote_user = ubuntu +private_key_file = ../deployer +host_key_checking = False +retry_files_enabled = False +``` + +4. Test the Ansible connection to the remote server with the following command: + +``` +ansible my_servers -m ping +``` + +Replace 'my_servers' with the appropriate group name + + +from your inventory file. + +# Additional Ansible Files in 6.8 Directory + +Below is a brief explanation of the additional Ansible files found in the `6.8` directory: + +- **ansible.cfg**: This is the Ansible configuration file that contains settings such as the inventory file path, remote user, private key file, host key checking, and retry file settings. +- **apache.yaml**: This Ansible playbook installs the Apache web server on the target machines. To run the playbook, use the following command: + +``` +ansible-playbook apache.yaml +``` + +- **host_vars.yml**: This file contains host-specific variables for Ansible configuration. It allows you to define variables for each host in your inventory. +- **inventory.ini**: This is the Ansible inventory file that contains the server details, such as the server's hostname and IP address. +- **jenkins.yaml**: This Ansible playbook installs Jenkins on the target machines. To run the playbook, use the following command: + +``` +ansible-playbook jenkins.yaml +``` + +- **node.yml**: This Ansible playbook installs Node.js on the target machines. To run the playbook, use the following command: + +``` +ansible-playbook node.yml +``` From e5a0155e150fe73ca329e4ff98fa10a8a7966b10 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sun, 7 May 2023 02:37:18 +0000 Subject: [PATCH 074/135] ansible readme --- 6-ansible/6.4-ansible-module/README.md | 32 +++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/6-ansible/6.4-ansible-module/README.md b/6-ansible/6.4-ansible-module/README.md index 2b2dba9..a9a02fc 100644 --- a/6-ansible/6.4-ansible-module/README.md +++ b/6-ansible/6.4-ansible-module/README.md @@ -27,4 +27,34 @@ ansible webservers -m file -a 'dest=/root/sample.txt state=touch mode=600 owner= - ansible webservers -m apt -a 'name=git state=present' --become: This command uses the apt module to install the git package on the remote hosts listed under the [webservers] group in the Ansible inventory file. The apt module provides a way to manage packages on Debian-based systems. The --become flag is used to elevate privileges and run the command as the root user. -- ansible webservers -m file -a 'dest=/root/sample.txt state=touch mode=600 owner=root group=root' --become: This command uses the file module to create a new file named sample.txt with root as the owner and group, and the file mode set to 600 on the remote hosts listed under the [webservers] group in the Ansible inventory file. The file module provides a way to manage files and directories on remote hosts. The --become flag is used to elevate privileges and run the command as the root user. \ No newline at end of file +- ansible webservers -m file -a 'dest=/root/sample.txt state=touch mode=600 owner=root group=root' --become: This command uses the file module to create a new file named sample.txt with root as the owner and group, and the file mode set to 600 on the remote hosts listed under the [webservers] group in the Ansible inventory file. The file module provides a way to manage files and directories on remote hosts. The --become flag is used to elevate privileges and run the command as the root user. + + +# Step 1: Ansible Ad-hoc Command without Configuration Files +``` +ansible all -i '18.209.59.137,' -m ping -u ubuntu --private-key ../deployer +``` + +# Step 2: Add Inventory File (inventory.ini) +echo "[my_servers]\nmy_server ansible_host=18.209.59.137" > inventory.ini +``` + +ansible my_servers -i inventory.ini -m ping -u ubuntu --private-key ../deployer +``` + + +# Step 3: Add Ansible Configuration File (ansible.cfg) + +echo -e "[defaults]\ninventory = inventory.ini\nremote_user = ubuntu\nprivate_key_file = ../deployer\nhost_key_checking = False\nretry_files_enabled = False" > ansible.cfg +``` + +ansible my_servers -m ping +``` + + +# Step 4: Simplified Ansible Command with Configuration Files +``` + +ansible my_servers -m ping +``` + From 00765373e11b0883329ba8b762314c9f31ebca99 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sun, 7 May 2023 02:41:19 +0000 Subject: [PATCH 075/135] ansible readme --- .gitignore | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.gitignore b/.gitignore index bd3d9f4..001a1d8 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,41 @@ override.tf.json # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan # example: *tfplan* +# Ansible +*.retry +*.log + +# Terraform +.terraform +*.tfstate +*.tfstate.backup +*.tfplan + +# Java +target/ +*.class +*.jar + +# Python +__pycache__/ +*.pyc +*.pyo +*.egg-info/ +dist/ +build/ +*.egg +*.log +*.retry + +# Docker +*.dockerignore +.docker/ +docker-compose.yml +docker-compose.yaml +docker-compose.override.yml +docker-compose.override.yaml +*.env + +# PHP +vendor/ +composer.lock From f10749265f706e96f8184b6f69a15b3283ce9164 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sun, 7 May 2023 04:37:32 +0000 Subject: [PATCH 076/135] ansible readme --- .../6.7-S3-Bucket-Using-Terraform/main.tf | 2 +- .../ansible/inventory.ini | 2 - 6-ansible/6.8-tf-ec2-provisioning/main.tf | 95 ------------------- .../6.8-tf-ec2-provisioning/ubuntu-vm.tf | 20 +--- 4 files changed, 3 insertions(+), 116 deletions(-) diff --git a/6-ansible/6.7-S3-Bucket-Using-Terraform/main.tf b/6-ansible/6.7-S3-Bucket-Using-Terraform/main.tf index 5f4318e..84b4269 100644 --- a/6-ansible/6.7-S3-Bucket-Using-Terraform/main.tf +++ b/6-ansible/6.7-S3-Bucket-Using-Terraform/main.tf @@ -3,7 +3,7 @@ provider "aws" { region = "us-east-1" } resource "aws_s3_bucket" "b" { - bucket = "my-tf-test-bucket-34561" + bucket = "my-tf-test-bucket-345611" acl = "private" tags = { diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini index 83727e2..5e04db6 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini @@ -1,4 +1,2 @@ [my_servers] my_server ansible_host=18.209.59.137 - -#ansible all -i '18.209.59.137,' --private-key=path/to/deployer -m ping \ No newline at end of file diff --git a/6-ansible/6.8-tf-ec2-provisioning/main.tf b/6-ansible/6.8-tf-ec2-provisioning/main.tf index cd9a076..a97b619 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/main.tf +++ b/6-ansible/6.8-tf-ec2-provisioning/main.tf @@ -13,98 +13,3 @@ provider "aws" { profile = "default" region = "us-east-1" } - - -# resource "aws_security_group" "allow_SSH" { -# name = "allow_SSH" -# description = "Allow SSH inbound traffic" -# # vpc_id = aws_vpc.main.id - - -# ingress { -# from_port = 0 -# to_port = 0 -# protocol = "-1" -# cidr_blocks = ["0.0.0.0/0"] -# ipv6_cidr_blocks = ["::/0"] -# # description = "SSH from VPC" -# # from_port = 22 -# # to_port = 22 -# # protocol = "tcp" -# # cidr_blocks = ["61.6.14.46/32"] -# # # ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block] -# } - -# egress { -# from_port = 0 -# to_port = 0 -# protocol = "-1" -# cidr_blocks = ["0.0.0.0/0"] -# ipv6_cidr_blocks = ["::/0"] -# } -# } - -# resource "aws_key_pair" "deployer1" { -# key_name = "deployer-key1" -# public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDD8gTEP0wdqJnHkVDc7IMzFygpsibTemZylZvk4gcGiaa+YX8/VpUEyOrqYOg/8OrOAsdQCpPcc8J3AhUBSvgjeKc7sJZ0N8v+AOKnVQDni/y+9mWD6oGOszzH6DVfoHOy1HRZAbF6n+xFkk0DeisSJ3FsGVQK/J5rYgXVCBJii34mL0+DOBogxLva8tDcLgWLz+qxs8QcH4hgrHkdT8whBKfKcypICGS4U/WgXFW5M3pN4OynSzeqJ9gXn0Fbq50J/t6Cpnr6wqlzRzocAMXnlgrchYZWZJgTL3W8zrg1Fx7RBy3fAbEyWoyrkB9cFIPSkmiUZG9xUhirI4MbdgHVNlkp7xU0V6KfCRlTNE+xzWlbPSga7kjlqiizjDoR7xExKNLbNthB6nlNIEwX+FljtgrTqMV2w6k8H3xfrhdG0993EnMMwdPVmltEjJeZ+l3BETUcibKGFFc5iyR99W7NKhriH5d6OvbXev7JmbqsXrwn8rnu3auDGJs7YaIwzmk= varunmanikoutlo@ip-172-31-17-206" -# } - -# # resource "aws_instance" "linux" { -# # ami = "ami-0c02fb55956c7d316" -# # instance_type = "t2.micro" -# # key_name = aws_key_pair.deployer1.key_name -# # # count = 1 -# # vpc_security_group_ids = ["${aws_security_group.allow_SSH.id}"] -# # tags = { -# # "Name" = "Linux-Node" -# # "ENV" = "Dev" -# # } - -# # depends_on = [aws_key_pair.deployer1] - -# # } - -# ####### Ubuntu VM ##### - - -# resource "aws_instance" "ubuntu" { -# ami = "ami-04505e74c0741db8d" -# instance_type = "t2.micro" -# key_name = aws_key_pair.deployer1.key_name -# vpc_security_group_ids = ["${aws_security_group.allow_SSH.id}"] -# tags = { -# "Name" = "UBUNTU-sl-1" -# "ENV" = "Dev" -# } - -# # Type of connection to be established -# connection { -# type = "ssh" -# user = "ubuntu" -# private_key = file("./deployer") -# host = self.public_ip -# } -# # Remotely execute commands to install Java, Python, Jenkins -# provisioner "remote-exec" { -# inline = [ -# "sudo apt update && upgrade", -# "sudo apt install -y python3.8", -# "wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -", -# "sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'", -# "sudo apt-get update", -# "sudo apt-get install default-jdk -y", -# "sudo apt-get install -y jenkins", -# "systemctl status jenkins --no-pager -l", -# "sudo systemctl enable --now jenkins", -# "sudo cat /var/lib/jenkins/secrets/initialAdminPassword", -# ] -# } - -# depends_on = [aws_key_pair.deployer1] - -# } - -# output "ubuntu" { -# value = aws_instance.ubuntu.public_ip -# description = "description" -# } diff --git a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf index 925bf01..785ee2b 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf +++ b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf @@ -1,9 +1,6 @@ - - resource "aws_security_group" "allow_SSH_ubuntu" { name = "allow_SSH_ubuntu" description = "Allow SSH inbound traffic" - # vpc_id = aws_vpc.main.id ingress { @@ -40,20 +37,7 @@ resource "aws_instance" "ubuntu" { "Name" = "UBUNTU-22-04" "ENV" = "Dev" } - # metadata_options { - # http_endpoint = "disabled" - # } - # Type of connection to be established - connection { - type = "ssh" - user = "ubuntu" - private_key = file("./deployer") - host = self.public_ip - timeout = "10m" - } - - associate_public_ip_address = true - + depends_on = [aws_key_pair.deployer] @@ -61,5 +45,5 @@ resource "aws_instance" "ubuntu" { output "ubuntu" { value = aws_instance.ubuntu.public_ip - description = "description" + description = "Ubuntu vm public IP" } From 6b5ba29680772c23f39bd1fc6a35bbc2486d4ee5 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sun, 7 May 2023 07:54:51 +0000 Subject: [PATCH 077/135] history commands for docker --- .../ansible/apache.yaml | 9 ++--- .../ansible/{host_vars.yml => host_vars.yaml} | 0 .../ansible/inventory.ini | 4 ++- .../ansible/{node.yml => node.yaml} | 0 .../6.8-tf-ec2-provisioning/ansible/ping.yaml | 33 +++++++++++++++++++ .../6.8-tf-ec2-provisioning/ubuntu-vm.tf | 7 ++-- 6 files changed, 43 insertions(+), 10 deletions(-) rename 6-ansible/6.8-tf-ec2-provisioning/ansible/{host_vars.yml => host_vars.yaml} (100%) rename 6-ansible/6.8-tf-ec2-provisioning/ansible/{node.yml => node.yaml} (100%) create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/ping.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/apache.yaml b/6-ansible/6.8-tf-ec2-provisioning/ansible/apache.yaml index ac3bdbf..445f6de 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/apache.yaml +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/apache.yaml @@ -1,14 +1,11 @@ --- -- hosts: all +- hosts: my_servers become: true tasks: - - name: install apache2 + - name: Install apache2 apt: name=apache2 update_cache=no state=latest - - name: enabled mod_rewrite - apache2_module: name=rewrite state=present - notify: - - restart apache2 + handlers: - name: restart apache2 diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yml rename to 6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini index 5e04db6..367ab9b 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini @@ -1,2 +1,4 @@ [my_servers] -my_server ansible_host=18.209.59.137 +my_server_1 ansible_host=3.83.161.207 +my_server_2 ansible_host=3.94.145.119 +my_server_3 ansible_host=54.196.214.244 \ No newline at end of file diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/node.yml b/6-ansible/6.8-tf-ec2-provisioning/ansible/node.yaml similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/node.yml rename to 6-ansible/6.8-tf-ec2-provisioning/ansible/node.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/ping.yaml b/6-ansible/6.8-tf-ec2-provisioning/ansible/ping.yaml new file mode 100644 index 0000000..52c7a72 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/ping.yaml @@ -0,0 +1,33 @@ +--- + +- name: This is a simple Playbook. + hosts: my_servers + become: yes + gather_facts: yes + + tasks: + - name: 1. Ping the remote server + ping: + - name: 2. Create index file + file: + path: /home/ubuntu/index.html + state: touch + + - name: 3. Apache2 + apt: + name: apache2 + state: present + + + - name: 4. Apache2-service + service: + name: apache2 + state: restarted + + # # - name: 2. Un-Install git + # # apt: + # # name: git + # # state: present + + + \ No newline at end of file diff --git a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf index 785ee2b..798bfe0 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf +++ b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf @@ -32,18 +32,19 @@ resource "aws_instance" "ubuntu" { ami = "ami-007855ac798b5175e" instance_type = "t2.micro" key_name = aws_key_pair.deployer.key_name + count = 3 vpc_security_group_ids = ["${aws_security_group.allow_SSH_ubuntu.id}"] tags = { - "Name" = "UBUNTU-22-04" + "Name" = "UBUNTU-${count.index}" "ENV" = "Dev" } - + depends_on = [aws_key_pair.deployer] } output "ubuntu" { - value = aws_instance.ubuntu.public_ip + value = aws_instance.ubuntu.*.public_ip description = "Ubuntu vm public IP" } From d9500e6374f981967126f2172d248b1babcd1598 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 11:07:16 +0000 Subject: [PATCH 078/135] docker commands --- 6-ansible/6.5-ansible-role/ansible.cfg | 6 + 6-ansible/6.5-ansible-role/demor-role.yml | 11 + 6-ansible/6.5-ansible-role/demor/.travis.yml | 29 + 6-ansible/6.5-ansible-role/demor/README.md | 38 ++ .../6.5-ansible-role/demor/defaults/main.yml | 2 + .../6.5-ansible-role/demor/meta/main.yml | 52 ++ .../6.5-ansible-role/demor/tasks/main.yml | 8 + .../6.5-ansible-role/demor/templates/demor.j2 | 7 + 6-ansible/6.5-ansible-role/deployer | 38 ++ 6-ansible/6.5-ansible-role/deployer.pub | 1 + 6-ansible/6.5-ansible-role/host_vars.yml | 3 + 6-ansible/6.5-ansible-role/inventory.ini | 4 + 7-docker/README.md | 543 ++++++++++++++++++ README.md | 22 + 14 files changed, 764 insertions(+) create mode 100644 6-ansible/6.5-ansible-role/ansible.cfg create mode 100644 6-ansible/6.5-ansible-role/demor-role.yml create mode 100644 6-ansible/6.5-ansible-role/demor/.travis.yml create mode 100644 6-ansible/6.5-ansible-role/demor/README.md create mode 100644 6-ansible/6.5-ansible-role/demor/defaults/main.yml create mode 100644 6-ansible/6.5-ansible-role/demor/meta/main.yml create mode 100644 6-ansible/6.5-ansible-role/demor/tasks/main.yml create mode 100644 6-ansible/6.5-ansible-role/demor/templates/demor.j2 create mode 100644 6-ansible/6.5-ansible-role/deployer create mode 100644 6-ansible/6.5-ansible-role/deployer.pub create mode 100644 6-ansible/6.5-ansible-role/host_vars.yml create mode 100644 6-ansible/6.5-ansible-role/inventory.ini create mode 100644 7-docker/README.md diff --git a/6-ansible/6.5-ansible-role/ansible.cfg b/6-ansible/6.5-ansible-role/ansible.cfg new file mode 100644 index 0000000..3b6c7ec --- /dev/null +++ b/6-ansible/6.5-ansible-role/ansible.cfg @@ -0,0 +1,6 @@ +[defaults] +inventory = inventory.ini +remote_user = ubuntu +private_key_file = ./deployer +host_key_checking = False +retry_files_enabled = False diff --git a/6-ansible/6.5-ansible-role/demor-role.yml b/6-ansible/6.5-ansible-role/demor-role.yml new file mode 100644 index 0000000..78bb297 --- /dev/null +++ b/6-ansible/6.5-ansible-role/demor-role.yml @@ -0,0 +1,11 @@ + + +--- +- name: use demor role playbook + hosts: my_server + user: ansible + become: true + + roles: + - role: demor + system_manager: admin@golinuxcloud.com diff --git a/6-ansible/6.5-ansible-role/demor/.travis.yml b/6-ansible/6.5-ansible-role/demor/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/6-ansible/6.5-ansible-role/demor/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/6-ansible/6.5-ansible-role/demor/README.md b/6-ansible/6.5-ansible-role/demor/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/6-ansible/6.5-ansible-role/demor/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/6-ansible/6.5-ansible-role/demor/defaults/main.yml b/6-ansible/6.5-ansible-role/demor/defaults/main.yml new file mode 100644 index 0000000..2c95bf8 --- /dev/null +++ b/6-ansible/6.5-ansible-role/demor/defaults/main.yml @@ -0,0 +1,2 @@ +# defaults file for demor +system_manager: admin@golinuxcloud.com diff --git a/6-ansible/6.5-ansible-role/demor/meta/main.yml b/6-ansible/6.5-ansible-role/demor/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/6-ansible/6.5-ansible-role/demor/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/6-ansible/6.5-ansible-role/demor/tasks/main.yml b/6-ansible/6.5-ansible-role/demor/tasks/main.yml new file mode 100644 index 0000000..7f9b97c --- /dev/null +++ b/6-ansible/6.5-ansible-role/demor/tasks/main.yml @@ -0,0 +1,8 @@ + +- name: copy demor file + template: + src: templates/demor.j2 + dest: /etc/demor + owner: root + group: root + mode: 0444 diff --git a/6-ansible/6.5-ansible-role/demor/templates/demor.j2 b/6-ansible/6.5-ansible-role/demor/templates/demor.j2 new file mode 100644 index 0000000..6a7c197 --- /dev/null +++ b/6-ansible/6.5-ansible-role/demor/templates/demor.j2 @@ -0,0 +1,7 @@ + +Welcome to {{ ansible_hostname }} + +This file was created on {{ ansible_date_time.date }} +Go away if you have no business being here + +Contact {{ system_manager }} if anything is wrong diff --git a/6-ansible/6.5-ansible-role/deployer b/6-ansible/6.5-ansible-role/deployer new file mode 100644 index 0000000..2b6525d --- /dev/null +++ b/6-ansible/6.5-ansible-role/deployer @@ -0,0 +1,38 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn +NhAAAAAwEAAQAAAYEAw/IExD9MHaiZx5FQ3OyDMxcoKbIm03pmcpWb5OIHBommvmF/P1aV +BMjq6mDoP/DqzgLHUAqT3HPCdwIVAUr4I3inO7CWdDfL/gDip1UA54v8vvZlg+qBjrM8x+ +g1X6BzstR0WQGxep/sRZJNA3orEidxbBlUCvyea2IF1QgSYot+Ji9PgzgaIMS72vLQ3C4F +i8/qsbPEHB+IYKx5HU/MIQSnynMqSAhkuFP1oFxVuTN6TeDsp0s3qifYF59BW6udCf7egq +Z6+sKpc0c6HADF55YK3IWGVmSYEy91vM64NRce0Qct3wGxMlqMq5AfXBSD0pJolGRvcVIY +qyODG3YB1TZZKe8VNFeinwkZUzRPsc1pWz0oGu5I5aoos4w6Ee8RMSjS2zbYQep5TSBMF/ +hZY7YK06jFdsOpPB98X64XRtPfdxJzDMHT1ZpbRIyXmfpdwRE1HImyhhRXOYskffVuzSoa +4h+Xejr213r+yZm6rF68J/K57t2rgxibO2GiMM5pAAAFmKv3VXqr91V6AAAAB3NzaC1yc2 +EAAAGBAMPyBMQ/TB2omceRUNzsgzMXKCmyJtN6ZnKVm+TiBwaJpr5hfz9WlQTI6upg6D/w +6s4Cx1AKk9xzwncCFQFK+CN4pzuwlnQ3y/4A4qdVAOeL/L72ZYPqgY6zPMfoNV+gc7LUdF +kBsXqf7EWSTQN6KxIncWwZVAr8nmtiBdUIEmKLfiYvT4M4GiDEu9ry0NwuBYvP6rGzxBwf +iGCseR1PzCEEp8pzKkgIZLhT9aBcVbkzek3g7KdLN6on2BefQVurnQn+3oKmevrCqXNHOh +wAxeeWCtyFhlZkmBMvdbzOuDUXHtEHLd8BsTJajKuQH1wUg9KSaJRkb3FSGKsjgxt2AdU2 +WSnvFTRXop8JGVM0T7HNaVs9KBruSOWqKLOMOhHvETEo0ts22EHqeU0gTBf4WWO2CtOoxX +bDqTwffF+uF0bT33cScwzB09WaW0SMl5n6XcERNRyJsoYUVzmLJH31bs0qGuIfl3o69td6 +/smZuqxevCfyue7dq4MYmzthojDOaQAAAAMBAAEAAAGBAIVNW7LKwRSYQ+4BzTpO6L7ULS +2YllNevN2NLF5c6pym/rocB/5l/8EekrparQX69zKpr0CjwY3DbvOZhgK4JvGyvkqcSu7L +msq1fXyLFq9vi8W6SLuiyPr0sw/oyI7C0JNDd9epkD01GP8Hlb8c2Lpj/QSmgodq7rdtGz +yfXiqObYa6vuQtQZEzZf2BHVf9Mya3jxnPi0X6qcPi8g5f4CZCTYgsKwKQOz0vWTX8OxFg +lP7wWu9A+6CVtKv1WvhrWZy0g68CaMsBRZ2weZ1K4ScqbZvJdvWPfJzY0rJgJk7wNPA5Ak +QEG+IaMtmFQ5phGEcxqXkoGcSlLEW7P8XMwLHTWdlFAgVwrWsvmU8dzZ+tOa82ZY8tIF+B +wzzYgFZoO3H4fFXd3sXx7f/ME5a1NTTiEU/8I16omN8xdrDSVHbJd4stljpUGda6iTgF2s +khXmZ7dxCq/ZDlbCQwsumzbmPz+ass13/bP/PG7e92CRhwxrRELQij0DWpRiLPc13c0QAA +AMEAg+5tOG/WZA1P8KfeDmZXImTWOuTnaOZzYRI9ZXFpF9gUa+zYO/0l5br4I0/SKQJs0Y +C+XIamiN7HoOjH4MDkqTHrmkliGsJ0Z5Ag/u6eEEvXqMqkdJ8dbhP9aHVUhPUJ9AuJ7Bsf +Jgy/hgjkntf165K83Gkrgmcql+iPOxA9EjrWFRuWdTrMFRJgqTirtwMPI7ywKXkXKB5tX+ +AqgpPb2s7cj00B4pQku9RA0apE0UOcRzEiAMUpP9egTHBIN1XzAAAAwQDnJbhvuZkZxKjD +KMJsta1nom0+TLNxix7y/oOaX+YRmYY+6vS7WHCY5qg/7wUNd6npTS/QU1FoL0HsQalVwy +YDYoUAbmfdT2xQEUesO6cKpFNfI+ToolsZppp+Nuqi60FEFE+S/pV/4gMxQnt0DcQ/Wumu +R/eBTBdjbFh4ZkedPIulue6XxtBmhfzor8IGNklChWrKib47D0/LN5AJA62uriQmo23yKG +AVDYuhSnEOt4yPZgW5e0tVrajkUti0cpUAAADBANkDXzsfmG1GyF9I68NdLhDfU0huxRWs +8bVPX92eKI2HKZ/ZzHx9s3gwkz/nj2iCmIKOEI0S7qNkGGjt+vQ+qH7oxWhjW4t8S7b/pe +JBVDvRUGNk2XIYk5Jdcgv+VPJDrfe51IV6cXxxkmOU5asMgvlsMue8pKuiBw/HgdmNOQBp +9Y/NSXLTUDh0jOwFyryYZKDZPSaP/iWN38Y3v6UHwa9wz0AnL1Iv1sT12sui9dEQ9hdTDd +thvT0LVaxmsBlrhQAAACB2YXJ1bm1hbmlrb3V0bG9AaXAtMTcyLTMxLTE3LTIwNgE= +-----END OPENSSH PRIVATE KEY----- diff --git a/6-ansible/6.5-ansible-role/deployer.pub b/6-ansible/6.5-ansible-role/deployer.pub new file mode 100644 index 0000000..d149548 --- /dev/null +++ b/6-ansible/6.5-ansible-role/deployer.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDD8gTEP0wdqJnHkVDc7IMzFygpsibTemZylZvk4gcGiaa+YX8/VpUEyOrqYOg/8OrOAsdQCpPcc8J3AhUBSvgjeKc7sJZ0N8v+AOKnVQDni/y+9mWD6oGOszzH6DVfoHOy1HRZAbF6n+xFkk0DeisSJ3FsGVQK/J5rYgXVCBJii34mL0+DOBogxLva8tDcLgWLz+qxs8QcH4hgrHkdT8whBKfKcypICGS4U/WgXFW5M3pN4OynSzeqJ9gXn0Fbq50J/t6Cpnr6wqlzRzocAMXnlgrchYZWZJgTL3W8zrg1Fx7RBy3fAbEyWoyrkB9cFIPSkmiUZG9xUhirI4MbdgHVNlkp7xU0V6KfCRlTNE+xzWlbPSga7kjlqiizjDoR7xExKNLbNthB6nlNIEwX+FljtgrTqMV2w6k8H3xfrhdG0993EnMMwdPVmltEjJeZ+l3BETUcibKGFFc5iyR99W7NKhriH5d6OvbXev7JmbqsXrwn8rnu3auDGJs7YaIwzmk= varunmanikoutlo@ip-172-31-17-206 diff --git a/6-ansible/6.5-ansible-role/host_vars.yml b/6-ansible/6.5-ansible-role/host_vars.yml new file mode 100644 index 0000000..22f9a46 --- /dev/null +++ b/6-ansible/6.5-ansible-role/host_vars.yml @@ -0,0 +1,3 @@ +--- +ansible_user: ubuntu +ansible_ssh_private_key_file: ./deployer diff --git a/6-ansible/6.5-ansible-role/inventory.ini b/6-ansible/6.5-ansible-role/inventory.ini new file mode 100644 index 0000000..83727e2 --- /dev/null +++ b/6-ansible/6.5-ansible-role/inventory.ini @@ -0,0 +1,4 @@ +[my_servers] +my_server ansible_host=18.209.59.137 + +#ansible all -i '18.209.59.137,' --private-key=path/to/deployer -m ping \ No newline at end of file diff --git a/7-docker/README.md b/7-docker/README.md new file mode 100644 index 0000000..5d9e87d --- /dev/null +++ b/7-docker/README.md @@ -0,0 +1,543 @@ + + +# Lesson 7 Demo 2 +Performing CRUD Operation on Containers + +### Steps to be followed: +1. Pulling a Docker image +2. Creating a new container +3. Stopping the container +4. Listing all the containers +5. Deleting the container +6. Removing the image + +### Step 1: Pulling a Docker image +1.1 Open the terminal and pull an image using the command: + +``` +sudo docker pull nginx + + +``` + + +1.2 List all the docker images to check the newly pulled nginx image: + +``` +sudo docker images + +``` + + +### Step 2: Creating a new container + 2.1 Create a new container from the nginx image: + +``` +sudo docker run -dt -p 81:81 nginx + +``` + + +2.2 List all the running containers to check the newly created container. You can find various details like port of container, it’s time of creation and ID. + +``` +sudo docker ps + +``` + +### Step 3: Stopping the container +3.1 Use the following command to stop the running container. (You can also us the container ID to stop the container: +``` +sudo docker stop CONTAINER_ID) + + +sudo docker stop CONTAINER_NAME + +``` + + +3.2 Use the following command to list all the running containers and verify if the container has stopped running: + +``` +sudo docker ps + +``` + +3.3 You can start the container again and check the running containers. (You can also us the container ID to start the container: + +``` +sudo docker start CONTAINER_ID) + + +sudo docker start CONTAINER_NAME + +sudo docker ps + +``` + + + +3.4 To start the container in interactive mode, use the –i and –t options. + +``` +sudo docker run -it --name=Test_1 ubuntu + +``` + +### Step 4: Listing all the containers +4.1 Use the below command to list all the containers started and the once which are stopped: + +``` +sudo docker ps -a + +``` + + +4.2 To list the containers by their ID, use the below command + +``` +sudo docker ps -aq + +``` + + +You can see the containers with ID are listed. + +4.3 To list the total file size of each container, use the below command: + + +``` +sudo docker ps -s + +``` + + +4.4 To list the latest created containers, use the following command: + + +``` +sudo docker ps -l + + +``` + +### Step 5: Deleting the container +5.1 Stop the running container and remove it using the following commands: + + +``` +sudo docker stop CONTAINER_NAME +sudo docker container rm CONTAINER_NAME + + +``` + + + + +### Step 6: Removing the image +6.1 Remove the image using the command: + +``` +sudo docker image rm nginx + +``` + + + +---------------------------- + + + +# Lesson 7 Demo 3 +Creating a Docker Image + + +### Steps to be followed: +1. Creating the Dockerfile +2. Executing the Dockerfile + +### Step 1: Creating the Dockerfile + 1.1 Create a directory + + +``` +mkdir demo +cd demo + +``` + +1.2 Create the Dockerfile + +``` +vi Dockerfile + +``` + + +1.3 Add the following code snippet to the Dockerfile + +``` +FROM ubuntu +RUN apt-get update +RUN apt-get install -y nginx +COPY index.nginx-debian.html /var/www/html +CMD nginx -g 'daemon off;' + +``` + + + +1.4 Create another file in the same directory + +``` +vi index.nginx-debian.html + +``` + +1.5 Add the following welcome message to the index file + +``` +WELCOME TO NGINX. + +``` + + + +### Step 2: Executing the file + 2.1 Execute the Dockerfile (note that there is space between build and “.”) + +``` +sudo docker build . + + +``` + + +2.2 Navigate to the root folder, and list the images to check the newly created Docker image + + +``` +cd +sudo docker images + +``` + + + +------------------------------ + + +# Lesson 7 Demo 4 + +``` +Docker Compose Setup + + +``` + + +### Steps to be followed: +1. Setting up docker-compose +2. Creating a docker-compose file + +### Step 1: Setting up docker-compose +1.1 Install docker-compose using the command given below: + +``` +mkdir compose-test +cd compose-test +pip --version + + +``` + + +1.2 Then type the command given below, to install docker-compose + +``` +sudo pip install docker-compose + +``` + + + +### Step 2: Creating docker-compose file +2.1 Inside compose-test folder, create docker-compose.yml file, and add the following code in it: + +``` +vi docker-compose.yml + +``` + +2.2 Add the following code snippet in the file: +version: '2' + + +``` +services: + compose-test: + image: centos + links: + - compose-db + command: /usr/bin/curl compose-db:6379 + compose-db: + image: redis + expose: + - "6379" + +``` + + + + + +2.3 Run the following command to execute the yaml file: + +``` +sudo docker-compose up + + +``` + + + + +------------------------------ +# Lesson 7 Demo 5 + +## Docker Registry + + +### Steps to be followed: +1. Pulling a Linux container +2. Pushing the image to the local repository +3. Running the new image + +### Step 1: Pulling a Linux container +1.1 Pull a recent version of the Centos Linux container. + +``` +sudo docker pull registry:2 + +``` + +1.2 Run the registry in a new Docker container with port 5000 exposed + +``` +sudo docker run -d -p 5000:5000 \ +--restart=always --name registry registry:2 + +``` + + +1.3 Pull another image from Docker Hub and store it in the local registry + +``` +sudo docker pull ubuntu + + +``` +1.4 Tag the image for the local registry + +``` +sudo docker tag ubuntu localhost:5000/ubuntu + +``` + + +### Step 2: Pushing the image to the local registry +2.1 Use the following command to push the image to a local registry: + +``` +sudo docker push localhost:5000/ubuntu + +``` +2.2 Remove the image from the local cache + +``` +sudo docker rmi ubuntu + +``` +2.3 Confirm that it has been removed + +``` +sudo docker images + +``` + + +### Step 3: Running the new image +3.1 Pull the image from the local registry + +``` +sudo docker pull localhost:5000/ubuntu + +``` +3.2 Confirm it is in the local cache + +``` +sudo docker images + +``` +3.3 Run the new image + +``` +sudo docker run -it --rm localhost:5000/ubuntu /bin/bash + +``` +3.4 Exit the container + +``` + +exit + +``` + +3.5 Clean up the images and containers + +``` +sudo docker rm -f $(docker ps -aq) + +``` + +**Note:** In case you get a permission denied error as shown below, run the following + +``` +sudo chmod 666 /var/run/docker.sock + +``` +After running this, run the +``` +sudo docker rm -f $(docker ps -aq) command. + + +sudo docker rmi $(docker images -q) + +``` + + + +------------------------------- +# Lesson 7 Demo 6 +## Docker Networking with SSHs + + +### Steps to be followed: +1. Creating a container and committing it +2. Creating a bridge network and finding its IP address +3. Connecting the network from another SSH server + +### Step 1: Creating a container, and commit it +1.1 Create a Centos Docker container. and install net-tools + +``` +sudo docker run -it --name centos centos /bin/bash +yum install -y net-tools + +``` + + +1.2 Check the IP address and hostname + + +``` +ifconfig +cat /etc/hosts +hostname + + +``` +1.3 Exit the container using CTRL+D + 1.3.1 Commit the container to an image (Please refer to the screenshot) + +``` + docker commit centos centos-net + docker images + docker rm centos + +``` + +### Step 2: Creating a bridge network, and find its IP address +2.1 Create a bridge network, and find its IP range + +``` +docker network create exnet +docker network ls +docker network inspect exnet + +``` + + + +2.2 Run the centos container using the new network + +``` +docker run -it --rm --network exnet centos-net /bin/bash + +``` + +2.3 Check the IP address and hostname + +``` +ifconfig +cat /etc/hosts +hostname + +``` + + +2.4 Exit the container using CTRL+D + 2.4.1 Start a new container using the default network + +``` + docker run -it --rm --name centos centos-net /bin/bash + +``` +2.5 Check the IP address and hostname + +``` +ifconfig +cat /etc/hosts +hostname + +``` + +### Step 3: Connecting the network from another SSH server +3.1 Click on + to open another Terminal window. Type the below given command to from the second SSH terminal to connect the network to the container + +``` +docker network connect exnet centos + +``` + + +3.2 Go back to the running container. You will see that it now has two IP addresses (Please refer to the screenshot) + +``` +ifconfig +cat /etc/hosts +hostname + + +``` + +3.3 Go to the second SSH window, and disconnect the network + +``` +docker network disconnect exnet centos + +``` + +3.4 Go back to the running container, and see that it now has one IP address + +``` +ifconfig +cat /etc/hosts +hostname + +``` + +3.5 Exit the container using CTRL+D + +______________ \ No newline at end of file diff --git a/README.md b/README.md index 8c74258..ecbef35 100644 --- a/README.md +++ b/README.md @@ -121,3 +121,25 @@ When you are ready to merge your changes with the master branch, create a pull r Remember to always keep your local repository up to date by fetching and merging changes from the remote repository. Happy coding! + +# Disclaimer +<details> + +Please note that the entire repository is owned and maintained by [Varun Kumar Manik](https://www.linkedin.com/in/vkmanik/). While every effort has been made to ensure the accuracy and reliability of the information and resources provided in this repository, Varun Kumar Manik takes full responsibility for any errors or inaccuracies that may be present. + +Simplilearn is not responsible for the content or materials provided in this repository and disclaims all liability for any issues, misunderstandings, or claims that may arise from the use of the information or materials provided. By using this repository, you acknowledge that Varun Kumar Manik is solely accountable for its content, and you agree to hold Simplilearn harmless from any claims or liabilities that may arise as a result of your use or reliance on the information provided herein. + +It is important to understand that this repository contains educational materials for a training course, and users are expected to apply their own judgment and discretion when utilizing the provided resources. Neither Varun Kumar Manik nor Simplilearn can guarantee specific results or outcomes from following the materials in this repository. + +</details> + +## Connect & Follow + +For more info, please connect and follow me: + +- Github: [https://github.com/manikcloud](https://github.com/manikcloud) +- LinkedIn: [https://www.linkedin.com/in/vkmanik/](https://www.linkedin.com/in/vkmanik/) +- Email: [varunmanik1@gmail.com](mailto:varunmanik1@gmail.com) +- Facebook: [https://www.facebook.com/cloudvirtualization/](https://www.facebook.com/cloudvirtualization/) +- YouTube: [https://bit.ly/32fknRN](https://bit.ly/32fknRN) +- Twitter: [https://twitter.com/varunkmanik](https://twitter.com/varunkmanik) \ No newline at end of file From 2e807b0f3356585de11f482adc14de1209c50738 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 11:12:05 +0000 Subject: [PATCH 079/135] docker commands --- 7-docker/Dockerfile | 11 +++++++++++ 7-docker/README.md | 13 ++++++++++--- 7-docker/index.html | 9 +++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 7-docker/Dockerfile create mode 100644 7-docker/index.html diff --git a/7-docker/Dockerfile b/7-docker/Dockerfile new file mode 100644 index 0000000..3331d7b --- /dev/null +++ b/7-docker/Dockerfile @@ -0,0 +1,11 @@ +# Use Ubuntu as a base image +FROM ubuntu + +# Update and install nginx +RUN apt-get update && apt-get install -y nginx + +# Copy the custom index file to the nginx directory +COPY index.nginx-debian.html /var/www/html + +# Start nginx in the foreground to keep the container running +CMD ["nginx", "-g", "daemon off;"] diff --git a/7-docker/README.md b/7-docker/README.md index 5d9e87d..7c4df8d 100644 --- a/7-docker/README.md +++ b/7-docker/README.md @@ -178,11 +178,18 @@ vi Dockerfile 1.3 Add the following code snippet to the Dockerfile ``` +# Use Ubuntu as a base image FROM ubuntu -RUN apt-get update -RUN apt-get install -y nginx + +# Update and install nginx +RUN apt-get update && apt-get install -y nginx + +# Copy the custom index file to the nginx directory COPY index.nginx-debian.html /var/www/html -CMD nginx -g 'daemon off;' + +# Start nginx in the foreground to keep the container running +CMD ["nginx", "-g", "daemon off;"] + ``` diff --git a/7-docker/index.html b/7-docker/index.html new file mode 100644 index 0000000..6d580ec --- /dev/null +++ b/7-docker/index.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<html> +<body> + +<h1>My First Heading</h1> +<p>My first paragraph.</p> + +</body> +</html> \ No newline at end of file From 0f0e2f934d627c9e2892dfd13311f5e2d54a288f Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 11:12:37 +0000 Subject: [PATCH 080/135] docker commands --- 7-docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/7-docker/README.md b/7-docker/README.md index 7c4df8d..0012a47 100644 --- a/7-docker/README.md +++ b/7-docker/README.md @@ -185,7 +185,7 @@ FROM ubuntu RUN apt-get update && apt-get install -y nginx # Copy the custom index file to the nginx directory -COPY index.nginx-debian.html /var/www/html +COPY index.html /var/www/html # Start nginx in the foreground to keep the container running CMD ["nginx", "-g", "daemon off;"] From e14934f3432748e208848beaf4d61d5c3ab64508 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 11:13:34 +0000 Subject: [PATCH 081/135] docker commands --- 7-docker/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/7-docker/README.md b/7-docker/README.md index 0012a47..217adea 100644 --- a/7-docker/README.md +++ b/7-docker/README.md @@ -212,12 +212,12 @@ WELCOME TO NGINX. ### Step 2: Executing the file - 2.1 Execute the Dockerfile (note that there is space between build and “.”) + +- 2.1 Execute the Dockerfile (note that there is space between build and “.”) ``` sudo docker build . - ``` From 092abbaa163eb2298b960ad525e850717ceb4933 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 11:15:55 +0000 Subject: [PATCH 082/135] docker commands --- 7-docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/7-docker/README.md b/7-docker/README.md index 217adea..8068cd5 100644 --- a/7-docker/README.md +++ b/7-docker/README.md @@ -198,7 +198,7 @@ CMD ["nginx", "-g", "daemon off;"] 1.4 Create another file in the same directory ``` -vi index.nginx-debian.html +vi index.html ``` From ec7be12c9d3f5fbcfc085a8867704c4314c904eb Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 11:16:50 +0000 Subject: [PATCH 083/135] docker commands --- 7-docker/README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/7-docker/README.md b/7-docker/README.md index 8068cd5..fa07775 100644 --- a/7-docker/README.md +++ b/7-docker/README.md @@ -278,20 +278,17 @@ vi docker-compose.yml ``` 2.2 Add the following code snippet in the file: -version: '2' - - -``` +version: '3' services: compose-test: image: centos - links: + command: /bin/bash -c "while true; do sleep 30; done" + depends_on: - compose-db - command: /usr/bin/curl compose-db:6379 compose-db: image: redis - expose: - - "6379" + ports: + - "6379:6379" ``` From 4d2b0c32f4f8272146dbcc112d257a07edca6898 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 11:17:39 +0000 Subject: [PATCH 084/135] docker commands --- 7-docker/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/7-docker/README.md b/7-docker/README.md index fa07775..6f1c211 100644 --- a/7-docker/README.md +++ b/7-docker/README.md @@ -292,7 +292,13 @@ services: ``` +- In this updated version, I've added version: '3' at the top. This is the version of the Docker Compose file format, and it's generally a good idea to specify it. +- I also replaced links with depends_on, which makes sure the compose-db service is started before the compose-test service. + +- I've replaced the command for the compose-test service to keep the container running indefinitely. Your previous command would execute curl once and then the container would exit. If you need to run curl, you can do it manually by exec-ing into the running container. + +- Finally, expose only exposes the port to linked services; it doesn't map the port to the host. If you want to access the Redis service from outside of the Docker network (from your host machine, for example), you should use ports instead. If not, you can stick with expose. From 56dbc6a80ac74b8d98a4fe8ed3452f5c26548765 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 11:18:39 +0000 Subject: [PATCH 085/135] docker commands --- 7-docker/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/7-docker/README.md b/7-docker/README.md index 6f1c211..f5f1f7d 100644 --- a/7-docker/README.md +++ b/7-docker/README.md @@ -278,6 +278,7 @@ vi docker-compose.yml ``` 2.2 Add the following code snippet in the file: +``` version: '3' services: compose-test: From d01f9f5abdc5878a483bf2fcc46738bac718a8b0 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 11:22:04 +0000 Subject: [PATCH 086/135] docker commands --- 7-docker/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/7-docker/README.md b/7-docker/README.md index f5f1f7d..95d7b04 100644 --- a/7-docker/README.md +++ b/7-docker/README.md @@ -1,3 +1,12 @@ +# Docker + +- [Lesson 7 Demo 2: Performing CRUD Operation on Containers](#lesson-7-demo-2) + - [Step 1: Pulling a Docker image](#step-1-pulling-a-docker-image) + - [Step 2: Creating a new container](#step-2-creating-a-new-container) + - [Step 3: Stopping the container](#step-3-stopping-the-container) + - [Step 4: Listing all the containers](#step-4-listing-all-the-containers) + - [Step 5: Deleting the container](#step-5-deleting-the-container) + - [Step 6: Removing the image](#step-6-removing-the-image) # Lesson 7 Demo 2 From 373c227ddf53ee9f3fc435b78a9d7220a59dd0b5 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 11:22:50 +0000 Subject: [PATCH 087/135] docker commands --- 7-docker/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/7-docker/README.md b/7-docker/README.md index 95d7b04..0acced9 100644 --- a/7-docker/README.md +++ b/7-docker/README.md @@ -7,6 +7,20 @@ - [Step 4: Listing all the containers](#step-4-listing-all-the-containers) - [Step 5: Deleting the container](#step-5-deleting-the-container) - [Step 6: Removing the image](#step-6-removing-the-image) +- [Lesson 7 Demo 3: Creating a Docker Image](#lesson-7-demo-3) + - [Step 1: Creating the Dockerfile](#step-1-creating-the-dockerfile) + - [Step 2: Executing the Dockerfile](#step-2-executing-the-dockerfile) +- [Lesson 7 Demo 4: Docker Compose Setup](#lesson-7-demo-4) + - [Step 1: Setting up docker-compose](#step-1-setting-up-docker-compose) + - [Step 2: Creating a docker-compose file](#step-2-creating-a-docker-compose-file) +- [Lesson 7 Demo 5: Docker Registry](#lesson-7-demo-5) + - [Step 1: Pulling a Linux container](#step-1-pulling-a-linux-container) + - [Step 2: Pushing the image to the local repository](#step-2-pushing-the-image-to-the-local-repository) + - [Step 3: Running the new image](#step-3-running-the-new-image) +- [Lesson 7 Demo 6: Docker Networking with SSHs](#lesson-7-demo-6) + - [Step 1: Creating a container, and committing it](#step-1-creating-a-container-and-committing-it) + - [Step 2: Creating a bridge network, and finding its IP address](#step-2-creating-a-bridge-network-and-finding-its-ip-address) + - [Step 3: Connecting the network from another SSH server](#step-3-connecting-the-network-from-another-ssh-server) # Lesson 7 Demo 2 From dea7d3accdd371dbb152bcf41ea90d19b5c957f2 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 15:59:48 +0000 Subject: [PATCH 088/135] ansible ep --- .../amazon-linux-vm.tf | 146 +++++++----------- .../ansible/ansible.cfg | 2 +- .../ansible/host_vars.yaml | 3 +- .../ansible/inventory.ini | 19 ++- .../ansible/ubuntu-wp-1.yaml | 64 ++++++++ .../ansible/wp-config.php.j2 | 51 ++++++ .../6.8-tf-ec2-provisioning/ansible/wp.yaml | 102 ++++++++++++ .../6.8-tf-ec2-provisioning/ubuntu-vm.tf | 2 +- 8 files changed, 290 insertions(+), 99 deletions(-) create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/wp-config.php.j2 create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf b/6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf index 3f56aed..5f93283 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf +++ b/6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf @@ -1,93 +1,55 @@ -# resource "aws_security_group" "allow_SSH_Slave" { -# name = "allow_SSH_Slave" -# description = "Allow SSH inbound traffic" -# # vpc_id = aws_vpc.main.id - - -# ingress { -# from_port = 0 -# to_port = 0 -# protocol = "-1" -# cidr_blocks = ["0.0.0.0/0"] -# ipv6_cidr_blocks = ["::/0"] -# # description = "SSH from VPC" -# # from_port = 22 -# # to_port = 22 -# # protocol = "tcp" -# # cidr_blocks = ["61.6.14.46/32"] -# # # ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block] -# } - -# egress { -# from_port = 0 -# to_port = 0 -# protocol = "-1" -# cidr_blocks = ["0.0.0.0/0"] -# ipv6_cidr_blocks = ["::/0"] -# } -# } - -# resource "aws_key_pair" "deployer3" { -# key_name = "deployer-key3" -# public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDD8gTEP0wdqJnHkVDc7IMzFygpsibTemZylZvk4gcGiaa+YX8/VpUEyOrqYOg/8OrOAsdQCpPcc8J3AhUBSvgjeKc7sJZ0N8v+AOKnVQDni/y+9mWD6oGOszzH6DVfoHOy1HRZAbF6n+xFkk0DeisSJ3FsGVQK/J5rYgXVCBJii34mL0+DOBogxLva8tDcLgWLz+qxs8QcH4hgrHkdT8whBKfKcypICGS4U/WgXFW5M3pN4OynSzeqJ9gXn0Fbq50J/t6Cpnr6wqlzRzocAMXnlgrchYZWZJgTL3W8zrg1Fx7RBy3fAbEyWoyrkB9cFIPSkmiUZG9xUhirI4MbdgHVNlkp7xU0V6KfCRlTNE+xzWlbPSga7kjlqiizjDoR7xExKNLbNthB6nlNIEwX+FljtgrTqMV2w6k8H3xfrhdG0993EnMMwdPVmltEjJeZ+l3BETUcibKGFFc5iyR99W7NKhriH5d6OvbXev7JmbqsXrwn8rnu3auDGJs7YaIwzmk= varunmanikoutlo@ip-172-31-17-206" -# } - -# resource "aws_instance" "linux" { -# ami = "ami-0c02fb55956c7d316" -# instance_type = "t2.micro" -# key_name = aws_key_pair.deployer3.key_name -# # count = 1 -# vpc_security_group_ids = ["${aws_security_group.allow_SSH_Slave.id}"] -# tags = { -# "Name" = "Linux-Node" -# "ENV" = "Dev" -# } - -# depends_on = [aws_key_pair.deployer3] - -# } - -# ####### Ubuntu VM ##### - - -# resource "aws_instance" "ubuntu" { -# ami = "ami-04505e74c0741db8d" -# instance_type = "t2.micro" -# key_name = aws_key_pair.deployer3.key_name -# vpc_security_group_ids = ["${aws_security_group.allow_SSH_Slave.id}"] -# tags = { -# "Name" = "UBUNTU-sl-1" -# "ENV" = "Dev" -# } - -# # Type of connection to be established -# connection { -# type = "ssh" -# user = "ubuntu" -# private_key = file("./deployer") -# host = self.public_ip -# } -# # Remotely execute commands to install Java, Python, Jenkins -# provisioner "remote-exec" { -# inline = [ -# "sudo apt update && upgrade", -# "sudo apt-get install -y python3.8 default-jdk mvn git", -# "echo 62c3f6eefeab36fe989cd376360e04baa0de08c325b93de880693a6e2af67298 > secret-file", -# "curl -sO http://54.160.148.48:8080/jnlpJars/agent.jar", -# "java -jar agent.jar -jnlpUrl http://54.160.148.48:8080/manage/computer/ubuntu/jenkins-agent.jnlp -secret @secret-file -workDir '/home/ubuntu/'", -# ] -# } - -# depends_on = [aws_key_pair.deployer3] - -# } - -# output "ubuntu" { -# value = aws_instance.ubuntu.public_ip -# description = "description" -# } -# output "linux" { -# value = aws_instance.linux.public_ip -# description = "description" -# } +resource "aws_security_group" "allow_ssh_slave" { + name = "allow_SSH_Slave_aws_linux" + description = "Allow SSH inbound traffic" + # vpc_id = aws_vpc.main.id + + + ingress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + # description = "SSH from VPC" + # from_port = 22 + # to_port = 22 + # protocol = "tcp" + # cidr_blocks = ["0.0.0.0/0"] + # # ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block] + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + } +} + +resource "aws_key_pair" "deployer3" { + key_name = "deployer-key3" + public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDD8gTEP0wdqJnHkVDc7IMzFygpsibTemZylZvk4gcGiaa+YX8/VpUEyOrqYOg/8OrOAsdQCpPcc8J3AhUBSvgjeKc7sJZ0N8v+AOKnVQDni/y+9mWD6oGOszzH6DVfoHOy1HRZAbF6n+xFkk0DeisSJ3FsGVQK/J5rYgXVCBJii34mL0+DOBogxLva8tDcLgWLz+qxs8QcH4hgrHkdT8whBKfKcypICGS4U/WgXFW5M3pN4OynSzeqJ9gXn0Fbq50J/t6Cpnr6wqlzRzocAMXnlgrchYZWZJgTL3W8zrg1Fx7RBy3fAbEyWoyrkB9cFIPSkmiUZG9xUhirI4MbdgHVNlkp7xU0V6KfCRlTNE+xzWlbPSga7kjlqiizjDoR7xExKNLbNthB6nlNIEwX+FljtgrTqMV2w6k8H3xfrhdG0993EnMMwdPVmltEjJeZ+l3BETUcibKGFFc5iyR99W7NKhriH5d6OvbXev7JmbqsXrwn8rnu3auDGJs7YaIwzmk= varunmanikoutlo@ip-172-31-17-206" +} + +resource "aws_instance" "linux" { + ami = "ami-0c02fb55956c7d316" + instance_type = "t3.micro" + key_name = aws_key_pair.deployer3.key_name + count = 2 + vpc_security_group_ids = ["${aws_security_group.allow_ssh_slave.id}"] + tags = { + "Name" = "WP-Node" + "ENV" = "Dev" + } + + depends_on = [aws_key_pair.deployer3] + +} + +####### Amazon Linux VM OutPut##### +output "linux" { + value = aws_instance.linux.*.public_ip + description = "description" +} diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg b/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg index 3f2db16..6379566 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg @@ -1,6 +1,6 @@ [defaults] inventory = inventory.ini -remote_user = ubuntu +remote_user = ec2-user private_key_file = ../deployer host_key_checking = False retry_files_enabled = False diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml b/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml index 58a3d6d..a0a1e5c 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml @@ -1,3 +1,4 @@ --- -ansible_user: ubuntu +ansible_user: ec2-user +# ansible_user: ubuntu ansible_ssh_private_key_file: ../deployer diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini index 367ab9b..59f09dd 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini @@ -1,4 +1,15 @@ -[my_servers] -my_server_1 ansible_host=3.83.161.207 -my_server_2 ansible_host=3.94.145.119 -my_server_3 ansible_host=54.196.214.244 \ No newline at end of file +[aws_linux_vm] +; wp-server ansible_host=54.158.174.154 +wp-server1 ansible_host=34.230.43.235 + +; [ubuntu-vm] +; my_server_1 ansible_host=3.89.49.215 + + +; my_server_2 ansible_host=3.94.145.119 +; my_server_3 ansible_host=54.196.214.244 +; ubuntu = [ +; "", +; "54.166.96.63", +; "35.172.211.176", +; ] diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml b/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml new file mode 100644 index 0000000..ca22a03 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml @@ -0,0 +1,64 @@ +--- +- name: LAMP and Wordpress Installation + hosts: aws_linux_vm + become: yes + vars: + db_name: wordpress + db_user: wordpress + db_password: secure-123 + db_host: 44.202.246.212 + wp_table_prefix: wp_ + + tasks: + - name: Update APT package cache + ansible.builtin.apt: + update_cache: yes + + - name: Install LAMP stack + ansible.builtin.apt: + name: + - apache2 + - mysql-server + - php + - libapache2-mod-php + - php-mysql + - python3-pymysql + state: present + + - name: Ensure Apache is running + ansible.builtin.service: + name: apache2 + state: started + enabled: yes + + - name: Ensure MySQL Service is running + ansible.builtin.service: + name: mysql + state: started + enabled: yes + + - name: Create WordPress database + community.mysql.mysql_db: + login_host: "{{ db_host }}" + login_user: "{{ db_user }}" + login_password: "{{ db_password }}" + name: "{{ db_name }}" + state: present + + - name: Download WordPress + get_url: + url: https://wordpress.org/latest.tar.gz + dest: /tmp/wordpress.tar.gz + mode: '0644' + + - name: Extract WordPress archive + ansible.builtin.unarchive: + src: /tmp/wordpress.tar.gz + dest: /var/www/html/ + remote_src: yes + + - name: Update WordPress config file + template: + src: ./wp-config.php.j2 + dest: /var/www/html/wordpress/wp-config.php + mode: '0644' diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/wp-config.php.j2 b/6-ansible/6.8-tf-ec2-provisioning/ansible/wp-config.php.j2 new file mode 100644 index 0000000..9aaf05c --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/wp-config.php.j2 @@ -0,0 +1,51 @@ +<?php +define( 'DB_NAME', '{{ db_name }}' ); + +/** MySQL database username */ +define( 'DB_USER', '{{ db_user }}' ); + +/** MySQL database password */ +define( 'DB_PASSWORD', '{{ db_password }}' ); + +/** MySQL hostname */ +define( 'DB_HOST', '{{ db_host }}' ); + +/** Database Charset to use in creating database tables. */ +define( 'DB_CHARSET', 'utf8' ); + +/** The Database Collate type. Don't change this if in doubt. */ +define( 'DB_COLLATE', '' ); + +/**#@+ + * Authentication Unique Keys and Salts. + * + * Change these to different unique phrases! + * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} + * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again. + * + * @since 2.6.0 + */ +define('AUTH_KEY', 'put your unique phrase here'); +define('SECURE_AUTH_KEY', 'put your unique phrase here'); +define('LOGGED_IN_KEY', 'put your unique phrase here'); +define('NONCE_KEY', 'put your unique phrase here'); +define('AUTH_SALT', 'put your unique phrase here'); +define('SECURE_AUTH_SALT', 'put your unique phrase here'); +define('LOGGED_IN_SALT', 'put your unique phrase here'); +define('NONCE_SALT', 'put your unique phrase here'); + +/**#@-*/ + +$table_prefix = '{{ wp_table_prefix }}'; +define( 'WP_DEBUG', false ); + +/* That's all, stop editing! Happy publishing. */ + +/** Absolute path to the WordPress directory. */ +if ( ! defined( 'ABSPATH' ) ) { + define( 'ABSPATH', dirname( __FILE__ ) . '/' ); +} + +/** Sets up WordPress vars and included files. */ +require_once( ABSPATH . 'wp-settings.php' ); + diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml b/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml new file mode 100644 index 0000000..bb297fe --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml @@ -0,0 +1,102 @@ +--- +- hosts: aws_linux_vm + become: yes + vars: + db_name: wordpress + db_user: wordpress + db_password: secure-123 + db_host: 34.230.43.235 # added DB_HOST + wp_table_prefix: wp_ # added wp_table_prefix + + + tasks: + + - name: Update all packages to the latest version + yum: + name: '*' + state: latest + + - name: Install python3-pip + yum: + name: python3-pip + state: present + + - name: Install PyMySQL + pip: + name: pymysql + state: present + + + - name: Install PHP 7.2 from Amazon Linux Extras + command: amazon-linux-extras install -y php7.2 + + - name: Install necessary packages + yum: + name: + - httpd + - mariadb-server + + state: latest + + - name: Start and enable Apache and MariaDB services + systemd: + name: "{{ item }}" + state: started + enabled: yes + loop: + - httpd + - mariadb + + - name: Remove anonymous MySQL user + mysql_user: + name: '' + host_all: + state: absent + notify: restart mysql + + - name: Remove MySQL test database + mysql_db: + name: test + state: absent + notify: restart mysql + + - name: Create new MySQL database + mysql_db: + name: "{{ db_name }}" + state: present + - name: Create new MySQL user + mysql_user: + name: "{{ db_user }}" + password: "{{ db_password }}" + priv: "*.*:ALL" + host: '%' + state: present + notify: restart mysql + + - name: Download WordPress + get_url: + url: https://wordpress.org/latest.tar.gz + dest: /tmp/wordpress.tar.gz + mode: 0644 + + - name: Extract WordPress + unarchive: + src: /tmp/wordpress.tar.gz + dest: /var/www/html/ + remote_src: yes + + - name: Update WordPress config file + template: + src: ./wp-config.php.j2 + dest: /var/www/html/wordpress/wp-config.php + + - name: Restart Apache + systemd: + name: httpd + state: restarted + + handlers: + - name: restart mysql + systemd: + name: mariadb + state: restarted diff --git a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf index 798bfe0..1a96f90 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf +++ b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf @@ -32,7 +32,7 @@ resource "aws_instance" "ubuntu" { ami = "ami-007855ac798b5175e" instance_type = "t2.micro" key_name = aws_key_pair.deployer.key_name - count = 3 + count = 1 vpc_security_group_ids = ["${aws_security_group.allow_SSH_ubuntu.id}"] tags = { "Name" = "UBUNTU-${count.index}" From 8dc885d445c67a528ec4d9ec988f38c09a04765b Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Fri, 12 May 2023 16:00:43 +0000 Subject: [PATCH 089/135] ansible ep --- 6-ansible/wordpress/README.md | 30 ++++++ 6-ansible/wordpress/wp-config.php.j2 | 51 ++++++++++ 6-ansible/wordpress/wp.yaml | 102 +++++++++++++++++++ 7-docker/7.4-docker-compose/Dockerfile | 9 ++ 7-docker/7.4-docker-compose/app.py | 26 +++++ 7-docker/7.4-docker-compose/requirements.txt | 2 + 6 files changed, 220 insertions(+) create mode 100644 6-ansible/wordpress/README.md create mode 100644 6-ansible/wordpress/wp-config.php.j2 create mode 100644 6-ansible/wordpress/wp.yaml create mode 100644 7-docker/7.4-docker-compose/Dockerfile create mode 100644 7-docker/7.4-docker-compose/app.py create mode 100644 7-docker/7.4-docker-compose/requirements.txt diff --git a/6-ansible/wordpress/README.md b/6-ansible/wordpress/README.md new file mode 100644 index 0000000..ce902c9 --- /dev/null +++ b/6-ansible/wordpress/README.md @@ -0,0 +1,30 @@ +# DevOps-Tutorial + +## Goal +The goal of this project is to provide an example of how to use Ansible to setup a WordPress site on an AWS EC2 instance running Amazon Linux 2. + +## Features +- This Ansible playbook will install all necessary dependencies including Python, PHP, Apache, and MariaDB. +- It sets up a WordPress database and user. +- It downloads the latest version of WordPress and configures it to use the database. +- It updates the WordPress config file using an Ansible template. + +## Prerequisites +- An AWS account with the necessary permissions to create EC2 instances. +- Ansible installed on your local machine or control node. +- Basic knowledge of Ansible playbooks. + +## Usage +1. Clone this repository to your local machine or control node: `git clone https://github.com/manikcloud/DevOps-Tutorial.git` +2. Change into the project directory: `cd DevOps-Tutorial` +3. Update the `aws_linux_vm` variable in the playbook with the IP address or hostname of your EC2 instance. +4. Run the playbook: `ansible-playbook playbook.yml` + +## Conclusion +This project provides a starting point for automating the setup of WordPress sites using Ansible and AWS. It can be extended or modified to suit your specific needs. This project is for demonstration purposes and should not be used as-is for production environments. + +## Contributing +Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. + +## License +[MIT](https://choosealicense.com/licenses/mit/) diff --git a/6-ansible/wordpress/wp-config.php.j2 b/6-ansible/wordpress/wp-config.php.j2 new file mode 100644 index 0000000..9aaf05c --- /dev/null +++ b/6-ansible/wordpress/wp-config.php.j2 @@ -0,0 +1,51 @@ +<?php +define( 'DB_NAME', '{{ db_name }}' ); + +/** MySQL database username */ +define( 'DB_USER', '{{ db_user }}' ); + +/** MySQL database password */ +define( 'DB_PASSWORD', '{{ db_password }}' ); + +/** MySQL hostname */ +define( 'DB_HOST', '{{ db_host }}' ); + +/** Database Charset to use in creating database tables. */ +define( 'DB_CHARSET', 'utf8' ); + +/** The Database Collate type. Don't change this if in doubt. */ +define( 'DB_COLLATE', '' ); + +/**#@+ + * Authentication Unique Keys and Salts. + * + * Change these to different unique phrases! + * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} + * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again. + * + * @since 2.6.0 + */ +define('AUTH_KEY', 'put your unique phrase here'); +define('SECURE_AUTH_KEY', 'put your unique phrase here'); +define('LOGGED_IN_KEY', 'put your unique phrase here'); +define('NONCE_KEY', 'put your unique phrase here'); +define('AUTH_SALT', 'put your unique phrase here'); +define('SECURE_AUTH_SALT', 'put your unique phrase here'); +define('LOGGED_IN_SALT', 'put your unique phrase here'); +define('NONCE_SALT', 'put your unique phrase here'); + +/**#@-*/ + +$table_prefix = '{{ wp_table_prefix }}'; +define( 'WP_DEBUG', false ); + +/* That's all, stop editing! Happy publishing. */ + +/** Absolute path to the WordPress directory. */ +if ( ! defined( 'ABSPATH' ) ) { + define( 'ABSPATH', dirname( __FILE__ ) . '/' ); +} + +/** Sets up WordPress vars and included files. */ +require_once( ABSPATH . 'wp-settings.php' ); + diff --git a/6-ansible/wordpress/wp.yaml b/6-ansible/wordpress/wp.yaml new file mode 100644 index 0000000..bb297fe --- /dev/null +++ b/6-ansible/wordpress/wp.yaml @@ -0,0 +1,102 @@ +--- +- hosts: aws_linux_vm + become: yes + vars: + db_name: wordpress + db_user: wordpress + db_password: secure-123 + db_host: 34.230.43.235 # added DB_HOST + wp_table_prefix: wp_ # added wp_table_prefix + + + tasks: + + - name: Update all packages to the latest version + yum: + name: '*' + state: latest + + - name: Install python3-pip + yum: + name: python3-pip + state: present + + - name: Install PyMySQL + pip: + name: pymysql + state: present + + + - name: Install PHP 7.2 from Amazon Linux Extras + command: amazon-linux-extras install -y php7.2 + + - name: Install necessary packages + yum: + name: + - httpd + - mariadb-server + + state: latest + + - name: Start and enable Apache and MariaDB services + systemd: + name: "{{ item }}" + state: started + enabled: yes + loop: + - httpd + - mariadb + + - name: Remove anonymous MySQL user + mysql_user: + name: '' + host_all: + state: absent + notify: restart mysql + + - name: Remove MySQL test database + mysql_db: + name: test + state: absent + notify: restart mysql + + - name: Create new MySQL database + mysql_db: + name: "{{ db_name }}" + state: present + - name: Create new MySQL user + mysql_user: + name: "{{ db_user }}" + password: "{{ db_password }}" + priv: "*.*:ALL" + host: '%' + state: present + notify: restart mysql + + - name: Download WordPress + get_url: + url: https://wordpress.org/latest.tar.gz + dest: /tmp/wordpress.tar.gz + mode: 0644 + + - name: Extract WordPress + unarchive: + src: /tmp/wordpress.tar.gz + dest: /var/www/html/ + remote_src: yes + + - name: Update WordPress config file + template: + src: ./wp-config.php.j2 + dest: /var/www/html/wordpress/wp-config.php + + - name: Restart Apache + systemd: + name: httpd + state: restarted + + handlers: + - name: restart mysql + systemd: + name: mariadb + state: restarted diff --git a/7-docker/7.4-docker-compose/Dockerfile b/7-docker/7.4-docker-compose/Dockerfile new file mode 100644 index 0000000..6463319 --- /dev/null +++ b/7-docker/7.4-docker-compose/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.7 + +WORKDIR /app + +COPY . /app + +RUN pip install --no-cache-dir -r requirements.txt + +CMD ["flask", "run", "--host=0.0.0.0", "--port=5000"] diff --git a/7-docker/7.4-docker-compose/app.py b/7-docker/7.4-docker-compose/app.py new file mode 100644 index 0000000..aefeeb6 --- /dev/null +++ b/7-docker/7.4-docker-compose/app.py @@ -0,0 +1,26 @@ +import logging + +# Add these lines at the beginning of your app.py file +logging.basicConfig(level=logging.DEBUG) + +# Your existing code goes here +from flask import Flask, request +from redis import Redis + +app = Flask(__name__) +redis = Redis(host='redis', port=6379) + +@app.route('/') + +def hello(): + return 'Hello World! This is a simple voting application.' + +@app.route('/vote', methods=['POST']) +def vote(): + option = request.form.get('option') + redis.incr(option) + return f"Voted for: {option}" + +@app.route('/results') +def results(): + return {option.decode(): int(redis.get(option)) for option in redis.keys()} diff --git a/7-docker/7.4-docker-compose/requirements.txt b/7-docker/7.4-docker-compose/requirements.txt new file mode 100644 index 0000000..1a5dc97 --- /dev/null +++ b/7-docker/7.4-docker-compose/requirements.txt @@ -0,0 +1,2 @@ +flask +redis From 02abc044c8685e8502b809fca6725be00ca8b9f4 Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 13 May 2023 03:40:21 +0000 Subject: [PATCH 090/135] docker commands --- .../ansible/ansible.cfg | 2 +- .../ansible/host_vars.yaml | 4 +- .../ansible/inventory copy.ini-backup | 15 +++ .../ansible/inventory.ini | 26 ++-- .../ansible/ubuntu-wp-1.yaml | 125 ++++++++++-------- .../ansible/ubuntu-wp-config.php.j2 | 13 ++ .../6.8-tf-ec2-provisioning/ansible/wp.yaml | 3 +- .../6.8-tf-ec2-provisioning/ubuntu-vm.tf | 4 +- 8 files changed, 122 insertions(+), 70 deletions(-) create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/inventory copy.ini-backup create mode 100644 6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-config.php.j2 diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg b/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg index 6379566..3f2db16 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg @@ -1,6 +1,6 @@ [defaults] inventory = inventory.ini -remote_user = ec2-user +remote_user = ubuntu private_key_file = ../deployer host_key_checking = False retry_files_enabled = False diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml b/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml index a0a1e5c..a2e3a6f 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml @@ -1,4 +1,4 @@ --- -ansible_user: ec2-user -# ansible_user: ubuntu +# ansible_user: ec2-user +ansible_user: ubuntu ansible_ssh_private_key_file: ../deployer diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory copy.ini-backup b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory copy.ini-backup new file mode 100644 index 0000000..88cc143 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory copy.ini-backup @@ -0,0 +1,15 @@ +[aws_linux_vm] +; wp-server ansible_host=54.158.174.154 +; wp-server1 ansible_host=34.230.43.235 + +[ubuntu-vm] +my_server_1 ansible_host=3.88.212.253 + + +; my_server_2 ansible_host=3.94.145.119 +; my_server_3 ansible_host=54.196.214.244 +; ubuntu = [ +; "", +; "54.166.96.63", +; "35.172.211.176", +; ] diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini index 59f09dd..b1f7f18 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini @@ -1,15 +1,19 @@ +[aws:children] +aws_linux_vm + +[aws:vars] +ansible_user=ec2-user +ansible_ssh_private_key_file=../deployer + [aws_linux_vm] -; wp-server ansible_host=54.158.174.154 -wp-server1 ansible_host=34.230.43.235 +wp-server ansible_host=3.84.131.121 -; [ubuntu-vm] -; my_server_1 ansible_host=3.89.49.215 +[ubuntu:children] +ubuntu_vm +[ubuntu:vars] +ansible_user=ubuntu +ansible_ssh_private_key_file=../deployer -; my_server_2 ansible_host=3.94.145.119 -; my_server_3 ansible_host=54.196.214.244 -; ubuntu = [ -; "", -; "54.166.96.63", -; "35.172.211.176", -; ] +[ubuntu_vm] +my_server_1 ansible_host=44.210.103.164 diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml b/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml index ca22a03..4526380 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml @@ -1,64 +1,83 @@ --- -- name: LAMP and Wordpress Installation - hosts: aws_linux_vm +- hosts: ubuntu_vm become: yes vars: - db_name: wordpress - db_user: wordpress - db_password: secure-123 - db_host: 44.202.246.212 - wp_table_prefix: wp_ - + wp_db_name: wordpress1 + wp_db_user: wordpress + wp_db_password: secure-123 + db_host: 44.210.103.164 # Added db_host + table_prefix: wp_ + tasks: - - name: Update APT package cache - ansible.builtin.apt: - update_cache: yes + - name: Update APT package cache + apt: + update_cache: yes - - name: Install LAMP stack - ansible.builtin.apt: - name: - - apache2 - - mysql-server - - php - - libapache2-mod-php - - php-mysql - - python3-pymysql - state: present + - name: Install LAMP stack + apt: + name: + - apache2 + - mysql-server + - php + - libapache2-mod-php + - php-mysql + - python3-pymysql + state: present - - name: Ensure Apache is running - ansible.builtin.service: - name: apache2 - state: started - enabled: yes + - name: Start Apache and MySQL services + systemd: + name: "{{ item }}" + state: started + enabled: yes + loop: + - apache2 + - mysql - - name: Ensure MySQL Service is running - ansible.builtin.service: - name: mysql - state: started - enabled: yes + - name: Remove MySQL root password + shell: | + mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';" + mysql -u root -e "FLUSH PRIVILEGES;" + + - name: Create a new database for WordPress + mysql_db: + name: "{{ wp_db_name }}" + state: present + login_user: root + login_password: "" - - name: Create WordPress database - community.mysql.mysql_db: - login_host: "{{ db_host }}" - login_user: "{{ db_user }}" - login_password: "{{ db_password }}" - name: "{{ db_name }}" - state: present + - name: Create a new user for WordPress + mysql_user: + name: "{{ wp_db_user }}" + password: "{{ wp_db_password }}" + priv: "*.*:ALL" + host: "%" + state: present + notify: restart mysql - - name: Download WordPress - get_url: - url: https://wordpress.org/latest.tar.gz - dest: /tmp/wordpress.tar.gz - mode: '0644' + - name: Download WordPress + get_url: + url: https://wordpress.org/latest.tar.gz + dest: /tmp/wordpress.tar.gz + mode: '0644' - - name: Extract WordPress archive - ansible.builtin.unarchive: - src: /tmp/wordpress.tar.gz - dest: /var/www/html/ - remote_src: yes + - name: Extract WordPress + unarchive: + src: /tmp/wordpress.tar.gz + dest: /var/www/html/ + remote_src: yes - - name: Update WordPress config file - template: - src: ./wp-config.php.j2 - dest: /var/www/html/wordpress/wp-config.php - mode: '0644' + - name: Update WordPress config file + template: + src: ./ubuntu-wp-config.php.j2 + dest: /var/www/html/wordpress/wp-config.php + + - name: Restart Apache service + systemd: + name: apache2 + state: restarted + + handlers: + - name: restart mysql + systemd: + name: mysql + state: restarted diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-config.php.j2 b/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-config.php.j2 new file mode 100644 index 0000000..bb1bbde --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-config.php.j2 @@ -0,0 +1,13 @@ +<?php +define( 'DB_NAME', '{{ wp_db_name }}' ); +define( 'DB_USER', '{{ wp_db_user }}' ); +define( 'DB_PASSWORD', '{{ wp_db_password }}' ); +define( 'DB_HOST', '{{ db_host }}' ); # Updated DB_HOST to use variable db_host +define( 'DB_CHARSET', 'utf8' ); +define( 'DB_COLLATE', '' ); +$table_prefix = 'wp_'; +define( 'WP_DEBUG', false ); +if ( ! defined( 'ABSPATH' ) ) { + define( 'ABSPATH', dirname( __FILE__ ) . '/' ); +} +require_once( ABSPATH . 'wp-settings.php' ); diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml b/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml index bb297fe..f6632bb 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml @@ -5,7 +5,7 @@ db_name: wordpress db_user: wordpress db_password: secure-123 - db_host: 34.230.43.235 # added DB_HOST + db_host: 3.84.131.121 # added DB_HOST wp_table_prefix: wp_ # added wp_table_prefix @@ -64,6 +64,7 @@ mysql_db: name: "{{ db_name }}" state: present + - name: Create new MySQL user mysql_user: name: "{{ db_user }}" diff --git a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf index 1a96f90..ef7e34a 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf +++ b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf @@ -30,9 +30,9 @@ resource "aws_key_pair" "deployer" { resource "aws_instance" "ubuntu" { ami = "ami-007855ac798b5175e" - instance_type = "t2.micro" + instance_type = "t3.micro" key_name = aws_key_pair.deployer.key_name - count = 1 + count = 2 vpc_security_group_ids = ["${aws_security_group.allow_SSH_ubuntu.id}"] tags = { "Name" = "UBUNTU-${count.index}" From 6c1ad08d05d3dcd5e10e8509aaa4637a4c95d80e Mon Sep 17 00:00:00 2001 From: Varun manik <sl-lab-vm@example.com> Date: Sat, 13 May 2023 04:54:33 +0000 Subject: [PATCH 091/135] docker commands --- 6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf | 10 +++++----- .../6.8-tf-ec2-provisioning/ansible/inventory.ini | 2 +- 6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml | 2 +- 6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf b/6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf index 5f93283..7f3d4cc 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf +++ b/6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf @@ -34,13 +34,13 @@ resource "aws_key_pair" "deployer3" { } resource "aws_instance" "linux" { - ami = "ami-0c02fb55956c7d316" - instance_type = "t3.micro" - key_name = aws_key_pair.deployer3.key_name - count = 2 + ami = "ami-0c02fb55956c7d316" + instance_type = "t3.micro" + key_name = aws_key_pair.deployer3.key_name + count = 3 vpc_security_group_ids = ["${aws_security_group.allow_ssh_slave.id}"] tags = { - "Name" = "WP-Node" + "Name" = "WP-Node-${count.index}" "ENV" = "Dev" } diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini index b1f7f18..0489eaf 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini @@ -6,7 +6,7 @@ ansible_user=ec2-user ansible_ssh_private_key_file=../deployer [aws_linux_vm] -wp-server ansible_host=3.84.131.121 +wp-server ansible_host=3.81.25.108 [ubuntu:children] ubuntu_vm diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml b/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml index f6632bb..76d46de 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml +++ b/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml @@ -5,7 +5,7 @@ db_name: wordpress db_user: wordpress db_password: secure-123 - db_host: 3.84.131.121 # added DB_HOST + db_host: 3.81.25.108 # added DB_HOST wp_table_prefix: wp_ # added wp_table_prefix diff --git a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf index ef7e34a..d070f9c 100644 --- a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf +++ b/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf @@ -32,7 +32,7 @@ resource "aws_instance" "ubuntu" { ami = "ami-007855ac798b5175e" instance_type = "t3.micro" key_name = aws_key_pair.deployer.key_name - count = 2 + count = 3 vpc_security_group_ids = ["${aws_security_group.allow_SSH_ubuntu.id}"] tags = { "Name" = "UBUNTU-${count.index}" From e9c429e811b7bdcf1710e2e446f2c0a513cced7a Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sun, 14 May 2023 13:31:46 +0800 Subject: [PATCH 092/135] readme --- 8-k8s/README.md | 235 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 8-k8s/README.md diff --git a/8-k8s/README.md b/8-k8s/README.md new file mode 100644 index 0000000..ba18135 --- /dev/null +++ b/8-k8s/README.md @@ -0,0 +1,235 @@ + +# Lesson 08 Demo 1 +Kubernetes Installation and Cluster Setup + + +### Steps to be followed: +1. Installing Kubernetes +2. Setting up a Kubernetes cluster + +### Step 1: Installing Kubernetes +1.1 To download and add the key to allow kubernetes installation, execute the commands mentioned below: + + +``` + +sudo su +curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - +sudo echo deb http://apt.kubernetes.io/ kubernetes-xenial main > /etc/apt/sources.list.d/kubernetes.list + +``` + + +1.2 Update the apt-get package by executing the command mentioned below: + + +``` + +sudo apt-get update + + +``` + +1.3 Install the kubernetes and the tools required to manage it. Run the command mentioned below in the terminal: + + +``` + +sudo apt install docker.io kubectl=1.20.5-00 kubeadm=1.20.5-00 kubelet=1.20.5-00 + +``` + + +### Step 2: Setting up a Kubernetes cluster +2.1 Update the apt-get package by executing the command mentioned below: + +``` + +sudo apt-get update + +``` + + +2.2 To initialize the cluster run the following command on the master node + +``` + +sudo kubeadm init + +``` + + +2.3 To start using your cluster, you need to run the following on master node: + +``` + +mkdir -p $HOME/.kube + sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config + sudo chown $(id -u):$(id -g) $HOME/.kube/config + +``` + + +2.4 You should see a single master node deployed on running the command: + +``` + +sudo kubectl get nodes + + +``` + + +2.5 Copy the kubeadm join command that you can see on the screen of your master node + + + + + +2.6 Run the copied kubeadm join command as a root user on the worker node. You can use the terminal only lab as a worker node. Make sure you have Kubernetes installed on the worker node and then run the below command. + + +``` + +kubeadm join 172.31.64.38:6443 --token 425qb8.51rbrxc5h862g202 \ + --discovery-token-ca-cert-hash sha256:a502867d97b05820f186e3ee748afddd9142aae4104aee804d30662148138bae + +``` + + + +2.7 On the master node, run the following command to install the weavenet plugin in order to create a network: + +``` + +kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 |tr -d '\n')" + +``` + + +2.8 List all the nodes again to check the status of nodes using the command: + +``` + +kubectl get nodes + + +``` + + + +--------------------------------------------- +# Lesson 08 Demo 2 +Pod Creation in Kubernetes + + +### Steps to be followed: +1. Creating multi-container pods +2. Creating a single container pod + +### Step 1: Creating multi-container pods +1.1 On the master node, create a new file named sample.yaml: + +sudo su +vi sample.yaml +1.2 Add the following code in the sample.yaml file: + +``` +apiVersion: v1 +kind: Pod +metadata: + name: multi-container +spec: + terminationGracePeriodSeconds: 0 + containers: + - name: nginx + image: nginx:1.10-alpine + ports: + - containerPort: 80 + - name: alpine + image: alpine:3.5 + command: ["watch", "wget", "-qO-", "localhost"] + ``` + + +1.3 Use the following command to create the multi-container pod: + +``` + +kubectl create -f sample.yaml + +``` + + + +### Step 2: Creating a single container pod +2.1 On the master node, create a single container pod with a tomcat image using the following command: + +``` + +kubectl run tomcat --image=tomcat:8.0 + +``` + + + +2.2 Check all the running pods + +``` + +kubectl get pods + +``` + + +2.3 To check why exactly a pod is in the pending state, run the command + +``` + +kubectl describe pods <pod_name> + +``` + +To check why multi-container pod is pending,use the command + +``` + +kubectl describe pods multi-container + +``` + + + +2.4 To remove the taint from the node run the following commands: + +``` + +kubectl get nodes +Copy the node name and use it in the below command + +``` + +kubectl taint nodes <node name> node-role.kubernetes.io/master- + +``` + +Here for example we use the command given below + +``` + +kubectl taint nodes ip-172-31-18-183 node-role.kubernetes.io/master- + +``` + + +2.5 Now check the pod status. The pods should be in the running state. + +``` + +sudo kubectl get pods + +``` + + + + From 916e9f50b0e1800a94bc6481d2b26d70469e80d8 Mon Sep 17 00:00:00 2001 From: varun-office <varunmanik1@gmail.com> Date: Tue, 16 May 2023 11:51:11 +0800 Subject: [PATCH 093/135] wp-compose file --- 7-docker/7.4-docker-compose/README.md | 348 ++++++++++++++++++ 7-docker/7.4-docker-compose/app.py | 39 +- .../7.4-docker-compose/docker-compose-wp.yml | 36 ++ 3 files changed, 397 insertions(+), 26 deletions(-) create mode 100644 7-docker/7.4-docker-compose/README.md create mode 100644 7-docker/7.4-docker-compose/docker-compose-wp.yml diff --git a/7-docker/7.4-docker-compose/README.md b/7-docker/7.4-docker-compose/README.md new file mode 100644 index 0000000..ae09000 --- /dev/null +++ b/7-docker/7.4-docker-compose/README.md @@ -0,0 +1,348 @@ +# Lesson 5 Demo 11: Convert an Application Deployment into a Stack + +This section will guide you to: +- Convert an application deployment into a stack using a file named docker-compose.yml + +| Feature | Docker Service | Docker Stack | +|---------|----------------|--------------| +| Definition | A Docker Service is the definition of the tasks to execute on the manager or worker nodes. It is a part of Docker Swarm, Docker's built-in orchestration solution. | A Docker Stack is a group of interrelated services that share dependencies, and can be orchestrated and scaled together. A stack effectively encapsulates a multi-service application. | +| Use Case | Docker Services are ideal for deploying the same image across multiple environments. You can adjust the number of replicas for each service based on the environment's requirements. | Docker Stacks are perfect for defining and managing multi-service applications. Stacks allow you to manage all the services of an application with just one file. | +| Scale | Services can be scaled up or down individually. | All services within a stack are scaled together, maintaining the application's functionality. | +| Command | `docker service create` | `docker stack deploy` | + +### Step 1: Drain the worker nodes in the swarm cluster to make sure the registry service runs on the manager node +- List all the nodes present in the swarm cluster and ensure that all nodes are in Active state + +``` +sudo docker node ls + +``` + + +**Note**: Copy the HOSTNAME of worker nodes +- Use the following command to drain the worker nodes: + +``` +sudo docker node update --availability drain hostname_Worker_Node + +``` + + +**Note**: Replace hostname_Worker_Node with the HOSTNAME copied in previous ### Step + + +### Step 2: Start the registry as a service on your swarm + +``` +sudo docker service create --name registry --publish published=5000,target=5000 registry:2 + + +``` + + +### Step 3: List the running services to check the status of registry service + +``` +sudo docker service ls + +``` + + + +### Step 4: Check if registry service is working with curl + +``` + +curl http://localhost:5000/v2/ + +``` + + + +### Step 5: Create a directory for the project + +``` + +mkdir stackdemo +cd stackdemo + +``` + + + +### Step 6: Create a file called app.py in the stackdemo directory +- Use the following command to create a project file: + +``` + +nano app.py + +``` + + +- Add the following code in the app.py file: + +``` + +from flask import Flask +from redis import Redis + +app = Flask(__name__) +redis = Redis(host='redis', port=6379) + +@app.route('/') +def hello(): + count = redis.incr('hits') + return 'Hello World! I have been seen {} times.\n'.format(count) + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8000, debug=True) + +``` + + +**Note**: Press Ctrl+X to exit the editor. Then type Y and press Enter to save the file. + +### Step 7: Create a file called requirements.txt +- Use the following command to create and open requirements.txt: + +``` + +nano requirements.txt + +``` + + +- Add the following text in the requirements.txt file: + +``` + +flask +redis + +``` + + +**Note**: Press Ctrl+X to exit the editor. Then type Y and press Enter to save the file. + +### Step 8: Create a file called Dockerfile +- Use the following command to create a Dockerfile: + +``` + +nano Dockerfile + +``` + + +- Add the following code in the Dockerfile: + +``` + +FROM python:3.4-alpine +ADD . /code +WORKDIR /code +RUN pip install -r requirements.txt +CMD ["python", "app.py"] + +``` + + +**Note**: Press Ctrl+X to exit the editor. Then type Y and press Enter to save the file. + +### Step 9: Create a file named docker-compose.yml +- Use the following command to create the docker-compose.yml file: + +``` + +nano docker-compose.yml + +``` + + +- Add the following code in the docker-compose.yml file: + +``` + +version: "3.3" +services: + web: + image: 127.0.0.1:5000/stackdemo + build: . + ports: + - "8000:8000" + redis: + image: redis:alpine + +``` + + +**Note**: Press Ctrl+X to exit the editor. Then type Y and press Enter to save the file. + +### Step 10: Start the application +- Use the following commands to install docker-compose: + +``` +sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + + +sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version + +``` + + + + +- Start docker-compose using the following command: + +``` +sudo docker-compose up -d + +``` + + + + +### Step 11: Use the following commands to check whether the app is running + +``` +sudo docker-compose ps + +curl http://localhost:8000 + +``` + + + +### Step 12: Bring the application down + +``` +sudo docker-compose down --volumes + + +``` + + +### Step 13: Push the application to the registry + +``` +sudo docker-compose push + +``` + + + +### Step 14: Use the following command to create the stack docker stack deploy: + +``` +sudo docker stack deploy --compose-file docker-compose.yml stackdemo + +``` + + + +### Step 15: Check if the stack is running + +``` +sudo docker stack services stackdemo + +``` + + + +### Step 16: Test the app again with curl command + +``` + +curl http://localhost:8000 +curl http://ip-172-31-26-147:8000 + +``` + +**Note**: In ### Step 10 while starting docker-compose if you get an error showing the port is already assigned, run the command + +``` +sudo docker ps and kill the container with the same port and then proceed. + +``` + + + +### Step 17: Use the following command to bring the stack down: + +``` +sudo docker stack rm stackdemo + +``` + +----------------------------------------------------------------- + +# Lesson 5 Demo 12: Increase Number of Replicas + +This section will guide you to: +- Increase the number of replicas of a task for any given service + +### Step 1: List the Docker services + +``` +sudo docker service ls +``` + +### Step 2: Scale up the redis service to five tasks + +``` +sudo docker service scale redis=5 + ``` + +### Step 3: Scale the registry service to four tasks using update flag + +``` +sudo docker service update --replicas=4 registry + ``` + +### Step 4: Use the scale flag to scale both redis and registry services at the same time + +``` +sudo docker service scale redis=4 registry=3 + ``` + +### Step 5: Check the actual number of replicas created + +``` +sudo docker service ls + ``` + +### Step 6: Create a global service and scale it up to ten tasks + +``` +sudo docker service create --mode global --name nginx nginx:latest + + +sudo docker service scale nginx=10 +``` + +**Note**: Notice that the scaling cannot be used with global services. It can only be done with replicated service. + + +# Disclaimer +<details> + +Please **Note** that the entire repository is owned and maintained by [Varun Kumar Manik](https://www.linkedin.com/in/vkmanik/). While every effort has been made to ensure the accuracy and reliability of the information and resources provided in this repository, Varun Kumar Manik takes full responsibility for any errors or inaccuracies that may be present. + +Simplilearn is not responsible for the content or materials provided in this repository and disclaims all liability for any issues, misunderstandings, or claims that may arise from the use of the information or materials provided. By using this repository, you acknowledge that Varun Kumar Manik is solely accountable for its content, and you agree to hold Simplilearn harmless from any claims or liabilities that may arise as a result of your use or reliance on the information provided herein. + +It is important to understand that this repository contains educational materials for a training course, and users are expected to apply their own judgment and discretion when utilizing the provided resources. Neither Varun Kumar Manik nor Simplilearn can guarantee specific results or outcomes from following the materials in this repository. + +</details> + +## Connect & Follow + +For more info, please connect and follow me: + +- Github: [https://github.com/manikcloud](https://github.com/manikcloud) +- LinkedIn: [https://www.linkedin.com/in/vkmanik/](https://www.linkedin.com/in/vkmanik/) +- Email: [varunmanik1@gmail.com](mailto:varunmanik1@gmail.com) +- Facebook: [https://www.facebook.com/cloudvirtualization/](https://www.facebook.com/cloudvirtualization/) +- YouTube: [https://bit.ly/32fknRN](https://bit.ly/32fknRN) +- Twitter: [https://twitter.com/varunkmanik](https://twitter.com/varunkmanik) diff --git a/7-docker/7.4-docker-compose/app.py b/7-docker/7.4-docker-compose/app.py index aefeeb6..c3bfb04 100644 --- a/7-docker/7.4-docker-compose/app.py +++ b/7-docker/7.4-docker-compose/app.py @@ -1,26 +1,13 @@ -import logging - -# Add these lines at the beginning of your app.py file -logging.basicConfig(level=logging.DEBUG) - -# Your existing code goes here -from flask import Flask, request -from redis import Redis - -app = Flask(__name__) -redis = Redis(host='redis', port=6379) - -@app.route('/') - -def hello(): - return 'Hello World! This is a simple voting application.' - -@app.route('/vote', methods=['POST']) -def vote(): - option = request.form.get('option') - redis.incr(option) - return f"Voted for: {option}" - -@app.route('/results') -def results(): - return {option.decode(): int(redis.get(option)) for option in redis.keys()} +from flask import Flask +from redis import Redis + +app = Flask(__name__) +redis = Redis(host='redis', port=6379) + +@app.route('/') +def hello(): + count = redis.incr('hits') + return 'Hello World! I have been seen {} times.\n'.format(count) + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8000, debug=True) diff --git a/7-docker/7.4-docker-compose/docker-compose-wp.yml b/7-docker/7.4-docker-compose/docker-compose-wp.yml new file mode 100644 index 0000000..99b8a12 --- /dev/null +++ b/7-docker/7.4-docker-compose/docker-compose-wp.yml @@ -0,0 +1,36 @@ +version: '3' + +services: + db: + image: mariadb + volumes: + - db_data:/var/lib/mysql + environment: + MYSQL_ROOT_PASSWORD: wordpress + MYSQL_DATABASE: wordpress + MYSQL_USER: wordpress + MYSQL_PASSWORD: wordpress + + wordpress: + depends_on: + - db + image: wordpress:latest + ports: + - "8000:80" + environment: + WORDPRESS_DB_HOST: db:3306 + WORDPRESS_DB_USER: wordpress + WORDPRESS_DB_PASSWORD: wordpress + WORDPRESS_DB_NAME: wordpress + volumes: + - wordpress_data:/var/www/html + + redis: + image: redis:latest + volumes: + - redis_data:/data + +volumes: + db_data: {} + wordpress_data: {} + redis_data: {} From 726d53ba267d5cb8763b16ffe3ebae4826e04667 Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sun, 21 May 2023 09:26:29 +0800 Subject: [PATCH 094/135] compose --- 7-docker/7.4-docker-compose/Dockerfile | 9 ----- 7-docker/7.4-docker-compose/app.py | 13 ------- .../7.4-docker-compose/docker-compose-wp.yml | 36 ------------------- 7-docker/7.4-docker-compose/requirements.txt | 2 -- 4 files changed, 60 deletions(-) delete mode 100644 7-docker/7.4-docker-compose/Dockerfile delete mode 100644 7-docker/7.4-docker-compose/app.py delete mode 100644 7-docker/7.4-docker-compose/docker-compose-wp.yml delete mode 100644 7-docker/7.4-docker-compose/requirements.txt diff --git a/7-docker/7.4-docker-compose/Dockerfile b/7-docker/7.4-docker-compose/Dockerfile deleted file mode 100644 index 6463319..0000000 --- a/7-docker/7.4-docker-compose/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM python:3.7 - -WORKDIR /app - -COPY . /app - -RUN pip install --no-cache-dir -r requirements.txt - -CMD ["flask", "run", "--host=0.0.0.0", "--port=5000"] diff --git a/7-docker/7.4-docker-compose/app.py b/7-docker/7.4-docker-compose/app.py deleted file mode 100644 index c3bfb04..0000000 --- a/7-docker/7.4-docker-compose/app.py +++ /dev/null @@ -1,13 +0,0 @@ -from flask import Flask -from redis import Redis - -app = Flask(__name__) -redis = Redis(host='redis', port=6379) - -@app.route('/') -def hello(): - count = redis.incr('hits') - return 'Hello World! I have been seen {} times.\n'.format(count) - -if __name__ == "__main__": - app.run(host="0.0.0.0", port=8000, debug=True) diff --git a/7-docker/7.4-docker-compose/docker-compose-wp.yml b/7-docker/7.4-docker-compose/docker-compose-wp.yml deleted file mode 100644 index 99b8a12..0000000 --- a/7-docker/7.4-docker-compose/docker-compose-wp.yml +++ /dev/null @@ -1,36 +0,0 @@ -version: '3' - -services: - db: - image: mariadb - volumes: - - db_data:/var/lib/mysql - environment: - MYSQL_ROOT_PASSWORD: wordpress - MYSQL_DATABASE: wordpress - MYSQL_USER: wordpress - MYSQL_PASSWORD: wordpress - - wordpress: - depends_on: - - db - image: wordpress:latest - ports: - - "8000:80" - environment: - WORDPRESS_DB_HOST: db:3306 - WORDPRESS_DB_USER: wordpress - WORDPRESS_DB_PASSWORD: wordpress - WORDPRESS_DB_NAME: wordpress - volumes: - - wordpress_data:/var/www/html - - redis: - image: redis:latest - volumes: - - redis_data:/data - -volumes: - db_data: {} - wordpress_data: {} - redis_data: {} diff --git a/7-docker/7.4-docker-compose/requirements.txt b/7-docker/7.4-docker-compose/requirements.txt deleted file mode 100644 index 1a5dc97..0000000 --- a/7-docker/7.4-docker-compose/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -flask -redis From 702f3ec96b0824dce8a79ba7a182347a47b7a50f Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sun, 21 May 2023 09:30:40 +0800 Subject: [PATCH 095/135] compose --- vs-code-installation.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vs-code-installation.sh b/vs-code-installation.sh index 9085f13..d09a94a 100755 --- a/vs-code-installation.sh +++ b/vs-code-installation.sh @@ -1,6 +1,6 @@ #!/bin/bash sudo apt update -sudo apt install software-properties-common apt-transport-https wget +sudo apt install software-properties-common apt-transport-https wget -y wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" -sudo apt install code \ No newline at end of file +sudo apt install code -y \ No newline at end of file From 726ea25a3c4c7a6decf7a0eadc5c39b23aa24443 Mon Sep 17 00:00:00 2001 From: Kumar <varkumar@deloitte.com> Date: Sun, 21 May 2023 09:43:18 +0800 Subject: [PATCH 096/135] compose --- .../6.8-tf-ec2-provisioning/deployer.ppk | 36 +++ .../python-flask-app/Dockerfile | 9 + .../python-flask-app/app.py | 13 + .../python-flask-app/requirements.txt | 2 + .../wordpress/docker-compose-wp.yml | 36 +++ 9.1-NagiOS/README.md | 268 ++++++++++++++++++ 6 files changed, 364 insertions(+) create mode 100644 6-ansible/6.8-tf-ec2-provisioning/deployer.ppk create mode 100644 7-docker/7.4-docker-compose/python-flask-app/Dockerfile create mode 100644 7-docker/7.4-docker-compose/python-flask-app/app.py create mode 100644 7-docker/7.4-docker-compose/python-flask-app/requirements.txt create mode 100644 7-docker/7.4-docker-compose/wordpress/docker-compose-wp.yml create mode 100644 9.1-NagiOS/README.md diff --git a/6-ansible/6.8-tf-ec2-provisioning/deployer.ppk b/6-ansible/6.8-tf-ec2-provisioning/deployer.ppk new file mode 100644 index 0000000..6ec0e48 --- /dev/null +++ b/6-ansible/6.8-tf-ec2-provisioning/deployer.ppk @@ -0,0 +1,36 @@ +PuTTY-User-Key-File-3: ssh-rsa +Encryption: none +Comment: varunmanikoutlo@ip-172-31-17-206 +Public-Lines: 9 +AAAAB3NzaC1yc2EAAAADAQABAAABgQDD8gTEP0wdqJnHkVDc7IMzFygpsibTemZy +lZvk4gcGiaa+YX8/VpUEyOrqYOg/8OrOAsdQCpPcc8J3AhUBSvgjeKc7sJZ0N8v+ +AOKnVQDni/y+9mWD6oGOszzH6DVfoHOy1HRZAbF6n+xFkk0DeisSJ3FsGVQK/J5r +YgXVCBJii34mL0+DOBogxLva8tDcLgWLz+qxs8QcH4hgrHkdT8whBKfKcypICGS4 +U/WgXFW5M3pN4OynSzeqJ9gXn0Fbq50J/t6Cpnr6wqlzRzocAMXnlgrchYZWZJgT +L3W8zrg1Fx7RBy3fAbEyWoyrkB9cFIPSkmiUZG9xUhirI4MbdgHVNlkp7xU0V6Kf +CRlTNE+xzWlbPSga7kjlqiizjDoR7xExKNLbNthB6nlNIEwX+FljtgrTqMV2w6k8 +H3xfrhdG0993EnMMwdPVmltEjJeZ+l3BETUcibKGFFc5iyR99W7NKhriH5d6OvbX +ev7JmbqsXrwn8rnu3auDGJs7YaIwzmk= +Private-Lines: 21 +AAABgQCFTVuyysEUmEPuAc06Tui+1C0tmJZTXrzdjSxeXOqcpv66HAf+Zf/BHpK6 +Wq0F+vcyqa9Ao8GNw27zmYYCuCbxsr5KnEruy5rKtX18ixavb4vFuki7osj69LMP +6MiOwtCTQ3fXqZA9NRj/B5W/HNi6Y/0EpoKHau63bRs8n14qjm2Gur7kLUGRM2X9 +gR1X/TMmt48Zz4tF+qnD4vIOX+AmQk2ILCsCkDs9L1k1/DsRYJT+8FrvQPuglbSr +9Vr4a1mctIOvAmjLAUWdsHmdSuEnKm2byXb1j3yc2NKyYCZO8DTwOQJEBBviGjLZ +hUOaYRhHMal5KBnEpSxFuz/FzMCx01nZRQIFcK1rL5lPHc2frTmvNmWPLSBfgcM8 +2IBWaDtx+HxV3d7F8e3/zBOWtTU04hFP/CNeqJjfMXaw0lR2yXeLLZY6VBnWuok4 +BdrJIV5me3cQqv2Q5WwkMLLps25j8/mrLNd/2z/zxu3vdgkYcMa0RC0Io9A1qUYi +z3Nd3NEAAADBAOcluG+5mRnEqMMowmy1rWeibT5Ms3GLHvL+g5pf5hGZhj7q9LtY +cJjmqD/vBQ13qelNL9BTUWgvQexBqVXDJgNihQBuZ91PbFARR6w7pwqkU18j5Oii +Wxmmmn426qLrQUQUT5L+lX/iAzFCe3QNxD9a6a5H94FMF2NsWHhmR508i6W57pfG +0GaF/OivwgY2SUKFasqJvjsPT8s3kAkDra6uJCajbfIoYBUNi6FKcQ63jI9mBbl7 +S1WtqORS2LRylQAAAMEA2QNfOx+YbUbIX0jrw10uEN9TSG7FFazxtU9f3Z4ojYcp +n9nMfH2zeDCTP+ePaIKYgo4QjRLuo2QYaO369D6ofujFaGNbi3xLtv+l4kFUO9FQ +Y2TZchiTkl1yC/5U8kOt97nUhXpxfHGSY5TlqwyC+Wwy57ykq6IHD8eB2Y05AGn1 +j81JctNQOHSM7AXKvJhkoNk9Jo/+JY3fxje/pQfBr3DPQCcvUi/WxPXay6L10RD2 +F1MN22G9PQtVrGawGWuFAAAAwQCD7m04b9ZkDU/wp94OZlciZNY65Odo5nNhEj1l +cWkX2BRr7Ng7/SXluvgjT9IpAmzRgL5chqaI3seg6MfgwOSpMeuaSWIawnRnkCD+ +7p4QS9eoyqR0nx1uE/1odVSE9Qn0C4nsGx8mDL+GCOSe1/XrkrzcaSuCZyqX6I87 +ED0SOtYVG5Z1OswVEmCpOKu3Aw8jvLApeRcoHm1f4CqCk9vaztyPTQHilCS71EDR +qkTRQ5xHMSIAxSk/16BMcEg3VfM= +Private-MAC: 62beb44708f7cb79b559846ab99d8647321bb8ab12f0189b9155a13dfe518800 diff --git a/7-docker/7.4-docker-compose/python-flask-app/Dockerfile b/7-docker/7.4-docker-compose/python-flask-app/Dockerfile new file mode 100644 index 0000000..6463319 --- /dev/null +++ b/7-docker/7.4-docker-compose/python-flask-app/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.7 + +WORKDIR /app + +COPY . /app + +RUN pip install --no-cache-dir -r requirements.txt + +CMD ["flask", "run", "--host=0.0.0.0", "--port=5000"] diff --git a/7-docker/7.4-docker-compose/python-flask-app/app.py b/7-docker/7.4-docker-compose/python-flask-app/app.py new file mode 100644 index 0000000..1465857 --- /dev/null +++ b/7-docker/7.4-docker-compose/python-flask-app/app.py @@ -0,0 +1,13 @@ +from flask import Flask +from redis import Redis + +app = Flask(__name__) +redis = Redis(host='redis', port=6379) + +@app.route('/') +def hello(): + count = redis.incr('hits') + return 'Hello World! I have been seen {} times.\n'.format(count) + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8000, debug=True) diff --git a/7-docker/7.4-docker-compose/python-flask-app/requirements.txt b/7-docker/7.4-docker-compose/python-flask-app/requirements.txt new file mode 100644 index 0000000..1a5dc97 --- /dev/null +++ b/7-docker/7.4-docker-compose/python-flask-app/requirements.txt @@ -0,0 +1,2 @@ +flask +redis diff --git a/7-docker/7.4-docker-compose/wordpress/docker-compose-wp.yml b/7-docker/7.4-docker-compose/wordpress/docker-compose-wp.yml new file mode 100644 index 0000000..99b8a12 --- /dev/null +++ b/7-docker/7.4-docker-compose/wordpress/docker-compose-wp.yml @@ -0,0 +1,36 @@ +version: '3' + +services: + db: + image: mariadb + volumes: + - db_data:/var/lib/mysql + environment: + MYSQL_ROOT_PASSWORD: wordpress + MYSQL_DATABASE: wordpress + MYSQL_USER: wordpress + MYSQL_PASSWORD: wordpress + + wordpress: + depends_on: + - db + image: wordpress:latest + ports: + - "8000:80" + environment: + WORDPRESS_DB_HOST: db:3306 + WORDPRESS_DB_USER: wordpress + WORDPRESS_DB_PASSWORD: wordpress + WORDPRESS_DB_NAME: wordpress + volumes: + - wordpress_data:/var/www/html + + redis: + image: redis:latest + volumes: + - redis_data:/data + +volumes: + db_data: {} + wordpress_data: {} + redis_data: {} diff --git a/9.1-NagiOS/README.md b/9.1-NagiOS/README.md new file mode 100644 index 0000000..0f57e58 --- /dev/null +++ b/9.1-NagiOS/README.md @@ -0,0 +1,268 @@ + +# Lesson 9 Demo 1 +How to Install Nagios Monitoring Tool + + +### Steps to be followed: +1. Updating the packages +- 2. Installing the latest version of Nagios XI + + + +**Note**: You need a blank ubuntu lab before you proceed with installations. Any pre-installed tool/package might interfere with the installation process giving errors. So kindly, terminate the lab access and launch a fresh lab instance before you proceed with this demo. + + +### Step 1: Updating the packages +1.1 Update the packages using the following command: + + +``` + sudo apt update + +``` + +### Step 2: Installing the latest version of Nagios Xi +- 2.1 Login as the root user using the command given below + +``` + sudo -i + +``` + +- 2.2 Execute the below command to install Nagios XI + +curl https://assets.nagios.com/downloads/nagiosxi/install.sh | sh + +**Note**: The installation takes around 20 mins. Please wait patiently till you get the Installation Complete message as shown below + + +- 2.3 Navigate to the user interface by using the URL provided in your terminal session. You can refer to the screenshot given above. +- 2.4 You will be presented with the Nagios XI Installation screen as shown below + + + + +- 2.5 You will be first prompted to define the General System Settings + +- 2.6 Once you've made your desired selections choose your License Settings. Here for demonstration purposes we have chosen a trial version. + +- 2.7 You will have to enter a key for the trial version. To get the key, click on the click to get a trial key link. You will be asked to enter details like the first name, last name and email id. Once you enter all those you will get the key mailed to the email-id you just mentioned. Enter the key as shown below + +- 2.8 Click Next to proceed. + +- 2.9 The next page provides you with options for the Admin Account. You can use the default password or change it if you want. After this click on Finish Install + +- 2.10 The page will display a spinning logo while it applies your settings to Nagios XI. + +- 2.11 The Installation Complete screen will be shown with the username and password required to login to Nagios XI. + +- 2.12 Click the Login to Nagios XI button to begin. + + + +- 2.13 The Login Screen will appear, provide your credentials and then click the Login button. + + + +- 2.14 You will need to accept the License Agreement to proceed. + + +- 2.15 You will be logged into Nagios XI and be placed at the home screen. + + + + +---------------------------------------------------------------------------------------- + +# Lesson 9 Demo 2 +Adding Hosts to the Nagios Monitoring Tool + + +### Steps to be followed: +1. Logging into the Nagios XI Dashboard +- 2. Adding a host using the core config manager + + +### Step 1: Logging into the Nagios Dashboard +1.1 Login to the nagios dashboard using the url as mentioned in the previous demo. + + +### Step 2: Adding a host using the core config manager +- 2.1 Navigate to Configure > Core config manager from the nagios dashboard + + +- 2.2 To manually add a new host, select the Hosts link located under Monitoring on the left menu of CCM + +- 2.3 This will bring up the Host Management page, which displays a list of the current hosts being monitored by Nagios XI. + +- 2.4 Click the Add New button to manually add a new host. + +- 2.5 The Host Management page will open on the Common Settings tab. + +- 2.6 Define the primary host parameters such as Host Name, Description, Address, and Display name. + +- 2.7 Use the Manage Parents button to associate parent host(s) for the host. +- 2.8 Use the Manage Templates button to associate template(s) to the host. + +- 2.9 Use the Manage Host Groups button to associate existing host group(s) to the host + + +- 2.10 On the previous screenshot of the Common Settings tab you'll notice that the Active checkbox is checked. If this box is unchecked the host configuration won't be put into production when Apply Configuration is performed. However the settings will remain in CCM until you activate the host object. + +- 2.11 To define the check command for this host, you select the appropriate command from the Check command drop down list . Every command in the Check command drop down list is associated with a set of Nagios Core commands and arguments, which are shown in the Command view field. + + +- 2.12 The Check Settings tab allows you to specify the settings for frequency of checks and also the host state + + +- 2.13 Configure settings as shown in the screenshot below + +- 2.14 The Alert Settings tab allows you to specify your notification settings. + + +- 2.15 Enter the value as shown below: + +- 2.16 Click on manage contacts to add any contact that needs to be notified about the host status. + +- 2.17 The Misc Settings tab is for defining additional host information + +- 2.18 Once you've finished entering information for your new host, click the Save button to return to the Host Management page + +- 2.19 Click the Apply Configuration button to restart Nagios XI and put the new settings info effect. Nagios XI will verify the settings and display a success message that the host was set up correctly + +- 2.20 You can see the apply configuration successful message as shown below: + +- 2.21 You can verify that the host is added to the monitoring tool. + + + + + +---------------------------------------------------------------------------------------- + +# Lesson 9 Demo 3 +Continuous Monitoring on Docker with ELK Stack + + +### Steps to be followed: +1. Set up ELK stack on Docker +2. Configure Jenkins pipeline for Docker build and deployment +3. Run the Spring Boot application and check the logs in Kibana + +### Step 1: Set up ELK stack on Docker + + + + + +1.1 Download Docker compose file in one of the git repositories and follow the set of commands given below to initialize the ELK stack. + + +``` + su +git clone https://github.com/Siraj-ul-muneera/ELKExample.git +cd ELKExample +ls -alrt + +``` + +1.2 Start the ELK stack using the docker-compose command. Usually, this binary is not installed on a server. So, follow the set of commands given below to install Docker Compose. + + +``` + apt install docker-compose +docker-compose version + +``` + +1.3 Before starting the ELK stack, run the command given below so that elastic search is configured properly. + +``` + +sysctl -w vm.max_map_count=262144 + +``` + +1.4 Run the docker-compose command to initialize the ELK stack. + + + +``` + docker-compose up -d +docker ps + +``` + + + + +1.5 Open the Kibana URL using the public IP of the host and 5601 port to access the Kibana dashboard. + +http://localhost:5601/app/kibana + + + +### Step 2: Configure Jenkins pipeline for Docker build and deployment +- 2.1 From the browser, navigate to http://localhost:8080 and login to Jenkins. +- 2.2 Configure your Docker hub credentials in Jenkins. Go to Manage Jenkins -> Manage Credentials -> click on Jenkins link -> click on Global credentials (unrestricted) -> click on Add Credentials from the left pane. + +- 2.3 Add the details as shown below + + +``` + Username: <Your_DockerHub_Username> +Password: <Your_DockerHub_Password> + +``` + +- 2.4 You should now see the credentials saved as shown below + +- 2.5 Create a Jenkins pipeline job to fetch Jenkinsfile from the URL mentioned below. + +- 2.6 You can either use the below git repository or Fork it in your Github account and use it +https://github.com/Siraj-ul-muneera/ELKExample.git + +- 2.7 Configure the job as shown in the screenshot below and then run the build. + + +- 2.8 Give 777 permission to the Docker sock file since we are running Docker command from a Jenkins user. + + +``` + chmod 777 /var/run/docker.sock + +``` + + +- 2.9 Build the Jenkins job to deploy the Docker container on the Docker host. + +- 2.10 Jenkins pipeline will complete the build and the deployment process for the Spring Boot application + + +- 2.11 We can see the Docker container deployed on the Docker host using the command: + + +``` + docker ps | grep springbootapp + +``` + + + +### Step 3: Run the Spring Boot application and check the logs in Kibana + +3.1 Access the Spring Boot web application and perform some random activity so that the logs will be pushed to ELK stack. + +http://localhost:81 + +3.2 Check the logs pushed to ELK stack in Kibana. + +3.3 Navigate to the Kibana dashboard. Select Management > Index Management from the navigation bar on the left. You can see the logs created. + + + + + +---------------------------------------------------------------------------------------- + +---------------------------------------------------------------------------------------- From 539dae2333188c813d70db6f16312eaefe598ab3 Mon Sep 17 00:00:00 2001 From: varun-sl <sl@example.com> Date: Sun, 21 May 2023 04:26:44 +0000 Subject: [PATCH 097/135] readme --- vs-code-installation.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vs-code-installation.sh b/vs-code-installation.sh index d09a94a..c67920f 100755 --- a/vs-code-installation.sh +++ b/vs-code-installation.sh @@ -1,6 +1,6 @@ #!/bin/bash -sudo apt update +sudo apt update -y sudo apt install software-properties-common apt-transport-https wget -y wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" -sudo apt install code -y \ No newline at end of file +sudo apt install code -y From 98da97e3763a4be7887ff1d81fb6a76156687597 Mon Sep 17 00:00:00 2001 From: varun-sl <sl@example.com> Date: Sun, 21 May 2023 04:27:42 +0000 Subject: [PATCH 098/135] readme --- 9.1-NagiOS/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/9.1-NagiOS/README.md b/9.1-NagiOS/README.md index 0f57e58..c9aec28 100644 --- a/9.1-NagiOS/README.md +++ b/9.1-NagiOS/README.md @@ -17,7 +17,7 @@ How to Install Nagios Monitoring Tool ``` - sudo apt update + sudo apt update -y ``` @@ -31,7 +31,9 @@ How to Install Nagios Monitoring Tool - 2.2 Execute the below command to install Nagios XI +``` curl https://assets.nagios.com/downloads/nagiosxi/install.sh | sh +``` **Note**: The installation takes around 20 mins. Please wait patiently till you get the Installation Complete message as shown below From b40aab28235ae9d6b0089757227369f4b8b0488e Mon Sep 17 00:00:00 2001 From: varun-sl <sl@example.com> Date: Sun, 21 May 2023 04:27:56 +0000 Subject: [PATCH 099/135] readme --- 9.1-NagiOS/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/9.1-NagiOS/README.md b/9.1-NagiOS/README.md index c9aec28..226ab73 100644 --- a/9.1-NagiOS/README.md +++ b/9.1-NagiOS/README.md @@ -17,7 +17,7 @@ How to Install Nagios Monitoring Tool ``` - sudo apt update -y + sudo apt update -y ``` From 9beacb82a522a36bdcfc21065f25348c0e054483 Mon Sep 17 00:00:00 2001 From: VARUN KUMAR MANIK <varunmanik1@gmail.com> Date: Sat, 6 Jan 2024 15:07:57 +0800 Subject: [PATCH 100/135] Create history-of-jan-06-2024.txt --- 1-Linux_Tutorial/history-of-jan-06-2024.txt | 104 ++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 1-Linux_Tutorial/history-of-jan-06-2024.txt diff --git a/1-Linux_Tutorial/history-of-jan-06-2024.txt b/1-Linux_Tutorial/history-of-jan-06-2024.txt new file mode 100644 index 0000000..b843b88 --- /dev/null +++ b/1-Linux_Tutorial/history-of-jan-06-2024.txt @@ -0,0 +1,104 @@ + + 1 cat /etc/issue + 2 clear + 3 ls + 4 pwd + 5 ls -l + 6 date + 7 ls -l + 8 cat hello > a.txt + 9 ll + 10 date + 11 clear + 12 ls -la + 13 ls -lah + 14 ls -lh + 15 ls -lht + 16 ls -lhtr + 17 ls -larth + 18 mkdir devops + 19 ll + 20 mkdir -p mgmt/dev/non-prod/code + 21 ll + 22 cd mgmt/ + 23 ll + 24 ll * + 25 ll ** + + 28 ll * + 29 tree + 30 apt install tree + 31 sudo apt install tree + 32 tree + 33 sudo -i + 34 sudo su + 35 cd dev/non-prod/ + 36 cd /home/varunmanikoutlo/mgmt/dev/ + 37 cd non-prod/ + 38 cd .. + 39 cd mgmt/dev/non-prod/ + 40 cd ../../ + 41 cd - + 42 tree + 43 rmdir -r dev + 44 rm -rf dev + 45 tree + 46 touch calc.java + 47 ls + 48 cat calc.java + 49 cat calc.java index.html calc.py + 50 touch calc.java index.html calc.py + 51 ls + 52 rm calc.java + 53 ls + 54 rm * + 55 ll + 56 cat Hi, we are learning Linux. + 57 cat Hi, we are learning Linux. > index.html + 58 cat "Hi, we are learning Linux." > index.html + 59 echo "Hi, we are learning Linux." > index.html + 60 echo "my name is: XYZ" + 61 ls + 62 cat index.html + 63 ll + 64 vim contacts.html + 65 ls + 66 nano aboutus.html + 67 ll + 68 cat aboutus.html + 69 history + 70 nano sales.html + 71 ls + 72 history + 73 ll + 74 vim install.sh + 75 ll + 76 chmod u+x + 77 chmod u+x install.sh + 78 ls + 79 ll + 80 chmod ug+x install.sh + 81 ll + 82 chmod ug-w install.sh + 83 ll + 84 mkdir test + 85 mv install.sh test/ + 86 cd test/ + 87 ll + 88 user>group>others chmod 777 install.sh + 89 chmod 777 install.sh + 90 ll + 91 chmod 774 install.sh + 92 ll + 93 echo "hi this is php page" > index.php + 94 ll + 97 + 101 cat /etc/passwd | grep -i tomcat + 102 ll + 103 + 110 sudo chown tomcat:tomcat index.php + 111 ll + 112 sudo chown tomcat: install.sh + 113 ll + 114 history | cut -8 + 115 history > jan-06-2024.txt From 079964bf74fc5f7449d8a63a00fd41cf01cd0722 Mon Sep 17 00:00:00 2001 From: VARUN KUMAR MANIK <varunmanik1@gmail.com> Date: Sun, 7 Jan 2024 11:15:47 +0800 Subject: [PATCH 101/135] Update README.md --- 2-Git/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2-Git/README.md b/2-Git/README.md index 3e9dad2..7848b8d 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -259,11 +259,11 @@ This command will create a new branch with the specified name and switch | | | git switch -c <new_branch_name> | | | | git switch --detach <commit_hash> | | | | | -| **Git Checkout** | Switches to a different branch or commit, creating a new branch if needed. | ``` | +| **Git Checkout** | Switches to a different branch or commit, creating a new branch if needed. | | | | | git checkout <branch_name> | | | | git checkout -b <new_branch_name> | | | | git checkout <commit_hash> | -| | | ``` | +| | | | # SSH Connectivity to your Simplilearn lab VM From d537ddb043f741279ac617cd34a0ffc28d0c69ec Mon Sep 17 00:00:00 2001 From: VARUN KUMAR MANIK <varunmanik1@gmail.com> Date: Sun, 7 Jan 2024 11:18:14 +0800 Subject: [PATCH 102/135] Update README.md --- 2-Git/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/2-Git/README.md b/2-Git/README.md index 7848b8d..01d195a 100644 --- a/2-Git/README.md +++ b/2-Git/README.md @@ -268,15 +268,15 @@ This command will create a new branch with the specified name and switch # SSH Connectivity to your Simplilearn lab VM -- Step 1 - Loging to github +- Step 1: Loging to github - Step 2: Create a Repo -- Step 3 : Click on your user profile and clicl on stetting +- Step 3: Click on your user profile and clicl on stetting - step 4: Click on ssh key -- step 4.: Copy and paste your pub key +- step 5: Copy and paste your pub key - Step 6: Click OK - Step 7: Clone your repo -## create ssh key in your lab vm +## Create ssh key in your lab vm - Step 1: Login to lab VM and open terminal - Step 2: runthe following command @@ -294,7 +294,7 @@ cat ~/.ssh/id_rsa.pub - Step 4 : Paste the content in privious step 6 -# Common error while stting the above steps +# Common error while setting the above steps ``` git clone git@github.com:sindhugowda1991/java.calculatore-delete.git From fc82b1860b752f98a4b04f59041c49511e5bace7 Mon Sep 17 00:00:00 2001 From: varun-sl <varun@gmail.com> Date: Sat, 13 Jan 2024 07:18:18 +0000 Subject: [PATCH 103/135] adding date --- 5-jenkins/5.2-simple-java-program/HelloWorld.java | 2 +- .../my-app/src/main/java/com/mycompany/app/App.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/5-jenkins/5.2-simple-java-program/HelloWorld.java b/5-jenkins/5.2-simple-java-program/HelloWorld.java index bbff415..3d090dc 100644 --- a/5-jenkins/5.2-simple-java-program/HelloWorld.java +++ b/5-jenkins/5.2-simple-java-program/HelloWorld.java @@ -1,5 +1,5 @@ public class HelloWorld { public static void main(String[] args) { - System.out.println("Hello, World From Varun Manik on date May 6 2023"); + System.out.println("Hello, World From Varun Manik on date MaJan 13 2024"); } } \ No newline at end of file diff --git a/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java b/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java index 32e3060..42a05d4 100644 --- a/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java +++ b/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java @@ -8,6 +8,6 @@ public class App { public static void main( String[] args ) { - System.out.println( "Hello World! From Varun Manik in Simplilearn class" ); + System.out.println( "Hello World! From Varun Manik in Simplilearn class on dat Jan 13 2024" ); } } From a247ab1ea124eedc643ed841405f8e9ac8dd5f65 Mon Sep 17 00:00:00 2001 From: varun-sl <varun@gmail.com> Date: Sat, 13 Jan 2024 07:20:00 +0000 Subject: [PATCH 104/135] adding date --- .../my-app/src/main/java/com/mycompany/app/App.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java b/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java index 42a05d4..cff2a1a 100644 --- a/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java +++ b/5-jenkins/5.3-maven-project/my-app/src/main/java/com/mycompany/app/App.java @@ -8,6 +8,6 @@ public class App { public static void main( String[] args ) { - System.out.println( "Hello World! From Varun Manik in Simplilearn class on dat Jan 13 2024" ); + System.out.println( "Hello World! From Varun Manik in Simplilearn class on date Jan 13 2024" ); } } From 0ce2a9c21ced8ad5ccf98ed3eb12042137f1e446 Mon Sep 17 00:00:00 2001 From: varun-sl <varun@gmail.com> Date: Sat, 13 Jan 2024 07:45:32 +0000 Subject: [PATCH 105/135] adding ant --- .../5.3-ant-java/HelloWorldAnt/build.xml | 11 ++++ .../HelloWorldAnt/src/HelloWorld.java | 5 ++ 5-jenkins/5.3-ant-java/README.md | 66 +++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 5-jenkins/5.3-ant-java/HelloWorldAnt/build.xml create mode 100644 5-jenkins/5.3-ant-java/HelloWorldAnt/src/HelloWorld.java create mode 100644 5-jenkins/5.3-ant-java/README.md diff --git a/5-jenkins/5.3-ant-java/HelloWorldAnt/build.xml b/5-jenkins/5.3-ant-java/HelloWorldAnt/build.xml new file mode 100644 index 0000000..cce072a --- /dev/null +++ b/5-jenkins/5.3-ant-java/HelloWorldAnt/build.xml @@ -0,0 +1,11 @@ +<project name="HelloWorld" default="run"> + <target name="compile"> + <mkdir dir="bin"/> + <javac srcdir="src" destdir="bin"/> + </target> + + <target name="run" depends="compile"> + <java classname="HelloWorld" classpath="bin"/> + </target> +</project> + diff --git a/5-jenkins/5.3-ant-java/HelloWorldAnt/src/HelloWorld.java b/5-jenkins/5.3-ant-java/HelloWorldAnt/src/HelloWorld.java new file mode 100644 index 0000000..70fd330 --- /dev/null +++ b/5-jenkins/5.3-ant-java/HelloWorldAnt/src/HelloWorld.java @@ -0,0 +1,5 @@ +public class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello, World!"); + } +} diff --git a/5-jenkins/5.3-ant-java/README.md b/5-jenkins/5.3-ant-java/README.md new file mode 100644 index 0000000..376fbdb --- /dev/null +++ b/5-jenkins/5.3-ant-java/README.md @@ -0,0 +1,66 @@ +# Hello World Java Program with Ant on Linux + +## Introduction +This tutorial guides you through creating and running a simple "Hello World" Java program using Apache Ant on a Linux system. + +## Prerequisites +- Java Development Kit (JDK) +- Apache Ant + +Ensure both are installed on your system. You can verify by running `java -version` and `ant -version` in your terminal. + +## Setup + +### Step 1: Project Structure +Create a project directory and set up the following structure: + + +HelloWorldAnt/ +├── src/ +└── build.xml + + +Navigate to your project directory: +```bash +mkdir HelloWorldAnt +cd HelloWorldAnt +``` + +Step 2: Java Source File +Inside the src directory, create a file HelloWorld.java: + + + +``` +public class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello, World!"); + } +} +``` +- Step 3: Ant Build File +Create build.xml at the root of your project with the following content: + +``` +<project name="HelloWorld" default="run"> + <target name="compile"> + <mkdir dir="bin"/> + <javac srcdir="src" destdir="bin"/> + </target> + + <target name="run" depends="compile"> + <java classname="HelloWorld" classpath="bin"/> + </target> +</project> + +``` + + +- Running the Program +To build and run your program, execute: + +``` +ant run +``` + +You should see Hello, World! printed in the console. \ No newline at end of file From 204b4c9a42defe8d341d055c005863c936da54d2 Mon Sep 17 00:00:00 2001 From: varun-sl <varun@gmail.com> Date: Sat, 13 Jan 2024 07:47:42 +0000 Subject: [PATCH 106/135] adding ant --- 5-jenkins/5.3-ant-java/README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/5-jenkins/5.3-ant-java/README.md b/5-jenkins/5.3-ant-java/README.md index 376fbdb..50c6e93 100644 --- a/5-jenkins/5.3-ant-java/README.md +++ b/5-jenkins/5.3-ant-java/README.md @@ -15,10 +15,6 @@ Ensure both are installed on your system. You can verify by running `java -versi Create a project directory and set up the following structure: -HelloWorldAnt/ -├── src/ -└── build.xml - Navigate to your project directory: ```bash @@ -26,7 +22,7 @@ mkdir HelloWorldAnt cd HelloWorldAnt ``` -Step 2: Java Source File +- Step 2: Java Source File Inside the src directory, create a file HelloWorld.java: From 6a0b1197da6a391a56cc9213ef197edcedff306a Mon Sep 17 00:00:00 2001 From: varun-sl <varun@gmail.com> Date: Sun, 14 Jan 2024 04:53:06 +0000 Subject: [PATCH 107/135] adding ant --- 5-jenkins/{5.3-ant-java => 5.4-ant-java}/HelloWorldAnt/build.xml | 0 .../HelloWorldAnt/src/HelloWorld.java | 0 5-jenkins/{5.3-ant-java => 5.4-ant-java}/README.md | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename 5-jenkins/{5.3-ant-java => 5.4-ant-java}/HelloWorldAnt/build.xml (100%) rename 5-jenkins/{5.3-ant-java => 5.4-ant-java}/HelloWorldAnt/src/HelloWorld.java (100%) rename 5-jenkins/{5.3-ant-java => 5.4-ant-java}/README.md (100%) diff --git a/5-jenkins/5.3-ant-java/HelloWorldAnt/build.xml b/5-jenkins/5.4-ant-java/HelloWorldAnt/build.xml similarity index 100% rename from 5-jenkins/5.3-ant-java/HelloWorldAnt/build.xml rename to 5-jenkins/5.4-ant-java/HelloWorldAnt/build.xml diff --git a/5-jenkins/5.3-ant-java/HelloWorldAnt/src/HelloWorld.java b/5-jenkins/5.4-ant-java/HelloWorldAnt/src/HelloWorld.java similarity index 100% rename from 5-jenkins/5.3-ant-java/HelloWorldAnt/src/HelloWorld.java rename to 5-jenkins/5.4-ant-java/HelloWorldAnt/src/HelloWorld.java diff --git a/5-jenkins/5.3-ant-java/README.md b/5-jenkins/5.4-ant-java/README.md similarity index 100% rename from 5-jenkins/5.3-ant-java/README.md rename to 5-jenkins/5.4-ant-java/README.md From 816a6530e0433b08cdd7dc57943c8e10bc174190 Mon Sep 17 00:00:00 2001 From: VARUN KUMAR MANIK <varunmanik1@gmail.com> Date: Sun, 14 Jan 2024 13:42:02 +0800 Subject: [PATCH 108/135] Update README.md --- 5-jenkins/5.4-ant-java/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/5-jenkins/5.4-ant-java/README.md b/5-jenkins/5.4-ant-java/README.md index 50c6e93..e081579 100644 --- a/5-jenkins/5.4-ant-java/README.md +++ b/5-jenkins/5.4-ant-java/README.md @@ -1,4 +1,4 @@ -# Hello World Java Program with Ant on Linux +# Hello World Java Program with Ant on Linux. ## Introduction This tutorial guides you through creating and running a simple "Hello World" Java program using Apache Ant on a Linux system. @@ -59,4 +59,4 @@ To build and run your program, execute: ant run ``` -You should see Hello, World! printed in the console. \ No newline at end of file +You should see Hello, World! printed in the console. From c0dc117c3c8cc9fcc53ff9d925450a66416777c9 Mon Sep 17 00:00:00 2001 From: VARUN KUMAR MANIK <varunmanik1@gmail.com> Date: Sun, 14 Jan 2024 13:56:42 +0800 Subject: [PATCH 109/135] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ecbef35..dc6ceb1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # DevOps-Tutorial - -- DevOps-Tutorial By Varun Kumar Manik. +## DevOps-Tutorial By Varun Kumar Manik. - Sending from User. # Caltech-DevOps Simplilearn PG Program @@ -142,4 +141,4 @@ For more info, please connect and follow me: - Email: [varunmanik1@gmail.com](mailto:varunmanik1@gmail.com) - Facebook: [https://www.facebook.com/cloudvirtualization/](https://www.facebook.com/cloudvirtualization/) - YouTube: [https://bit.ly/32fknRN](https://bit.ly/32fknRN) -- Twitter: [https://twitter.com/varunkmanik](https://twitter.com/varunkmanik) \ No newline at end of file +- Twitter: [https://twitter.com/varunkmanik](https://twitter.com/varunkmanik) From 7126ffaf5c16078a42771f60f5376a8495fc3423 Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sat, 20 Jan 2024 11:11:32 +0800 Subject: [PATCH 110/135] aws --- .../6.7-S3-Bucket-Using-Terraform/README.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/6-ansible/6.7-S3-Bucket-Using-Terraform/README.md b/6-ansible/6.7-S3-Bucket-Using-Terraform/README.md index bfbace2..17a0124 100644 --- a/6-ansible/6.7-S3-Bucket-Using-Terraform/README.md +++ b/6-ansible/6.7-S3-Bucket-Using-Terraform/README.md @@ -113,3 +113,55 @@ terraform apply 2.8 Verify the creation of S3 bucket in the AWS Management console. +--- + +# Creating and Using Secret Access Keys and Access IDs in AWS IAM for Linux VMs + +## Steps + +1. **Create an IAM User:** + - Access the AWS Management Console and navigate to IAM. + - Click "Users" -> "Add user." + - Assign a meaningful username and select "Programmatic access." + - Click "Next: Permissions." + +2. **Attach Permissions:** + - Choose an existing policy or create a custom one, granting only necessary permissions. + - Click "Next: Tags." + - Optionally add tags. + - Click "Next: Review." + - Verify details and click "Create user." + +3. **Securely Store Access Key and ID:** + - Immediately download and securely store the secret access key (not retrievable later). + - Note the access key ID. + +4. **Add Credentials to Linux VM:** + - Choose a secure storage method: + + - **Environment variables (temporary):** + ```bash + export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID + export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY + ``` + + - **AWS CLI configuration file:** + Create `~/.aws/credentials`: + ``` + [default] + aws_access_key_id = YOUR_ACCESS_KEY_ID + aws_secret_access_key = YOUR_SECRET_ACCESS_KEY + + + - **AWS SDK environment variables:** + Set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` for applications using the SDK. + +## Security Best Practices + +- **Avoid hardcoding access keys:** Use AWS Secrets Manager or similar for secure storage and rotation. +- **Regularly rotate access keys:** Enhance security. +- **Use strong passwords for IAM users:** Strengthen protection. +- **Enable MFA:** Add a layer of security. +- **Implement AWS CloudTrail:** Log API activity for auditing and analysis. +- **Regularly review and update permissions:** Maintain least privilege. + From f154b9641449d13e1054af774d2252ff4fd68ec3 Mon Sep 17 00:00:00 2001 From: varun <v@gmail.com> Date: Sat, 20 Jan 2024 03:54:44 +0000 Subject: [PATCH 111/135] adding tf local --- .../6.2-node-ansible-playbook/README.md | 0 .../6.2-node-ansible-playbook/node.yml | 0 .../6.3-apache-ansible-playbook/apache.yaml | 0 .../6.4-ansible-module/README.md | 0 .../6.5-ansible-role/README.md | 0 .../6.5-ansible-role/ansible.cfg | 0 .../6.5-ansible-role/demor-role.yml | 0 .../6.5-ansible-role/demor/.travis.yml | 0 .../6.5-ansible-role/demor/README.md | 0 .../6.5-ansible-role/demor/defaults/main.yml | 0 .../6.5-ansible-role/demor/meta/main.yml | 0 .../6.5-ansible-role/demor/tasks/main.yml | 0 .../6.5-ansible-role/demor/templates/demor.j2 | 0 .../6.5-ansible-role/deployer | 0 .../6.5-ansible-role/deployer.pub | 0 .../6.5-ansible-role/host_vars.yml | 0 .../6.5-ansible-role/inventory.ini | 0 .../6.6-setup-terraform/README.md | 0 .../6.6-setup-terraform/tf-installation.sh | 0 .../6.6.1-tf-local-file/.terraform.lock.hcl | 21 +++++++++++++++++++ .../6.6.1-tf-local-file/index.html | 1 + .../6.6.1-tf-local-file/main.tf | 7 +++++++ .../6.7-S3-Bucket-Using-Terraform/.gitignore | 0 .../.terraform.lock.hcl | 0 .../6.7-S3-Bucket-Using-Terraform/README.md | 0 .../6.7-S3-Bucket-Using-Terraform/creds.tf | 8 +++++++ .../6.7-S3-Bucket-Using-Terraform/main.tf | 0 .../6.8-tf-ec2-provisioning/.gitignore | 0 .../.terraform.lock.hcl | 0 .../6.8-tf-ec2-provisioning/README.md | 0 .../amazon-linux-vm.tf | 0 .../6.8-tf-ec2-provisioning/ansible/README.md | 0 .../ansible/ansible.cfg | 0 .../ansible/apache.yaml | 0 .../ansible/host_vars.yaml | 0 .../ansible/inventory copy.ini-backup | 0 .../ansible/inventory.ini | 0 .../ansible/jenkins.yaml | 0 .../6.8-tf-ec2-provisioning/ansible/node.yaml | 0 .../6.8-tf-ec2-provisioning/ansible/ping.yaml | 0 .../ansible/ubuntu-wp-1.yaml | 0 .../ansible/ubuntu-wp-config.php.j2 | 0 .../ansible/wp-config.php.j2 | 0 .../6.8-tf-ec2-provisioning/ansible/wp.yaml | 0 .../6.8-tf-ec2-provisioning/deployer | 0 .../6.8-tf-ec2-provisioning/deployer.ppk | 0 .../6.8-tf-ec2-provisioning/deployer.pub | 0 .../6.8-tf-ec2-provisioning/main.tf | 0 .../6.8-tf-ec2-provisioning/ubuntu-vm.tf | 0 {6-ansible => 6-ansible-terraform}/README.md | 0 .../wordpress/README.md | 0 .../wordpress/wp-config.php.j2 | 0 .../wordpress/wp.yaml | 0 53 files changed, 37 insertions(+) rename {6-ansible => 6-ansible-terraform}/6.2-node-ansible-playbook/README.md (100%) rename {6-ansible => 6-ansible-terraform}/6.2-node-ansible-playbook/node.yml (100%) rename {6-ansible => 6-ansible-terraform}/6.3-apache-ansible-playbook/apache.yaml (100%) rename {6-ansible => 6-ansible-terraform}/6.4-ansible-module/README.md (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/README.md (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/ansible.cfg (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/demor-role.yml (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/demor/.travis.yml (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/demor/README.md (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/demor/defaults/main.yml (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/demor/meta/main.yml (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/demor/tasks/main.yml (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/demor/templates/demor.j2 (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/deployer (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/deployer.pub (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/host_vars.yml (100%) rename {6-ansible => 6-ansible-terraform}/6.5-ansible-role/inventory.ini (100%) rename {6-ansible => 6-ansible-terraform}/6.6-setup-terraform/README.md (100%) rename {6-ansible => 6-ansible-terraform}/6.6-setup-terraform/tf-installation.sh (100%) create mode 100644 6-ansible-terraform/6.6.1-tf-local-file/.terraform.lock.hcl create mode 100755 6-ansible-terraform/6.6.1-tf-local-file/index.html create mode 100644 6-ansible-terraform/6.6.1-tf-local-file/main.tf rename {6-ansible => 6-ansible-terraform}/6.7-S3-Bucket-Using-Terraform/.gitignore (100%) rename {6-ansible => 6-ansible-terraform}/6.7-S3-Bucket-Using-Terraform/.terraform.lock.hcl (100%) rename {6-ansible => 6-ansible-terraform}/6.7-S3-Bucket-Using-Terraform/README.md (100%) create mode 100644 6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf rename {6-ansible => 6-ansible-terraform}/6.7-S3-Bucket-Using-Terraform/main.tf (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/.gitignore (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/.terraform.lock.hcl (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/README.md (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/amazon-linux-vm.tf (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/README.md (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/ansible.cfg (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/apache.yaml (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/host_vars.yaml (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/inventory copy.ini-backup (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/inventory.ini (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/jenkins.yaml (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/node.yaml (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/ping.yaml (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-config.php.j2 (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/wp-config.php.j2 (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ansible/wp.yaml (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/deployer (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/deployer.ppk (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/deployer.pub (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/main.tf (100%) rename {6-ansible => 6-ansible-terraform}/6.8-tf-ec2-provisioning/ubuntu-vm.tf (100%) rename {6-ansible => 6-ansible-terraform}/README.md (100%) rename {6-ansible => 6-ansible-terraform}/wordpress/README.md (100%) rename {6-ansible => 6-ansible-terraform}/wordpress/wp-config.php.j2 (100%) rename {6-ansible => 6-ansible-terraform}/wordpress/wp.yaml (100%) diff --git a/6-ansible/6.2-node-ansible-playbook/README.md b/6-ansible-terraform/6.2-node-ansible-playbook/README.md similarity index 100% rename from 6-ansible/6.2-node-ansible-playbook/README.md rename to 6-ansible-terraform/6.2-node-ansible-playbook/README.md diff --git a/6-ansible/6.2-node-ansible-playbook/node.yml b/6-ansible-terraform/6.2-node-ansible-playbook/node.yml similarity index 100% rename from 6-ansible/6.2-node-ansible-playbook/node.yml rename to 6-ansible-terraform/6.2-node-ansible-playbook/node.yml diff --git a/6-ansible/6.3-apache-ansible-playbook/apache.yaml b/6-ansible-terraform/6.3-apache-ansible-playbook/apache.yaml similarity index 100% rename from 6-ansible/6.3-apache-ansible-playbook/apache.yaml rename to 6-ansible-terraform/6.3-apache-ansible-playbook/apache.yaml diff --git a/6-ansible/6.4-ansible-module/README.md b/6-ansible-terraform/6.4-ansible-module/README.md similarity index 100% rename from 6-ansible/6.4-ansible-module/README.md rename to 6-ansible-terraform/6.4-ansible-module/README.md diff --git a/6-ansible/6.5-ansible-role/README.md b/6-ansible-terraform/6.5-ansible-role/README.md similarity index 100% rename from 6-ansible/6.5-ansible-role/README.md rename to 6-ansible-terraform/6.5-ansible-role/README.md diff --git a/6-ansible/6.5-ansible-role/ansible.cfg b/6-ansible-terraform/6.5-ansible-role/ansible.cfg similarity index 100% rename from 6-ansible/6.5-ansible-role/ansible.cfg rename to 6-ansible-terraform/6.5-ansible-role/ansible.cfg diff --git a/6-ansible/6.5-ansible-role/demor-role.yml b/6-ansible-terraform/6.5-ansible-role/demor-role.yml similarity index 100% rename from 6-ansible/6.5-ansible-role/demor-role.yml rename to 6-ansible-terraform/6.5-ansible-role/demor-role.yml diff --git a/6-ansible/6.5-ansible-role/demor/.travis.yml b/6-ansible-terraform/6.5-ansible-role/demor/.travis.yml similarity index 100% rename from 6-ansible/6.5-ansible-role/demor/.travis.yml rename to 6-ansible-terraform/6.5-ansible-role/demor/.travis.yml diff --git a/6-ansible/6.5-ansible-role/demor/README.md b/6-ansible-terraform/6.5-ansible-role/demor/README.md similarity index 100% rename from 6-ansible/6.5-ansible-role/demor/README.md rename to 6-ansible-terraform/6.5-ansible-role/demor/README.md diff --git a/6-ansible/6.5-ansible-role/demor/defaults/main.yml b/6-ansible-terraform/6.5-ansible-role/demor/defaults/main.yml similarity index 100% rename from 6-ansible/6.5-ansible-role/demor/defaults/main.yml rename to 6-ansible-terraform/6.5-ansible-role/demor/defaults/main.yml diff --git a/6-ansible/6.5-ansible-role/demor/meta/main.yml b/6-ansible-terraform/6.5-ansible-role/demor/meta/main.yml similarity index 100% rename from 6-ansible/6.5-ansible-role/demor/meta/main.yml rename to 6-ansible-terraform/6.5-ansible-role/demor/meta/main.yml diff --git a/6-ansible/6.5-ansible-role/demor/tasks/main.yml b/6-ansible-terraform/6.5-ansible-role/demor/tasks/main.yml similarity index 100% rename from 6-ansible/6.5-ansible-role/demor/tasks/main.yml rename to 6-ansible-terraform/6.5-ansible-role/demor/tasks/main.yml diff --git a/6-ansible/6.5-ansible-role/demor/templates/demor.j2 b/6-ansible-terraform/6.5-ansible-role/demor/templates/demor.j2 similarity index 100% rename from 6-ansible/6.5-ansible-role/demor/templates/demor.j2 rename to 6-ansible-terraform/6.5-ansible-role/demor/templates/demor.j2 diff --git a/6-ansible/6.5-ansible-role/deployer b/6-ansible-terraform/6.5-ansible-role/deployer similarity index 100% rename from 6-ansible/6.5-ansible-role/deployer rename to 6-ansible-terraform/6.5-ansible-role/deployer diff --git a/6-ansible/6.5-ansible-role/deployer.pub b/6-ansible-terraform/6.5-ansible-role/deployer.pub similarity index 100% rename from 6-ansible/6.5-ansible-role/deployer.pub rename to 6-ansible-terraform/6.5-ansible-role/deployer.pub diff --git a/6-ansible/6.5-ansible-role/host_vars.yml b/6-ansible-terraform/6.5-ansible-role/host_vars.yml similarity index 100% rename from 6-ansible/6.5-ansible-role/host_vars.yml rename to 6-ansible-terraform/6.5-ansible-role/host_vars.yml diff --git a/6-ansible/6.5-ansible-role/inventory.ini b/6-ansible-terraform/6.5-ansible-role/inventory.ini similarity index 100% rename from 6-ansible/6.5-ansible-role/inventory.ini rename to 6-ansible-terraform/6.5-ansible-role/inventory.ini diff --git a/6-ansible/6.6-setup-terraform/README.md b/6-ansible-terraform/6.6-setup-terraform/README.md similarity index 100% rename from 6-ansible/6.6-setup-terraform/README.md rename to 6-ansible-terraform/6.6-setup-terraform/README.md diff --git a/6-ansible/6.6-setup-terraform/tf-installation.sh b/6-ansible-terraform/6.6-setup-terraform/tf-installation.sh similarity index 100% rename from 6-ansible/6.6-setup-terraform/tf-installation.sh rename to 6-ansible-terraform/6.6-setup-terraform/tf-installation.sh diff --git a/6-ansible-terraform/6.6.1-tf-local-file/.terraform.lock.hcl b/6-ansible-terraform/6.6.1-tf-local-file/.terraform.lock.hcl new file mode 100644 index 0000000..62da99d --- /dev/null +++ b/6-ansible-terraform/6.6.1-tf-local-file/.terraform.lock.hcl @@ -0,0 +1,21 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/local" { + version = "2.4.1" + hashes = [ + "h1:FzraUapGrJoH3ZOWiUT2m6QpZAD+HmU+JmqZgM4/o2Y=", + "zh:244b445bf34ddbd167731cc6c6b95bbed231dc4493f8cc34bd6850cfe1f78528", + "zh:3c330bdb626123228a0d1b1daa6c741b4d5d484ab1c7ae5d2f48d4c9885cc5e9", + "zh:5ff5f9b791ddd7557e815449173f2db38d338e674d2d91800ac6e6d808de1d1d", + "zh:70206147104f4bf26ae67d730c995772f85bf23e28c2c2e7612c74f4dae3c46f", + "zh:75029676993accd6bef933c196b2fad51a9ec8a69a847dbbe96ec8ebf7926cdc", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:7d48d5999fe1fcdae9295a7c3448ac1541f5a24c474bd82df6d4fa3732483f2b", + "zh:b766b38b027f0f84028244d1c2f990431a37d4fc3ac645962924554016507e77", + "zh:bfc7ad301dada204cf51c59d8bd6a9a87de5fddb42190b4d6ba157d6e08a1f10", + "zh:c902b527702a8c5e2c25a6637d07bbb1690cb6c1e63917a5f6dc460efd18d43f", + "zh:d68ae0e1070cf429c46586bc87580c3ed113f76241da2b6e4f1a8348126b3c46", + "zh:f4903fd89f7c92a346ae9e666c2d0b6884c4474ae109e9b4bd15e7efaa4bfc29", + ] +} diff --git a/6-ansible-terraform/6.6.1-tf-local-file/index.html b/6-ansible-terraform/6.6.1-tf-local-file/index.html new file mode 100755 index 0000000..f077469 --- /dev/null +++ b/6-ansible-terraform/6.6.1-tf-local-file/index.html @@ -0,0 +1 @@ +Hi How are you ? \ No newline at end of file diff --git a/6-ansible-terraform/6.6.1-tf-local-file/main.tf b/6-ansible-terraform/6.6.1-tf-local-file/main.tf new file mode 100644 index 0000000..5c53112 --- /dev/null +++ b/6-ansible-terraform/6.6.1-tf-local-file/main.tf @@ -0,0 +1,7 @@ +resource "local_file" "index_file" { + + content = "Hi How are you ?" + + filename = "index.html" + +} diff --git a/6-ansible/6.7-S3-Bucket-Using-Terraform/.gitignore b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/.gitignore similarity index 100% rename from 6-ansible/6.7-S3-Bucket-Using-Terraform/.gitignore rename to 6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/.gitignore diff --git a/6-ansible/6.7-S3-Bucket-Using-Terraform/.terraform.lock.hcl b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/.terraform.lock.hcl similarity index 100% rename from 6-ansible/6.7-S3-Bucket-Using-Terraform/.terraform.lock.hcl rename to 6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/.terraform.lock.hcl diff --git a/6-ansible/6.7-S3-Bucket-Using-Terraform/README.md b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/README.md similarity index 100% rename from 6-ansible/6.7-S3-Bucket-Using-Terraform/README.md rename to 6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/README.md diff --git a/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf new file mode 100644 index 0000000..398a034 --- /dev/null +++ b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf @@ -0,0 +1,8 @@ + + +provider "aws" { + access_key = "" + secret_key = "" + token = "" + region = "us-east-1" +} \ No newline at end of file diff --git a/6-ansible/6.7-S3-Bucket-Using-Terraform/main.tf b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/main.tf similarity index 100% rename from 6-ansible/6.7-S3-Bucket-Using-Terraform/main.tf rename to 6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/main.tf diff --git a/6-ansible/6.8-tf-ec2-provisioning/.gitignore b/6-ansible-terraform/6.8-tf-ec2-provisioning/.gitignore similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/.gitignore rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/.gitignore diff --git a/6-ansible/6.8-tf-ec2-provisioning/.terraform.lock.hcl b/6-ansible-terraform/6.8-tf-ec2-provisioning/.terraform.lock.hcl similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/.terraform.lock.hcl rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/.terraform.lock.hcl diff --git a/6-ansible/6.8-tf-ec2-provisioning/README.md b/6-ansible-terraform/6.8-tf-ec2-provisioning/README.md similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/README.md rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/README.md diff --git a/6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf b/6-ansible-terraform/6.8-tf-ec2-provisioning/amazon-linux-vm.tf similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/amazon-linux-vm.tf rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/amazon-linux-vm.tf diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/README.md b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/README.md similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/README.md rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/README.md diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ansible.cfg similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/ansible.cfg rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ansible.cfg diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/apache.yaml b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/apache.yaml similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/apache.yaml rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/apache.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/host_vars.yaml similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/host_vars.yaml rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/host_vars.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory copy.ini-backup b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory copy.ini-backup similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/inventory copy.ini-backup rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory copy.ini-backup diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/inventory.ini rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins.yaml b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/jenkins.yaml similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/jenkins.yaml rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/jenkins.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/node.yaml b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/node.yaml similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/node.yaml rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/node.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/ping.yaml b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ping.yaml similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/ping.yaml rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ping.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-1.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-config.php.j2 b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-config.php.j2 similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-config.php.j2 rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ubuntu-wp-config.php.j2 diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/wp-config.php.j2 b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/wp-config.php.j2 similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/wp-config.php.j2 rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/wp-config.php.j2 diff --git a/6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/wp.yaml similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ansible/wp.yaml rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/wp.yaml diff --git a/6-ansible/6.8-tf-ec2-provisioning/deployer b/6-ansible-terraform/6.8-tf-ec2-provisioning/deployer similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/deployer rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/deployer diff --git a/6-ansible/6.8-tf-ec2-provisioning/deployer.ppk b/6-ansible-terraform/6.8-tf-ec2-provisioning/deployer.ppk similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/deployer.ppk rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/deployer.ppk diff --git a/6-ansible/6.8-tf-ec2-provisioning/deployer.pub b/6-ansible-terraform/6.8-tf-ec2-provisioning/deployer.pub similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/deployer.pub rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/deployer.pub diff --git a/6-ansible/6.8-tf-ec2-provisioning/main.tf b/6-ansible-terraform/6.8-tf-ec2-provisioning/main.tf similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/main.tf rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/main.tf diff --git a/6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf b/6-ansible-terraform/6.8-tf-ec2-provisioning/ubuntu-vm.tf similarity index 100% rename from 6-ansible/6.8-tf-ec2-provisioning/ubuntu-vm.tf rename to 6-ansible-terraform/6.8-tf-ec2-provisioning/ubuntu-vm.tf diff --git a/6-ansible/README.md b/6-ansible-terraform/README.md similarity index 100% rename from 6-ansible/README.md rename to 6-ansible-terraform/README.md diff --git a/6-ansible/wordpress/README.md b/6-ansible-terraform/wordpress/README.md similarity index 100% rename from 6-ansible/wordpress/README.md rename to 6-ansible-terraform/wordpress/README.md diff --git a/6-ansible/wordpress/wp-config.php.j2 b/6-ansible-terraform/wordpress/wp-config.php.j2 similarity index 100% rename from 6-ansible/wordpress/wp-config.php.j2 rename to 6-ansible-terraform/wordpress/wp-config.php.j2 diff --git a/6-ansible/wordpress/wp.yaml b/6-ansible-terraform/wordpress/wp.yaml similarity index 100% rename from 6-ansible/wordpress/wp.yaml rename to 6-ansible-terraform/wordpress/wp.yaml From ccb854721f523d03e6cf102561b00915a97ecfe1 Mon Sep 17 00:00:00 2001 From: varun <v@gmail.com> Date: Sat, 20 Jan 2024 04:23:46 +0000 Subject: [PATCH 112/135] adding creds --- 6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf | 1 - 6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/main.tf | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf index 398a034..44c46e8 100644 --- a/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf +++ b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf @@ -1,5 +1,4 @@ - provider "aws" { access_key = "" secret_key = "" diff --git a/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/main.tf b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/main.tf index 84b4269..74a335d 100644 --- a/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/main.tf +++ b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/main.tf @@ -1,9 +1,6 @@ -provider "aws" { - region = "us-east-1" -} -resource "aws_s3_bucket" "b" { - bucket = "my-tf-test-bucket-345611" +resource "aws_s3_bucket" "bucket" { + bucket = "varun-tf-test-bucket-0acb9876" acl = "private" tags = { From 84959570597995007bd49b4a962e2e45b8e4ce7e Mon Sep 17 00:00:00 2001 From: varun <v@gmail.com> Date: Sat, 20 Jan 2024 05:28:38 +0000 Subject: [PATCH 113/135] adding cred.tf --- .../6.7-S3-Bucket-Using-Terraform/creds.tf | 8 ++++++++ 6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf | 6 ++++++ 6-ansible-terraform/6.8-tf-ec2-provisioning/main.tf | 4 ---- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf diff --git a/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf index 44c46e8..05f34e5 100644 --- a/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf +++ b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf @@ -1,3 +1,11 @@ +Access key +Secret access key + +AKIAQ7ZCMYMX5SZC6CEZ + +KkrdjS9rbQRAYuROhVsE26pH7/d3+qg7TOzkHXZA +Hide + provider "aws" { access_key = "" diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf b/6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf new file mode 100644 index 0000000..9b3bfe6 --- /dev/null +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf @@ -0,0 +1,6 @@ +provider "aws" { + access_key = "" + secret_key = "" + token = "" + region = "us-east-1" +} \ No newline at end of file diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/main.tf b/6-ansible-terraform/6.8-tf-ec2-provisioning/main.tf index a97b619..aa62dda 100644 --- a/6-ansible-terraform/6.8-tf-ec2-provisioning/main.tf +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/main.tf @@ -9,7 +9,3 @@ terraform { required_version = ">= 0.14.9" } -provider "aws" { - profile = "default" - region = "us-east-1" -} From cea556f9c8505249e1bcd1f001d46cd78c498514 Mon Sep 17 00:00:00 2001 From: varun <v@gmail.com> Date: Sun, 21 Jan 2024 03:33:17 +0000 Subject: [PATCH 114/135] wp-manual --- .../ansible/inventory.ini | 14 +-- .../ansible/inventory.ini.org | 19 ++++ .../6.8-tf-ec2-provisioning/ansible/ping.yaml | 34 +++---- .../ansible/rue/my_server_1 | 1 + .../ansible/rue/my_server_2 | 1 + .../ansible/rue/my_server_3 | 1 + .../6.8-tf-ec2-provisioning/creds.tf | 4 +- 6-ansible-terraform/wordpress/README.md | 93 +++++++++++++++++++ 8 files changed, 139 insertions(+), 28 deletions(-) create mode 100644 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini.org create mode 100644 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_1 create mode 100644 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_2 create mode 100644 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_3 diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini index 0489eaf..fd3f990 100644 --- a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini @@ -1,12 +1,8 @@ -[aws:children] -aws_linux_vm -[aws:vars] -ansible_user=ec2-user -ansible_ssh_private_key_file=../deployer - -[aws_linux_vm] -wp-server ansible_host=3.81.25.108 +[ubuntu_vm] +my_server_1 ansible_host=3.87.250.203 +my_server_2 ansible_host=54.198.128.135 +my_server_3 ansible_host=107.22.117.179 [ubuntu:children] ubuntu_vm @@ -15,5 +11,3 @@ ubuntu_vm ansible_user=ubuntu ansible_ssh_private_key_file=../deployer -[ubuntu_vm] -my_server_1 ansible_host=44.210.103.164 diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini.org b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini.org new file mode 100644 index 0000000..0489eaf --- /dev/null +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini.org @@ -0,0 +1,19 @@ +[aws:children] +aws_linux_vm + +[aws:vars] +ansible_user=ec2-user +ansible_ssh_private_key_file=../deployer + +[aws_linux_vm] +wp-server ansible_host=3.81.25.108 + +[ubuntu:children] +ubuntu_vm + +[ubuntu:vars] +ansible_user=ubuntu +ansible_ssh_private_key_file=../deployer + +[ubuntu_vm] +my_server_1 ansible_host=44.210.103.164 diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ping.yaml b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ping.yaml index 52c7a72..0bcf0e0 100644 --- a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ping.yaml +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ping.yaml @@ -1,33 +1,35 @@ --- - name: This is a simple Playbook. - hosts: my_servers - become: yes + hosts: ubuntu_vm + become: true gather_facts: yes tasks: - name: 1. Ping the remote server ping: - - name: 2. Create index file - file: - path: /home/ubuntu/index.html - state: touch - - name: 3. Apache2 + + # - name: 2. Create index file + # file: + # path: /home/ubuntu/index.html + # state: touch + + - name: 3. Nginx apt: - name: apache2 + name: nginx state: present - - name: 4. Apache2-service - service: - name: apache2 - state: restarted + # - name: 4. Apache2-service + # service: + # name: apache2 + # state: restarted - # # - name: 2. Un-Install git - # # apt: - # # name: git - # # state: present + # # # - name: 2. Un-Install git + # # # apt: + # # # name: git + # # # state: present \ No newline at end of file diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_1 b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_1 new file mode 100644 index 0000000..f2c413c --- /dev/null +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_1 @@ -0,0 +1 @@ +{"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": true, "cmd": "apt update -y", "delta": "0:00:02.166809", "end": "2024-01-20 07:28:54.068907", "msg": "", "rc": 0, "start": "2024-01-20 07:28:51.902098", "stderr": "\nWARNING: apt does not have a stable CLI interface. Use with caution in scripts.", "stderr_lines": ["", "WARNING: apt does not have a stable CLI interface. Use with caution in scripts."], "stdout": "Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease\nHit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease\nHit:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease\nHit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease\nReading package lists...\nBuilding dependency tree...\nReading state information...\n168 packages can be upgraded. Run 'apt list --upgradable' to see them.", "stdout_lines": ["Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease", "Hit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease", "Hit:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease", "Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease", "Reading package lists...", "Building dependency tree...", "Reading state information...", "168 packages can be upgraded. Run 'apt list --upgradable' to see them."]} \ No newline at end of file diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_2 b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_2 new file mode 100644 index 0000000..46b4678 --- /dev/null +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_2 @@ -0,0 +1 @@ +{"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": true, "cmd": "apt update -y", "delta": "0:00:02.238591", "end": "2024-01-20 07:28:54.160319", "msg": "", "rc": 0, "start": "2024-01-20 07:28:51.921728", "stderr": "\nWARNING: apt does not have a stable CLI interface. Use with caution in scripts.", "stderr_lines": ["", "WARNING: apt does not have a stable CLI interface. Use with caution in scripts."], "stdout": "Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease\nHit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease\nHit:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease\nHit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease\nReading package lists...\nBuilding dependency tree...\nReading state information...\n168 packages can be upgraded. Run 'apt list --upgradable' to see them.", "stdout_lines": ["Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease", "Hit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease", "Hit:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease", "Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease", "Reading package lists...", "Building dependency tree...", "Reading state information...", "168 packages can be upgraded. Run 'apt list --upgradable' to see them."]} \ No newline at end of file diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_3 b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_3 new file mode 100644 index 0000000..fbf4eae --- /dev/null +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/rue/my_server_3 @@ -0,0 +1 @@ +{"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": true, "cmd": "apt update -y", "delta": "0:00:02.234414", "end": "2024-01-20 07:28:54.111227", "msg": "", "rc": 0, "start": "2024-01-20 07:28:51.876813", "stderr": "\nWARNING: apt does not have a stable CLI interface. Use with caution in scripts.", "stderr_lines": ["", "WARNING: apt does not have a stable CLI interface. Use with caution in scripts."], "stdout": "Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease\nHit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease\nHit:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease\nHit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease\nReading package lists...\nBuilding dependency tree...\nReading state information...\n168 packages can be upgraded. Run 'apt list --upgradable' to see them.", "stdout_lines": ["Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease", "Hit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease", "Hit:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease", "Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease", "Reading package lists...", "Building dependency tree...", "Reading state information...", "168 packages can be upgraded. Run 'apt list --upgradable' to see them."]} \ No newline at end of file diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf b/6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf index 9b3bfe6..2441861 100644 --- a/6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf @@ -1,6 +1,6 @@ provider "aws" { - access_key = "" - secret_key = "" + access_key = "AKIAQ7ZCMYMXWIQ45EDI" + secret_key = "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" token = "" region = "us-east-1" } \ No newline at end of file diff --git a/6-ansible-terraform/wordpress/README.md b/6-ansible-terraform/wordpress/README.md index ce902c9..0803bd6 100644 --- a/6-ansible-terraform/wordpress/README.md +++ b/6-ansible-terraform/wordpress/README.md @@ -20,6 +20,99 @@ The goal of this project is to provide an example of how to use Ansible to setup 3. Update the `aws_linux_vm` variable in the playbook with the IP address or hostname of your EC2 instance. 4. Run the playbook: `ansible-playbook playbook.yml` +--- + + +# Setting up WordPress on an Amazon Linux Instance + +This guide provides a simplified overview of setting up WordPress on an Amazon Linux instance. **It assumes familiarity with the command line and AWS services.** + +**## Steps:** + +1. **Launch an Amazon Linux EC2 Instance:** + - Log into your AWS account. + - Launch an Amazon Linux EC2 instance. + - Ensure security groups allow HTTP (port 80) and SSH (port 22) access. + +2. **Connect to Your Instance:** + - Use SSH to connect to your instance: + ```bash + ssh -i /path/to/your-key.pem ec2-user@your-instance-public-dns + ``` + +3. **Update Your Instance:** + - Once connected, update your instance: + ```bash + sudo yum update -y + ``` + +4. **Install Apache Web Server:** + - Install and start Apache: + ```bash + sudo yum install httpd -y + sudo systemctl start httpd.service + sudo systemctl enable httpd.service + ``` + +5. **Install MySQL (MariaDB):** + - Install the MariaDB server: + ```bash + sudo yum install mariadb-server mariadb -y + sudo systemctl start mariadb + sudo mysql_secure_installation + sudo systemctl enable mariadb.service + ``` + +6. **Create a WordPress Database and User:** + - Log into the MariaDB shell and create a database and user: + ```sql + mysql -u root -p + CREATE DATABASE wordpress; + GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password'; + FLUSH PRIVILEGES; + EXIT; + ``` + +7. **Install PHP:** + - Install PHP and necessary extensions: + ```bash + sudo yum install php php-mysql php-gd php-pear -y + sudo systemctl restart httpd.service + ``` + +8. **Download and Install WordPress:** + - Download and configure WordPress: + ```bash + wget [https://wordpress.org/latest.tar.gz](https://wordpress.org/latest.tar.gz) + tar -xzf latest.tar.gz + sudo rsync -avP ~/wordpress/ /var/www/html/ + mkdir /var/www/html/wp-content/uploads + sudo chown -R apache:apache /var/www/html/* + ``` + +9. **Configure WordPress:** + - Navigate to the `/var/www/html` directory. + - Rename and edit the WordPress configuration file: + ```bash + cd /var/www/html + mv wp-config-sample.php wp-config.php + sudo nano wp-config.php + ``` + - Update the database settings. + +10. **Complete Installation Through the Web Interface:** + - Access your server's domain or IP address in a web browser. + - Complete the WordPress installation through the web interface. + +**## Additional Considerations:** + +- **HTTPS:** Set up HTTPS for secure communication. +- **Virtual Hosts:** Configure virtual hosts to manage multiple websites. +- **Server Optimization:** Optimize server performance for WordPress. +- **WordPress Security:** Secure your WordPress installation. + + + ## Conclusion This project provides a starting point for automating the setup of WordPress sites using Ansible and AWS. It can be extended or modified to suit your specific needs. This project is for demonstration purposes and should not be used as-is for production environments. From 115ac1557b373c80bd604945afea82920f48e34b Mon Sep 17 00:00:00 2001 From: varun <v@gmail.com> Date: Sun, 21 Jan 2024 04:11:27 +0000 Subject: [PATCH 115/135] adding history --- ansible-cmd-history.txt | 147 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 ansible-cmd-history.txt diff --git a/ansible-cmd-history.txt b/ansible-cmd-history.txt new file mode 100644 index 0000000..074a595 --- /dev/null +++ b/ansible-cmd-history.txt @@ -0,0 +1,147 @@ +ll +git clone +git clone git@github.com:manikcloud/DevOps-Tutorial.git +ssh-keygen +cat ~/.ssh/id_rsa.pub +git clone git@github.com:manikcloud/DevOps-Tutorial.git +ll +cd DevOps-Tutorial/ +code . +cd DevOps-Tutorial/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ +ansible-playbook ping.yaml +ansible all -m shell -a "apt upda +ansible all -m shell -a "apt update -y" become true +ansible all -m shell -a "apt update -y" +ansible all -m shell -a "apt update -y" -b=yes +ansible all -m shell -a "apt update -y" -b true +ansible all -m shell -a "apt update -y" -b=true +ansible-playbook ping.yaml +code +ll +cd DevOps-Tutorial/ +ls +mv 6-ansible 6-ansible-terraform +ll +cd 6-ansible-terraform/ +ls +mkdir 6.6.1-tf-local-file +cd 6.6.1-tf-local-file/ +terraform +terraform -version +vim main.tf +terraform init +cleaf +terraform plan +terraform apply +ll +cat index.html +git add . && git commit-am"adding tf local" +git add . && git commit -am"adding tf local" +git push +resource "local_file" "foo" { +git push +cd .. +git add . && git commit -am"adding tf local" && git push +git config --global user.name "varun" +git add . && git commit -am"adding tf local" && git push +ll +ansible +ansible --version +ansible -m ping localhost +ansible -m ping localhost -v +ansible -m ping localhost -vv +ansible -m ping localhost -vvv +ansible -m ping localhost -vvvv +cd 6-ansible-terraform/6.8-tf-ec2-provisioning/ +ll +cd .. +ll +ls +cd 6.8-tf-ec2-provisioning/ +ls +ansible all -i '3.87.250.203,' -m ping -u ubuntu --private-key ../deployer +ansible all -i '3.87.250.203,' -m ping -u ubuntu --private-key deployer +chmod 400 deployer +ansible all -i '3.87.250.203,' -m ping -u ubuntu --private-key deployer +ansible all -i '3.87.250.203,' -m ping -u ubuntu --private-key deployer -v +ansible all -i '3.87.250.203,' -m ping -u ubuntu --private-key deployer -vv +ansible all -i '3.87.250.203,' -m ping -u ubuntu --private-key deployer -vvvv +ansible all -i '3.87.250.203, 54.198.128.135, 107.22.117.179' -m ping -u ubuntu --private-key deployer +ansible all -i ' 54.198.128.135' -m ping -u ubuntu --private-key deployer +ls +ansible all -i '54.198.128.135' -m ping -u ubuntu --private-key deployer +vim ~/.ssh/known_hosts +ansible all -i '54.198.128.135' -m ping -u ubuntu --private-key deployer +ansible all -i '3.87.250.203,' -m ping -u ubuntu --private-key deployer +ansible all -i '54.198.128.135,' -m ping -u ubuntu --private-key deployer +ansible all -i '107.22.117.179,' -m ping -u ubuntu --private-key deployer +ll +cd ansible/ +ll +cd .. +ansible all -i ansible/inventory.ini -m ping +cd - +ll +ansible all -i inventory.ini -m ping +ansible all -i inventory.ini -m shell -a "la -l" +ansible all -i inventory.ini -m shell -a "ls -l" +ansible all -i inventory.ini -m shell -a "pwd" +ansible all -i inventory.ini -m shell -a "touch index.txt" +ansible all -i inventory.ini -m shell -a "ls -l" +ansible -m ping localhost -v +ansible -m ping localhost -vv +cd ../../.. +ansible -m ping localhost -vv +vim /etc/ansible/ansible.cfg +cd - +ansible all -m shell -a "ls -l" +ansible all -m shell -a "rm -rf index.txt" +ansible all -m shell -a "ls -l" +ansible all -m setup +ll +ansible-playbook ping.yaml +ansible all -m shell -a "ls -l" +ansible-playbook ping.yaml +ansible-doc -l +ansible-doc apt +q q +ansible-doc aptans +cd 6-ansible-terraform/6.8-tf-ec2-provisioning/ +terraform plan +terraform apply +terraform output +cd 6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/ +ll +terraform ini +terraform init +terraform plan +terraform apply +terraform plan +terraform apply +terraform plan +terraform apply +cd .. +git add . +git commit -am "adding creds" +git push +ll +cd 6-ansible-terraform/ +ll +cd 6.8-tf-ec2-provisioning/ +ll +cd .. +cd - +terraform init +terraform plan +terraform apply +terraform plan +terraform apply +terraform destroy +git push +cd .. +git add . +git commit -am"adding cred.tf" +git push +cd DevOps-Tutorial/ +code . +history | cut -c 8- > ansible-cmd-history.txt From 9ae76e9f7d30c2ec0f9a181270e304e29b0fea88 Mon Sep 17 00:00:00 2001 From: varun <v@gmail.com> Date: Sun, 21 Jan 2024 05:09:27 +0000 Subject: [PATCH 116/135] adding changes --- .../ansible/inventory.ini | 22 ++++++++++-- .../6.8-tf-ec2-provisioning/ansible/ping.yaml | 35 ------------------- .../6.8-tf-ec2-provisioning/creds.tf | 4 +-- 3 files changed, 21 insertions(+), 40 deletions(-) delete mode 100644 6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ping.yaml diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini index fd3f990..16e9fff 100644 --- a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini @@ -1,8 +1,9 @@ [ubuntu_vm] -my_server_1 ansible_host=3.87.250.203 -my_server_2 ansible_host=54.198.128.135 -my_server_3 ansible_host=107.22.117.179 +my_server_1 ansible_host=54.224.173.170 +my_server_2 ansible_host=54.166.216.181 +my_server_3 ansible_host=50.16.161.255 + [ubuntu:children] ubuntu_vm @@ -11,3 +12,18 @@ ubuntu_vm ansible_user=ubuntu ansible_ssh_private_key_file=../deployer + + +[aws_linux_vm] +# aws_linux ansible_host=54.210.170.163 +aws_linux ansible_host=54.161.95.81 +# aws_linux ansible_host=34.207.226.250 + + + +[aws:children] +aws_linux_vm + +[aws:vars] +ansible_user=ec2-user +ansible_ssh_private_key_file=../deployer diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ping.yaml b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ping.yaml deleted file mode 100644 index 0bcf0e0..0000000 --- a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/ping.yaml +++ /dev/null @@ -1,35 +0,0 @@ ---- - -- name: This is a simple Playbook. - hosts: ubuntu_vm - become: true - gather_facts: yes - - tasks: - - name: 1. Ping the remote server - ping: - - - # - name: 2. Create index file - # file: - # path: /home/ubuntu/index.html - # state: touch - - - name: 3. Nginx - apt: - name: nginx - state: present - - - # - name: 4. Apache2-service - # service: - # name: apache2 - # state: restarted - - # # # - name: 2. Un-Install git - # # # apt: - # # # name: git - # # # state: present - - - \ No newline at end of file diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf b/6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf index 2441861..9d4d164 100644 --- a/6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/creds.tf @@ -1,6 +1,6 @@ provider "aws" { - access_key = "AKIAQ7ZCMYMXWIQ45EDI" - secret_key = "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" + access_key = "AKIAQ7ZCMYMXTD7Q2FOK" + secret_key = "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" token = "" region = "us-east-1" } \ No newline at end of file From 722604a9748713f4598bc59df07ac1c7d4842c5c Mon Sep 17 00:00:00 2001 From: varun <v@gmail.com> Date: Sun, 21 Jan 2024 05:11:22 +0000 Subject: [PATCH 117/135] adding changes --- .../6.8-tf-ec2-provisioning/ansible/inventory.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini index 16e9fff..2f2a14f 100644 --- a/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini +++ b/6-ansible-terraform/6.8-tf-ec2-provisioning/ansible/inventory.ini @@ -19,7 +19,7 @@ ansible_ssh_private_key_file=../deployer aws_linux ansible_host=54.161.95.81 # aws_linux ansible_host=34.207.226.250 - + [aws:children] aws_linux_vm From c7877c91702800c3929ea750dc962b13ad328250 Mon Sep 17 00:00:00 2001 From: varun <v@gmail.com> Date: Sun, 21 Jan 2024 06:02:22 +0000 Subject: [PATCH 118/135] roles changes --- 6-ansible-terraform/6.5-ansible-role/demor-role.yml | 4 ++-- 6-ansible-terraform/6.5-ansible-role/demor/meta/main.yml | 4 ++-- 6-ansible-terraform/6.5-ansible-role/inventory.ini | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/6-ansible-terraform/6.5-ansible-role/demor-role.yml b/6-ansible-terraform/6.5-ansible-role/demor-role.yml index 78bb297..b42b276 100644 --- a/6-ansible-terraform/6.5-ansible-role/demor-role.yml +++ b/6-ansible-terraform/6.5-ansible-role/demor-role.yml @@ -2,8 +2,8 @@ --- - name: use demor role playbook - hosts: my_server - user: ansible + hosts: localhost + user: ubuntu become: true roles: diff --git a/6-ansible-terraform/6.5-ansible-role/demor/meta/main.yml b/6-ansible-terraform/6.5-ansible-role/demor/meta/main.yml index c572acc..0dbdfb9 100644 --- a/6-ansible-terraform/6.5-ansible-role/demor/meta/main.yml +++ b/6-ansible-terraform/6.5-ansible-role/demor/meta/main.yml @@ -1,6 +1,6 @@ galaxy_info: - author: your name - description: your role description + author: Varun + description: Cloud Engineer company: your company (optional) # If the issue tracker for your role is not on github, uncomment the diff --git a/6-ansible-terraform/6.5-ansible-role/inventory.ini b/6-ansible-terraform/6.5-ansible-role/inventory.ini index 83727e2..4dbc68f 100644 --- a/6-ansible-terraform/6.5-ansible-role/inventory.ini +++ b/6-ansible-terraform/6.5-ansible-role/inventory.ini @@ -1,4 +1,3 @@ [my_servers] -my_server ansible_host=18.209.59.137 - -#ansible all -i '18.209.59.137,' --private-key=path/to/deployer -m ping \ No newline at end of file +my_server ansible_host=localhost +# my_server ansible_host=54.224.173.170 From 8bc50837ed25e363b6553880917d765045815ac6 Mon Sep 17 00:00:00 2001 From: varun <v@gmail.com> Date: Sat, 27 Jan 2024 06:16:44 +0000 Subject: [PATCH 119/135] adding docker file --- 7-docker/Dockerfile | 10 +++++++--- 7-docker/index.html | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/7-docker/Dockerfile b/7-docker/Dockerfile index 3331d7b..b4723a1 100644 --- a/7-docker/Dockerfile +++ b/7-docker/Dockerfile @@ -1,11 +1,15 @@ # Use Ubuntu as a base image -FROM ubuntu +FROM ubuntu:22.04 # Update and install nginx -RUN apt-get update && apt-get install -y nginx +RUN apt-get update + +RUN apt-get install -y nginx # Copy the custom index file to the nginx directory -COPY index.nginx-debian.html /var/www/html +COPY index.html /var/www/html + +EXPOSE 80 # Start nginx in the foreground to keep the container running CMD ["nginx", "-g", "daemon off;"] diff --git a/7-docker/index.html b/7-docker/index.html index 6d580ec..e0cf6b2 100644 --- a/7-docker/index.html +++ b/7-docker/index.html @@ -3,7 +3,8 @@ <body> <h1>My First Heading</h1> -<p>My first paragraph.</p> +<p style="color:Green;">Lorem ipsum...</p> +<p>This is DevOps class. </p> </body> -</html> \ No newline at end of file +</html> From b668c4a03739b929b20a6d9da0d34e45ecef68ab Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 28 Jan 2024 10:09:56 +0800 Subject: [PATCH 120/135] adding readme and k8s files --- 7-docker/README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/7-docker/README.md b/7-docker/README.md index 0acced9..13d7062 100644 --- a/7-docker/README.md +++ b/7-docker/README.md @@ -1,5 +1,5 @@ # Docker - +- [# Docekr basic commands & their flags](#Docekr-basic-commands-their-flags) - [Lesson 7 Demo 2: Performing CRUD Operation on Containers](#lesson-7-demo-2) - [Step 1: Pulling a Docker image](#step-1-pulling-a-docker-image) - [Step 2: Creating a new container](#step-2-creating-a-new-container) @@ -23,6 +23,26 @@ - [Step 3: Connecting the network from another SSH server](#step-3-connecting-the-network-from-another-ssh-server) + +# Docekr basic commands their flags + +| Command | Description | Flags/Options | +|---------|-------------|---------------| +| `docker run` | Run a new container | `-d` (detached), `-p` (port mapping), `--name` (name of the container), `-e` (environment variables) | +| `docker ps` | List running containers | `-a` (all containers), `--format` (format output) | +| `docker stop` | Stop a running container | `<container_id/name>` (ID or name of the container) | +| `docker rm` | Remove a container | `-f` (force), `<container_id/name>` | +| `docker images` | List Docker images | `-a` (all images), `--format` (format output) | +| `docker rmi` | Remove a Docker image | `<image_id/name>` (ID or name of the image), `-f` (force) | +| `docker build` | Build an image from a Dockerfile | `-t` (tag/name of the image), `<path_to_Dockerfile>` | +| `docker pull` | Pull an image from a registry | `<image_name>` (name of the image) | +| `docker push` | Push an image to a registry | `<image_name>` (name of the image) | +| `docker exec` | Execute a command in a running container | `-it` (interactive terminal), `<container_id/name>` (ID or name of the container), `<command>` (command to execute) | +| `docker logs` | Fetch the logs of a container | `<container_id/name>` (ID or name of the container), `--tail` (number of lines to show) | +| `docker network` | Manage Docker networks | `create`, `inspect`, `ls`, `rm` (subcommands for network management) | +| `docker volume` | Manage Docker volumes | `create`, `inspect`, `ls`, `rm` (subcommands for volume management) | + + # Lesson 7 Demo 2 Performing CRUD Operation on Containers From 4661fd0bde61104fcb4b16fcb0c7997724ff28a8 Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 28 Jan 2024 10:11:50 +0800 Subject: [PATCH 121/135] adding readme and k8s files --- .../6.7-S3-Bucket-Using-Terraform/creds.tf | 9 --------- 1 file changed, 9 deletions(-) diff --git a/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf index 05f34e5..9b3bfe6 100644 --- a/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf +++ b/6-ansible-terraform/6.7-S3-Bucket-Using-Terraform/creds.tf @@ -1,12 +1,3 @@ -Access key -Secret access key - -AKIAQ7ZCMYMX5SZC6CEZ - -KkrdjS9rbQRAYuROhVsE26pH7/d3+qg7TOzkHXZA -Hide - - provider "aws" { access_key = "" secret_key = "" From fe435ab97bb50ee67fba0bd2ee709fed7ecf5248 Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 28 Jan 2024 10:13:16 +0800 Subject: [PATCH 122/135] adding readme and k8s files --- 8-k8s/Installation/cleanup-k8s-docker.sh | 32 ++++++++++++++ 8-k8s/Installation/setup-k8s.sh | 55 ++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 8-k8s/Installation/cleanup-k8s-docker.sh create mode 100644 8-k8s/Installation/setup-k8s.sh diff --git a/8-k8s/Installation/cleanup-k8s-docker.sh b/8-k8s/Installation/cleanup-k8s-docker.sh new file mode 100644 index 0000000..89f1740 --- /dev/null +++ b/8-k8s/Installation/cleanup-k8s-docker.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +echo "Kube Admin Reset" +sudo kubeadm reset -f + +echo "Remove all packages related to Kubernetes" +sudo apt remove -y kubeadm kubectl kubelet kubernetes-cni +sudo apt purge -y kube* + +echo "Remove Docker images (optional if using Docker)" +# Note: Docker doesn't support '-y' for automatic yes to prompts in 'docker image prune'. +# You can use 'yes | command' to auto-confirm, but be cautious with this approach. +sudo docker image prune -a + +echo "Removing Docker and its associated packages..." +sudo apt-get remove docker docker-engine docker.io containerd runc -y + +echo "Removing any residual packages and dependencies..." +sudo apt-get autoremove -y + +echo "Cleaning up Docker's system files..." +sudo rm -rf /var/lib/docker +sudo rm -rf /var/lib/containerd + +echo "Cleaning up Kubernetes configuration files..." +sudo rm -rf /etc/kubernetes/ +sudo rm -rf $HOME/.kube/ + +echo "Removing additional Kubernetes and etcd related files and directories..." +sudo rm -rf /etc/cni /var/lib/dockershim /var/lib/etcd /var/lib/kubelet /var/run/kubernetes + +echo "Cleanup complete." diff --git a/8-k8s/Installation/setup-k8s.sh b/8-k8s/Installation/setup-k8s.sh new file mode 100644 index 0000000..0c37199 --- /dev/null +++ b/8-k8s/Installation/setup-k8s.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +echo "Updating and upgrading the package index..." +sleep 2 +sudo apt update + +echo "Installing necessary packages for transport over HTTPS..." +sleep 2 +sudo apt-get install -y apt-transport-https ca-certificates curl + +echo "Installing Docker..." +sleep 2 +sudo apt install docker.io -y + +echo "Starting Docker and enabling it to run on boot..." +sleep 2 +sudo systemctl start docker +sudo systemctl enable docker + +echo "Adding the Kubernetes signing key..." +sleep 2 +curl -fsSL "https://packages.cloud.google.com/apt/doc/apt-key.gpg" | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/kubernetes-archive-keyring.gpg + +echo "Adding the Kubernetes APT repository..." +sleep 2 +echo 'deb https://packages.cloud.google.com/apt kubernetes-xenial main' | sudo tee /etc/apt/sources.list.d/kubernetes.list + +echo "Updating the package index after adding Kubernetes repository..." +sleep 2 +sudo apt update + +echo "Installing Kubernetes components (kubeadm, kubectl, kubelet)..." +sleep 2 +sudo apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y + +echo "Initializing Kubernetes cluster with kubeadm..." +sleep 2 +sudo kubeadm init + +echo "Setting up local kubeconfig..." +sleep 2 +mkdir -p $HOME/.kube +sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config +sudo chown $(id -u):$(id -g) $HOME/.kube/config + +echo "Applying Weave Net CNI plugin..." +sleep 2 +kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml + + +echo "Displaying the status of the nodes in the Kubernetes cluster..." +sleep 2 +kubectl get nodes + +echo "The Kubernetes cluster setup is complete." From f167376ed4192209d0b66fa2ff05218497d88af6 Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 28 Jan 2024 10:19:43 +0800 Subject: [PATCH 123/135] adding readme and k8s files --- 8-k8s/README.md | 224 +++++++++++++++++++++++++ 8-k8s/ReplicaSet/ReplicaSet-sl-ex.yaml | 27 +++ 8-k8s/ReplicaSet/ReplicaSet.yaml | 25 +++ 8-k8s/ReplicaSet/blue-replicaset.yaml | 25 +++ 8-k8s/ReplicaSet/green-replicaset.yaml | 25 +++ 8-k8s/deployment/bg-deployment.yaml | 25 +++ 8-k8s/deployment/deployment.yaml | 26 +++ 8-k8s/pods/blue-pod.yaml | 14 ++ 8-k8s/pods/database.yaml | 17 ++ 8-k8s/pods/green-pod.yaml | 14 ++ 8-k8s/pods/multi-container.yaml | 28 ++++ 8-k8s/pods/my-pod.yml | 13 ++ 8-k8s/pods/pod-def.yaml | 12 ++ 8-k8s/pods/web-container.yaml | 17 ++ 8-k8s/resources/pods.yaml | 14 ++ 15 files changed, 506 insertions(+) create mode 100644 8-k8s/ReplicaSet/ReplicaSet-sl-ex.yaml create mode 100644 8-k8s/ReplicaSet/ReplicaSet.yaml create mode 100644 8-k8s/ReplicaSet/blue-replicaset.yaml create mode 100644 8-k8s/ReplicaSet/green-replicaset.yaml create mode 100644 8-k8s/deployment/bg-deployment.yaml create mode 100644 8-k8s/deployment/deployment.yaml create mode 100644 8-k8s/pods/blue-pod.yaml create mode 100644 8-k8s/pods/database.yaml create mode 100644 8-k8s/pods/green-pod.yaml create mode 100644 8-k8s/pods/multi-container.yaml create mode 100644 8-k8s/pods/my-pod.yml create mode 100644 8-k8s/pods/pod-def.yaml create mode 100644 8-k8s/pods/web-container.yaml create mode 100644 8-k8s/resources/pods.yaml diff --git a/8-k8s/README.md b/8-k8s/README.md index ba18135..da6802a 100644 --- a/8-k8s/README.md +++ b/8-k8s/README.md @@ -230,6 +230,230 @@ sudo kubectl get pods ``` +# kubectl commands + +``` +kubectl get namespace + +kubeadm token list +kubectl get namespaces + +kubectl get replicationcontroller,services +kubectl get pods -n kube-public +kubectl get pods -n kube-system +kubectl get pods --all-namespaces + +kubectl run nginx --image=nginx +kubectl get pods --all-namespaces + +kubectl get pods +kubectl get pods -o wide +kubectl describe pod nginx +kubectl get pods +kubectl run nginx --image=httpd +kubectl run httpd --image=httpd +kubectl get pods + +service docker status +sudo kubectl get nodes + +``` +# Pod Creation in Kubernetes + +- Steps to be followed: +1. Creating multi-container pods +2. Creating a single container pod + +## Step 1: Creating multi-container pods +- 1.1 On the master node, create a new file named sample.yaml: +``` +sudo su +vi sample.yaml +1.2 Add the following code in the multi-container.yaml file: +https://github.com/manikcloud/k8s/blob/main/pods/multi-container.yaml +``` + +- 1.3 Use the following command to create the multi-container pod: +``` +kubectl create -f sample.yaml + ``` + +## Step 2: Creating a single container pod +- 2.1 On the master node, create a single container pod with a tomcat image using the following command: +``` +kubectl run tomcat --image=tomcat:8.0 + ``` + +- 2.2 Check all the running pods +``` +kubectl get pods +``` +- 2.3 To check why exactly a pod is in the pending state, run the command +-- kubectl describe pods <pod_name> +- To check why multi-container pod is pending,use the command +``` +kubectl describe pods multi-container +``` + + +## 2.4 To remove the taint from the node run the following commands: +``` +kubectl get nodes +``` +- Copy the node name and use it in the below command +- kubectl taint nodes <node name> node-role.kubernetes.io/master- + +### Here for example we use the command given below +``` +kubectl taint nodes ip-172-31-17-206 node-role.kubernetes.io/master- + ``` +-- 2.5 Now check the pod status. The pods should be in the running state. +``` +sudo kubectl get pods + +``` + +# Dashboard Creation in Kubernetes + +``` +kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.1/aio/deploy/recommended.yaml + +kubectl proxy + +http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/ + +kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | awk '/^deployment-controller-token-/{print $1}') | awk '$1=="token:"{print $2}' + +kubectl -n kube-system describe secret $( + kubectl -n kube-system get secret | \ + awk '/^deployment-controller-token-/{print $1}' +) | \ +awk '$1=="token:"{print $2}' + +``` +## After executing the above commands, there are 4 distinct commands and they get called in this order: + +- Line 1 - This is the second command from @silverfox's Token section. +- Line 2 - This is the first command from @silverfox's Token section. +- Line 3 - Print only the first field of the line beginning with deployment-controller-token- (which is the pod name) +- Line 5 - Print only the second field of the line whose first field is "token:" + +# ReplicaSet commands in K8S + +``` + +kubectl apply -f ReplicaSet/ReplicaSet.yaml +kubectl get pods +kubectl get replicaset +kubectl delete pod sl-replicaset-hnd76 +kubectl descr +kubectl apply -f pods/pod-def.yaml +kubectl get pods +kubectl apply -f pods/pod-def.yaml +kubectl get pods +kubectl get replicaset sl-replicaset +kubectl edit replicaset sl-replicaset +kubectl get replicaset sl-replicaset +kubectl scale replicaset sl-replicaset --replicas=2 +kubectl get replicaset sl-replicaset + +kubectl get replicaset sl-replicaset +``` +# Deployment commands in K8S +``` +kubectl create -f deployment/deployment.yaml +kubectl get pods -o wide + +kubectl get deployment +kubectl get deployment -o wide +kubectl describe deployment +kubectl create -f deployment/deployment.yaml +kubectl get pods -o wide +kubectl rollout history deployment/web-app-deployment +kubectl delete deployment web-app-deployment +kubectl get pods -o wide +kubectl create -f deployment/deployment.yaml --record +kubectl rollout history deployment/web-app-deployment +kubectl edit deployment web-app-deployment --record +kubectl rollout history deployment/web-app-deployment +kubectl rollout status deployment/web-app-deployment +kubectl get pods -o wide +kubectl describe deployment web-app-deployment +kubectl rollout status deployment/web-app-deployment +kubectl set image deployment web-app-deployment blue=varunmanik/httpd:v1-blue --record +kubectl get pods -o wide +kubectl rollout history deployment web-app-deployment +``` +# scaling commands in K8S +``` +kubectl scale deployment web-app-deployment --replicas=6 +``` + +# Roll Out +``` +kubectl rollout undo deployment/web-app-deployment --to-revision=3 +kubectl rollout history deployment web-app-deployment +``` + +# Docker testing in you K8S setup +``` +docker build -t varunmanik/httpd:green . +docker run -itd -p 9000:80 varunmanik/httpd:green +docker build -t varunmanik/httpd:blue . +docker run -itd -p 9001:80 varunmanik/httpd:blue +kubectl describe pod green-app | grep -i "IP:" +``` + +# Services commands in K8S + +``` +kubectl create -f services/service-def.yaml +kubectl describe svc web-app-service +kubectl get svc,pods -o wide +kubectl delete service web-app-service +kubectl get svc,pods -o wide +kubectl scale deployment/blue-green-deployment --replicas=1 +kubectl get svc,pods -o wide +kubectl get svc,pods,deployment -o wide + +``` + + +# Cleanup the entire setup + +- Run this command to cleanup +``` +sh installation/cleanup.sh +``` +- OR copy and paste below commands one by one. + +``` +docker ps +kubeadm reset -f +rm -rf /etc/cni /etc/kubernetes /var/lib/dockershim /var/lib/etcd /var/lib/kubelet /var/run/kubernetes ~/.kube/* +v +apt remove -y kubeadm kubectl kubelet kubernetes-cni +sudo apt-get purge kubeadm kubectl kubelet kubernetes-cni kube* +sudo apt-get autoremove +sudo rm -rf ~/.kube +docker ps +system restart docker +systemctl restart docker +``` + +# Check your history from below command + +``` +history | cut -c 8- > history.txt +``` + +# References +1. https://kubernetes.io/ +2. https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/ +3. https://kubernetes.io/docs/concepts/workloads/pods/ +4. https://etcd.io/ +5. https://kubernetes.io/docs/reference/kubectl/ +6. https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/ diff --git a/8-k8s/ReplicaSet/ReplicaSet-sl-ex.yaml b/8-k8s/ReplicaSet/ReplicaSet-sl-ex.yaml new file mode 100644 index 0000000..8cfcc36 --- /dev/null +++ b/8-k8s/ReplicaSet/ReplicaSet-sl-ex.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 + + + +kind: Pod + + + + + +metadata: + + name: web-pod + + labels: + + application: web-app3 + +spec: + + containers: + + - name: google-ex + + image: gcr.io/google_samples/gb-frontend:v3 + + diff --git a/8-k8s/ReplicaSet/ReplicaSet.yaml b/8-k8s/ReplicaSet/ReplicaSet.yaml new file mode 100644 index 0000000..73ae3cc --- /dev/null +++ b/8-k8s/ReplicaSet/ReplicaSet.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 + +kind: ReplicaSet + +metadata: + name: sl-replicaset + labels: + application: web-app + +spec: + selector: + matchLabels: + application: web-app + replicas: 20 + template: + metadata: + name: web2 + labels: + application: web-app + env: dev + + spec: + containers: + - name: httpd + image: varunmanik/httpd:alpine diff --git a/8-k8s/ReplicaSet/blue-replicaset.yaml b/8-k8s/ReplicaSet/blue-replicaset.yaml new file mode 100644 index 0000000..d4cbe1e --- /dev/null +++ b/8-k8s/ReplicaSet/blue-replicaset.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 + +kind: ReplicaSet + +metadata: + name: blue-replicaset + labels: + application: web-app + +spec: + template: + metadata: + name: blue-app + labels: + env: dev + application: web-app + color: blue + spec: + containers: + - name: httpd + image: varunmanik/httpd:blue + selector: + matchLabels: + color: blue + replicas: 5 \ No newline at end of file diff --git a/8-k8s/ReplicaSet/green-replicaset.yaml b/8-k8s/ReplicaSet/green-replicaset.yaml new file mode 100644 index 0000000..a358d39 --- /dev/null +++ b/8-k8s/ReplicaSet/green-replicaset.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 + +kind: ReplicaSet + +metadata: + name: green-replicaset + labels: + application: web-app + +spec: + template: + metadata: + name: green-app + labels: + env: dev + application: web-app + color: green + spec: + containers: + - name: httpd + image: varunmanik/httpd:green + selector: + matchLabels: + color: green + replicas: 5 \ No newline at end of file diff --git a/8-k8s/deployment/bg-deployment.yaml b/8-k8s/deployment/bg-deployment.yaml new file mode 100644 index 0000000..af8b2e6 --- /dev/null +++ b/8-k8s/deployment/bg-deployment.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 + +kind: Deployment + +metadata: + name: blue-green-deployment + labels: + application: web-app + +spec: + template: + metadata: + name: blue-app + labels: + application: web-app + env: dev + color: blue + spec: + containers: + - name: httpd + image: varunmanik/httpd:green + selector: + matchLabels: + application: web-app + replicas: 3 \ No newline at end of file diff --git a/8-k8s/deployment/deployment.yaml b/8-k8s/deployment/deployment.yaml new file mode 100644 index 0000000..92609e5 --- /dev/null +++ b/8-k8s/deployment/deployment.yaml @@ -0,0 +1,26 @@ +apiVersion: apps/v1 + +kind: Deployment + +metadata: + name: web-app-deployment + labels: + application: web-app + +spec: + selector: + matchLabels: + application: web-app + replicas: 3 + template: + metadata: + name: web2 + labels: + application: web-app + env: dev + color: blue + + spec: + containers: + - name: blue + image: varunmanik/httpd:v1-blue diff --git a/8-k8s/pods/blue-pod.yaml b/8-k8s/pods/blue-pod.yaml new file mode 100644 index 0000000..1334765 --- /dev/null +++ b/8-k8s/pods/blue-pod.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 + +kind: Pod +metadata: + name: blue-app + labels: + env: dev + application: web-app + color: blue + +spec: + containers: + - name: httpd + image: varunmanik/httpd:blue \ No newline at end of file diff --git a/8-k8s/pods/database.yaml b/8-k8s/pods/database.yaml new file mode 100644 index 0000000..693382f --- /dev/null +++ b/8-k8s/pods/database.yaml @@ -0,0 +1,17 @@ +apiVersion:vi + +kind: Pod + +metadata: + name : postgress-database + labels: + tier: db-tier + +spec: + containers: + - name: postgres + image: postgres + env: + - name: db_pass + value: 123456 + diff --git a/8-k8s/pods/green-pod.yaml b/8-k8s/pods/green-pod.yaml new file mode 100644 index 0000000..dec9cac --- /dev/null +++ b/8-k8s/pods/green-pod.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 + +kind: Pod +metadata: + name: green-app + labels: + env: dev + application: web-app + color: green + +spec: + containers: + - name: httpd + image: varunmanik/httpd:green \ No newline at end of file diff --git a/8-k8s/pods/multi-container.yaml b/8-k8s/pods/multi-container.yaml new file mode 100644 index 0000000..35ca890 --- /dev/null +++ b/8-k8s/pods/multi-container.yaml @@ -0,0 +1,28 @@ +apiVersion: v1 + +kind: Pod + +metadata: + name: mulit-container + labels: + env: dev + tier: frontend + + +spec: + containers: + - name: nginx + image: nginx:1.10-alpine + ports: + - containerPort: 80 + - name: alpine + image: alpine:3.5 + command: + - "watch" + - "wget" + - "-qO-" + - "localhost" + + + + diff --git a/8-k8s/pods/my-pod.yml b/8-k8s/pods/my-pod.yml new file mode 100644 index 0000000..b98ba13 --- /dev/null +++ b/8-k8s/pods/my-pod.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Pod +metadata: + name: myapp + labels: + name: myapp +spec: + containers: + - name: myapp + image: varunmanik/httpd:green + + ports: + - containerPort: 80 \ No newline at end of file diff --git a/8-k8s/pods/pod-def.yaml b/8-k8s/pods/pod-def.yaml new file mode 100644 index 0000000..c96cefc --- /dev/null +++ b/8-k8s/pods/pod-def.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 + + +kind: Pod + +metadata: + name: pod-def + +spec: + containers: + - name: web-blue + image: varunmanik/httpd:blue \ No newline at end of file diff --git a/8-k8s/pods/web-container.yaml b/8-k8s/pods/web-container.yaml new file mode 100644 index 0000000..889e233 --- /dev/null +++ b/8-k8s/pods/web-container.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 + +kind: Pod + +metadata: + + name: web-server + +spec: + + containers: + + - name: web-container + + image: httpd + + diff --git a/8-k8s/resources/pods.yaml b/8-k8s/resources/pods.yaml new file mode 100644 index 0000000..3debaa1 --- /dev/null +++ b/8-k8s/resources/pods.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: web-server + labels: + env: dev + acconut: non-prod + +spec: + containers: + - name: nginx-server + image: nginx:alpine + + From d9a6667f66d1a2e3ceadcc3892c4255c6a2d9b45 Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 28 Jan 2024 10:21:17 +0800 Subject: [PATCH 124/135] adding readme and k8s files --- 8-k8s/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/8-k8s/README.md b/8-k8s/README.md index da6802a..82598b5 100644 --- a/8-k8s/README.md +++ b/8-k8s/README.md @@ -227,9 +227,8 @@ kubectl taint nodes ip-172-31-18-183 node-role.kubernetes.io/master- ``` sudo kubectl get pods - ``` - +``` # kubectl commands ``` From 9e0c710e534b4b2f6479d58e5482afa9a0210dd3 Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 28 Jan 2024 12:24:49 +0800 Subject: [PATCH 125/135] adding readme and k8s files --- .../5.11-docker-compose/Dockerfile | 5 + .../5.11-docker-compose/README.md | 348 ++++++++++++++++++ .../5.11-docker-compose/app.py | 13 + .../5.11-docker-compose/requirements.txt | 2 + 4 files changed, 368 insertions(+) create mode 100644 7-docker/Final-project-docker/5.11-docker-compose/Dockerfile create mode 100644 7-docker/Final-project-docker/5.11-docker-compose/README.md create mode 100644 7-docker/Final-project-docker/5.11-docker-compose/app.py create mode 100644 7-docker/Final-project-docker/5.11-docker-compose/requirements.txt diff --git a/7-docker/Final-project-docker/5.11-docker-compose/Dockerfile b/7-docker/Final-project-docker/5.11-docker-compose/Dockerfile new file mode 100644 index 0000000..9ec6968 --- /dev/null +++ b/7-docker/Final-project-docker/5.11-docker-compose/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.4-alpine +ADD . /code +WORKDIR /code +RUN pip install -r requirements.txt +CMD ["python", "app.py"] diff --git a/7-docker/Final-project-docker/5.11-docker-compose/README.md b/7-docker/Final-project-docker/5.11-docker-compose/README.md new file mode 100644 index 0000000..ae09000 --- /dev/null +++ b/7-docker/Final-project-docker/5.11-docker-compose/README.md @@ -0,0 +1,348 @@ +# Lesson 5 Demo 11: Convert an Application Deployment into a Stack + +This section will guide you to: +- Convert an application deployment into a stack using a file named docker-compose.yml + +| Feature | Docker Service | Docker Stack | +|---------|----------------|--------------| +| Definition | A Docker Service is the definition of the tasks to execute on the manager or worker nodes. It is a part of Docker Swarm, Docker's built-in orchestration solution. | A Docker Stack is a group of interrelated services that share dependencies, and can be orchestrated and scaled together. A stack effectively encapsulates a multi-service application. | +| Use Case | Docker Services are ideal for deploying the same image across multiple environments. You can adjust the number of replicas for each service based on the environment's requirements. | Docker Stacks are perfect for defining and managing multi-service applications. Stacks allow you to manage all the services of an application with just one file. | +| Scale | Services can be scaled up or down individually. | All services within a stack are scaled together, maintaining the application's functionality. | +| Command | `docker service create` | `docker stack deploy` | + +### Step 1: Drain the worker nodes in the swarm cluster to make sure the registry service runs on the manager node +- List all the nodes present in the swarm cluster and ensure that all nodes are in Active state + +``` +sudo docker node ls + +``` + + +**Note**: Copy the HOSTNAME of worker nodes +- Use the following command to drain the worker nodes: + +``` +sudo docker node update --availability drain hostname_Worker_Node + +``` + + +**Note**: Replace hostname_Worker_Node with the HOSTNAME copied in previous ### Step + + +### Step 2: Start the registry as a service on your swarm + +``` +sudo docker service create --name registry --publish published=5000,target=5000 registry:2 + + +``` + + +### Step 3: List the running services to check the status of registry service + +``` +sudo docker service ls + +``` + + + +### Step 4: Check if registry service is working with curl + +``` + +curl http://localhost:5000/v2/ + +``` + + + +### Step 5: Create a directory for the project + +``` + +mkdir stackdemo +cd stackdemo + +``` + + + +### Step 6: Create a file called app.py in the stackdemo directory +- Use the following command to create a project file: + +``` + +nano app.py + +``` + + +- Add the following code in the app.py file: + +``` + +from flask import Flask +from redis import Redis + +app = Flask(__name__) +redis = Redis(host='redis', port=6379) + +@app.route('/') +def hello(): + count = redis.incr('hits') + return 'Hello World! I have been seen {} times.\n'.format(count) + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8000, debug=True) + +``` + + +**Note**: Press Ctrl+X to exit the editor. Then type Y and press Enter to save the file. + +### Step 7: Create a file called requirements.txt +- Use the following command to create and open requirements.txt: + +``` + +nano requirements.txt + +``` + + +- Add the following text in the requirements.txt file: + +``` + +flask +redis + +``` + + +**Note**: Press Ctrl+X to exit the editor. Then type Y and press Enter to save the file. + +### Step 8: Create a file called Dockerfile +- Use the following command to create a Dockerfile: + +``` + +nano Dockerfile + +``` + + +- Add the following code in the Dockerfile: + +``` + +FROM python:3.4-alpine +ADD . /code +WORKDIR /code +RUN pip install -r requirements.txt +CMD ["python", "app.py"] + +``` + + +**Note**: Press Ctrl+X to exit the editor. Then type Y and press Enter to save the file. + +### Step 9: Create a file named docker-compose.yml +- Use the following command to create the docker-compose.yml file: + +``` + +nano docker-compose.yml + +``` + + +- Add the following code in the docker-compose.yml file: + +``` + +version: "3.3" +services: + web: + image: 127.0.0.1:5000/stackdemo + build: . + ports: + - "8000:8000" + redis: + image: redis:alpine + +``` + + +**Note**: Press Ctrl+X to exit the editor. Then type Y and press Enter to save the file. + +### Step 10: Start the application +- Use the following commands to install docker-compose: + +``` +sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + + +sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version + +``` + + + + +- Start docker-compose using the following command: + +``` +sudo docker-compose up -d + +``` + + + + +### Step 11: Use the following commands to check whether the app is running + +``` +sudo docker-compose ps + +curl http://localhost:8000 + +``` + + + +### Step 12: Bring the application down + +``` +sudo docker-compose down --volumes + + +``` + + +### Step 13: Push the application to the registry + +``` +sudo docker-compose push + +``` + + + +### Step 14: Use the following command to create the stack docker stack deploy: + +``` +sudo docker stack deploy --compose-file docker-compose.yml stackdemo + +``` + + + +### Step 15: Check if the stack is running + +``` +sudo docker stack services stackdemo + +``` + + + +### Step 16: Test the app again with curl command + +``` + +curl http://localhost:8000 +curl http://ip-172-31-26-147:8000 + +``` + +**Note**: In ### Step 10 while starting docker-compose if you get an error showing the port is already assigned, run the command + +``` +sudo docker ps and kill the container with the same port and then proceed. + +``` + + + +### Step 17: Use the following command to bring the stack down: + +``` +sudo docker stack rm stackdemo + +``` + +----------------------------------------------------------------- + +# Lesson 5 Demo 12: Increase Number of Replicas + +This section will guide you to: +- Increase the number of replicas of a task for any given service + +### Step 1: List the Docker services + +``` +sudo docker service ls +``` + +### Step 2: Scale up the redis service to five tasks + +``` +sudo docker service scale redis=5 + ``` + +### Step 3: Scale the registry service to four tasks using update flag + +``` +sudo docker service update --replicas=4 registry + ``` + +### Step 4: Use the scale flag to scale both redis and registry services at the same time + +``` +sudo docker service scale redis=4 registry=3 + ``` + +### Step 5: Check the actual number of replicas created + +``` +sudo docker service ls + ``` + +### Step 6: Create a global service and scale it up to ten tasks + +``` +sudo docker service create --mode global --name nginx nginx:latest + + +sudo docker service scale nginx=10 +``` + +**Note**: Notice that the scaling cannot be used with global services. It can only be done with replicated service. + + +# Disclaimer +<details> + +Please **Note** that the entire repository is owned and maintained by [Varun Kumar Manik](https://www.linkedin.com/in/vkmanik/). While every effort has been made to ensure the accuracy and reliability of the information and resources provided in this repository, Varun Kumar Manik takes full responsibility for any errors or inaccuracies that may be present. + +Simplilearn is not responsible for the content or materials provided in this repository and disclaims all liability for any issues, misunderstandings, or claims that may arise from the use of the information or materials provided. By using this repository, you acknowledge that Varun Kumar Manik is solely accountable for its content, and you agree to hold Simplilearn harmless from any claims or liabilities that may arise as a result of your use or reliance on the information provided herein. + +It is important to understand that this repository contains educational materials for a training course, and users are expected to apply their own judgment and discretion when utilizing the provided resources. Neither Varun Kumar Manik nor Simplilearn can guarantee specific results or outcomes from following the materials in this repository. + +</details> + +## Connect & Follow + +For more info, please connect and follow me: + +- Github: [https://github.com/manikcloud](https://github.com/manikcloud) +- LinkedIn: [https://www.linkedin.com/in/vkmanik/](https://www.linkedin.com/in/vkmanik/) +- Email: [varunmanik1@gmail.com](mailto:varunmanik1@gmail.com) +- Facebook: [https://www.facebook.com/cloudvirtualization/](https://www.facebook.com/cloudvirtualization/) +- YouTube: [https://bit.ly/32fknRN](https://bit.ly/32fknRN) +- Twitter: [https://twitter.com/varunkmanik](https://twitter.com/varunkmanik) diff --git a/7-docker/Final-project-docker/5.11-docker-compose/app.py b/7-docker/Final-project-docker/5.11-docker-compose/app.py new file mode 100644 index 0000000..c3bfb04 --- /dev/null +++ b/7-docker/Final-project-docker/5.11-docker-compose/app.py @@ -0,0 +1,13 @@ +from flask import Flask +from redis import Redis + +app = Flask(__name__) +redis = Redis(host='redis', port=6379) + +@app.route('/') +def hello(): + count = redis.incr('hits') + return 'Hello World! I have been seen {} times.\n'.format(count) + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8000, debug=True) diff --git a/7-docker/Final-project-docker/5.11-docker-compose/requirements.txt b/7-docker/Final-project-docker/5.11-docker-compose/requirements.txt new file mode 100644 index 0000000..02c585a --- /dev/null +++ b/7-docker/Final-project-docker/5.11-docker-compose/requirements.txt @@ -0,0 +1,2 @@ +flask +redis From d1abeccf4b7a7710fd853c1be572c9e6158da2bb Mon Sep 17 00:00:00 2001 From: VARUN KUMAR MANIK <varunmanik1@gmail.com> Date: Mon, 29 Jan 2024 15:09:03 +0800 Subject: [PATCH 126/135] Update README.md --- README.md | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dc6ceb1..396c78a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,47 @@ -# DevOps-Tutorial -## DevOps-Tutorial By Varun Kumar Manik. -- Sending from User. +# DevOps Tutorial + +Welcome to the [DevOps Tutorial Repository](https://github.com/manikcloud/DevOps-Tutorial/tree/main), a key resource for AWS-focused DevOps learning! This repository is an extensive collection of tutorials and guides, specifically curated for those leveraging AWS in their DevOps practices. Whether you're just starting your journey in DevOps, or you're an experienced practitioner seeking to deepen your expertise with AWS tools and methodologies, this repository is tailored for you. + +## Emphasis on AWS and DevOps + +Our tutorials and resources provide in-depth coverage of various DevOps tools and practices, with a special focus on integrating them within the AWS ecosystem. AWS offers a broad set of services and tools that are crucial in the DevOps landscape, and our repository aims to help you harness these capabilities to their fullest potential. + +## Ideal for All Skill Levels + +Whether you're a beginner who's curious about AWS and DevOps, or a seasoned DevOps professional looking to integrate more AWS services into your workflow, this repository has something for everyone. It's designed to guide you through the nuances of AWS services and how they can optimize your DevOps processes. + +## Repository Contents + +1. **[Linux Tutorial](https://github.com/manikcloud/DevOps-Tutorial/tree/main/Linux_Tutorial):** Dive into the world of Linux with our tutorials, starting with the `history-of-jan-06-2024.txt`, a comprehensive guide to Linux basics and advanced concepts. + +2. **[Git](https://github.com/manikcloud/DevOps-Tutorial/tree/main/2-Git):** Master version control with Git. Our tutorials provide insights from basic usage to advanced Git strategies and workflows. + +3. **[Jenkins](https://github.com/manikcloud/DevOps-Tutorial/tree/main/5-jenkins):** Learn about Jenkins, a cornerstone tool for continuous integration and continuous deployment (CI/CD). + +4. **[Ansible and Terraform](https://github.com/manikcloud/DevOps-Tutorial/tree/main/6-ansible-terraform):** Explore the world of infrastructure as code (IaC) with Ansible and Terraform tutorials, perfect for automating your infrastructure setup. + +5. **[Docker](https://github.com/manikcloud/DevOps-Tutorial/tree/main/7-docker):** Delve into containerization with Docker. Understand how to containerize applications and manage them effectively. + +6. **[Kubernetes (k8s)](https://github.com/manikcloud/DevOps-Tutorial/tree/main/8-k8s):** Get hands-on with Kubernetes, a powerful system for automating deployment, scaling, and management of containerized applications. + +7. **[Nagios](https://github.com/manikcloud/DevOps-Tutorial/tree/main/9.1-NagiOS):** Learn about Nagios for monitoring systems, networks, and infrastructure. + +## Additional Resources + +- **[Ansible Command History](https://github.com/manikcloud/DevOps-Tutorial/blob/main/ansible-cmd-history.txt):** A log of practical Ansible commands for reference. +- **[VS Code Installation Script](https://github.com/manikcloud/DevOps-Tutorial/blob/main/vs-code-installation.sh):** A handy script for installing VS Code, a popular editor among DevOps professionals. + +## Contribution + +Your contributions to enhance or extend the tutorials and resources in this repository are most welcome! Feel free to fork the repository, make your changes, and submit a pull request. + +Happy learning, and let's make DevOps easy and accessible for everyone! + +--- + +*Disclaimer: The contents of this repository are intended for educational purposes. Please ensure to test and validate in a controlled environment before applying in production.* +---- + # Caltech-DevOps Simplilearn PG Program This repository contains course materials for the Caltech-DevOps Simplilearn Postgraduate Program. From 36ab75bc5afd79b3b3e0dd54d54fba1ae7c5bd7d Mon Sep 17 00:00:00 2001 From: VARUN KUMAR MANIK <varunmanik1@gmail.com> Date: Sat, 3 Feb 2024 11:04:47 +0800 Subject: [PATCH 127/135] Update README.md --- 9.1-NagiOS/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/9.1-NagiOS/README.md b/9.1-NagiOS/README.md index 226ab73..cedd631 100644 --- a/9.1-NagiOS/README.md +++ b/9.1-NagiOS/README.md @@ -1,3 +1,7 @@ +# ELK +## https://github.com/manikcloud/elk-stack +# NagiOS (https://github.com/manikcloud/DevOps-Tutorial/tree/main/9.1-NagiOS) +--- # Lesson 9 Demo 1 How to Install Nagios Monitoring Tool From 7e770eecf239373def3dfc0e0b1b4da5bf23c9d5 Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 4 Feb 2024 11:29:46 +0800 Subject: [PATCH 128/135] adding readme and k8s files --- 8-k8s/FAQ/Readme.md | 126 ++++++++++++++++++++++++++++++ 8-k8s/FAQ/vol-k8s.ymal | 73 +++++++++++++++++ 8-k8s/lesson-end-project/calc.yml | 26 ++++++ 8-k8s/pods/multi-container.yaml | 2 +- 8-k8s/pods/new_pod.yaml | 14 ++++ 5 files changed, 240 insertions(+), 1 deletion(-) create mode 100644 8-k8s/FAQ/Readme.md create mode 100644 8-k8s/FAQ/vol-k8s.ymal create mode 100644 8-k8s/lesson-end-project/calc.yml create mode 100644 8-k8s/pods/new_pod.yaml diff --git a/8-k8s/FAQ/Readme.md b/8-k8s/FAQ/Readme.md new file mode 100644 index 0000000..85e193e --- /dev/null +++ b/8-k8s/FAQ/Readme.md @@ -0,0 +1,126 @@ + + +# PodDisruptionBudget (PDB) in Kubernetes + +A `PodDisruptionBudget` (PDB) in Kubernetes is a policy that sets limits on the number of Pods of a replicated application that can be simultaneously down among a set of Pods. It helps ensure that a specified minimum number of Pods are always available during voluntary disruptions, such as when performing cluster maintenance (e.g., node upgrades, resizes). + +## Key Concepts + +- **MinAvailable**: Specifies the minimum number of Pods that should remain available during the disruption. +- **MaxUnavailable**: Defines the maximum number of Pods that can be unavailable during the disruption. + +## Usage + +PDBs are particularly useful in production environments to maintain application availability during operations that require Pod eviction, like node maintenance. + +## Example + +A simple PDB might look like this: + +```yaml +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: myapp-pdb +spec: + minAvailable: 2 + selector: + matchLabels: + app: myapp +``` + +--- + +# Finding Configuration Files in Kubernetes + +Kubernetes configuration files are YAML or JSON files that define how resources should be created and managed within the Kubernetes cluster. These files can specify configurations for pods, services, volumes, and more. Here's how you can find and manage these configuration files. + +## Locations of Configuration Files + +### System-Wide Configuration + +- **Kubernetes Master Node**: + - `/etc/kubernetes/manifests`: Contains static pod manifests for the Kubernetes control plane components (apiserver, controller-manager, scheduler, etc.). + - `/etc/kubernetes/admin.conf`, `/etc/kubernetes/kubelet.conf`, and `/etc/kubernetes/controller-manager.conf`: Configuration files for accessing the Kubernetes API. + +- **Kubelet**: + - `/var/lib/kubelet/config.yaml`: The primary configuration file for the kubelet. + +- **Kubeadm**: + - `/etc/kubernetes/kubeadm-config.yaml`: The configuration file used by `kubeadm init` and `kubeadm join`. + +### User-Defined Resource Configurations + +- **Application Specific**: Typically, the configuration files for your applications (pods, deployments, services, etc.) are not stored on the cluster nodes. Instead, they are managed by users and stored wherever is convenient for version control, such as in a Git repository. + +--- + +# Kubernetes Storage and Stateful Workloads Explained + +Understanding Persistent Volumes (PV), Persistent Volume Claims (PVC), and StatefulSets is crucial for managing stateful applications in Kubernetes. Here's a surface-level overview of these concepts without diving into specific commands. + +## Persistent Volumes (PV) + +**Persistent Volumes** are a way for users to manage durable storage in Kubernetes. PVs are resources in the cluster that provision storage, such as disks, that persist beyond the lifecycle of individual pods. Administrators typically create PVs to represent available storage in the cluster. + +### Key Points: + +- **Cluster Resource**: PVs are a cluster-level resource, meaning they are not tied to a specific namespace. +- **Storage Abstraction**: Provides an abstraction over underlying storage systems, supporting various storage backends like NFS, iSCSI, cloud storage services, and more. +- **Lifecycle Independent**: PVs exist independently of pods, ensuring data persists even when pods are deleted or moved. + +## Persistent Volume Claims (PVC) + +**Persistent Volume Claims** are requests for storage by users. PVCs specify size, access modes (e.g., read/write), and sometimes specific storage class requirements. Kubernetes matches a PVC to an available PV and binds them together. + +### Key Points: + +- **User Request**: PVCs allow users to request specific sizes and types of storage. +- **Dynamic Provisioning**: If no suitable PV exists, a new one can be dynamically provisioned according to the requested storage class. +- **Binding**: A PVC is bound to a single PV, creating a one-to-one relationship that reserves the PV for the PVC's use. + +## StatefulSets + +**StatefulSets** are used to manage stateful applications, providing stable, unique network identifiers, stable persistent storage, and ordered, graceful deployment and scaling. + +### Key Points: + +- **Stable Identity**: Each pod in a StatefulSet has a unique ordinal index and stable network identity. +- **Ordered Operations**: Pods are created, scaled, and deleted in a predictable order, important for stateful applications like databases that require careful management of replicas. +- **Persistent Storage**: StatefulSets can use PVCs to provide each pod with its persistent storage, ensuring data persists across pod rescheduling and restarts. + +### Conclusion + +While PVs and PVCs provide the mechanisms for handling persistent storage in Kubernetes, StatefulSets allow for the management of stateful applications, leveraging PVs and PVCs to ensure data persistence. Together, these components enable the deployment and management of complex, stateful applications within a Kubernetes cluster. + +## Script Explanation + +This guide explains the components of the script that creates Kubernetes resources, including Persistent Volumes (PVs), Persistent Volume Claims (PVCs), and a StatefulSet. + +## Components + +### Persistent Volume (PV) + +- **What it Does**: Creates a PV named `example-pv` with a capacity of 1Gi and a storage class of `standard`. +- **Storage Method**: Utilizes `hostPath` for storage, which mounts a directory from the host. This approach is primarily for testing purposes on a single-node cluster. + +### Persistent Volume Claim (PVC) + +- **What it Does**: Generates a PVC named `example-pvc` that requests 1Gi of storage with the same storage class, `standard`. +- **Binding**: This PVC is designed to bind to the previously created PV, `example-pv`. + +### StatefulSet + +- **What it Does**: Constructs a StatefulSet named `example-statefulset` with 2 replicas. +- **Configuration**: Each pod within the StatefulSet mounts the PVC created by the `volumeClaimTemplates`. +- **Use Case**: Provides a simple example that employs an Nginx container to deliver content stored on the persistent volume. + +## How to Run + +1. **Save the Script**: Store the script in a file, for instance, `create-pv-pvc-statefulset.sh`. +2. **Make Executable**: + ```bash + chmod +x create-pv-pvc-statefulset.sh +./create-pv-pvc-statefulset.sh +``` + diff --git a/8-k8s/FAQ/vol-k8s.ymal b/8-k8s/FAQ/vol-k8s.ymal new file mode 100644 index 0000000..e60747d --- /dev/null +++ b/8-k8s/FAQ/vol-k8s.ymal @@ -0,0 +1,73 @@ +#!/bin/bash + +# Create a Persistent Volume +cat <<EOF | kubectl apply -f - +apiVersion: v1 +kind: PersistentVolume +metadata: + name: example-pv +spec: + capacity: + storage: 1Gi + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: standard + hostPath: + path: "/mnt/data" +EOF + +# Create a Persistent Volume Claim +cat <<EOF | kubectl apply -f - +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: example-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + storageClassName: standard +EOF + +# Create a StatefulSet that uses the PVC +cat <<EOF | kubectl apply -f - +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: example-statefulset +spec: + serviceName: "example" + replicas: 2 + selector: + matchLabels: + app: example + template: + metadata: + labels: + app: example + spec: + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 + name: web + volumeMounts: + - name: www + mountPath: /usr/share/nginx/html + volumeClaimTemplates: + - metadata: + name: www + spec: + accessModes: [ "ReadWriteOnce" ] + storageClassName: "standard" + resources: + requests: + storage: 1Gi +EOF + +echo "Persistent Volume, Persistent Volume Claim, and StatefulSet have been created." diff --git a/8-k8s/lesson-end-project/calc.yml b/8-k8s/lesson-end-project/calc.yml new file mode 100644 index 0000000..a1daaae --- /dev/null +++ b/8-k8s/lesson-end-project/calc.yml @@ -0,0 +1,26 @@ +apiVersion: apps/v1 + +kind: Deployment + +metadata: + name: web-calc + labels: + application: web-app-calc + +spec: + selector: + matchLabels: + application: web-app-calc + replicas: 3 + template: + metadata: + name: calculator + labels: + application: web-app-calc + env: dev + product: calculator-py + + spec: + containers: + - name: calc-image + image: varunmanik/python-calc-app \ No newline at end of file diff --git a/8-k8s/pods/multi-container.yaml b/8-k8s/pods/multi-container.yaml index 35ca890..99265e9 100644 --- a/8-k8s/pods/multi-container.yaml +++ b/8-k8s/pods/multi-container.yaml @@ -7,7 +7,7 @@ metadata: labels: env: dev tier: frontend - + costcenter: devops spec: containers: diff --git a/8-k8s/pods/new_pod.yaml b/8-k8s/pods/new_pod.yaml new file mode 100644 index 0000000..f841749 --- /dev/null +++ b/8-k8s/pods/new_pod.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 + +kind: Pod +metadata: + name: varunapp + labels: + name: webapp +spec: + containers: + - name: httpdBlueApp + image: varunmanik/httpd:blue + + ports: + - containerPort: 80 From 8a4888abe4e33c327ba9c6f33f8672eb19f6f5be Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 4 Feb 2024 11:32:39 +0800 Subject: [PATCH 129/135] adding readme and k8s files --- 8-k8s/FAQ/Readme.md | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/8-k8s/FAQ/Readme.md b/8-k8s/FAQ/Readme.md index 85e193e..e32aa46 100644 --- a/8-k8s/FAQ/Readme.md +++ b/8-k8s/FAQ/Readme.md @@ -123,4 +123,56 @@ This guide explains the components of the script that creates Kubernetes resourc chmod +x create-pv-pvc-statefulset.sh ./create-pv-pvc-statefulset.sh ``` +--- + +# Using Vault in Jenkins + +HashiCorp Vault is a tool for secrets management, allowing you to securely store and access sensitive data like passwords, tokens, and keys. Integrating Vault with Jenkins can significantly enhance the security of your CI/CD pipelines by providing a secure way to handle credentials and other sensitive information. + +## Benefits of Integrating Vault with Jenkins + +- **Security**: Keeps sensitive data out of your build logs and source code. +- **Centralization**: Manages all your secrets in one place, making them easier to rotate, revoke, and keep track of. +- **Auditing**: Vault offers detailed audit logs, allowing you to track access to secrets, which is invaluable for compliance and security. + +## How to Use Vault with Jenkins + +### Step 1: Install Vault Plugin in Jenkins + +First, you need to install the [HashiCorp Vault Plugin](https://plugins.jenkins.io/hashicorp-vault-plugin/) for Jenkins. This can be done through the "Manage Jenkins" > "Manage Plugins" menu in the Jenkins UI. + +### Step 2: Configure Vault in Jenkins + +After installing the plugin, configure Jenkins to communicate with your Vault server: + +1. Go to "Manage Jenkins" > "Configure System". +2. Find the Vault section and add a new Vault configuration. +3. Enter your Vault Server URL and the Vault Credential. + +### Step 3: Set Up Vault Credentials + +Vault credentials in Jenkins can be set up as follows: + +1. Navigate to "Credentials" in Jenkins. +2. Choose the appropriate scope and click "Add Credentials". +3. Select "Vault Token" or the appropriate credential type. +4. Enter your Vault Token and other details as necessary. + +### Step 4: Accessing Secrets in Jenkins Jobs + +To access Vault secrets in your Jenkins jobs: + +1. In your job configuration, add a "Build Environment" step. +2. Select "Vault Secrets" and configure the Vault Key/Values you wish to inject into the build environment. +3. Use the injected environment variables in your build steps. + +## Best Practices + +- **Least Privilege**: Grant Jenkins access only to the secrets it needs, nothing more. +- **Audit**: Regularly review access logs and rotate secrets. +- **Secure Communication**: Ensure communication between Jenkins and Vault is over HTTPS to prevent eavesdropping. + +## Conclusion + +Integrating Vault with Jenkins allows you to manage and inject secrets into your CI/CD pipelines securely. By centralizing secret management, you not only improve the security posture of your development environment but also make managing and rotating secrets much more manageable. From 6d61f108de153ea7f0a988a871e1c4b270c45d14 Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 4 Feb 2024 11:55:35 +0800 Subject: [PATCH 130/135] adding readme and k8s files --- 8-k8s/FAQ/Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/8-k8s/FAQ/Readme.md b/8-k8s/FAQ/Readme.md index e32aa46..db4c10d 100644 --- a/8-k8s/FAQ/Readme.md +++ b/8-k8s/FAQ/Readme.md @@ -125,7 +125,7 @@ This guide explains the components of the script that creates Kubernetes resourc ``` --- -# Using Vault in Jenkins +# Using Vault in Jenkins HashiCorp Vault is a tool for secrets management, allowing you to securely store and access sensitive data like passwords, tokens, and keys. Integrating Vault with Jenkins can significantly enhance the security of your CI/CD pipelines by providing a secure way to handle credentials and other sensitive information. From 168c889b6b2f4f8edd3898dff4cdc460bc99b71a Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 4 Feb 2024 11:56:46 +0800 Subject: [PATCH 131/135] adding readme and k8s files --- 8-k8s/FAQ/Readme.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/8-k8s/FAQ/Readme.md b/8-k8s/FAQ/Readme.md index db4c10d..46e226f 100644 --- a/8-k8s/FAQ/Readme.md +++ b/8-k8s/FAQ/Readme.md @@ -119,9 +119,12 @@ This guide explains the components of the script that creates Kubernetes resourc 1. **Save the Script**: Store the script in a file, for instance, `create-pv-pvc-statefulset.sh`. 2. **Make Executable**: - ```bash + + ``` + chmod +x create-pv-pvc-statefulset.sh ./create-pv-pvc-statefulset.sh + ``` --- From f5dae6e156e00265529a051a2343e17be47d347c Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 4 Feb 2024 11:57:37 +0800 Subject: [PATCH 132/135] adding readme and k8s files --- 8-k8s/FAQ/Readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/8-k8s/FAQ/Readme.md b/8-k8s/FAQ/Readme.md index 46e226f..1df76d4 100644 --- a/8-k8s/FAQ/Readme.md +++ b/8-k8s/FAQ/Readme.md @@ -121,11 +121,11 @@ This guide explains the components of the script that creates Kubernetes resourc 2. **Make Executable**: ``` - + chmod +x create-pv-pvc-statefulset.sh -./create-pv-pvc-statefulset.sh + create-pv-pvc-statefulset.sh -``` + ``` --- # Using Vault in Jenkins From f769e0c32be50439bb4df937823dddc604573e9e Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 4 Feb 2024 14:52:42 +0800 Subject: [PATCH 133/135] adding readme and k8s files --- .../terraform-jenkins-pipeline/Jenkinsfile | 35 +++++++++++++++++++ 5-jenkins/terraform-jenkins-pipeline/main.tf | 8 +++++ .../terraform-jenkins-pipeline/output.tf | 9 +++++ .../terraform-jenkins-pipeline/provider.tf | 1 + .../terraform-jenkins-pipeline/variables.tf | 17 +++++++++ 5 files changed, 70 insertions(+) create mode 100644 5-jenkins/terraform-jenkins-pipeline/Jenkinsfile create mode 100644 5-jenkins/terraform-jenkins-pipeline/main.tf create mode 100644 5-jenkins/terraform-jenkins-pipeline/output.tf create mode 100644 5-jenkins/terraform-jenkins-pipeline/provider.tf create mode 100644 5-jenkins/terraform-jenkins-pipeline/variables.tf diff --git a/5-jenkins/terraform-jenkins-pipeline/Jenkinsfile b/5-jenkins/terraform-jenkins-pipeline/Jenkinsfile new file mode 100644 index 0000000..570d029 --- /dev/null +++ b/5-jenkins/terraform-jenkins-pipeline/Jenkinsfile @@ -0,0 +1,35 @@ +pipeline { + agent any + + environment { + AWS_REGION = 'us-east-1' + // AWS_ACCESS_KEY_ID = "" + // AWS_SECRET_ACCESS_KEY = "" + } + + stages { + stage('Checkout') { + steps { + checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/vijeshnair89/terraform-jenkins-pipeline.git']]) + } + } + + stage('Terraform Init') { + steps { + sh 'terraform init' + } + } + + stage('Terraform Plan') { + steps { + sh 'terraform plan' + } + } + + stage('Terraform Apply') { + steps { + sh 'terraform apply -auto-approve' + } + } + } +} diff --git a/5-jenkins/terraform-jenkins-pipeline/main.tf b/5-jenkins/terraform-jenkins-pipeline/main.tf new file mode 100644 index 0000000..553af60 --- /dev/null +++ b/5-jenkins/terraform-jenkins-pipeline/main.tf @@ -0,0 +1,8 @@ +resource "aws_instance" "public_instance" { + ami = var.ami + instance_type = var.instance_type + + tags = { + Name = var.name_tag, + } +} \ No newline at end of file diff --git a/5-jenkins/terraform-jenkins-pipeline/output.tf b/5-jenkins/terraform-jenkins-pipeline/output.tf new file mode 100644 index 0000000..5d746db --- /dev/null +++ b/5-jenkins/terraform-jenkins-pipeline/output.tf @@ -0,0 +1,9 @@ +output "public_ip" { + value = aws_instance.public_instance.public_ip + description = "Public IP Address of EC2 instance" +} + +output "instance_id" { + value = aws_instance.public_instance.id + description = "Instance ID" +} \ No newline at end of file diff --git a/5-jenkins/terraform-jenkins-pipeline/provider.tf b/5-jenkins/terraform-jenkins-pipeline/provider.tf new file mode 100644 index 0000000..b21d3b6 --- /dev/null +++ b/5-jenkins/terraform-jenkins-pipeline/provider.tf @@ -0,0 +1 @@ +provider "aws" {} diff --git a/5-jenkins/terraform-jenkins-pipeline/variables.tf b/5-jenkins/terraform-jenkins-pipeline/variables.tf new file mode 100644 index 0000000..84d2520 --- /dev/null +++ b/5-jenkins/terraform-jenkins-pipeline/variables.tf @@ -0,0 +1,17 @@ +variable "ami" { + type = string + description = "Ubuntu AMI ID" + default = "ami-03f4878755434977f" +} + +variable "instance_type" { + type = string + description = "Instance type" + default = "t2.micro" +} + +variable "name_tag" { + type = string + description = "Name of the EC2 instance" + default = "Terraform" +} From a26ce4bc5e7698b924d16a785146ea024b0d1334 Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 4 Feb 2024 15:03:27 +0800 Subject: [PATCH 134/135] adding readme and k8s files --- 5-jenkins/terraform-jenkins-pipeline/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/5-jenkins/terraform-jenkins-pipeline/Jenkinsfile b/5-jenkins/terraform-jenkins-pipeline/Jenkinsfile index 570d029..bdfdce3 100644 --- a/5-jenkins/terraform-jenkins-pipeline/Jenkinsfile +++ b/5-jenkins/terraform-jenkins-pipeline/Jenkinsfile @@ -3,8 +3,8 @@ pipeline { environment { AWS_REGION = 'us-east-1' - // AWS_ACCESS_KEY_ID = "" - // AWS_SECRET_ACCESS_KEY = "" + AWS_ACCESS_KEY_ID = "AKIA37SIIUEVGIJGBPNG" + AWS_SECRET_ACCESS_KEY = "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" } stages { From 549084c9c97c06a315b9f2f4619cb8c85c06b4f0 Mon Sep 17 00:00:00 2001 From: varun <varun@> Date: Sun, 4 Feb 2024 15:14:57 +0800 Subject: [PATCH 135/135] adding readme and k8s files --- 5-jenkins/terraform-jenkins-pipeline/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/5-jenkins/terraform-jenkins-pipeline/Jenkinsfile b/5-jenkins/terraform-jenkins-pipeline/Jenkinsfile index bdfdce3..0a9d382 100644 --- a/5-jenkins/terraform-jenkins-pipeline/Jenkinsfile +++ b/5-jenkins/terraform-jenkins-pipeline/Jenkinsfile @@ -3,8 +3,8 @@ pipeline { environment { AWS_REGION = 'us-east-1' - AWS_ACCESS_KEY_ID = "AKIA37SIIUEVGIJGBPNG" - AWS_SECRET_ACCESS_KEY = "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" + AWS_ACCESS_KEY_ID = "" + AWS_SECRET_ACCESS_KEY = "" } stages {