πŸš€πŸ“ Ansible Playbook: Automating Docker & Web Server Deployment! 🐳🌐

VinayGupta
3 min readJul 30, 2023

--

Hello there, I’m Vinay Gupta! Welcome to another exciting adventure in the realm of Ansible! Today, we will create an Ansible Playbook that automates the setup of Docker and a web server on managed nodes.

Let’s dive in!

What You’ll Need: Before we begin, make sure you have the following tools at your disposal:

  1. Ansible tool installed on your control node.
  2. Managed nodes with SSH access and Python installed.

Before start:

  • Write IP address of your managed node in β€œinventory” file
  • Run below ad-hoc command to verify connection between hosts

Let’s get started with our magical Ansible Playbook!

Step 1: πŸ“ Create new playbook

Step 2: 🐳 Configuring Docker & Services

Step 3: 🌐 Pulling & Running the Docker Container

Step 4: πŸ“‚ Copying HTML Code & Moving inside container

Step 5: 🌟 Time to Cast the Spell!

It’s time to unleash the magic of Ansible and deploy our web server. Run the following command:

ansible-playbook deploy_webserver.yml

Output:

Test:

You’ve done it! πŸŽ‰ With just a few lines of code in your Ansible Playbook, you’ve configured Docker, pulled the httpd image, deployed a web server, and made it accessible to the public! 🐳🌐

Thank you for following the article untill now!

--

--

VinayGupta

Hey..! I'm Vinay Gupta, on the way of learning new technologies.