Module Expr Str Import alias ImportFrom alias ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str Return CompareIn NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr BinOpMod Str NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str Return CompareIn NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr BinOpMod Str NameLoad keyword NameLoad keyword NameLoad attr If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Raise Call NameLoad BinOpMod Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Return CompareIn NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad If UnaryOpNot NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad keyword NameLoad keyword NameLoad orelse Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults ListLoad body For NameStore NameLoad body If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad Str ListLoad NameLoad NameLoad body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad NameLoad If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad orelse If BoolOpAnd NameLoad UnaryOpNot Call AttributeLoad NameLoad attr NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Assign NameStore Call AttributeLoad Str attr Call AttributeLoad NameLoad attr Assign NameStore Str Assign NameStore BoolOpOr NameLoad BinOpMod Str NameLoad Assign NameStore BoolOpOr BoolOpAnd NameLoad SubscriptLoad NameLoad Index Num NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod NameLoad Dict Str Str Str Str Str BoolOpOr NameLoad NameLoad BoolOpOr BoolOpAnd NameLoad NameLoad Str NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr If CompareEq AttributeLoad NameLoad attr Str body Assign NameStore Str orelse Assign NameStore Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad Str attr keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call AttributeLoad Str attr keyword IfExp NameLoad Str Str keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad keyword NameLoad decorator_list decorator_list
N/A N/A Roles in this namespace are meant to provide user management operations for Debian distributions. N/A StringIO provy.core Role UserRole N/A Role N/A N/A 
    This role provides many utility methods for user management operations within Debian distributions.

    Example:
    ::

        from provy.core import Role
        from provy.more.debian import UserRole

        class MySampleRole(Role):
            def provision(self):
                with self.using(UserRole) as role:
                    role.ensure_user('myuser', identified_by='mypass', is_admin=True)
     group_exists N/A N/A self group_name N/A N/A N/A 
        Returns :data:`True` if the given group exist, :data:`False` otherwise.

        :param group_name: Name of the group to verify.
        :type group_name: :class:`str`
        :return: Whether the group exists or not.
        :rtype: :class:`bool`

        Example:
        ::

            class MySampleRole(Role):
                def provision(self):
                    with self.using(UserRole) as role:
                        if role.group_exists('usersgroup'):
                            pass
         N/A values N/A N/A self __first_values_from group N/A N/A group_name values N/A __first_values_from N/A N/A self basename N/A N/A N/A values N/A N/A self execute N/A cat /etc/%s | cut -d ':' -f 1 basename stdout False sudo True N/A values N/A N/A N/A N/A values strip split N/A values N/A user_exists N/A N/A self username N/A N/A N/A 
        Returns :data:`True` if the given user exist, :data:`False` otherwise.

        :param username: Name of the user to verify.
        :type username: :class:`str`
        :return: Whether the user exists or not.
        :rtype: :class:`bool`

        Example:
        ::

            class MySampleRole(Role):
                def provision(self):
                    with self.using(UserRole) as role:
                        if role.user_exists('myuser'):
                            pass
         N/A values N/A N/A self __first_values_from passwd N/A N/A username values N/A user_in_group N/A N/A self username group_name N/A N/A N/A 
        Returns :data:`True` if the given user is in the given group, :data:`False` otherwise.

        :param username: Name of the user to verify.
        :type username: :class:`str`
        :param group_name: Name of the group to verify.
        :type group_name: :class:`str`
        :return: Whether the user pertains to the group or not.
        :rtype: :class:`bool`

        Example:
        ::

            from provy.core import Role
            from provy.more.debian import UserRole

            class MySampleRole(Role):
                def provision(self):
                    with self.using(UserRole) as role:
                        if role.user_in_group('myuser', 'mygroup'):
                            pass
         N/A raw_groups N/A N/A N/A N/A self execute N/A groups %s username sudo True stdout False strip N/A N/A N/A N/A raw_groups startswith username N/A N/A N/A ValueError N/A User '%s' doesn't exist username N/A groups_string N/A N/A raw_groups replace N/A %s :  username N/A groups N/A N/A groups_string split N/A N/A group_name groups N/A ensure_group N/A N/A self group_name group_id N/A None N/A N/A 
        Ensures that a given user group is present in the remote server.

        :param group_name: Name of the group to create.
        :type group_name: :class:`str`
        :param group_id: GID of the group. Defaults to :data:`None`, which assigns the next available GID.
        :type group_id: :class:`int`

        Example:
        ::

            from provy.core import Role
            from provy.more.debian import UserRole

            class MySampleRole(Role):
                def provision(self):
                    with self.using(UserRole) as role:
                        role.ensure_group('users-group')
         N/A N/A N/A N/A self group_exists group_name N/A N/A N/A N/A self log N/A Group %s not found! Creating... group_name N/A N/A group_id N/A N/A N/A N/A self execute N/A groupadd %s group_name stdout False sudo True N/A N/A N/A N/A self execute N/A groupadd --gid %s %s N/A group_id group_name stdout False sudo True N/A N/A N/A self log N/A Group %s created! group_name N/A ensure_user_groups N/A N/A self username groups N/A N/A N/A N/A user_group groups N/A N/A N/A N/A N/A self user_in_group username user_group N/A N/A N/A N/A self log N/A User %s should be in group %s! Rectifying that... N/A username user_group N/A N/A N/A self execute N/A usermod -G %s %s N/A user_group username stdout False sudo True N/A N/A N/A self log N/A User %s is in group %s now! N/A username user_group N/A ensure_user N/A N/A self username identified_by home_folder default_script groups is_admin password_encrypted N/A None None /bin/bash N/A False False N/A N/A 
        Ensures that a given user is present in the remote server.

        :param username: Name of the user.
        :type username: :class:`str`
        :param identified_by: Password that the user will use to login to the remote server. If set to :data:`None`, the user will not have a password.
        :type identified_by: :class:`str`
        :param home_folder: Specifies the user's home folder. Defaults to `/home/<username>`.
        :type home_folder: :class:`str`
        :param default_script: Sets the user's default script, the one that will execute commands per default when logging in. Defaults to `/bin/sh`.
        :type default_script: :class:`str`
        :param groups: Groups that this user belongs to. If the groups do not exist they are created prior to user creation. Defaults to the name of the user.
        :type groups: :class:`iterable`
        :param is_admin: If set to :data:`True` the user is added to the 'admin' (or 'sudo' if provisioning to Ubuntu) user group as well. Defaults to :data:`False`.
        :type is_admin: :class:`bool`
        :param password_encrypted:
            If set to :data:`True` password is considered to be in ecrypted form
            (as found in /etc/shadow). To generate encrypted form of password you
            may use :func:`provy.more.debian.users.passwd_utils.hash_password_function`.
            defaults to :data:`False`
        :type password_encrypted: :class:`bool`

        Example:
        ::

            from provy.core import Role
            from provy.more.debian import UserRole

            class MySampleRole(Role):
                def provision(self):
                    with self.using(UserRole) as role:
                        role.ensure_user('myuser', identified_by='mypass', is_admin=True)
         N/A admin_group N/A N/A self __get_admin_group N/A N/A N/A self __ensure_initial_groups groups username N/A N/A N/A N/A self user_exists username N/A N/A N/A N/A self __create_new_user username home_folder groups default_script is_admin N/A N/A N/A is_admin N/A N/A N/A self user_in_group username admin_group N/A N/A N/A N/A self __set_user_as_admin username admin_group N/A N/A N/A self ensure_user_groups username groups N/A N/A N/A self set_user_password username identified_by password_encrypted N/A N/A N/A self context N/A owner username N/A __set_user_as_admin N/A N/A self username admin_group N/A N/A N/A N/A N/A self log N/A User %s should be administrator! Rectifying that... username N/A N/A N/A self execute N/A usermod -G %s %s N/A admin_group username stdout False sudo True N/A N/A N/A self log N/A User %s is administrator now! username N/A __create_new_user N/A N/A self username home_folder groups default_script is_admin N/A N/A N/A is_admin_command N/A N/A  -G {} format N/A N/A self __get_admin_group N/A command useradd -g %(group)s%(is_admin_command)s -s %(default_script)s -d %(home_folder)s -m %(username)s N/A home_folder N/A home_folder N/A /home/%s username N/A group N/A N/A groups N/A groups N/A 0 username N/A N/A N/A self log N/A User %s not found! Creating... username N/A N/A N/A self execute N/A command N/A group is_admin_command home_folder default_script username N/A group username N/A N/A is_admin is_admin_command home_folder default_script username stdout False sudo True N/A N/A N/A self log N/A User %s created! username N/A __ensure_initial_groups N/A N/A self groups username N/A N/A N/A user_group groups N/A N/A N/A N/A self ensure_group user_group N/A N/A groups N/A N/A N/A N/A self ensure_group username N/A __get_admin_group N/A N/A self N/A N/A N/A distro_info N/A N/A self get_distro_info N/A N/A N/A distro_info distributor_id Ubuntu N/A N/A admin_group sudo N/A N/A admin_group admin N/A admin_group N/A set_user_password N/A N/A self username password encrypted N/A False N/A N/A 
        Sets user password.

        :param username: Name of user for which to update password
        :type username: :class:`str`
        :param password: Password to set
        :type password: :class:`str`
        :param encrypted: If :data:`True` it meas that `password` is encrypted,
            (that is in hashed format), else it means password is in plaintext.
        :type encrypted: :class:`bool`

         N/A tmp_file N/A N/A self create_remote_temp_file N/A password_line N/A N/A {username}:{password} format username username password password N/A N/A N/A self put_file N/A N/A StringIO StringIO password_line tmp_file sudo True stdout False N/A command N/A N/A cat "{tmp_file}" | chpasswd {encrypted} format encrypted N/A encrypted -e tmp_file tmp_file N/A N/A N/A self execute command stdout False sudo True N/A N/A N/A self remove_file tmp_file sudo True N/A N/A