Recognize Puppet Managed Files – Part 1

On Puppet managed systems it might be interesting and sometimes even important to know, if a file is managed by Puppet, because manual changes will be overridden next time Puppet executes. There are some exceptions from this behavior, e.g. files below /var/spool/cron still allow manual changes. In any case, it would be nice to know if the file is managed by Puppet. Of course it’s good practice to have a header in every file from Puppet, but this may not be possible in every case.

I’m only using vim on my machines and discovered a very nice plugin. It’s called Tangledstrings by Chris Jones and displays a warning message once a file is opened or saved. However, it does of course not prevent from saving the file.

This plugin is both simple and awesome! So I’d like to share some of my experiences and the way I rolled out the plugin on my Puppet boxes.

Once the plugin is downloaded – it’s just a simple file – open it with vim:

[root@somehost ~]# vim tangledstrings.vba

Then, inside vim, source the plugin in command mode by issuing:

:so %

Then you may quit vim or continue working as usual. However, looking at the directory structure below ~/.vim brings up these files:

[root@somehost ~]# tree .vim
├── doc
├── tags
│ └── tangledstrings.txt
├── plugin
│ ├── tangledstrings.vba
│ └── tangledstrings.vim
└── .VimballRecord

For rolling out with Puppet, I simply copied this directory structure to the files directory of my unix-common module. A very common file resource then takes care of having everything in place on my machines:

file {"/root/.vim":
    ensure => directory,
    source => 'puppet:///modules/unix-common/vim',
    recurse => true,
    purge => false,
    group => "root",
    owner => "root",
    mode => 0755,

Beware that I used user root for installing and rolling out the plugin. There’s some hard-wired user stuff inside the plugin after installing. So if you want to use it for other users, please refer to the second part of this post here.

If everything went well and you open a Puppet managed file, you will see a warning message like this one:

Tangledstrings warning message.

Warning message displayed when a Puppet managed file is opened.


  • Thanks to Chris Jones who provided this plugin! He gives a short introduction on the plugin on his blog here.
  • Download the plugin from its launchpad site here.

By the way: VIM turned 20 this year (2011)! Congratulations!


No comments yet.

Leave a Reply

* Copy This Password *

* Type Or Paste Password Here *