Welcome to the Ansible playbook for configuring Docker effortlessly and setting up a web server using Ansible automation. This playbook allows you to perform the following tasks:
- Configure Docker effortlessly.
- Start and enable Docker services.
- Pull the latest httpd server image from the Docker Hub with ease.
- Run the Docker container smoothly and expose it to the public.
- Copy your HTML code to the /var/www/html directory and kickstart your web server in a blink.
Let's break down the setup into steps:
$ sudo yum install ansible -y
$ mkdir ansible
$ cd ansible
$ vim ansible.cfg
Add the following content to the ansible.cfg file:
[defaults]
remote_user = your_username
Create an inventory file (e.g., inventory.txt) and add the IP address of your slave node.
Establish password access from the slave node to the master node.
$ ansible all -m ping
Create a YAML file (e.g., docker.yml) and insert your Docker playbook code. You can find an example YAML code on my GitHub profile.
$ ansible-playbook docker.yml
Your playbook should run successfully. Check the IP of your slave node and any other desired outcomes.
For detailed instructions and example YAML code, please refer to the docker.yml file in this repository.