Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Unmanaged files and notification

A common question in the #puppet irc channel on freenode is: “How can I have puppet notify a service when I manually update a file?”

While I believe this “manual update” portion is an antipattern, in some cases (development server, whatever) it is desirable, and frankly I don't know your infrastructure and I don't know all of your motives, so it's worth showing how this is done :)

The code in this directory implements it. The gist of it is that you have puppet copy a local file and notify when that copy occurs.

Running it

# Start fresh:
% rm -f /tmp/flag /tmp/original

% echo "foo" > /tmp/original
% puppet apply unmanaged-notify.pp
notice: /Stage[main]//File[/tmp/flag]/ensure: defined content as '{md5}d3b07384d113edec49eaa6238ad5ff00'
notice: /Stage[main]//Exec[hello world]: Triggered 'refresh' from 1 events

# Run it again with no changes, no notify should happen:
% puppet apply unmanaged-notify.pp
<no output>

# Now change /tmp/original again
% echo "bar" > /tmp/original   
% puppet apply unmanaged-notify.pp
notice: /Stage[main]//File[/tmp/flag]/content: content changed '{md5}d3b07384d113edec49eaa6238ad5ff00' to '{md5}c157a79031e1c40f85931829bc5fc552'
notice: /Stage[main]//Exec[hello world]: Triggered 'refresh' from 1 events
You can’t perform that action at this time.