Skip to content

Latest commit

 

History

History
115 lines (88 loc) · 4.21 KB

lab5.md

File metadata and controls

115 lines (88 loc) · 4.21 KB

Ansible and Docker Deployment

Overview

In this lab, you will get acquainted with Ansible, a powerful configuration management and automation tool. Your objective is to use Ansible to deploy Docker on a newly created cloud VM. This knowledge will be essential for your application deployment in the next lab.

Task 1: Initial Setup

6 Points:

  1. Repository Structure:

    • Organize your repository following the recommended structure below:

      .
      |-- README.md
      |-- ansible
      |   |-- inventory
      |   |   `-- default_aws_ec2.yml
      |   |-- playbooks
      |   |   `-- dev
      |   |       `-- main.yaml
      |   |-- roles
      |   |   |-- docker
      |   |   |   |-- defaults
      |   |   |   |   `-- main.yml
      |   |   |   |-- handlers
      |   |   |   |   `-- main.yml
      |   |   |   |-- tasks
      |   |   |   |   |-- install_compose.yml
      |   |   |   |   |-- install_docker.yml
      |   |   |   |   `-- main.yml
      |   |   |   `-- README.md
      |   |   `-- web_app
      |   |       |-- defaults
      |   |       |   `-- main.yml
      |   |       |-- handlers
      |   |       |   `-- main.yml
      |   |       |-- meta
      |   |       |   `-- main.yml
      |   |       |-- tasks
      |   |       |   `-- main.yml
      |   |       `-- templates
      |   |           `-- docker-compose.yml.j2
      |   `-- ansible.cfg
      |-- app_go
      |-- app_python
      `-- terraform
  2. Installation and Introduction:

  3. Use an Existing Ansible Role for Docker:

    • Utilize an existing Ansible role for Docker from ansible-galaxy as a template. You can explore this Docker role as an example.
  4. Create a Playbook and Testing:

    • Develop an Ansible playbook for deploying Docker.
    • Test your playbook to ensure it works as expected.

Task 2: Custom Docker Role

4 Points:

  1. Create Your Custom Docker Role:

    • Develop a custom Ansible role for Docker with the following tasks:
      1. Install pip.
      2. Install Docker using apt and Docker Compose using pip.
      3. Update your playbook to utilize this custom role. Tricks and Tips.
      4. Test your playbook with the custom role to ensure successful deployment.
  2. Documentation:

    • Develop an ANSIBLE.md file in the ansible folder to document your Ansible-related work.
    • Create a README.md file in the ansible/roles/docker folder.
    • Use a Markdown template to describe your Docker role, its requirements and usage.
  3. Deployment Output:

    • Execute your playbook to deploy the Docker role (either custom or existing).
    • Provide the last 50 lines of the output from your deployment command in the ANSIBLE.md file.

    Example command:

     ansible-playbook <path_to your_playbook> --diff
  4. Inventory Details:

    • Execute the following command and provide its output in the ANSIBLE.md file:
     ansible-inventory -i <name_of_your_inventory_file>.yaml --list

    Ensure you have documented the inventory information.

Bonus Task: Dynamic Inventory

2.5 Points:

  1. Set up Dynamic Inventory:

    Implementing dynamic inventory can enhance your automation capabilities.

Guidelines

  • Use proper Markdown formatting and structure for documentation files.
  • Organize files within the lab folder with suitable naming conventions.
  • Create pull requests (PRs) as needed: from your fork to the main branch of this repository, and from your fork's branch to your fork's master branch.

Note: Ensure that your repository is well-structured, follow Ansible best practices, and provide clear documentation for a successful submission.