I have a database which consists of individual records, where each “record” lives in an independent YAML file. Let’s assume something like this, although the content is irrelevant:
YAML is a rather easy format to type, and I use it for recording all sorts of information, but I do occasionally introduce an error into a file, for example, a colon (:) where there shouldn’t be one. I’ve always wanted to be quickly notified of an error (before onwards conversion of the YAML, which is out of scope of this post).
I check files into git, so I could use git hooks, but I wanted more immediate feedback, something that, say, Inotify could provide, but that’s not portable across platforms.
One thing to note when using vim to edit files is, that the editor saves the current file under a temporary name and then unlinks/links to the original. To avoid that, I make sure the particular directory I’m watching modifies the original file directly by configuring this in my .vimrc:
I could imaging using watchdog for other things, such as
Checking that I’ve bumped a zone’s SOA serial number after editing a zone master file
Verifying that Ansible playbooks, which are also YAML, are valid
Creating a backup whenever something changes; for example versioned backups on a
Ideally the file system would reject modifications to a file containing errors, but that would mean a lot more work, for example implementing such a system atop a FUSE file system. For my use case, a warning suffices.