Understanding idempotency
A key feature of Puppet is its idempotency: the ability to repeatedly apply a manifest to guarantee a desired resource state on a system, with the same results every time.
If a given resource is already in the desired state, Puppet performs no actions. If a given resource is not in the desired state, Puppet takes whatever action is necessary to put the resource into the desired state. Idempotency enables Puppet to simulate resource changes without performing them, and lets you set up configuration management one time, fixing configuration drift without recreating resources from scratch each time Puppet runs.
To demonstrate how Puppet can be applied
repeatedly to get the same results, change the manifest at c:\myfiles\file.pp
to the following:
file { 'C:\\Temp\\foo.txt':
ensure => present,
content => 'I have changed my file content.'
}
Apply the manifest by running puppet apply c:\myfiles\file.pp
. Open c:\Temp\foo.txt
and notice that Puppet changes the
file's contents.
Applying the manifest again with puppet apply c:\myfiles\file.pp
results in no changes to the system, demonstrating
that Puppet behaves idempotently.
Many of the samples in Puppet documentation
assume that you have this basic understanding of creating and editing manifest files, and
applying them with puppet apply
.