NetDevOps: important idempotence
As more and more network engineers dive into network automation, the word idempotence keeps coming up. What is it? Why is it important? Why should we care? Idempotence is often described as the ability to perform the same task repeatedly and produce the same result. I want to demonstrate a super simple example of what this means.
If I am logged into a Linux box and want to add an IP address to the loopback address, I could use something simple like a sed command.
root@leaf01:mgmt-vrf:~# sed -i '/loopback/ a address 1.1.1.1/32' /etc/network/interfaces
This produces exactly what I want!
auto lo
iface lo inet loopback
address 1.1.1.1/32
address 10.0.0.11/32
I have appended the address 1.1.1.1/32 to the loopback interface stanza of the /etc/network/interfaces file. Now what happens if I run that same exact command again?
Running the command again produces the following output:
auto lo
iface lo inet loopback
address 1.1.1.1/32
address 1.1.1.1/32
address 10.0.0.11/32
That is not what I wanted. I performed the same task but instead of just leaving the file alone, since the 1.1.1. Continue reading