HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/consul.cpython-310.pyc
o

�N�g��@sLdZddlZe�e�Zddd�Zddd�Z						dd
d�Zddd
�ZdS)a
Consul Management
=================

.. versionadded:: 3005

The consul module is used to create and manage Consul ACLs

.. code-block:: yaml

    acl_present:
      consul.acl_present:
        - id: 38AC8470-4A83-4140-8DFD-F924CD32917F
        - name: acl_name
        - rules: node "" {policy = "write"} service "" {policy = "read"} key "_rexec" {policy = "write"}
        - type: client
        - consul_url: http://localhost:8500

    acl_delete:
       consul.acl_absent:
         - id: 38AC8470-4A83-4140-8DFD-F924CD32917F
�NcCsvtd|||d�}|dr|ddd|krdS|dr)|ddd|kr)dS|dr9|ddd	|kr9dSd
S)zY
    return True if the acl need to be update, False if it doesn't need to be update
    �consul.acl_info��id�token�
consul_url�res�datar�NameTZRulesZTypeF)�__salt__)�namer�type�rulesrr�info�r�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/consul.py�_acl_changessrcCs�ddd�}|rtd|||d�}n
|rtd||d�}n|S|�d�rM|dD]%}|r:|d	|kr:d
|d<||d<q'|rL|d
|krLd
|d<|d	|d<q'|S)z�
    Check the acl exists by using the name or the ID,
    name is ignored if ID is specified,
    if only Name is used the ID associated with it is returned
    FN)�resultrrrzconsul.acl_list)rrr�IDTrrr	)r
�get)rrrr�retrZaclrrr�_acl_exists-s 


�r�client��http://localhost:8500cCs,|idd|�d�d�}t||||�}|dsLtdr$d|d<d|d	<|Std
||||||d�}|dr>d|d<d
|d	<|S|dsJd|d<d|d	<|S|dr�t||d||||d�}	|	r�tdrld|d<d|d	<|Std||d||||d�}
|
dr�d|d<d|d	<|S|
ds�d|d<d|d	<|S)a
    Ensure the ACL is present

    name
        Specifies a human-friendly name for the ACL token.

    id
        Specifies the ID of the ACL.

    type: client
        Specifies the type of ACL token. Valid values are: client and management.

    rules
        Specifies rules for this ACL token.

    consul_url : http://locahost:8500
        consul URL to query

    .. note::
        For more information https://www.consul.io/api/acl.html#create-acl-token, https://www.consul.io/api/acl.html#update-acl-token
    T�ACL "z" exists and is up to date�r�changesr�commentr�testNz)The acl doesn't exist, it will be createdrzconsul.acl_create)rrrrr
rrzThe acl has been createdFzFailed to create the aclrz"The acl exists and will be updatedzconsul.acl_updatezThe acl has been updatedzFailed to update the acl)r�__opts__r
r)rrrrr
rr�exists�creater�updaterrr�acl_presentIsh
��"�����r#cCs�|idd|�d�d�}t||||�}|drItdr$d|d<d|d	<|Std
|d||d�}|d
r=d|d<d|d	<|S|d
sId|d<d|d	<|S)ar
    Ensure the ACL is absent

    name
        Specifies a human-friendly name for the ACL token.

    id
        Specifies the ID of the ACL.

    token
        token to authenticate you Consul query

    consul_url : http://locahost:8500
        consul URL to query

    .. note::
        For more information https://www.consul.io/api/acl.html#delete-acl-token

    Trz" does not existrrrNz"The acl exists, it will be deletedrzconsul.acl_deleterrrzThe acl has been deletedFzFailed to delete the acl)rrr
)rrrrrr �deleterrr�
acl_absent�s,
�
��r%)NNNNN)NNNN)NNrrr)NNr)	�__doc__�logging�	getLogger�__name__�logrrr#r%rrrr�<module>s



�W