Learning Automation - Good Automation Practices | Roei Amsalem Learning Automation - Good Automation Practices | Roei Amsalem

Good Automation Practices

This page focuses on the practices that make automation safer and more reliable.

Idempotency

Idempotency means repeated runs keep the same desired end-state.

state: present means “this config should exist in the final state.”

state: absent means “this config should not exist in the final state.”

Single idempotent code example (state: present):

- name: Ensure MOTD banner is present
  cisco.ios.ios_banner:
    banner: motd
    text: Authorized access only
    state: present


This single task achieves idempotency with the 3 outcomes:

When you want the opposite behavior (remove instead of enforce), use state: absent.