Installing configuration files to /etc or /usr/local/etc
Hi all,
I am working on my first serious python project. I am making a server application. This application has a config-file to store the configuration. At the moment the file has to reside in the current working directory to work, but I am making it so it needs to read from /etc or /usr/local/etc (in case of FreeBSD).
To install my application I use setup.py/setup.cfg generated with pyscaffold. How do I need to configure setup.cfg, so that it installs my config file in /etc (for Linux) or /usr/local/etc (for FreeBSD)?
Link to repo (Disclamer: It is far from finished, but it is functional)
Thanks in advance!
Posted Oct 12, 2015, 6:57 PM UTC
32
Generally, you would be better off using provisioning software like ansible to manage your configuration files. This is especially the case since most config files contain "secrets" that you do not want to keep in your source code. If you have never messed with server provisioning before, I would definitely suggest starting off with ansible, as it is easy to use, and requires only SSH.
http://www.ansible.com/
If you must keep the config file in your source control, you can place it wherever you want during package installation using 'data_files' in setup.py.
https://docs.python.org/2/distutils/setupscript.html#installing-additional-files
Thanks, I will definitely take a look at Ansible.