Method __init__
__init__( self )
Undocumented
wrapper_descriptor
x.__repr__() <==> repr(x)
Class mode_sudo
Cuisine functions will be executed with sudo.
Method __init__
__init__( self )
Undocumented
Class mode_user
Cuisine functions will be executed as the current user.
Function command_check
command_check( command )
Tests if the given command is available on the system.
Function command_ensure
command_ensure( command, package=None )
Ensures that the given command is present, if not installs the package with the given
name, which is the same as the command by default.
Function dir_attribs
dir_attribs( location, mode=None, owner=None, group=None, recursive=False )
Updates the mode/owner/group for the given remote directory.
Function dir_ensure
dir_ensure( location, recursive=False, mode=None, owner=None, group=None )
Ensures that there is a remote directory at the given location, optionnaly
updating its mode/owner/group.
If we are not updating the owner/group then this can be done as a single
ssh call, so use that method, otherwise set owner/group after creation.
Function dir_exists
dir_exists( location )
Tells if there is a remote directory at the given location.
Function file_append
file_append( location, content, mode=None, owner=None, group=None )
Appends the given content to the remote file at the given location, optionally
updating its mode/owner/group.
Function file_attribs
file_attribs( location, mode=None, owner=None, group=None, recursive=False )
Updates the mode/owner/group for the remote file at the given location.
Function file_attribs_get
file_attribs_get( location )
Get the mode, owner, and group for a remote file.
Function file_exists
file_exists( location )
Tests if there is a *remote* file at the given location.
Function file_read
file_read( location )
Reads the *remote* file at the given location.
Function file_update
file_update( location, updater= at 0x25787d0> )
Updates the content of the given by passing the existing content of the remote file
at the given location to the 'updater' function.
For instance, if you'd like to convert an existing file to all uppercase, simply do:
> file_update("/etc/myfile", lambda _:_.upper())
Function file_write
file_write( location, content, mode=None, owner=None, group=None )
Writes the given content to the file at the given remote location, optionally
setting mode/owner/group.
Function group_check
group_check( name )
Checks if there is a group defined with the given name, returning its information
as a '{"name":<str>,"gid":<str>,"members":<list[str]>}' or 'None' if the group
does not exists.
Function group_create
group_create( name, gid=None )
Creates a group with the given name, and optionally given gid.
Function group_ensure
group_ensure( name, gid=None )
Ensures that the group with the given name (and optional gid) exists.
Function wrapper
wrapper( *args, **kwargs )
Undocumented
Function group_user_check
group_user_check( group, user )
Checks if the given user is a member of the given group. It will return 'False'
if the group does not exist.
Function group_user_ensure
group_user_ensure( group, user )
Ensure that a given user is a member of a given group.
Function local_read
local_read( location )
Reads a *local* file from the given location, expanding '~' and shell variables.
Function multiargs
multiargs( function )
Decorated functions will be 'map'ed to every element of the first argument
if it is a list or a tuple, otherwise the function will execute normally.
Function wrapper
wrapper( *args, **kwargs )
Undocumented
Function package_install
package_install( package, update=False )
Installs the given package/list of package, optionnaly updating the package
database.
Function package_update
package_update( package=None )
Updates the package database (when no argument) or update the package
or list of packages given as argument.
Function run
run( *args, **kwargs )
A wrapper to Fabric's run/sudo commands, using the 'cuisine.MODE' global
to tell wether the command should be run as regular user or sudo.
Function ssh_authorize
ssh_authorize( user, key )
Adds the given key to the '.ssh/authorized_keys' for the given user.
Function ssh_keygen
ssh_keygen( user, keytype='dsa' )
Generates a pair of ssh keys in the user's home .ssh directory.
Function sudo
sudo( *args, **kwargs )
A wrapper to Fabric's run/sudo commands, using the 'cuisine.MODE' global
to tell wether the command should be run as regular user or sudo.
Function text_detect_eol
text_detect_eol( text )
Undocumented
Function text_ensure_line
text_ensure_line( text, *lines )
Ensures that the given lines are present in the given text, otherwise appends the lines
that are not already in the text at the end of it.
Function text_get_line
text_get_line( text, predicate )
Returns the first line that matches the given predicate.
Function text_normalize
text_normalize( text )
Converts tabs and spaces to single space and strips the text.
Function text_nospace
text_nospace( text )
Converts tabs and spaces to single space and strips the text.
Function text_replace_line
text_replace_line( text, old, new, find= at 0x2578230>, process= at 0x25782a8> )
Replaces lines equal to 'old' with 'new', returning the new text and the
count of replacements.
Function text_strip_margin
text_strip_margin( text, margin='|' )
Undocumented
Function text_template
text_template( text, variables )
Substitutes '${PLACEHOLDER}'s within the text with the
corresponding values from variables.
Function upstart_ensure
upstart_ensure( name )
Ensures that the given upstart service is running, restarting it if necessary
Function user_check
user_check( name )
Checks if there is a user defined with the given name, returning its information
as a '{"name":<str>,"uid":<str>,"gid":<str>,"home":<str>,"shell":<str>}' or 'None' if
the user does not exists.
Function user_create
user_create( name, passwd=None, home=None, uid=None, gid=None, shell=None, uid_min=None, uid_max=None )
Creates the user with the given name, optionally giving a specific password/home/uid/gid/shell.
Function user_ensure
user_ensure( name, passwd=None, home=None, uid=None, gid=None, shell=None )
Ensures that the given users exists, optionally updating their passwd/home/uid/gid/shell.
str
'\n'
str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
str
'user'
str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
SRE_Pattern
Compiled regular expression objects
str
'0.0.9'
str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
str
'\r\n'
str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
Module cuisine
Cuisine
~~~~~~~
``cuisine`` makes it easy to write automatic server installation and
configuration recipies by wrapping common administrative tasks
(installing packages, creating users and groups) in Python functions.
``cuisine`` is designed to work with Fabric and provide all you need
for getting your new server up and running in minutes.
Note, that right now, Cuisine only supports Debian-based Linux systems.
.. seealso::
`Deploying Django with Fabric
<http://lethain.com/entry/2008/nov/04/deploying-django-with-fabric>`_
`Notes on Python Fabric 0.9b1
<http://www.saltycrane.com/blog/2009/10/notes-python-fabric-09b1>`_
`EC2, fabric, and "err: stdin: is not a tty"
<http://blog.markfeeney.com/2009/12/ec2-fabric-and-err-stdin-is-not-tty.html>`_
:copyright: (c) 2011 by Sebastien Pierre, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
str
'0.0.9'
str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
Function text_detect_eol
text_detect_eol( text )
Undocumented
str
'\r\n'
str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
Function user_check
user_check( name )
Checks if there is a user defined with the given name, returning its information
as a '{"name":<str>,"uid":<str>,"gid":<str>,"home":<str>,"shell":<str>}' or 'None' if
the user does not exists.
Function user_create
user_create( name, passwd=None, home=None, uid=None, gid=None, shell=None, uid_min=None, uid_max=None )
Creates the user with the given name, optionally giving a specific password/home/uid/gid/shell.
Function text_template
text_template( text, variables )
Substitutes '${PLACEHOLDER}'s within the text with the
corresponding values from variables.
Function upstart_ensure
upstart_ensure( name )
Ensures that the given upstart service is running, restarting it if necessary
str
'user'
str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
SRE_Pattern
Compiled regular expression objects
Function user_ensure
user_ensure( name, passwd=None, home=None, uid=None, gid=None, shell=None )
Ensures that the given users exists, optionally updating their passwd/home/uid/gid/shell.
str
'\n'
str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
Function text_ensure_line
text_ensure_line( text, *lines )
Ensures that the given lines are present in the given text, otherwise appends the lines
that are not already in the text at the end of it.
Function text_get_line
text_get_line( text, predicate )
Returns the first line that matches the given predicate.
Function sudo
sudo( *args, **kwargs )
A wrapper to Fabric's run/sudo commands, using the 'cuisine.MODE' global
to tell wether the command should be run as regular user or sudo.
Function group_user_ensure
group_user_ensure( group, user )
Ensure that a given user is a member of a given group.
Function text_replace_line
text_replace_line( text, old, new, find= at 0x2578230>, process= at 0x25782a8> )
Replaces lines equal to 'old' with 'new', returning the new text and the
count of replacements.
Function text_strip_margin
text_strip_margin( text, margin='|' )
Undocumented
Function text_normalize
text_normalize( text )
Converts tabs and spaces to single space and strips the text.
Function text_nospace
text_nospace( text )
Converts tabs and spaces to single space and strips the text.
Function wrapper
wrapper( *args, **kwargs )
Undocumented
Function package_install
package_install( package, update=False )
Installs the given package/list of package, optionnaly updating the package
database.
Function multiargs
multiargs( function )
Decorated functions will be 'map'ed to every element of the first argument
if it is a list or a tuple, otherwise the function will execute normally.
Function ssh_authorize
ssh_authorize( user, key )
Adds the given key to the '.ssh/authorized_keys' for the given user.
Function ssh_keygen
ssh_keygen( user, keytype='dsa' )
Generates a pair of ssh keys in the user's home .ssh directory.
Function package_update
package_update( package=None )
Updates the package database (when no argument) or update the package
or list of packages given as argument.
Function run
run( *args, **kwargs )
A wrapper to Fabric's run/sudo commands, using the 'cuisine.MODE' global
to tell wether the command should be run as regular user or sudo.
Function local_read
local_read( location )
Reads a *local* file from the given location, expanding '~' and shell variables.
Function group_user_check
group_user_check( group, user )
Checks if the given user is a member of the given group. It will return 'False'
if the group does not exist.
Function file_update
file_update( location, updater= at 0x25787d0> )
Updates the content of the given by passing the existing content of the remote file
at the given location to the 'updater' function.
For instance, if you'd like to convert an existing file to all uppercase, simply do:
> file_update("/etc/myfile", lambda _:_.upper())
Function file_write
file_write( location, content, mode=None, owner=None, group=None )
Writes the given content to the file at the given remote location, optionally
setting mode/owner/group.
Function file_exists
file_exists( location )
Tests if there is a *remote* file at the given location.
Function file_read
file_read( location )
Reads the *remote* file at the given location.
Function group_ensure
group_ensure( name, gid=None )
Ensures that the group with the given name (and optional gid) exists.
Function wrapper
wrapper( *args, **kwargs )
Undocumented
Function group_check
group_check( name )
Checks if there is a group defined with the given name, returning its information
as a '{"name":<str>,"gid":<str>,"members":<list[str]>}' or 'None' if the group
does not exists.
Function group_create
group_create( name, gid=None )
Creates a group with the given name, and optionally given gid.
Function dir_attribs
dir_attribs( location, mode=None, owner=None, group=None, recursive=False )
Updates the mode/owner/group for the given remote directory.
Function dir_ensure
dir_ensure( location, recursive=False, mode=None, owner=None, group=None )
Ensures that there is a remote directory at the given location, optionnaly
updating its mode/owner/group.
If we are not updating the owner/group then this can be done as a single
ssh call, so use that method, otherwise set owner/group after creation.
Function command_check
command_check( command )
Tests if the given command is available on the system.
Function command_ensure
command_ensure( command, package=None )
Ensures that the given command is present, if not installs the package with the given
name, which is the same as the command by default.
Function file_attribs
file_attribs( location, mode=None, owner=None, group=None, recursive=False )
Updates the mode/owner/group for the remote file at the given location.
Function file_attribs_get
file_attribs_get( location )
Get the mode, owner, and group for a remote file.
Function dir_exists
dir_exists( location )
Tells if there is a remote directory at the given location.
Function file_append
file_append( location, content, mode=None, owner=None, group=None )
Appends the given content to the remote file at the given location, optionally
updating its mode/owner/group.
Class mode_sudo
Cuisine functions will be executed with sudo.
Method __init__
__init__( self )
Undocumented
Module cuisine
Cuisine
~~~~~~~
``cuisine`` makes it easy to write automatic server installation and
configuration recipies by wrapping common administrative tasks
(installing packages, creating users and groups) in Python functions.
``cuisine`` is designed to work with Fabric and provide all you need
for getting your new server up and running in minutes.
Note, that right now, Cuisine only supports Debian-based Linux systems.
.. seealso::
`Deploying Django with Fabric
<http://lethain.com/entry/2008/nov/04/deploying-django-with-fabric>`_
`Notes on Python Fabric 0.9b1
<http://www.saltycrane.com/blog/2009/10/notes-python-fabric-09b1>`_
`EC2, fabric, and "err: stdin: is not a tty"
<http://blog.markfeeney.com/2009/12/ec2-fabric-and-err-stdin-is-not-tty.html>`_
:copyright: (c) 2011 by Sebastien Pierre, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
Class mode_user
Cuisine functions will be executed as the current user.
Method __init__
__init__( self )
Undocumented
wrapper_descriptor
x.__repr__() <==> repr(x)