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.
6 Points:
-
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
-
-
Installation and Introduction:
- Install Ansible and familiarize yourself with its basics. You can follow the Ansible installation guide.
-
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.
- Utilize an existing Ansible role for Docker from
-
Create a Playbook and Testing:
- Develop an Ansible playbook for deploying Docker.
- Test your playbook to ensure it works as expected.
4 Points:
-
Create Your Custom Docker Role:
- Develop a custom Ansible role for Docker with the following tasks:
- Install pip.
- Install Docker using apt and Docker Compose using pip.
- Update your playbook to utilize this custom role. Tricks and Tips.
- Test your playbook with the custom role to ensure successful deployment.
- Develop a custom Ansible role for Docker with the following tasks:
-
Documentation:
- Develop an
ANSIBLE.md
file in theansible
folder to document your Ansible-related work. - Create a
README.md
file in theansible/roles/docker
folder. - Use a Markdown template to describe your Docker role, its requirements and usage.
- Develop an
-
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
-
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.
- Execute the following command and provide its output in the
2.5 Points:
-
Set up Dynamic Inventory:
-
Implement dynamic inventory for your cloud environment, if available.
-
You may explore ready-made solutions for dynamic inventories:
Implementing dynamic inventory can enhance your automation capabilities.
-
- 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.