Skip to content

Instantly share code, notes, and snippets.

@bitprophet
Created January 7, 2011 18:18
Show Gist options
  • Save bitprophet/769861 to your computer and use it in GitHub Desktop.
Save bitprophet/769861 to your computer and use it in GitHub Desktop.
Fabric subroutine for prepping debconf
def debconf(package, key, value, type_='string', key_prefix=None):
"""
Seeds the debconf database with given values.
Take the following example::
debconf(
package='mysql-server',
key='root_password',
type_='password',
value='secret'
)
The above is equivalent to the following debconf seed line::
mysql-server mysql-server/root_password password secret
and results in that string being `sudo` echo'd into
`debconf-set-selections`.
By default, the package name is used as the prefix to the key; to
explicitly override this, set ``key_prefix``.
The default ``type_`` is `'string'`, which may also be overridden.
"""
return sudo("echo \"%s %s %s %s\" | debconf-set-selections" % (
package,
(key_prefix and key_prefix or package) + '/' + key,
type_,
value
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment