Restarting HTTPD Service is not
idempotence in nature and also consume more
resources suggest a way to rectify this challenge
in Ansible playbook

Pravat kumar Nath sharma
2 min readMar 31, 2021

What is idempotence:

Idempotence is a safe practice for DevOps teams when developing applications. Idempotence ensures a safe, quality experience for both users and software teams. No one has to go in afterwards and clean up a mess.

For example, idempotence is the design standard for Ansible, a DevOps tool for system administrators to manage their servers. Ansible can automate the server setup process, consistently create the same servers, and automatically deploy them. There is a lot of orchestration that occurs in automating this process — and it is idempotent behaviors that ensure only one directory gets created on a server, and only an exact number of servers get created.

The idempotence function can be used in a variety of ways. Engineers want the destination to be the same, but the route that an orchestrator wishes to take can be different. If one function is called and the route it takes fails, another route can be tried. If one route lags, and a new one is fired, then, if both tasks make it to the endpoint, the result at the destination can still be the same.

Idempotent behavior is ever more crucial in cloud computing and edge devices. When multiple accounts can be logged in at once, accessed from different locations and different devices, updated from multiple user accounts, and data sent from one place to another, idempotent design helps manage the application’s state more efficiently and without error.

in thsi program i had setup httpd idempptent:

  • hosts: localhost
    tasks:
    — name: “Installing HTTPD”
    package:
    name: httpd
    state: present
    — name:
    copy:
    src: “index.html”
    dest: “/var/www/html/”
    register: x
    — name: “testing”
    debug:
    var: x
    — name: “Starting the services provided that the service isn’t running”
    service:
    name: httpd
    state: restarted
    when: x.changed == true
    handlers:
    — name: changed
    service:
    name: “httpd”
    state: restarted
    enabled: yes

--

--