SaltStack and Debconfmod

Saltstack does a great job of installing packages. Unfortunately for Devops practitioners in the Debian/Ubuntu world, there is this wonderful addition to package management called debconf.

When packages are being installed, debconf asks the user questions which determine the contents of the system-wide configuration files associated with that package.

This is great for my friends that want to install MySQL on their Ubuntu laptop at home, but when I want to deploy 100 servers using my Configuration Management tools it tends to get underfoot.

Luckily, SaltStack has a very nice module to handle these use cases. The documentation could use a little work, so I have included a full example.

First you need to understand the questions that debconf is going to ask and the structure of the response. The easiest way to do this is simply install the package. Before we do this, we need a method to examine the results. We can do this with the debconf-get-selections command in Ubuntu.

If your server does not already have it, install it now.

apt-get install debconf-utils

Now, install your package. I am using proftpd as an example.

apt-get install proftpd-basic

Here is the ncurses prompt that you should encounter.
proftpd-ubuntu

Select ‘Standalone’ and let the package finish installing.

Now lets check the results. The result fields are program name, question, question_type, answer.

root@ubuntu-01:~# debconf-get-selections | grep proftpd-basic
proftpd-basic shared/proftpd/inetd_or_standalone select standalone

With this in hand, we can now implement our salt state. You can clearly see the data structure of question, type, value. Keep in mind the yaml intricacy noted in the docs about extra indentation for the data field.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
proftpd-debconf:
  pkg:
    - installed
    - name: debconf-utils
  debconf.set:
    - name: proftpd-basic
    - data:
        'shared/proftpd/inetd_or_standalone': {'type': 'select', 'value': 'standalone'}
 
proftpd:
  pkg:
    - installed
    - name: proftpd-basic
  service.running:
    - enable: True

Leave a Reply

Your email address will not be published. Required fields are marked *