debconf
A preset answer to a question a Debian or Ubuntu package asks when it installs, such as postfix’s mailer type, so apt installs it without a prompt. Removing it leaves the answer as it is.
Use debconf to answer a package’s install-time questions before apt asks them. Some Debian and Ubuntu packages stop to ask something on first install: postfix wants its mailer type, tzdata its area, iptables-persistent whether to save the current rules. Preset the answer and the package step that follows installs without a prompt. It’s what debconf-set-selections does from a preseed file, as a step that notices when the answer changes.
Example usage
Section titled “Example usage”Install postfix as an internet site without the dialog:
step "postfix_answers" { debconf { name = "postfix" question = "postfix/main_mailer_type" vtype = "select" value = "Internet Site" }}A password question takes value_wo, so the secret stays out of plan and state:
step "db_password" { debconf { name = "app" question = "app/db_password" vtype = "password" value_wo = "use an ephemeral variable here" }}In a real configuration, set value_wo from a variable with ephemeral = true, as Secrets in files shows.
Arguments
Section titled “Arguments”| Name | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Package that owns the question, such as postfix. |
question |
string | Yes | The question, such as postfix/main_mailer_type. debconf-show |
value |
string | No | The answer, as debconf-set-selections takes it: true or false for a boolean, the choices separated by “, “ for a multiselect. State keeps it, so put a password in value_wo. Set exactly one of value and value_wo. |
value_wo |
string | No | Write-only: the answer, kept out of plan and state, for a password question. State records only value_hmac. debconf-show hides a password, so a refresh asks debconf itself for the answer the host has and compares its HMAC, which is how a password changed on the host shows as drift. |
vtype |
string | Yes | The question’s type, as the package’s templates declare it: boolean, select, multiselect, string, password, text, note, title or error. |
Read-only attributes
Section titled “Read-only attributes”Conn3x sets these; reference them as conn3x_debconf.<circuit>__<step>["<host>"].<name>.
| Name | Type | Description |
|---|---|---|
in_sync |
bool | Whether debconf on the host has the answer. |
revision |
string | Changes each time Conn3x changes this on the host. Handlers watch it. |
value_hmac |
string | HMAC-SHA256 of value_wo, keyed by CONN3X_HMAC_KEY or ~/.config/conn3x/hmac.key. Null with value. |
A step lowers to the conn3x_debconf resource, one instance per host, and connects with its circuit’s ssh block.
How it works
Section titled “How it works”Reading. On every plan, Conn3x runs debconf-show <name> on the host and looks for question and its answer. in_sync is true when the answer is value. A question the host doesn’t have yet is out of sync, so the first apply records it.
Applying. Conn3x feeds name question vtype value to debconf-set-selections, then reads the answer back: the tool exits 0 even on a line it skipped, so the step fails if the answer didn’t take. Set the answer before the package step that installs the package; an answer set after the install doesn’t change what the package already did.
Passwords. debconf-show prints (password omitted) for a password question, so for one Conn3x asks debconf itself, through debconf-communicate, for the answer the host has. With value_wo, state keeps only value_hmac, an HMAC of the answer keyed by CONN3X_HMAC_KEY or ~/.config/conn3x/hmac.key; a refresh hashes the host’s answer with the same key and compares. A password changed on the host shows up as drift and the next apply sets yours again, without the password ever reaching the plan or state. Every machine that runs this circuit needs the same key, as for a file with content_wo.
Types. vtype is the type the package’s templates declare: boolean, select, multiselect, string, password, text, note, title or error. debconf-set-selections writes whatever it’s given, so a boolean must be true or false here. A changed vtype is an update, but a type changed on the host isn’t drift: only the answer is compared.
Where it runs. debconf is Debian and Ubuntu’s. On a host in the Red Hat family the step fails and says so; give those hosts their own steps.
Changes. Changing value, value_wo or vtype updates the answer in place. Changing name or question is a different answer, so the plan replaces the step. There’s no on_remove: removing the step leaves the answer in debconf.
From Ansible
Section titled “From Ansible”conn3x convert ansible turns ansible.builtin.debconf tasks that set a question into debconf steps. A password question gets a TODO to set value_wo from an ephemeral variable, since the converter never copies a secret. A task with only name, which lists a package’s answers, and vtype: seen or unseen: true, which only touch the seen flag, stay for review.