Subject: Bug#487300: debconf: preseeding values for questions with template of other name (from dbconfig-common)

From: Vaclav Ovsik <[email-masked]>
Date: Wed, 16 Nov 2016 22:56:30 +0100

Package: debconf
Version: 1.5.59
Followup-For: Bug #487300

I work on scripts for unattended installing OpenStack instance for
testing (work-in-progress) and I use debconf preseeding using
debconf-set-selections.
https://anonscm.debian.org/cgit/users/zito-guest/setup-openstack.git/
Packages use dbconfig-common for database setup. The first such package
in sequence is keystone in script os-controller-install.
Before installing keystone I feed debconf-set-selections with e.g.

  keystone        keystone/database-type          select  mysql

this creates following record in config.dat file

  Name: keystone/database-type
  Template: keystone/database-type
  Value: mysql
  Owners: keystone
  Flags: seen

and record in templates.dat file:

  Name: keystone/database-type
  Description: Dummy template
  Extended_description: This is a fake template used to pre-seed the debconf database. If you are seeing this, something is probably wrong.
  Type: select
  Owners: keystone/database-type

After installing keystone, records are transformed into:

config.dat contains:

  Name: keystone/database-type
  Template: dbconfig-common/database-type
  Value: mysql
  Owners: keystone
  Flags: seen
  Variables:
   database_types = sqlite3, mysql
   dbvendor = MySQL
   pkg = keystone
  
templates.dat contains:

  Name: dbconfig-common/database-type
  Choices: ${database_types}
  Description: Database type to be used by ${pkg}:
  ...
  Type: select 
  Owners: dbconfig-common/database-type, keystone/database-type 

So far so good, But because some values are removed from debconf database by
postinst maintainer script (e.g. password of database admin) I need to preseed
some values with keystone installed again so I can do unattended package
removal. This second preseeding doesn't affect record in config.dat
(because value is the same), but debconf-set-selections creates one more
time "Dummy template". After purging the package keystone, this dummy
value left in templates db.

This dummy template (orphaned) now breaks the next try to preseed values
again, because debconf-set-selections fails:

  error: Cannot find a question for keystone/database-type

Dummy template must be removed, to preseed values again.
Hope this helps a bit.
Cheers
-- 
Zito