Skip to content

debconf

Collection Note

This module is part of the ansible.builtin collection. To install the collection, use:

ansible-galaxy collection install ansible.builtin
Added in version 1.6.

You need further requirements to be able to use this module, see the Requirements section for details.

Synopsis

  • Configure a .deb package using debconf-set-selections.
  • Or just query existing selections.

Requirements

The following Python packages are needed on the host that executes this module:

Parameters

Parameter Defaults / Choices Comments
name
str
required
Name of package to configure.
question
str
A debconf configuration setting.
unseen
bool
Do not set C(seen) flag when pre-seeding.
value
raw
Value to set the configuration to.
After Ansible 2.17, C(value) is of type C(raw).
vtype
str
Choices: boolean, error, multiselect, note, password, seen, select, string, text, title The type of the value supplied.
It is highly recommended to add C(no_log=True) to task while specifying O(vtype=password).
V(seen) was added in Ansible 2.2.
After Ansible 2.17, user can specify C(value) as a list, if C(vtype) is set as V(multiselect).

Notes

Note

  • This module requires the command line debconf tools.
  • Several questions have to be answered (depending on the package). Use 'debconf-show ' on any Debian or derivative with the package installed to see questions/settings available.
  • Some distros will always record tasks involving the setting of passwords as changed. This is due to C(debconf-get-selections) masking passwords.
  • It is highly recommended to add C(no_log=True) to the task while handling sensitive information using this module.
  • The M(ansible.builtin.debconf) module does not reconfigure packages, it just updates the debconf database. An additional step is needed (typically with C(notify) if debconf makes a change) to reconfigure the package and apply the changes. C(debconf) is extensively used for pre-seeding configuration prior to installation rather than modifying configurations. So, while C(dpkg-reconfigure) does use debconf data, it is not always authoritative and you may need to check how your package is handled.
  • Also note C(dpkg-reconfigure) is a 3-phase process. It invokes the control scripts from the C(/var/lib/dpkg/info) directory with the C(.prerm reconfigure ), C(.config reconfigure ) and C(.postinst control ) arguments.
  • The main issue is that the C(.config reconfigure) step for many packages will first reset the debconf database (overriding changes made by this module) by checking the on-disk configuration. If this is the case for your package then C(dpkg-reconfigure) will effectively ignore changes made by debconf.
  • However as C(dpkg-reconfigure) only executes the C(.config) step if the file exists, it is possible to rename it to C(/var/lib/dpkg/info/.config.ignore) before executing C(dpkg-reconfigure -f noninteractive ) and then restore it. This seems to be compliant with Debian policy for the .config file.

Examples

- name: Set default locale to fr_FR.UTF-8
  ansible.builtin.debconf:
    name: locales
    question: locales/default_environment_locale
    value: fr_FR.UTF-8
    vtype: select

- name: Set to generate locales
  ansible.builtin.debconf:
    name: locales
    question: locales/locales_to_be_generated
    value: en_US.UTF-8 UTF-8, fr_FR.UTF-8 UTF-8
    vtype: multiselect

- name: Accept oracle license
  ansible.builtin.debconf:
    name: oracle-java7-installer
    question: shared/accepted-oracle-license-v1-1
    value: 'true'
    vtype: select

- name: Specifying package you can register/return the list of questions and current values
  ansible.builtin.debconf:
    name: tzdata

- name: Pre-configure tripwire site passphrase
  ansible.builtin.debconf:
    name: tripwire
    question: tripwire/site-passphrase
    value: "{{ site_passphrase }}"
    vtype: password
  no_log: True

Authors

  • Brian Coca (@bcoca)