Undertsanding the problem that httpd is not idempotent in nature and solving this issue using ansible.

Abhijeet Bakale
4 min readApr 18, 2021

In this context we are going to rectify that the httpd service is not idempotent in nature and consumes more resources so we are creating playbook in such a way that the service will restart only when the changes are made.

Introduction to Ansible :

Ansible is a software tool that provides simple but powerful automation for cross-platform computer support. It is primarily intended for IT professionals, who use it for application deployment, updates on workstations and servers, cloud provisioning, configuration management, intra-service orchestration, and nearly anything a systems administrator does on a weekly or daily basis. Ansible doesn’t depend on agent software and has no additional security infrastructure, so it’s easy to deploy.

Ansible Playbook

Ansible is a tool used for configuration management. In this context, configuration management entails keeping a record of company hardware and software, and making changes to them remotely.

Ansible Playbooks are the files where Ansible code is written. These files are written in the language, YAML, which is a funny acronym for, “YAML Ain’t no Markup Language.”

Play-books contain one or more Plays. Plays map a group of computers to a few well-defined roles known as
Tasks. Tasks can be defined as Ansible scripts.

Introduction to apache webserver

What is Apache Web Server?

Apache HTTP Server is a free and open-source web server that delivers web content through the internet. It is commonly referred to as Apache and after development, it quickly became the most popular HTTP client on the web. It’s widely thought that Apache gets its name from its development history and process of improvement through applied patches and modules but that was corrected back in 2000. It was revealed that the name originated from the respect of the Native American tribe for its resiliency and durability.

Apache supports a variety of features, many implemented as compiled modules which extend the core functionality. These can range from authentication schemes to supporting server-side programming languages such as Perl, Python, Tcl and PHP. Popular authentication modules include mod_access, mod_auth, mod_digest, and mod_auth_digest, the successor to mod_digest. A sample of other features include Secure Sockets Layer and Transport Layer Security support, a proxy module, a URL rewriting module, custom log files, and filtering support.

Idempotency in Ansible

Idempotence is “the property of certain operations in mathematics and computer science that can be applied multiple times without changing the result beyond the initial application”. For Ansible it means after 1 run of a playbook to set things to a desired state, further runs of the same playbook should result in 0 changes. In simplest terms, idempotency means you can be sure of a consistent state in your environment.

you can download and get this complete setup @ my GitHub https://github.com/Abhijeet-274/httpd-idempotent-ansible.git

Lets take a look at the Setup :

Configured the inventory of ansible.

Configured the host file of ansible.

Making our workspace and writing their our yaml file.

Writing the handler.conf file.

In this playbook we had installed apache webserver, Copied out html code, Created a template and handler.

Using ansible-playbook command to run the playbook

Thankyou so much for watching please dont forget to like ☺️

--

--