Created
January 7, 2011 18:18
-
-
Save bitprophet/769861 to your computer and use it in GitHub Desktop.
Fabric subroutine for prepping debconf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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