Concepts / Automation and APIs

Automation and APIs

Idempotence

Also called idempotent, changed=0, desired state, declarative

Doing it again changes nothing: a run that describes a state leaves a device already in that state alone.

The second run changes nothing
The second run changes nothing

A run that describes a state changes only the difference, so once the device matches there is nothing left to do. The same command typed twice is not like that: it repeats or fails.

Idempotence means doing it again changes nothing. An idempotent playbook compares what is with what should be and changes only the difference, so a second run reports changed=0. So it is safe to repeat, and changed means a device was not as described. A script of commands is not idempotent: replayed, it may add a line twice or fail. In HTTP, PUT and DELETE are idempotent; POST is not.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab