[PYTHON] Donner une égalité au tissu avec la cuisine

Qu'est-ce que la cuisine

cuisine est une bibliothèque qui donne l'égalité à fabric.

L'égalité est une caractéristique qui produit le même résultat, qu'elle soit exécutée une ou plusieurs fois. Dans le domaine des infrastructures, Chef, Puppet, [Ansible](http: //www.ansible. Des outils tels que com /) sont équitables. En d'autres termes, ces outils ont la propriété que le serveur sera dans le même état, qu'il soit exécuté une ou plusieurs fois.

Cependant, étant donné que le fabric n'est pas inégal, si vous ne tenez pas compte de l'état du paramètre au moment de l'exécution, une erreur se produira si vous l'exécutez plusieurs fois. Par exemple, si vous écrivez un script qui ajoute un utilisateur, la première exécution sera ajoutée avec succès, mais la seconde entraînera une erreur car l'utilisateur existe déjà.

J'ai utilisé Fabric pour les paramètres initiaux du serveur, mais j'écrivais le script avec uniquement les paramètres initiaux à l'esprit, donc j'étais en difficulté car je ne pouvais pas ré-exécuter même un petit changement ou une modification. De nos jours, il est difficile de passer à Chef, Puppet, Ansible et à d'autres outils capables de maintenir l'égalité, alors que dois-je faire? C'est donc la cuisine.

Le sens de la cuisine est comme la cuisine, la cuisine, etc. en français. Est-ce l'influence du chef? Est-ce l'origine de la cuisine? Est-il correct de lire "Cuigene"?

effet

La cuisine vous permet d'écrire des scripts de type tissu. Cela vous permet d'écrire l'état du serveur sous forme de script Fabric et de l'exécuter plusieurs fois. Vous pouvez également utiliser le script de suppression des paramètres par défaut pour ajouter ou modifier des paramètres pendant le fonctionnement.

Comment installer

L'installation est simple. Comme le tissu, il peut être installé avec pip. C'est tout. Tout ce que vous avez à faire est de l'importer et de l'utiliser dans votre script Fabric.

$ pip install fabric cuisine

Exemple de script

Vous trouverez ci-dessous un exemple de script Fabric pour les paramètres RPM et les paramètres utilisateur. Le package_ensure, ʻuser_ensure et ssh_authorized` dans le script sont les méthodes de cuisine. Puisque le serveur que j'ai essayé cette fois-ci était un système Red Hat, yum est sélectionné comme méthode de package.

fabfile.py


#-*- encoding:utf-8 -*-

from fabric.api import *
from fabric.decorators import task
from cuisine import *

#Sélection de la méthode de gestion des colis
select_package('yum')

#Liste des RPM que vous souhaitez installer
rpms = [ 'zip', 'unzip' ]

#Liste des utilisateurs que vous souhaitez enregistrer
#La clé publique est pubkeys/pubkey.Préparez-vous avec le nom d'utilisateur
users = ['hoge', 'fuga' ]


@task
def setup_rpms():
  for rpm in rpms:
    with mode_sudo():
      #Paramètres RPM
      package_ensure(rpm, update=False)


@task
def setup_users():
  for user in users:
    #Paramètres utilisateur
    user_ensure(user, passwd='password')

    #Réglage de la clé SSH
    pubkey = 'pubkeys/pubkey.' + user
    with open(pubkey) as f:
      pubkey_str = f.read()
    with mode_sudo():
      ssh_authorize(user, pubkey_str)

pydoc

Je n'ai pas beaucoup d'informations, donc je posterai le résultat de la cuisine pydoc. Dans l'exemple, nous avons utilisé des packages et des paramètres utilisateur, mais il existe d'autres mécanismes pour maintenir l'équivalence.

Help on module cuisine:

NAME
    cuisine

FILE
    /Library/Python/2.7/site-packages/cuisine.py

DESCRIPTION
    `cuisine` makes it easy to write automatic server installation
    and configuration recipes 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.

    See also:

    - 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-2013 by Sébastien Pierre.
    :license:   BSD, see LICENSE for more details.

CLASSES
    __builtin__.object
        Stats
    __mode_switcher(__builtin__.object)
        mode_local
        mode_remote
        mode_sudo
        mode_user

    class Stats(__builtin__.object)
     |  A work-in-progress class to store cuisine's statistics, so that you
     |  can have a summary of what has been done.
     |
     |  Methods defined here:
     |
     |  __init__(self)
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __dict__
     |      dictionary for instance variables (if defined)
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class mode_local(__mode_switcher)
     |  Sets Cuisine into local mode, where run/sudo won't go through
     |  Fabric's API, but directly through a popen. This allows you to
     |  easily test your Cuisine scripts without using Fabric.
     |
     |  Method resolution order:
     |      mode_local
     |      __mode_switcher
     |      __builtin__.object
     |
     |  Data and other attributes defined here:
     |
     |  MODE_KEY = 'CUISINE_MODE_LOCAL'
     |
     |  MODE_VALUE = True
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from __mode_switcher:
     |
     |  __enter__(self)
     |
     |  __exit__(self, type, value, traceback)
     |
     |  __init__(self, value=None)
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from __mode_switcher:
     |
     |  __dict__
     |      dictionary for instance variables (if defined)
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class mode_remote(__mode_switcher)
     |  Comes back to Fabric's API for run/sudo. This basically reverts
     |  the effect of calling `mode_local()`.
     |
     |  Method resolution order:
     |      mode_remote
     |      __mode_switcher
     |      __builtin__.object
     |
     |  Data and other attributes defined here:
     |
     |  MODE_KEY = 'CUISINE_MODE_LOCAL'
     |
     |  MODE_VALUE = False
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from __mode_switcher:
     |
     |  __enter__(self)
     |
     |  __exit__(self, type, value, traceback)
     |
     |  __init__(self, value=None)
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from __mode_switcher:
     |
     |  __dict__
     |      dictionary for instance variables (if defined)
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class mode_sudo(__mode_switcher)
     |  Cuisine functions will be executed with sudo.
     |
     |  Method resolution order:
     |      mode_sudo
     |      __mode_switcher
     |      __builtin__.object
     |
     |  Data and other attributes defined here:
     |
     |  MODE_KEY = 'CUISINE_MODE_SUDO'
     |
     |  MODE_VALUE = True
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from __mode_switcher:
     |
     |  __enter__(self)
     |
     |  __exit__(self, type, value, traceback)
     |
     |  __init__(self, value=None)
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from __mode_switcher:
     |
     |  __dict__
     |      dictionary for instance variables (if defined)
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class mode_user(__mode_switcher)
     |  Cuisine functions will be executed as the current user.
     |
     |  Method resolution order:
     |      mode_user
     |      __mode_switcher
     |      __builtin__.object
     |
     |  Data and other attributes defined here:
     |
     |  MODE_KEY = 'CUISINE_MODE_SUDO'
     |
     |  MODE_VALUE = False
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from __mode_switcher:
     |
     |  __enter__(self)
     |
     |  __exit__(self, type, value, traceback)
     |
     |  __init__(self, value=None)
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from __mode_switcher:
     |
     |  __dict__
     |      dictionary for instance variables (if defined)
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

FUNCTIONS
    apt_get(cmd)

    cd(*args, **kwargs)
        A wrapper around Fabric's cd to change the local directory if
        mode is local

    command_check(command)
        Tests if the given command is available on the system.

    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.

    connect(*args, **kwargs)
        Sets Fabric's current host to the given host. This is useful when
        using Cuisine in standalone.

    dir_attribs(*args, **kwargs)
        Updates the mode/owner/group for the given remote directory.

    dir_ensure(location, recursive=False, mode=None, owner=None, group=None)
        Ensures that there is a remote directory at the given location,
        optionally 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.

    dir_exists(location)
        Tells if there is a remote directory at the given location.

    dir_remove(*args, **kwargs)
        Removes a directory

    dispatch(prefix=None)
        Dispatches the current function to specific implementation. The `prefix`
        parameter indicates the common option prefix, and the `select_[option]()`
        function will determine the function suffix.

        For instance the package functions are defined like this:

        {{{
        @dispatch("package")
        def package_ensure(...):
                ...
        def package_ensure_apt(...):
                ...
        def package_ensure_yum(...):
                ...
        }}}

        and then when a user does

        {{{
        cuisine.select_package("yum")
        cuisine.package_ensure(...)
        }}}

        then the `dispatch` function will dispatch `package_ensure` to
        `package_ensure_yum`.

        If your prefix is the first word of the function name before the
        first `_` then you can simply use `@dispatch` without parameters.

    file_append(*args, **kwargs)
        Appends the given content to the remote file at the given
        location, optionally updating its mode/owner/group.

    file_attribs(*args, **kwargs)
        Updates the mode/owner/group for the remote file at the given
        location.

    file_attribs_get(*args, **kwargs)
        Return mode, owner, and group for remote path.
        Return mode, owner, and group if remote path exists, 'None'
        otherwise.

    file_backup(*args, **kwargs)
        Backups the file at the given location in the same directory, appending
        the given suffix. If `once` is True, then the backup will be skipped if
        there is already a backup file.

    file_base64(*args, **kwargs)
        Returns the base64-encoded content of the file at the given location.

    file_ensure(*args, **kwargs)
        Updates the mode/owner/group for the remote file at the given
        location.

    file_exists(location)
        Tests if there is a *remote* file at the given location.

    file_is_dir(location)

    file_is_file(location)

    file_is_link(location)

    file_link(*args, **kwargs)
        Creates a (symbolic) link between source and destination on the remote host,
        optionally setting its mode/owner/group.

    file_local_read(*args, **kwargs)
        Reads a *local* file from the given location, expanding '~' and
        shell variables.

    file_md5(*args, **kwargs)
        Returns the MD5 sum (as a hex string) for the remote file at the given location.

    file_read(*args, **kwargs)
        Reads the *remote* file at the given location, if default is not `None`,
        default will be returned if the file does not exist.

    file_sha256(*args, **kwargs)
        Returns the SHA-256 sum (as a hex string) for the remote file at the given location.

    file_unlink(*args, **kwargs)

    file_update(*args, **kwargs)
        Updates the content of the given by passing the existing
        content of the remote file at the given location to the 'updater'
        function. Return true if file content was changed.

        For instance, if you'd like to convert an existing file to all
        uppercase, simply do:

        >   file_update("/etc/myfile", lambda _:_.upper())

        Or restart service on config change:

        >   if file_update("/etc/myfile.cfg", lambda _: text_ensure_line(_, line)): run("service restart")

    file_upload(*args, **kwargs)
        Uploads the local file to the remote location only if the remote location does not
        exists or the content are different.

    file_write(*args, **kwargs)
        Writes the given content to the file at the given remote
        location, optionally setting mode/owner/group.

    group_check(*args, **kwargs)
        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.

    group_check_bsd(name)
        Checks if there is a group defined with the given name,
        returning its information as:
        '{"name":<str>,"gid":<str>,"members":<list[str]>}'
        or
        '{"name":<str>,"gid":<str>}' if the group has no members
        or
        'None' if the group does not exists.

    group_check_linux(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.

    group_create(*args, **kwargs)
        Creates a group with the given name, and optionally given gid.

    group_create_bsd(name, gid=None)
        Creates a group with the given name, and optionally given gid.

    group_create_linux(name, gid=None)
        Creates a group with the given name, and optionally given gid.

    group_ensure(*args, **kwargs)
        Ensures that the group with the given name (and optional gid)
        exists.

    group_ensure_bsd(name, gid=None)
        Ensures that the group with the given name (and optional gid)
        exists.

    group_ensure_linux(name, gid=None)
        Ensures that the group with the given name (and optional gid)
        exists.

    group_remove(*args, **kwargs)
        Removes the given group, this implies to take members out the group
        if there are any.  If wipe=True and the group is a primary one,
        deletes its user as well.

    group_remove_bsd(group=None, wipe=False)
        Removes the given group, this implies to take members out the group
        if there are any.  If wipe=True and the group is a primary one,
        deletes its user as well.

    group_remove_linux(group=None, wipe=False)
        Removes the given group, this implies to take members out the group
        if there are any.  If wipe=True and the group is a primary one,
        deletes its user as well.

    group_user_add(*args, **kwargs)
        Adds the given user/list of users to the given group/groups.

    group_user_add_bsd(group, user)
        Adds the given user/list of users to the given group/groups.

    group_user_add_linux(group, user)
        Adds the given user/list of users to the given group/groups.

    group_user_check(*args, **kwargs)
        Checks if the given user is a member of the given group. It
        will return 'False' if the group does not exist.

    group_user_check_bsd(group, user)
        Checks if the given user is a member of the given group. It
        will return 'False' if the group does not exist.

    group_user_check_linux(group, user)
        Checks if the given user is a member of the given group. It
        will return 'False' if the group does not exist.

    group_user_del(*args, **kwargs)
        remove the given user from the given group.

    group_user_del_bsd(group, user)
        remove the given user from the given group.

    group_user_del_linux(group, user)
        remove the given user from the given group.

    group_user_ensure(*args, **kwargs)
        Ensure that a given user is a member of a given group.

    group_user_ensure_bsd(group, user)
        Ensure that a given user is a member of a given group.

    group_user_ensure_linux(group, user)
        Ensure that a given user is a member of a given group.

    host(name=<module 'base64' from '/System/Library/Framework...framework/Versions/2.7/lib/python2.7/base64.pyc'>)
        Returns or sets the host

    is_local()

    is_remote()

    is_sudo()

    locale_check(locale)

    locale_ensure(locale)

    log_call(function, args, kwargs)
        Logs the given function call

    log_message(message)
        Logs the given message

    logged(message=None)
        Logs the invoked function name and arguments.

    mode(key)
        Queries the given Cuisine mode (ie. MODE_LOCAL, MODE_SUDO)

    options()
        Retrieves the list of options as a dictionary.

    package_clean(*args, **kwargs)
        Clean the repository for un-needed files.

    package_clean_apt(package=None)

    package_clean_emerge(package=None)

    package_clean_pacman()

    package_clean_pkgin(package=None)

    package_clean_pkgng(package=None)

    package_clean_yum(package=None)

    package_clean_zypper()

    package_ensure(*args, **kwargs)
        Tests if the given package is installed, and installs it in
        case it's not already there. If `update` is true, then the
        package will be updated if it already exists.

    package_ensure_apt(package, update=False)
        Ensure apt packages are installed

    package_ensure_emerge(package, update=False)

    package_ensure_pacman(package, update=False)
        Ensure apt packages are installed

    package_ensure_pkgin(package, update=False)

    package_ensure_pkgng(package, update=False)

    package_ensure_yum(package, update=False)

    package_ensure_zypper(package, update=False)

    package_install(*args, **kwargs)
        Installs the given package/list of package, optionally updating
        the package database.

    package_install_apt(package, update=False)

    package_install_emerge(package, update=False)

    package_install_pacman(package, update=False)

    package_install_pkgin(package, update=False)

    package_install_pkgng(package, update=False)

    package_install_yum(package, update=False)

    package_install_zypper(package, update=False)

    package_remove(*args, **kwargs)
        Remove package and optionally clean unused packages

    package_remove_apt(package, autoclean=False)

    package_remove_emerge(package, autoclean=False)

    package_remove_pacman(package, autoclean=False)

    package_update(*args, **kwargs)
        Updates the package database (when no argument) or update the package
        or list of packages given as argument.

    package_update_apt(package=None)

    package_update_emerge(package=None)

    package_update_pacman(package=None)

    package_update_pkgin(package=None)

    package_update_pkgng(package=None)

    package_update_yum(package=None)

    package_update_zypper(package=None)

    package_upgrade(*args, **kwargs)
        Updates every package present on the system.

    package_upgrade_apt(distupgrade=False)

    package_upgrade_emerge(distupgrade=False)

    package_upgrade_pacman()

    package_upgrade_pkgin()

    package_upgrade_pkgng()

    package_upgrade_yum()

    package_upgrade_zypper()

    process_find(*args, **kwargs)
        Returns the pids of processes with the given name. If exact is `False`
        it will return the list of all processes that start with the given
        `name`.

    process_kill(*args, **kwargs)
        Kills the given processes with the given name. If exact is `False`
        it will return the list of all processes that start with the given
        `name`.

    pwd()
        Returns the current directory.

    python_package_ensure(*args, **kwargs)
        Tests if the given python package is installed, and installes it in
        case it's not already there.

    python_package_ensure_easy_install(package)
        The "package" argument, defines the name of the package that will be ensured.

    python_package_ensure_pip(package=None, r=None, pip=None)
        The "package" argument, defines the name of the package that will be ensured.
        The argument "r" referes to the requirements file that will be used by pip and
        is equivalent to the "-r" parameter of pip.
        Either "package" or "r" needs to be provided

    python_package_install(*args, **kwargs)
        Installs the given python package/list of python packages.

    python_package_install_easy_install(package)
        The "package" argument, defines the name of the package that will be installed.

    python_package_install_pip(package=None, r=None, pip=None)
        The "package" argument, defines the name of the package that will be installed.
        The argument "r" referes to the requirements file that will be used by pip and
        is equivalent to the "-r" parameter of pip.
        Either "package" or "r" needs to be provided
        The optional argument "E" is equivalent to the "-E" parameter of pip. E is the
        path to a virtualenv. If provided, it will be added to the pip call.

    python_package_remove(*args, **kwargs)
        Removes the given python package.

    python_package_remove_easy_install(package)
        The "package" argument, defines the name of the package that will be removed.

    python_package_remove_pip(package, pip=None)
        The "package" argument, defines the name of the package that will be ensured.
        The argument "r" referes to the requirements file that will be used by pip and
        is equivalent to the "-r" parameter of pip.
        Either "package" or "r" needs to be provided

    python_package_upgrade(*args, **kwargs)
        Upgrades the defined python package.

    python_package_upgrade_easy_install(package)
        The "package" argument, defines the name of the package that will be upgraded.

    python_package_upgrade_pip(package)
        The "package" argument, defines the name of the package that will be upgraded.

    repository_ensure_apt(*args, **kwargs)

    repository_ensure_emerge(repository)

    repository_ensure_pacman(repository)

    repository_ensure_pkgin(repository)
        # This should be simple but I have to think it properly

    repository_ensure_pkgng(repository)

    repository_ensure_yum(repository)

    repository_ensure_zypper(repository)

    rsync(local_path, remote_path, compress=True, progress=False, verbose=True, owner=None, group=None)
        Rsyncs local to remote, using the connection's host and user.

    run(*args, **kwargs)
        A wrapper to Fabric's run/sudo commands that takes into account
        the `MODE_LOCAL` and `MODE_SUDO` modes of Cuisine.

    run_local(command, sudo=False, shell=True, pty=True, combine_stderr=None)
        Local implementation of fabric.api.run() using subprocess.

        Note: pty option exists for function signature compatibility and is
        ignored.

    select_group(selection=None)

    select_hash(selection=None)

    select_os_flavour(selection=None)

    select_package(selection=None)
        Selects the type of package subsystem to use (ex:apt, yum, zypper, pacman, or emerge).

    select_python_package(selection=None)

    select_user(selection=None)

    shell_safe(path)
        Makes sure that the given path/string is escaped and safe for shell

    ssh_authorize(user, key)
        Adds the given key to the '.ssh/authorized_keys' for the given
        user.

    ssh_keygen(user, keytype='dsa')
        Generates a pair of ssh keys in the user's home .ssh directory.

    ssh_unauthorize(user, key)
        Removes the given key to the remote '.ssh/authorized_keys' for the given
        user.

    stringify(value)
        Turns the given value in a user-friendly string that can be displayed

    sudo(*args, **kwargs)
        A wrapper to Fabric's run/sudo commands, using the
        'cuisine.MODE_SUDO' global to tell whether the command should be run as
        regular user or sudo.

    sudo_password(password=None)
        Sets the password for the sudo command.

    system_uuid()
        Gets a machines UUID (Universally Unique Identifier).

    system_uuid_alias_add()
        Adds system UUID alias to /etc/hosts.
        Some tools/processes rely/want the hostname as an alias in
        /etc/hosts e.g. `127.0.0.1 localhost <hostname>`.

    text_detect_eol(text)

    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.

    text_get_line(text, predicate)
        Returns the first line that matches the given predicate.

    text_normalize(text)
        Converts tabs and spaces to single space and strips the text.

    text_nospace(text)
        Converts tabs and spaces to single space and strips the text.

    text_replace_line(text, old, new, find=<function <lambda>>, process=<function <lambda>>)
        Replaces lines equal to 'old' with 'new', returning the new
        text and the count of replacements.

        Returns: (text, number of lines replaced)

        `process` is a function that will pre-process each line (you can think of
        it as a normalization function, by default it will return the string as-is),
        and `find` is the function that will compare the current line to the
        `old` line.

        The finds the line using `find(process(current_line), process(old_line))`,
        and if this matches, will insert the new line instead.

    text_strip_margin(text, margin='|')
        Will strip all the characters before the left margin identified
        by the `margin` character in your text. For instance

        ```
                        |Hello, world!
        ```

        will result in

        ```
        Hello, world!
        ```

    text_template(text, variables)
        Substitutes '${PLACEHOLDER}'s within the text with the
        corresponding values from variables.

    upstart_ensure(name)
        Ensures that the given upstart service is running, starting
        it if necessary.

    upstart_reload(name)
        Reloads the given service, or starts it if it is not running.

    upstart_restart(name)
        Tries a `restart` command to the given service, if not successful
        will stop it and start it. If the service is not started, will start it.

    upstart_stop(name)
        Ensures that the given upstart service is stopped.

    user(name=<module 'base64' from '/System/Library/Framework...framework/Versions/2.7/lib/python2.7/base64.pyc'>)
        Returns or sets the user

    user_check(*args, **kwargs)
        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.
        need_passwd (Boolean) indicates if password to be included in result or not.
                If set to True it parses 'getent shadow' and needs sudo access

    user_check_bsd(name=None, uid=None, need_passwd=True)
        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.
        need_passwd (Boolean) indicates if password to be included in result or not.
                If set to True it parses 'getent passwd' and needs sudo access

    user_check_linux(name=None, uid=None, need_passwd=True)
        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.
        need_passwd (Boolean) indicates if password to be included in result or not.
                If set to True it parses 'getent shadow' and needs sudo access

    user_create(*args, **kwargs)
        Creates the user with the given name, optionally giving a
        specific password/home/uid/gid/shell.

    user_create_bsd(name, passwd=None, home=None, uid=None, gid=None, shell=None, uid_min=None, uid_max=None, encrypted_passwd=True, fullname=None, createhome=True)
        Creates the user with the given name, optionally giving a
        specific password/home/uid/gid/shell.

    user_create_linux(name, passwd=None, home=None, uid=None, gid=None, shell=None, uid_min=None, uid_max=None, encrypted_passwd=True, fullname=None, createhome=True)
        Creates the user with the given name, optionally giving a
        specific password/home/uid/gid/shell.

    user_create_passwd_bsd(name, passwd=None, home=None, uid=None, gid=None, shell=None, uid_min=None, uid_max=None, encrypted_passwd=True, fullname=None, createhome=True)
        Creates the user with the given name, optionally giving a
        specific password/home/uid/gid/shell.

    user_ensure(*args, **kwargs)
        Ensures that the given users exists, optionally updating their
        passwd/home/uid/gid/shell.

    user_ensure_bsd(name, passwd=None, home=None, uid=None, gid=None, shell=None, fullname=None, encrypted_passwd=True)
        Ensures that the given users exists, optionally updating their
        passwd/home/uid/gid/shell.

    user_ensure_linux(name, passwd=None, home=None, uid=None, gid=None, shell=None, fullname=None, encrypted_passwd=True)
        Ensures that the given users exists, optionally updating their
        passwd/home/uid/gid/shell.

    user_passwd(*args, **kwargs)
        Sets the given user password. Password is expected to be encrypted by default.

    user_passwd_bsd(name, passwd, encrypted_passwd=True)
        Sets the given user password. Password is expected to be encrypted by default.

    user_passwd_linux(name, passwd, encrypted_passwd=True)
        Sets the given user password. Password is expected to be encrypted by default.

    user_remove(*args, **kwargs)
        Removes the user with the given name, optionally
        removing the home directory and mail spool.

    user_remove_bsd(name, rmhome=None)
        Removes the user with the given name, optionally
        removing the home directory and mail spool.

    user_remove_linux(name, rmhome=None)
        Removes the user with the given name, optionally
        removing the home directory and mail spool.

DATA
    AVAILABLE_OPTIONS = {'group': ['linux', 'bsd'], 'hash': ['python', 'op...
    CMD_APT_GET = 'DEBIAN_FRONTEND=noninteractive apt-get -q --yes ...ce-c...
    DEFAULT_OPTIONS = {'group': 'linux', 'hash': 'python', 'os_flavour': '...
    MAC_EOL = '\n'
    MODE_LOCAL = 'CUISINE_MODE_LOCAL'
    MODE_SUDO = 'CUISINE_MODE_SUDO'
    OPTION_GROUP = 'CUISINE_OPTION_GROUP'
    OPTION_HASH = 'CUISINE_OPTION_HASH'
    OPTION_OS_FLAVOUR = 'CUISINE_OPTION_OS_FLAVOUR'
    OPTION_PACKAGE = 'CUISINE_OPTION_PACKAGE'
    OPTION_PYTHON_PACKAGE = 'CUISINE_OPTION_PYTHON_PACKAGE'
    OPTION_USER = 'CUISINE_OPTION_USER'
    RE_SPACES = <_sre.SRE_Pattern object>
    SHELL_ESCAPE = ' \'";`|'
    STATS = None
    STRINGIFY_MAXLISTSTRING = 20
    STRINGIFY_MAXSTRING = 80
    SUDO_PASSWORD = 'CUISINE_SUDO_PASSWORD'
    UNIX_EOL = '\n'
    VERSION = '0.7.10'
    WINDOWS_EOL = '\r\n'
    with_statement = _Feature((2, 5, 0, 'alpha', 1), (2, 6, 0, 'alpha', 0)...

Recommended Posts

Donner une égalité au tissu avec la cuisine
Garantie d'égalité avec l'outil de déploiement fabric + cuisine
Convertir 202003 en 2020-03 avec les pandas
Créez un script de déploiement avec fabric et cuisine et réutilisez-le
Essayez de défier le sol par récursif
Connectez-vous à BigQuery avec Python
Connectez-vous à Wikipedia avec Python
Publiez sur Slack avec Python 3
Connectez-vous à Postgresql avec GO
Transfert de fichiers rapide avec tissu
Introduction à RDB avec sqlalchemy Ⅰ
Rendre avec la syntaxe facile
Comment mettre à jour avec SQLAlchemy?
Pour exécuter gym_torcs avec ubutnu16
Comment lancer avec Theano
Comment modifier avec SQLAlchemy?
Basculer python vers 2.7 avec des alternatives
Écrire en csv avec Python
Comment séparer les chaînes avec ','
Comment faire RDP sur Fedora31
2 façons de gérer SessionNotCreatedException
Comment supprimer avec SQLAlchemy?
Faites du SSH en plusieurs étapes avec Fabric