Ansible is a simple automation language that can perfectly describe an IT application infrastructure. It’s easy-to-learn, self-documenting, and doesn’t require a grad-level computer science degree to read. Automation shouldn’t be more complex than the tasks it’s replacing.
A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
Apache httpd Server
The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.
🔰Write an Ansible PlayBook that does the following operations in the managed nodes:
🔹 Configure Docker
🔹 Start and enable Docker services
🔹 Pull the httpd server image from the Docker Hub
🔹 Run the docker container and expose it to the public
🔹 Copy the html code in /var/www/html directory and start the web server
Analysis and code
The above playbook uses a html file hi.html and sends it to the managed node and uses this file as the server home page. A httpd server was setup along with the SELinux firewall settings on a docker container, mynewos1, with a httpd docker image. The playbook on running gives the following output.
The server was exposed at port 8080, hence to visit the page, it is required to visit the IP address of the system followed by the port number 8080.
This gives the basic example of an Apache server being set in a docker container remotely through Ansible automation.