Puppet – exec resource type

During one of the interviews I’ve been asked the question what is “idempotency” and how it is related to Puppet. Forget about the relation but I dont even know the meaning of the word.

All the resources in puppet is to make sure the status of the system is maintained with what is configured and if the status matches then do not run once again. For e.g. package resource with ensure as present – so on the system if it is already present do not do anything and if not present then install it.

There is one exception though – exec resource which is used to execute the command. If there are no constraints then the command given in the exec resource every time puppet agent runs on the server which is not ideal for the concept of puppet idempotency. So there are additional arguments we need to use like “onlyif”, “unless”, “creates” and “refreshonly” etc.

For e.g. we have a exec resource to download a file- use “onlyif” to download when the file is not present. use “creates” to the full of the file where it is going to be downloaded so first time when the file is not present it downloads and the next time when the file is present then it won’t do anything. use “refreshonly” to execute the command only when it receives a notification from another event.

More information : https://docs.puppet.com/puppet/latest/types/exec.html


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s