How do I provide dpkg configuration parameters to aptitude or apt-get?

When installing gitolite I find that:

# aptitude install gitolite
The following NEW packages will be installed:
  gitolite 
0 packages upgraded, 1 newly installed, 0 to remove and 29 not upgraded.
Need to get 114 kB of archives. After unpacking 348 kB will be used.
Get:1 http://security.debian.org/ squeeze/updates/main gitolite all 1.5.4-2+squeeze1 [114 kB]
Fetched 114 kB in 0s (202 kB/s)
Preconfiguring packages ...
Selecting previously deselected package gitolite.
(Reading database ... 30593 files and directories currently installed.)
Unpacking gitolite (from .../gitolite_1.5.4-2+squeeze1_all.deb) ...
Setting up gitolite (1.5.4-2+squeeze1) ...
No adminkey given - not initializing gitolite in /var/lib/gitolite.

The last line is of interest to me. If I run dpkg-reconfigure -plow gitolite I am presented with a dialog and can modify:

  • the system user name for gitolite,
  • the location of the gitolite repositories and
  • provide the admin pubkey.

I'd prefer to use the git system user and provide the admin pubkey on installation, say something of the sort:

# aptitude install gitolite --user git --admin-pubkey 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDAc7kCAi2WkvqpAL1fK1sIw6xjpatJ+Ms2nrwLJPhdovEY3MPZF7mtH+rv1CHFDn66fLGiWevOFp...'

That, of course, doesn't work. Can something similar be done? How do I determine the configuration parameters ahead of time? This would be remarkably useful, for instance, when installing gitolite automatically, via puppet or chef.


I haven't tested this, but I believe that after you run your dpkg-reconfigure on an example machine, you can run debconf-get-selections | egrep "^gitolite\s" to get what was set. (it's in the debconf-utils package if you don't have it).

Then on the CLI, debconf-set-selections $FILENAME before running apt.

Then with puppet it would be something like:

file {
  "/var/cache/debconf/gitolite.preseed":
     source => '...'; # someplace with that output
}
package {
  "gitolite":
    require      => File["/var/cache/debconf/gitolite.preseed"],
    responsefile => "/var/cache/debconf/gitolite.preseed";
}

More info on puppet's site:

  • https://projects.puppetlabs.com/projects/1/wiki/Debian_Preseed_Patterns
  • https://projects.puppetlabs.com/projects/1/wiki/Debian_Patterns
  • https://puppet.com/docs/puppet/7/types/package.html

I suspect Chef has a similar mechanism for specifying a responsefile or preseed file or something like that, but I'm not a Chef user.


You need to provide a preseed to work around this. See how it is done for Java in this module. I find that the easiest way to get a preseed file is to do a manual installation and configuration first, and then getting the seed from that. This blog has a good example of this.