%PDF- %PDF-
Direktori : /lib/python2.7/site-packages/salt/states/ |
Current File : //lib/python2.7/site-packages/salt/states/mysql_user.pyc |
� ���^c @@ sw d Z d d l m Z m Z m Z d d l Z d d l Z d � Z d � Z d d d e e d d � Z d d � Z d S( u. Management of MySQL users ========================= :depends: - MySQLdb Python module :configuration: See :py:mod:`salt.modules.mysql` for setup instructions. .. code-block:: yaml frank: mysql_user.present: - host: localhost - password: bobcat .. versionadded:: 0.16.2 Authentication overrides have been added. The MySQL authentication information specified in the minion config file can be overridden in states using the following arguments: ``connection_host``, ``connection_port``, ``connection_user``, ``connection_pass``, ``connection_db``, ``connection_unix_socket``, ``connection_default_file`` and ``connection_charset``. .. code-block:: yaml frank: mysql_user.present: - host: localhost - password: "bob@cat" - connection_user: someuser - connection_pass: somepass - connection_charset: utf8 - saltenv: - LC_ALL: "en_US.utf8" This state is not able to grant permissions for the user. See :py:mod:`salt.states.mysql_grants` for further instructions. i ( t absolute_importt print_functiont unicode_literalsNc C@ s d t k S( u6 Only load if the mysql module is in __salt__ u mysql.user_create( t __salt__( ( ( s: /usr/lib/python2.7/site-packages/salt/states/mysql_user.pyt __virtual__4 s c C@ s! t j t d j j j d d � S( up Look in module context for a MySQL error. Eventually we should make a less ugly way of doing this. u test.pingu mysql.errorN( t syst modulesR t __module__t __context__t popt None( ( ( s: /usr/lib/python2.7/site-packages/salt/states/mysql_user.pyt _get_mysql_error; s u localhostc K@ s^ i | d 6i d 6t d 6d j | | � d 6} t | | f � } | r� t j j j | � st d | d <t | d <| St d | | d t d | d | | �r� | d c d 7<| St � } | d k ri| | d <t | d <| Sn� t d | | | | d | d | | �r<| d c d 7<| r8| r8| d c d 7<n | St � } | d k ri| | d <t | d <| St d | | d | | �r�t d rd j | | � | d <d | d <| r�| d c d 7<t j j j | � s | d c d 7<t | d <q n | d c d 7<| St d | | | | | | | � rfd j | | | rHd n d � | d <d | d | <qZd j | rxd n d | | � | d <t � } | d k r�| d c d j | � 7<n | r�t j j j | � r�| d c d 7<n t | d <nbt � } | d k r%| | d <t | d <| St d r�d j | | � | d <d | d <| r�| d c d 7<t j j j | � s�| d c d 7<t | d <q�n | St d | | | | | d | d | | �r d j | | � | d <| r�| d c d 7<n d | d | <nQ d j | | � | d <t � } | d k rP| d c d j | � 7<n t | d <| S(! uT Ensure that the named user is present with the specified properties. A passwordless user can be configured by omitting ``password`` and ``password_hash``, and setting ``allow_passwordless`` to ``True``. name The name of the user to manage host Host for which this user/password combo applies password The password to use for this user. Will take precedence over the ``password_hash`` option if both are specified. password_hash The password in hashed form. Be sure to quote the password because YAML doesn't like the ``*``. A password hash can be obtained from the mysql command-line client like so:: mysql> SELECT PASSWORD('mypass'); +-------------------------------------------+ | PASSWORD('mypass') | +-------------------------------------------+ | *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4 | +-------------------------------------------+ 1 row in set (0.00 sec) allow_passwordless If ``True``, then ``password`` and ``password_hash`` can be omitted to permit a passwordless login. .. versionadded:: 0.16.2 unix_socket If ``True`` and allow_passwordless is ``True``, the unix_socket auth plugin will be used. u nameu changesu resultu User {0}@{1} is already presentu commentuU Either password or password_hash must be specified, unless allow_passwordless is Trueu mysql.user_existst passwordlesst unix_sockett password_columnu with passwordless loginu with the desired passwordu hashu testu'