Hello cdist users! Good news to all of us, cdist (from version 4.2.0) now features files export.
As you know, types are the main component of cdist and define functionality. Many types use static files that have to be copied to remote host, or use its content. Types can also use templating.
Static files and templating scripts along template results are by convention stored into type's files sub-directory. And in your manifest and gencode scripts you reference these file through __type environment variables.
For example, to configure host with ssl certificate you put crt and key files into type's files sub-directory, e.g. /home/darko/.cdist/type/__ungleich_ssl_certificates/files and use it like:
__file /etc/ssl/certs/star.ungleich.ch.crt --mode 0644 –source $__type/files/star.ungleich.ch.crt
__file /etc/ssl/private/star.ungleich.ch.key --mode 0644 –source $__type/files/star.ungleich.ch.key
cdist now has new directory. Its path is <confdir>/files/, e.g. /home/darko/.cdist/files. Cdist does not care about this directory besides providing access to it. It is thought to be a general file storage area. You can access this directory using new environment variable __files. It is available for initial manifest, type manifest, type gencode and shell.
Now you can put all your static files into this new directory. You can have your files grouped logically into other directories or in type's files sub-directory, as before, and have links in this new directory.
For the above example with crt and key files you can now put those files, or links to them, into /home/darko/.cdist/files/ and use it like:
__file /etc/ssl/certs/star.ungleich.ch.crt --mode 0644 –source $__files/star.ungleich.ch.crt
__file /etc/ssl/private/star.ungleich.ch.key --mode 0644 –source $__files/star.ungleich.ch.key
Now you have a central place for files used for various types where you can more easily manipulate them.
Note that this is an additional feature, not a feature that will replace old way of doing. You don't need to move/make links of your existing files under type directories, you can continue using files as you used before.
We'll be back soon with more cool features, stay tuned!