From 67b19f674a4b662b5bded48d6cd593d6394b4728 Mon Sep 17 00:00:00 2001 From: Dinuka Sanjana Madhumal <98506454+DinukaSanjana@users.noreply.github.com> Date: Sat, 23 Aug 2025 10:28:28 +0530 Subject: [PATCH 01/11] Update Dockerfile --- setup/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/Dockerfile b/setup/Dockerfile index f07836c..189c79f 100644 --- a/setup/Dockerfile +++ b/setup/Dockerfile @@ -1,4 +1,4 @@ -FROM jenkins/jenkins:2.387.2 +FROM jenkins/jenkins:lts-jdk17 USER root RUN apt-get update && apt-get install -y lsb-release RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \ From 786a26c60d9e66bb6ab25212ebb57c1adbe4904a Mon Sep 17 00:00:00 2001 From: Dinuka Sanjana Madhumal <98506454+DinukaSanjana@users.noreply.github.com> Date: Sat, 23 Aug 2025 10:33:44 +0530 Subject: [PATCH 02/11] Update Dockerfile --- setup/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/Dockerfile b/setup/Dockerfile index 189c79f..7f0b90d 100644 --- a/setup/Dockerfile +++ b/setup/Dockerfile @@ -1,4 +1,4 @@ -FROM jenkins/jenkins:lts-jdk17 +FROM jenkins/jenkins:2.452.1-lts-jdk17 USER root RUN apt-get update && apt-get install -y lsb-release RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \ From 89111216fbcdc08aa31122a53f2366ea8a447565 Mon Sep 17 00:00:00 2001 From: Dinuka Sanjana Madhumal <98506454+DinukaSanjana@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:17:21 +0530 Subject: [PATCH 03/11] Update docker-compose.yml by Removing the Version --- setup/docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/setup/docker-compose.yml b/setup/docker-compose.yml index 5d37a30..7b18e29 100644 --- a/setup/docker-compose.yml +++ b/setup/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.0' - networks: custom: driver: bridge From 3456e48063aa80dfcc6e444e0b75d4f59a436da7 Mon Sep 17 00:00:00 2001 From: Dinuka Sanjana Madhumal <98506454+DinukaSanjana@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:06:14 +0530 Subject: [PATCH 04/11] Update docker-compose.yml - Changed the Jenkins Image in Dockerfile --- setup/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/docker-compose.yml b/setup/docker-compose.yml index 7b18e29..a99b9ed 100644 --- a/setup/docker-compose.yml +++ b/setup/docker-compose.yml @@ -66,7 +66,7 @@ services: MONGO_INITDB_ROOT_PASSWORD: admin123 jenkins: - image: myjenkins/blueocean:2.375.1-1 + image: jenkins/jenkins:lts-jdk17 build: context: ./ dockerfile: Dockerfile From 62dd0ae893461acee1992cc1859516537d3727b5 Mon Sep 17 00:00:00 2001 From: Dinuka Sanjana Madhumal <98506454+DinukaSanjana@users.noreply.github.com> Date: Sun, 23 Nov 2025 06:22:07 +0530 Subject: [PATCH 05/11] Rename README.md to README1.md --- README.md => README1.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README.md => README1.md (100%) diff --git a/README.md b/README1.md similarity index 100% rename from README.md rename to README1.md From 7d10a2fc1cd80ebcaa4fb5640eaac0c32879ef3e Mon Sep 17 00:00:00 2001 From: Dinuka Sanjana Madhumal <98506454+DinukaSanjana@users.noreply.github.com> Date: Sun, 23 Nov 2025 06:23:13 +0530 Subject: [PATCH 06/11] Create README for Ansible Practical setup and usage Added comprehensive README with environment setup, key services, and usage instructions for Ansible lab. --- README.md | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..50b9ddc --- /dev/null +++ b/README.md @@ -0,0 +1,119 @@ +```markdown +# Ansible Practical - Just Enough Ansible to be Dangerous + +## Environment Setup (Docker Compose) + +```bash +git clone https://github.com/DinukaSanjana/bootcamp.git +cd bootcamp/setup + +# Optional cleanup +docker compose down --rmi all --volumes --remove-orphans + +# Start lab +docker compose up -d +``` + +## Access Web IDE (Control Node) +http://:8000 +Example: http://159.65.77.142:8000 + +## Key Docker Services +```yaml +control: + image: codespaces/ansible-control:3.0.0 + ports: ["8000:8000"] +frontend: + image: codespaces/ansible-node-ubuntu:18.04 +catalogue: + image: codespaces/ansible-node-ubuntu:18.04 +carts: + image: codespaces/ansible-node-ubuntu:18.04 +``` + +## SSH to Managed Nodes (from control node) +```bash +ssh devops@frontend # Password: codespaces +ssh devops@carts +ssh devops@catalogue +``` + +## Inside Control Node - Project Setup +```bash +git clone https://github.com/DinukaSanjana/bootcamp.git +cd bootcamp/ansible + +ls +# README.md ansible.cfg carts.yml catalogue.yml common.yml +# frontend.yml mogambo.yml environments group_vars roles +``` + +## Ansible Version +```bash +ansible --version +# ansible 2.9.10 +# config file = /root/workspace/bootcamp/ansible/ansible.cfg +``` + +## Sync Fork with Upstream (if forked) +```bash +git remote add upstream https://github.com/udbc/bootcamp.git +git pull upstream master +``` + +## Test Connectivity +```bash +ansible all -m ping +``` + +## LAB 1 - Completed Tasks +- Started Docker Compose lab +- Accessed web IDE at port 8000 +- SSH into frontend, carts, catalogue nodes +- Cloned bootcamp repo inside control node +- Verified Ansible ping to all nodes + +## Inventory Example +```ini +[frontend] +frontend ansible_host=172.18.0.3 ansible_user=devops + +[webservers] +frontend ansible_host=172.18.0.3 ansible_user=devops + +[all:vars] +ansible_python_interpreter=/usr/bin/python3 +``` + +## Sample Playbook +```yaml +- name: Install Nginx on webserver + hosts: webservers + become: yes + tasks: + - name: Install nginx + apt: + name: nginx + state: present +``` + +Run: +```bash +ansible-playbook -i inventory.ini site.yml +``` + +## Project Structure Learned +``` +ansible.cfg +environments/ +group_vars/ +roles/ +*.yml playbooks (frontend.yml, catalogue.yml, etc.) +``` + +**Status: Completed** +**Environment: Fully containerized Ansible lab with web IDE** +**Ansible Version: 2.9.10** +**Control Node: Browser-based Theia IDE** +**Managed Nodes: frontend, catalogue, carts, etc.** +``` From b76b24ab303c958252a43c500c9f9a84e37aae8b Mon Sep 17 00:00:00 2001 From: Dinuka Sanjana Madhumal <98506454+DinukaSanjana@users.noreply.github.com> Date: Sun, 23 Nov 2025 06:24:02 +0530 Subject: [PATCH 07/11] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 50b9ddc..be4c570 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -```markdown + # Ansible Practical - Just Enough Ansible to be Dangerous ## Environment Setup (Docker Compose) @@ -12,7 +12,7 @@ docker compose down --rmi all --volumes --remove-orphans # Start lab docker compose up -d -``` + ## Access Web IDE (Control Node) http://:8000 From 4c0e6517dce9b46fe511c72290aae56fa021b457 Mon Sep 17 00:00:00 2001 From: Dinuka Sanjana Madhumal <98506454+DinukaSanjana@users.noreply.github.com> Date: Sat, 29 Nov 2025 09:23:00 +0530 Subject: [PATCH 08/11] Refactor README for improved clarity and structure Updated README to enhance formatting and structure, added section numbers, and improved clarity of instructions. --- README.md | 253 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 184 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index be4c570..1ce9c92 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ +```markdown +# Ansible Practical - Just Enough Ansible to be Dangerous -# Ansible Practical - Just Enough Ansible to be Dangerous - -## Environment Setup (Docker Compose) +## 1. Environment Setup (Docker Compose) ```bash git clone https://github.com/DinukaSanjana/bootcamp.git @@ -10,110 +10,225 @@ cd bootcamp/setup # Optional cleanup docker compose down --rmi all --volumes --remove-orphans -# Start lab +# Start the lab docker compose up -d +``` +## 2. Docker Compose File Overview -## Access Web IDE (Control Node) -http://:8000 -Example: http://159.65.77.142:8000 +**File location:** `bootcamp/setup/docker-compose.yml` -## Key Docker Services ```yaml -control: - image: codespaces/ansible-control:3.0.0 - ports: ["8000:8000"] -frontend: - image: codespaces/ansible-node-ubuntu:18.04 -catalogue: - image: codespaces/ansible-node-ubuntu:18.04 -carts: - image: codespaces/ansible-node-ubuntu:18.04 -``` - -## SSH to Managed Nodes (from control node) +services: + control: + image: codespaces/ansible-control:3.0.0 + ports: + - "8000:8000" + hostname: control + container_name: control + + frontend: + image: codespaces/ansible-node-ubuntu:18.04 + hostname: frontend + + catalogue: + image: codespaces/ansible-node-ubuntu:18.04 + hostname: catalogue + + carts: + image: codespaces/ansible-node-ubuntu:18.04 + hostname: carts + + # Additional nodes: user, payment, orders, etc. +``` + +## 3. Containers Created by Docker Compose + +| Container Name | Image | Role | Access Method | +|----------------|----------------------------------|--------------------------|-----------------------------------| +| control | codespaces/ansible-control:3.0.0 | Ansible Control Node + Web IDE | http://:8000 | +| frontend | codespaces/ansible-node-ubuntu:18.04 | Managed Node | ssh devops@frontend | +| catalogue | codespaces/ansible-node-ubuntu:18.04 | Managed Node | ssh devops@catalogue | +| carts | codespaces/ansible-node-ubuntu:18.04 | Managed Node | ssh devops@carts | + +## 4. Preparing & Opening Ansible Control Node + ```bash -ssh devops@frontend # Password: codespaces -ssh devops@carts -ssh devops@catalogue +# Open in browser +http://:8000 +# Example: http://159.65.77.142:8000 ``` +→ Opens Theia (VS Code-based) Web IDE → This is your Ansible Control Node + +## 5. Inside Control Node - Initial Setup -## Inside Control Node - Project Setup ```bash +# Clone project git clone https://github.com/DinukaSanjana/bootcamp.git cd bootcamp/ansible -ls -# README.md ansible.cfg carts.yml catalogue.yml common.yml -# frontend.yml mogambo.yml environments group_vars roles +# Verify Ansible +ansible --version +# ansible 2.9.10 ``` -## Ansible Version +## 6. Test Connectivity + ```bash -ansible --version -# ansible 2.9.10 -# config file = /root/workspace/bootcamp/ansible/ansible.cfg +ansible all -m ping +``` +→ Should return green "pong" from all nodes + +## 7. Inventory File & Path + +**Location:** `/root/workspace/bootcamp/ansible/ansible.cfg` (config points to default inventory) + +**Actual inventory used:** Dynamic inventory via Docker network + `/etc/ansible/hosts` or embedded in `ansible.cfg` + +**Sample host entry format used in lab:** +```ini +frontend ansible_host=frontend ansible_user=devops ansible_ssh_pass=codespaces ``` -## Sync Fork with Upstream (if forked) +## 8. SSH to Managed Nodes + ```bash -git remote add upstream https://github.com/udbc/bootcamp.git -git pull upstream master +ssh devops@frontend # Password: codespaces +ssh devops@carts +ssh devops@catalogue ``` -## Test Connectivity +Check service after playbook run: ```bash -ansible all -m ping +sudo systemctl status nginx ``` -## LAB 1 - Completed Tasks -- Started Docker Compose lab -- Accessed web IDE at port 8000 -- SSH into frontend, carts, catalogue nodes -- Cloned bootcamp repo inside control node -- Verified Ansible ping to all nodes +## 9. Ad-hoc Commands Executed -## Inventory Example -```ini -[frontend] -frontend ansible_host=172.18.0.3 ansible_user=devops +```bash +# Check uptime on all nodes +ansible all -a "uptime" -[webservers] -frontend ansible_host=172.18.0.3 ansible_user=devops +# Check disk usage +ansible all -a "df -h" -[all:vars] -ansible_python_interpreter=/usr/bin/python3 +# Reboot all nodes +ansible all -a "/sbin/reboot" --forks=10 ``` -## Sample Playbook -```yaml -- name: Install Nginx on webserver - hosts: webservers - become: yes - tasks: - - name: Install nginx - apt: - name: nginx - state: present +## 10. Run Ansible Playbooks + +```bash +cd ~/bootcamp/ansible + +ansible-playbook frontend.yml +ansible-playbook catalogue.yml +ansible-playbook carts.yml +ansible-playbook mogambo.yml ``` -Run: +## 11. Ansible Roles - Project Structure + +**Path:** `roles/` + ```bash -ansible-playbook -i inventory.ini site.yml +roles/ +├── frontend/ +│ ├── tasks/ +│ │ └── main.yml +│ ├── handlers/ +│ │ └── main.yml +│ ├── templates/ +│ ├── files/ +│ ├── vars/ +│ │ └── main.yml +│ └── defaults/ +│ └── main.yml +├── catalogue/ +├── carts/ +└── common/ ``` -## Project Structure Learned +## 12. Normal Playbook vs Large Project (Roles-Based) + +| Type | Structure | Use Case | +|-----------------------|-------------------------------------------|--------------------------------| +| Simple Playbook | All tasks, vars, templates in one .yml | Small scripts, demos | +| Large Project (Roles) | Separated: tasks, vars, templates, handlers, files | Reusable, modular, maintainable, team-friendly | + +## 13. Generate New Role + +```bash +ansible-galaxy init --offline roles/frontend +ansible-galaxy init --offline roles/catalogue +``` + +Creates full role directory structure automatically. + +## 14. Playbook Using Roles + +```yaml +# frontend.yml +- name: Deploy Frontend Service + hosts: frontend + become: yes + roles: + - common + - nginx + - frontend +``` + +## 15. Full Playbook Structure Used + ``` ansible.cfg environments/ group_vars/ +hosts # inventory (if static) roles/ -*.yml playbooks (frontend.yml, catalogue.yml, etc.) + └── / + ├── tasks/ + ├── handlers/ + ├── templates/ + ├── files/ + ├── vars/ + └── defaults/ +frontend.yml +catalogue.yml +carts.yml +mogambo.yml # Master playbook ``` -**Status: Completed** -**Environment: Fully containerized Ansible lab with web IDE** -**Ansible Version: 2.9.10** -**Control Node: Browser-based Theia IDE** -**Managed Nodes: frontend, catalogue, carts, etc.** +## 16. Deploy mogambo.org E-commerce Website + +```bash +ansible-playbook mogambo.yml ``` + +After successful run → Open in browser: + +**Website URL:** +`http://:3000` + +**Services deployed:** +- Nginx (port 80) +- Node.js apps (frontend, catalogue, carts) +- MongoDB +- Full mogambo.org e-commerce site running + +Accessible via: `http://:3000` + +## Final Status: Completed + +- Full multi-node Ansible lab running via Docker Compose +- Web-based control node at port 8000 +- All nodes reachable via `ansible all -m ping` +- Roles-based, clean, reusable playbook structure +- Successfully deployed full-stack mogambo.org website +- Used ad-hoc commands, inventory, roles, handlers, templates + +**Project Completed Successfully** +**Live Site:** http://:3000 +**Control Panel:** http://:8000 + +Ready for production-grade Ansible automation! From 5a67c47a283d77291374a2bf676759db8407f5c6 Mon Sep 17 00:00:00 2001 From: Dinuka Sanjana Madhumal <98506454+DinukaSanjana@users.noreply.github.com> Date: Sat, 29 Nov 2025 09:25:05 +0530 Subject: [PATCH 09/11] Fix markdown syntax in README.md Updated README to fix markdown syntax and improve formatting. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ce9c92..7ea4f4d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -```markdown + # Ansible Practical - Just Enough Ansible to be Dangerous ## 1. Environment Setup (Docker Compose) @@ -14,6 +14,7 @@ docker compose down --rmi all --volumes --remove-orphans docker compose up -d ``` + ## 2. Docker Compose File Overview **File location:** `bootcamp/setup/docker-compose.yml` From ac29e3d6fd3f925c2cb33e1961a5ff0c8f8d4995 Mon Sep 17 00:00:00 2001 From: Dinuka Sanjana Madhumal <98506454+DinukaSanjana@users.noreply.github.com> Date: Sat, 29 Nov 2025 09:26:18 +0530 Subject: [PATCH 10/11] Update project title in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ea4f4d..877cfbe 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# Ansible Practical - Just Enough Ansible to be Dangerous +# Ansible - Deploy mogombo ecommerce website ..! ## 1. Environment Setup (Docker Compose) From 10250862934e4268a0d2d8854af35fdb6af362ff Mon Sep 17 00:00:00 2001 From: Dinuka Sanjana Madhumal <98506454+DinukaSanjana@users.noreply.github.com> Date: Tue, 2 Dec 2025 00:21:38 +0530 Subject: [PATCH 11/11] Update README to reflect port changes --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 877cfbe..3fdc68c 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ ansible-playbook mogambo.yml After successful run → Open in browser: **Website URL:** -`http://:3000` +`http://:80` **Services deployed:** - Nginx (port 80) @@ -217,7 +217,7 @@ After successful run → Open in browser: - MongoDB - Full mogambo.org e-commerce site running -Accessible via: `http://:3000` +Accessible via: `http://:80` ## Final Status: Completed @@ -229,7 +229,7 @@ Accessible via: `http://:3000` - Used ad-hoc commands, inventory, roles, handlers, templates **Project Completed Successfully** -**Live Site:** http://:3000 +**Live Site:** http://:80 **Control Panel:** http://:8000 Ready for production-grade Ansible automation!