Skip to content

A collection of Ansible playbooks and solutions for KodeKloud Engineer tasks, covering all levels (1-4). This repository provides well-documented, tested solutions to help learners and DevOps enthusiasts master Ansible automation through practical examples.

Notifications You must be signed in to change notification settings

MiqdadProjects/KodeKloud-Ansible-Solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌟 KodeKloud Ansible Solutions

Repository Status
Environment
Tool

πŸ“Œ Project Overview

Section

This repository contains solutions for Ansible lab tasks from KodeKloud, organized by difficulty levels (Levels 1–4). All tasks in Levels 1 to 4 are completed, with each task documented in a detailed Markdown file containing step-by-step instructions, inventory and playbook configurations, verification commands, troubleshooting tips, and production notes. These solutions are designed to assist the Nautilus DevOps team in automating server management tasks efficiently in Stratos DC.

Important Note: When starting any Ansible task, users are already logged into the Jump Host by default as the thor user. The SSH command to connect (e.g., ssh thor@jumphost) is included for educational purposes. This repository serves as a comprehensive record of my learning experience through the KodeKloud Engineer challenge, showcasing real-world Ansible tasks and projects designed to build practical DevOps expertise. The tasks reflect specific challenges encountered, with detailed solutions and verification steps.

Caveat: While the core objectives and approaches remain consistent, specific values (e.g., server names, IP addresses, file paths, or credentials) may differ in your environment. The concepts and problem-solving strategies provided here are adaptable to your specific context.

πŸ” Purpose: Provide clear, executable solutions for Ansible labs, ensuring best practices and alignment with task requirements.

πŸ› οΈ Tools Used:

  • Ansible: Managed via ansible and ansible-playbook on the jump host.
  • Modules: yum, service, copy, file, template, replace, user, group, ping, archive, unarchive, blockinfile, lineinfile for package, service, file, and user management.
  • Environment: KodeKloud lab environment with pre-installed Ansible.

πŸ“‚ Repository Structure

Section

KodeKloud-Ansible-Solutions/
β”œβ”€β”€ level-1/
β”‚   β”œβ”€β”€ task01-install-package.md
β”‚   β”œβ”€β”€ task02-install-httpd.md
β”‚   β”œβ”€β”€ task03-configure-ansible-remote-user.md
β”‚   β”œβ”€β”€ task04-copy-index-html.md
β”‚   β”œβ”€β”€ task05-create-file-with-permissions.md
β”œβ”€β”€ level-2/
β”‚   β”œβ”€β”€ task01-ping-module-usage.md
β”‚   β”œβ”€β”€ task02-install-package.md
β”‚   β”œβ”€β”€ task03-archive-module.md
β”‚   β”œβ”€β”€ task04-unarchive-module.md
β”‚   β”œβ”€β”€ task05-blockinfile-module.md
β”œβ”€β”€ level-3/
β”‚   β”œβ”€β”€ task01-create-soft-links.md
β”‚   β”œβ”€β”€ task02-manage-acls.md
β”‚   β”œβ”€β”€ task03-manage-services.md
β”‚   β”œβ”€β”€ task04-lineinfile-module.md
β”‚   β”œβ”€β”€ task05-replace-module.md
β”œβ”€β”€ level-4/
β”‚   β”œβ”€β”€ task01-facts-gathering.md
β”‚   β”œβ”€β”€ task02-create-users-groups.md
β”‚   β”œβ”€β”€ task03-deploy-httpd-role.md
β”‚   β”œβ”€β”€ task04-setup-apache-php.md
β”‚   β”œβ”€β”€ task05-copy-files-conditionals.md
└── README.md

πŸš€ Level 1 Tasks

Section

Task # Title/Link Status Difficulty Description
1 Install Package βœ… Done 🟒 Basic Install httpd package on App Server 1 using Ansible playbook
2 Install httpd βœ… Done 🟒 Basic Install and start httpd on App Server 3
3 Configure Ansible Remote User βœ… Done 🟒 Basic Set james as default SSH user in Ansible config
4 Copy index.html βœ… Done 🟒 Basic Copy index.html to /opt/itadmin/ on all app servers
5 Create File with Permissions βœ… Done 🟑 Intermediate Create /usr/src/app.txt with 0777 permissions and specific ownership

πŸš€ Level 2 Tasks

Section

Task # Title/Link Status Difficulty Description
1 Ansible Ping Module Usage βœ… Done 🟑 Intermediate Test connectivity to app servers using the Ansible ping module
2 Ansible Install Package βœ… Done 🟑 Intermediate Install a specified package on app servers using Ansible
3 Ansible Archive Module βœ… Done 🟑 Intermediate Create an archive of files or directories using the archive module
4 Ansible Unarchive Module βœ… Done 🟑 Intermediate Extract an archive to a specified location using the unarchive module
5 Ansible Blockinfile Module βœ… Done 🟑 Intermediate Insert or update a block of text in a file using the blockinfile module

πŸš€ Level 3 Tasks

Section

