In the official Puppet docs it says that there are two chaining arrows: https://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html
-> (ordering arrow) Causes the resource on the left to be applied before the resource on the right. Written with a hyphen and a greater-than sign.
~> (notification arrow) Causes the resource on the left to be applied first, and sends a refresh event to the resource on the right if the left resource changes. Written with a tilde and a greater-than sign.
Can someone clarify the difference between these two?
The document you mentioned has given the best explanation. If you try to understand it by simple way, using the exist sample.
Package['ntp'] -> File['/etc/ntp.conf'] ~> Service['ntpd']
For File['/etc/ntp.conf']
, puppet needs to make sure that the package ntp
has been installed before it creates or updates the file ntp.conf
. There is no restart request.
But for Service['ntpd'], ntp.conf
needs to exist first - that's the same order as ->
. * But if puppet finds the file ntp.conf
has any changes (whether it is created or updated), service ntp needs to be restarted. That's the difference*.
For more reading about ordering in puppet, please see these documents:
Learning Puppet — Resource Ordering
And do some testing by yourself to understand how it works.
--debug
option with the puppet apply
command. The debug log will give you detail in the background - for example, you should see that the file gets updated and the ntpd service gets restarted.