Task # Title/Link Status Difficulty Description
1 Creating Soft Links Using Ansible βœ… Done 🟠 Advanced Create symbolic links on app servers using Ansible
2 Managing ACLs Using Ansible βœ… Done 🟠 Advanced Configure access control lists (ACLs) for files or directories
3 Ansible Manage Services βœ… Done 🟠 Advanced Manage service states (start, stop, enable) on app servers
4 Ansible Lineinfile Module βœ… Done 🟠 Advanced Modify specific lines in files using the lineinfile module
5 Ansible Replace Module βœ… Done 🟠 Advanced Replace text in files using the replace module

πŸš€ Level 4 Tasks

Section

Task # Title/Link Status Difficulty Description
1 Ansible Facts Gathering βœ… Done 🟠 Advanced Gather and store Ansible facts from App Server 1
2 Ansible Create Users and Groups βœ… Done 🟠 Advanced Create users and groups on App Server 2 with specific permissions
3 Managing Jinja2 Templates Using Ansible βœ… Done 🟠 Advanced Deploy httpd on App Server 1 using a role with a dynamic index.html
4 Ansible Setup Httpd and PHP βœ… Done 🟠 Advanced Install httpd and php, configure custom document root, deploy phpinfo.php
5 Using Ansible Conditionals βœ… Done 🟠 Advanced Copy specific files to app servers using conditionals based on inventory_hostname

πŸ’‘ How to Use This Repository

Section

  1. Clone the Repository:

    git clone https://github.com/MiqdadProjects/KodeKloud-Ansible-Solutions.git
    cd KodeKloud-Ansible-Solutions
  2. Navigate to Task Files:

    • Level 1 tasks: level-1/
    • Level 2 tasks: level-2/
    • Level 3 tasks: level-3/
    • Level 4 tasks: level-4/
  3. Apply Solutions:

    • Copy the inventory, playbook, and template content from each task’s Markdown file.
    • Create files on the jump host (e.g., vi ~/ansible/inventory, vi ~/ansible/playbook.yml, vi ~/ansible/roles/httpd_role/templates/index.html.j2).
    • Run playbooks with:
      ansible-playbook -i inventory playbook.yml
    • Follow verification steps (e.g., ssh, ls -la, systemctl status, curl) to ensure success.
  4. Troubleshooting:

    • Refer to the Troubleshooting Common Issues section in each task file.
    • Use commands like ansible-playbook -v or ansible --version for debugging.
    • Check the troubleshooting/Common-Issues-Solutions.md file (TBD) for common fixes.
  5. Test in Lab Environment:

    • Use the jump host (ssh thor@jumphost) with pre-configured Ansible.
    • Verify tasks using SSH to app servers and checking file or service states.

πŸ”§ Prerequisites

Section

  • Ansible Installation: Pre-installed on the jump host via yum.
  • Text Editor: vi or similar for editing inventory, playbook, and template files.
  • Git: For version control and repository management.
  • Lab Environment: KodeKloud lab with pre-configured jump host and app servers.

πŸ“‹ Detailed Setup Guide

Section

  1. Access the Jump Host:

    ssh thor@jumphost
  2. Create and Edit Files:

    cd ~/ansible
    vi inventory
    vi playbook.yml
    # For roles/templates (e.g., Level 4 TASK03, TASK04)
    mkdir -p roles/httpd_role/templates
    vi roles/httpd_role/templates/index.html.j2
    # Paste content from task’s Markdown file
    # Save with :wq
  3. Run Playbooks:

    ansible-playbook -i inventory playbook.yml
  4. Verify Results:

    ssh <user>@<server>
    ls -la <path>
    systemctl status <service>
    cat <file>
    curl http://localhost/<file>
  5. Debug Issues:

    • Check playbook syntax: ansible-playbook -i inventory playbook.yml --syntax-check
    • View verbose output: ansible-playbook -i inventory playbook.yml -v
    • Test connectivity: ssh <user>@<ip>

⚠️ Important Notes

Section

  • Filenames: Task files use the format taskXX-descriptive-name.md for clarity and VS Code compatibility.
  • Security: Avoid plain-text passwords (ansible_ssh_pass) in production; use SSH keys or Ansible Vault.
  • Dry Runs: Test playbooks with --check to simulate changes:
    ansible-playbook -i inventory playbook.yml --check
  • Production Readiness: Each task includes production notes for real-world considerations (e.g., SELinux, SSL/TLS, logging).
  • Level Completion: All tasks in Levels 1–4 are completed.

πŸš€ Contributing

Section

Contributions are welcome! To add improvements or update documentation:

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b update-level-X
  3. Update Markdown files in the appropriate level directory.
  4. Commit changes:
    git commit -m "Update Level X task solutions"
  5. Push to the branch:
    git push origin update-level-X
  6. Open a pull request with a detailed description of changes.

πŸ“œ License

Section

This project is licensed under the MIT License. See the LICENSE file for details.


πŸ“ž Contact

Section

For questions, issues, or task details, contact the Nautilus DevOps team or open an issue in the repository.

Happy Automating with Ansible! πŸš€

About

A collection of Ansible playbooks and solutions for KodeKloud Engineer tasks, covering all levels (1-4). This repository provides well-documented, tested solutions to help learners and DevOps enthusiasts master Ansible automation through practical examples.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published