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__/pcs.cpython-310.pyc
o

�N�g��@sdZddlZddlZddlZddlZddlZe�e�Z	dd�Z
dd�Zdd�Zd	d
�Z
dd�Zd
d�Zdd�Zdd�Z				d0dd�Zd1dd�Z						d2dd�Zd3dd�Zd4d d!�Zd4d"d#�Zd4d$d%�Zd4d&d'�Zd4d(d)�Z	d4d*d+�Z	d4d,d-�Z	d4d.d/�ZdS)5a�
Management of Pacemaker/Corosync clusters with PCS
==================================================

A state module to manage Pacemaker/Corosync clusters
with the Pacemaker/Corosync configuration system (PCS)

.. versionadded:: 2016.11.0

:depends: pcs

Walkthrough of a complete PCS cluster setup:
http://clusterlabs.org/doc/en-US/Pacemaker/1.1/html/Clusters_from_Scratch/

Requirements:
    PCS is installed, pcs service is started and
    the password for the hacluster user is set and known.

Remark on the cibname variable used in the examples:
    The use of the cibname variable is optional.
    Use it only if you want to deploy your changes into a cibfile first and then push it.
    This makes only sense if you want to deploy multiple changes (which require each other) at once to the cluster.

At first the cibfile must be created:

.. code-block:: yaml

    mysql_pcs__cib_present_cib_for_galera:
        pcs.cib_present:
            - cibname: cib_for_galera
            - scope: None
            - extra_args: None

Then the cibfile can be modified by creating resources (creating only 1 resource for demonstration, see also 7.):

.. code-block:: yaml

    mysql_pcs__resource_present_galera:
        pcs.resource_present:
            - resource_id: galera
            - resource_type: "ocf:heartbeat:galera"
            - resource_options:
                - 'wsrep_cluster_address=gcomm://node1.example.org,node2.example.org,node3.example.org'
                - '--master'
            - cibname: cib_for_galera

After modifying the cibfile, it can be pushed to the live CIB in the cluster:

.. code-block:: yaml

    mysql_pcs__cib_pushed_cib_for_galera:
        pcs.cib_pushed:
            - cibname: cib_for_galera
            - scope: None
            - extra_args: None

Create a cluster from scratch:

1. This authorizes nodes to each other. It probably won't work with Ubuntu as
    it rolls out a default cluster that needs to be destroyed before the
    new cluster can be created. This is a little complicated so it's best
    to just run the cluster_setup below in most cases.:

   .. code-block:: yaml

       pcs_auth__auth:
           pcs.auth:
               - nodes:
                   - node1.example.com
                   - node2.example.com
               - pcsuser: hacluster
               - pcspasswd: hoonetorg


2. Do the initial cluster setup:

   .. code-block:: yaml

       pcs_setup__setup:
           pcs.cluster_setup:
               - nodes:
                   - node1.example.com
                   - node2.example.com
               - pcsclustername: pcscluster
               - extra_args:
                   - '--start'
                   - '--enable'
               - pcsuser: hacluster
               - pcspasswd: hoonetorg

3. Optional: Set cluster properties:

   .. code-block:: yaml

       pcs_properties__prop_has_value_no-quorum-policy:
           pcs.prop_has_value:
               - prop: no-quorum-policy
               - value: ignore
               - cibname: cib_for_cluster_settings

4. Optional: Set resource defaults:

   .. code-block:: yaml

       pcs_properties__resource_defaults_to_resource-stickiness:
           pcs.resource_defaults_to:
               - default: resource-stickiness
               - value: 100
               - cibname: cib_for_cluster_settings

5. Optional: Set resource op defaults:

   .. code-block:: yaml

       pcs_properties__resource_op_defaults_to_monitor-interval:
           pcs.resource_op_defaults_to:
               - op_default: monitor-interval
               - value: 60s
               - cibname: cib_for_cluster_settings

6. Configure Fencing (!is often not optional on production ready cluster!):

   .. code-block:: yaml

       pcs_stonith__created_eps_fence:
           pcs.stonith_present:
               - stonith_id: eps_fence
               - stonith_device_type: fence_eps
               - stonith_device_options:
                   - 'pcmk_host_map=node1.example.org:01;node2.example.org:02'
                   - 'ipaddr=myepsdevice.example.org'
                   - 'power_wait=5'
                   - 'verbose=1'
                   - 'debug=/var/log/pcsd/eps_fence.log'
                   - 'login=hidden'
                   - 'passwd=hoonetorg'
               - cibname: cib_for_stonith

7. Add resources to your cluster:

   .. code-block:: yaml

       mysql_pcs__resource_present_galera:
           pcs.resource_present:
               - resource_id: galera
               - resource_type: "ocf:heartbeat:galera"
               - resource_options:
                   - 'wsrep_cluster_address=gcomm://node1.example.org,node2.example.org,node3.example.org'
                    - '--master'
                - cibname: cib_for_galera

8. Optional: Add constraints (locations, colocations, orders):

   .. code-block:: yaml

       haproxy_pcs__constraint_present_colocation-vip_galera-haproxy-clone-INFINITY:
           pcs.constraint_present:
               - constraint_id: colocation-vip_galera-haproxy-clone-INFINITY
               - constraint_type: colocation
               - constraint_options:
                   - 'add'
                   - 'vip_galera'
                   - 'with'
                   - 'haproxy-clone'
               - cibname: cib_for_haproxy

.. versionadded:: 2016.3.0
�NcCstjj�d�r	dSdS)z/
    Only load if pcs package is installed
    �pcs)FzUnable to locate command: pcs)�salt�utils�path�which�rr�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/pcs.py�__virtual__�sr	cCs^d}tj�|�r-tjj�|d��}tjj�|�	��}Wd�n1s$wY|�
�|S)z(
    Read a file and return content
    Fzr+N)�osr�existsrr�files�fopen�stringutilsZ
to_unicode�read�close�r�contentZfp_rrr�
_file_read�s�rcCsPtjj�|d��}|�tjj�|��Wd�n1swY|��dS)z!
    Write content to a file
    zw+N)rrrr
�writerZto_strrrrrr�_file_write�s�rcCs$tj�tddt�}t�d|�|S)zK
    Get the path to the directory on the minion where CIB's are saved
    Zcachedirrzcibpath: %s)r
r�join�__opts__Z__env__�log�trace)�cibpathrrr�_get_cibpath�srcCs(tj�t�d�|d��}t�d|�|S)zI
    Get the full path of a cached CIB-file with the name of the CIB
    z{}.{}Zcibzcibfile: %s)r
rrr�formatrr)�cibname�cibfilerrr�_get_cibfile�srcC�t|��d�}t�d|�|S)zL
    Get the full path of a temporary CIB-file with the name of the CIB
    z.tmpzcibfile_tmp: %s�rrr)r�cibfile_tmprrr�_get_cibfile_tmp��r#cCr )zd
    Get the full path of the file containing a checksum of a CIB-file with the name of the CIB
    z.cksumzcibfile_cksum: %sr!)r�
cibfile_cksumrrr�_get_cibfile_cksum�r$r&cCsBtdd�}td|d�dkrt�d�dd�|D�}|S|}|S)	z�
    PCS with version < 0.10 returns lowercase hostnames. Newer versions return the proper hostnames.
    This accomodates for the old functionality.
    zpkg.versionrzpkg.version_cmpz0.10���z<Node list converted to lower case for backward compatibilitycSsg|]}|���qSr)�lower)�.0�xrrr�
<listcomp>�sz._get_node_list_for_version.<locals>.<listcomp>)�__salt__r�info)�nodesZpcs_versionZnodes_for_versionrrr�_get_node_list_for_version�s
�r/�show�createc
Cs�|ddid�}d}	d}
t|t�rt|�}
t|ttf�sg}|}d}d|vrD|�d�d��}|�|�d�ddd���}t�	d||�|}
|dvsNd|vrPd}
t
d	||
|||
d
�}t�	d||
||
|�|dur�|d��D])}t|�d
��dvr�|�d
�d��}|�d
�d��}||fvr�||fvr�d}	qon |dvr�|d��D]}d|�d�|vr�d}	q�n|ddvr�d}	|	s�|dd�
t|�t|�t|��7<|Stdr�d|d<|dd�
t|�t|�t|��7<|St
d||||||
d�}t�	d|�|ddv�r(|dd|�d|�d|�d �7<|d!�|dt|�d"�i�nd|d<|dd#�
|||�7<t�	d$|�|S)%a�
    Ensure that an item is created

    name
        Irrelevant, not used
    item
        config, property, resource, constraint etc.
    item_id
        id of the item
    item_type
        item type
    show
        show command (probably None, default: show)
    create
        create command (create or set f.e., default: create)
    extra_args
        additional options for the pcs command
    cibname
        use a cached CIB-file named like cibname instead of the live CIB
    T���name�result�comment�changesN�=rzitem_id_key=%s item_id_value=%s)�
constraintz
pcs.item_show)�item�item_id�	item_typer0rzFOutput of pcs.item_show item=%s item_id=%s item_type=%s cibfile=%s: %s�stdout�:���Fz(id:�)�retcode�rr6z{} {} ({}) is already existing
�testr5z {} {} ({}) is set to be created
zpcs.item_create)r:r;r<r1�
extra_argsrzOutput of pcs.item_create: %szCreated � z (z)
r7��old�newzFailed to create {} {} ({})
�ret: %s)�
isinstance�strr�list�tuple�split�strip�replacerrr,�
splitlines�lenrr�update)r4r:r;r<r0r1rFr�retZitem_create_requiredrZitem_id_keyZ
item_id_valueZitem_id_showZis_existing�line�key�valueZitem_createrrr�
_item_presents�

��


��	�����	$�rZ�	haclusterc	Cs<|ddid�}d}t|�}td|||d�}t�d|�i}|d��D]}	|	�d	�d
��}
|	�d	�d��}|
|vrC|�|
|i�q$t�d|�|D]1}
|
|vrk||
d
ks^||
dkrk|dd|
�d�7<qLd}tdr}|dd|
�d�7<qL|s�|Stdr�d|d<|Std||||d�}t�d|�i}
|d��D]}	|	�d	�d
��}
|	�d	�d��}|
|vr�|
�|
|i�q�t�d|
�|D]O}
|
|
vr�|
|
dkr�|dd|
�d�7<|d�|
ddd�i�q�d|d<|
|v�r|dd�	|
||
�7<|
|
v�r|dd�	|
|
|
�7<q�|S) a�
    Ensure all nodes are authorized to the cluster

    name
        Irrelevant, not used (recommended: pcs_auth__auth)
    nodes
        a list of nodes which should be authorized to the cluster
    pcsuser
        user for communication with pcs (default: hacluster)
    pcspasswd
        password for pcsuser (default: hacluster)
    extra_args
        list of extra args for the 'pcs cluster auth' command, there are none so it's here for compatibility.

    Example:

    .. code-block:: yaml

        pcs_auth__auth:
            pcs.auth:
                - nodes:
                    - node1.example.com
                    - node2.example.com
                - pcsuser: hacluster
                - pcspasswd: hoonetorg
                - extra_args: []
    Tr2r3Fzpcs.is_auth)r.�pcsuser�	pcspasswdzOutput of pcs.is_auth: %sr=r>rrAzauthorized_dict: %szAlready authorizedZ
Authorizedr6�Node z is already authorized
rEzNode is set to authorize: �
Nr5zpcs.auth)r.r\r]rFzOutput of pcs.auth: %szauthorize_dict: %szAuthorized r7rHz-Authorization check for node {} returned: {}
z%Failed to authorize {} with error {}
)
r/r,rrrSrPrQrUrr)r4r.r\r]rFrVZ
auth_requiredZ
authorizedZauthorized_dictrW�nodeZ
auth_stateZ	authorizeZauthorize_dictrrr�auth�sx�����
���
��ra�
pcsclusterFcCs�|ddid�}d}	td�}
t�d|
�|
d��D]C}t|�d��d	vr]|�d�d
��}|�d�d��}
|dvr]|
|fvrL|d
d�|�7<qd}	tdr]|d
d�|�7<q|	sgt�	d�|Stdrqd|d<|St�
dt�d��t�d�dkr�|r�tdd�tdd�tdd�t
d||||�t|�}t|ttf�s�g}td|||d�}t�d|�i}|d��D]9}t�d |�t�d!t|�d���t|�d��d	vr�|�d�d
��}|�d�d��}||vr�|�||i�q�t�d"|�|D]X}||v�r+||d#v�r+|d
d$|�d%�7<|d&�|dd'd(�i��qd|d<|d
d)|�d%�7<||v�rP|d
|�d*||�d%�7<|d
t|�7<�qt�d+|�|S),a�
    Setup Pacemaker cluster on nodes.
    Should be run on one cluster node only to avoid race conditions.
    This performs auth as well as setup so can be run in place of the auth state.
    It is recommended not to run auth on Debian/Ubuntu for a new cluster and just
    to run this because of the initial cluster config that is installed on
    Ubuntu/Debian by default.


    name
        Irrelevant, not used (recommended: pcs_setup__setup)
    nodes
        a list of nodes which should be set up
    pcsclustername
        Name of the Pacemaker cluster
    extra_args
        list of extra args for the 'pcs cluster setup' command
    pcsuser
        The username for authenticating the cluster (default: hacluster)
    pcspasswd
        The password for authenticating the cluster (default: hacluster)
    pcs_auth_extra_args
        Extra args to be passed to the auth function in case of reauth.
    wipe_default
        This removes the files that are installed with Debian based operating systems.

    Example:

    .. code-block:: yaml

        pcs_setup__setup:
            pcs.cluster_setup:
                - nodes:
                    - node1.example.com
                    - node2.example.com
                - pcsclustername: pcscluster
                - extra_args:
                    - '--start'
                    - '--enable'
                - pcsuser: hacluster
                - pcspasswd: hoonetorg
    Tr2r3Fzpcs.config_showzOutput of pcs.config_show: %sr=r>r?rrA)zCluster Namer6zCluster {} is already set up
rEzCluster {} is set to set up
zNo setup requiredNr5z
OS_Family: %sZ	os_familyZDebian�file.removez/etc/corosync/corosync.confz/var/lib/pacemaker/cib/cib.xmlzservice.stop�corosyncZpcs_auth__authzpcs.cluster_setup)r.�pcsclusternamerFzOutput of pcs.cluster_setup: %s�line: %s�line.split(:).len: %szsetup_dict: %s)�	Succeeded�SuccesszCluster enabledzSet up r_r7ZSetuprHzFailed to setup z: setup_dict: rK)r,rrrSrTrPrQrrr-�debugZ
__grains__�getrar/rLrNrOrUrM)r4r.rerFr\r]Zpcs_auth_extra_argsZwipe_defaultrVZsetup_requiredZconfig_showrWrXrY�setupZ
setup_dictr`Zsetup_staterrr�
cluster_setup�sx5


���
��
 rmc	Cs�|ddid�}d}g}gd�}td|ddd�}t�d	|�|d
��D]D}t|�d��dvrh|�d�d
��}	|�d�d��}
|	dvrht|
���d
krh||
��vrbd}|dd|�d�7<q$||
��7}q$|sm|Stdr�d|d<|dd|�d�7<|St|t	t
f�s�g}td||d�}t�d|�i}|d
��D]<}t�d|�t�dt|�d���t|�d��dvr�|�d�d
��}
|�d�d��}|
||gvr�|�|
|i�q�t�d|�|D];}
|
|v�r||
dv�rd|d<|dd�|
�7<|dd�|
||
�7<q�d|d<|dd�|
�7<q�||v�rH||d v�rH|dd!|�d"�7<|d#�|dd$d%�i�n-d|d<|dd&|�d"�7<||v�rk|dd�|||�7<|dt
|�7<t�d'|�|S)(a�
    Add a node to the Pacemaker cluster via PCS
    Should be run on one cluster node only
    (there may be races)
    Can only be run on a already setup/added node

    name
        Irrelevant, not used (recommended: pcs_setup__node_add_{{node}})
    node
        node that should be added
    extra_args
        list of extra args for the 'pcs cluster node add' command

    Example:

    .. code-block:: yaml

        pcs_setup__node_add_node1.example.com:
            pcs.cluster_node_present:
                - node: node1.example.com
                - extra_args:
                    - '--start'
                    - '--enable'
    Tr2r3)r�statusr.rdzcmd.run_allrF)Zoutput_loglevelZpython_shellz'Output of pcs status nodes corosync: %sr=r>r?rrA)ZOfflineZOnliner6r^z" is already member of the cluster
rENr5z# is set to be added to the cluster
zpcs.cluster_node_add)r`rFz"Output of pcs.cluster_node_add: %srfrgznode_add_dict: %s)zCorosync updatedz*Failed to update corosync.conf on node {}
z{}: node_add_dict: {}
)rhrizAdded node r_r7ZAddedrHzFailed to add noderK)r,rrrSrTrPrQrrLrNrOrUrrM)r4r`rFrVZnode_add_requiredZ
current_nodesZ
is_member_cmdZ	is_memberrWrXrYZnode_addZ
node_add_dictZcurrent_nodeZcurrent_node_add_staterrr�cluster_node_presentms���
���
���
�
�rocCs�|ddid�}d}d}d}d}t�}	t|�}
t|�}t|�}tj�|	�s)t�|	�t|t	t
f�s2g}tj�|�r>td|�td|||d�}
t�
d	|
�|
d
dvsYtj�|�sgd|d<|d
d7<|Sd�|td||d��}t�
d|�t|d�}||fvr�d}t�
d|�tj�|
�r�td|
|d�s�d}|s�|r�d}|s�td|�|d
d|�d�7<|s�|d
d|�d�7<|s�|Stdr�td|�d|d<|r�|d
d|�d�7<|r�|d
d�|�7<|S|�r+td||
�td|
|d��r|d
d|�d �7<|d!�d"|
i�nd|d<|d
d#|�d �7<|�rat||�t|�|fv�rQ|d
d$�||�7<|d!�d%|i�nd|d<|d
d&�||�7<t�
d'|�|S)(a�
    Ensure that a CIB-file with the content of the current live CIB is created

    Should be run on one cluster node only
    (there may be races)

    name
        Irrelevant, not used (recommended: {{formulaname}}__cib_present_{{cibname}})
    cibname
        name/path of the file containing the CIB
    scope
        specific section of the CIB (default: None)
    extra_args
        additional options for creating the CIB-file

    Example:

    .. code-block:: yaml

        mysql_pcs__cib_present_cib_for_galera:
            pcs.cib_present:
                - cibname: cib_for_galera
                - scope: None
                - extra_args: None
    Tr2r3�sha256Frczpcs.cib_create�r�scoperFzOutput of pcs.cib_create: %srCrDr5r6zFailed to get live CIB
�{}:{}�
file.get_hash�rZformzcib_hash_live: %s)rzcib_hash_cur: %szfile.check_hash)rZ	file_hashzCIB z" is already equal to the live CIB
z checksum is correct
rENz is set to be created/updated
z-CIB {} checksum is set to be created/updated
z	file.movezCreated/updated CIB r_r7rzFailed to create/update CIB z&Created/updated checksum {} of CIB {}
Zcibcksumz+Failed to create/update checksum {} CIB {}
rK)rrr#r&r
rr�makedirsrLrNrOr,rrrrrrUr)r4rrrrFrV�
cib_hash_formZcib_create_requiredZcib_cksum_requiredZcib_requiredrrr"r%Z
cib_createZ
cib_hash_liveZcib_hash_currrr�cib_present�s�
��

��
��rxcCsl|ddid�}d}d}t|�}t|�}t|ttf�sg}tj�|�s4d|d<|dd|�d	�7<|Sd
�|t	d||d��}	t
�d
|	�t|�|	fvrOd}|s^|dd�|�7<|St
drsd|d<|dd�|�7<|St	d|||d�}
t
�d|
�|
ddvr�|dd|�d�7<|d�d|i�nd|d<|dd|�d�7<t
�d|�|S)a�
    Ensure that a CIB-file is pushed if it is changed since the creation of it with pcs.cib_present

    Should be run on one cluster node only
    (there may be races)

    name
        Irrelevant, not used (recommended: {{formulaname}}__cib_pushed_{{cibname}})
    cibname
        name/path of the file containing the CIB
    scope
        specific section of the CIB
    extra_args
        additional options for creating the CIB-file

    Example:

    .. code-block:: yaml

        mysql_pcs__cib_pushed_cib_for_galera:
            pcs.cib_pushed:
                - cibname: cib_for_galera
                - scope: None
                - extra_args: None
    Tr2r3rpFr5r6z	CIB-file z does not exist
rsrtruzcib_hash_cibfile: %sz=CIB {} is not changed since creation through pcs.cib_present
rENz/CIB {} is set to be pushed as the new live CIB
zpcs.cib_pushrqzOutput of pcs.cib_push: %srCrDzPushed CIB r_r7Zcibfile_pushedzFailed to push CIB rK)rr&rLrNrOr
rrrr,rrrrrU)r4rrrrFrVrwZcib_push_requiredrr%Zcib_hash_cibfileZcib_pushrrr�
cib_pushedYsV������ryc	Cs t|d|�d|��dd||d�S)a�
    Ensure that a property in the cluster is set to a given value

    Should be run on one cluster node only
    (there may be races)

    name
        Irrelevant, not used (recommended: pcs_properties__prop_has_value_{{prop}})
    prop
        name of the property
    value
        value of the property
    extra_args
        additional options for the pcs property command
    cibname
        use a cached CIB-file named like cibname instead of the live CIB

    Example:

    .. code-block:: yaml

        pcs_properties__prop_has_value_no-quorum-policy:
            pcs.prop_has_value:
                - prop: no-quorum-policy
                - value: ignore
                - cibname: cib_for_cluster_settings
    �propertyr8N�set�r4r:r;r<r1rFr�rZ)r4ZproprYrFrrrr�prop_has_value�s�r~c
Cs"t|d|�d|��ddd||d�S)aP
    Ensure a resource default in the cluster is set to a given value

    Should be run on one cluster node only
    (there may be races)
    Can only be run on a node with a functional pacemaker/corosync

    name
        Irrelevant, not used (recommended: pcs_properties__resource_defaults_to_{{default}})
    default
        name of the default resource property
    value
        value of the default resource property
    extra_args
        additional options for the pcs command
    cibname
        use a cached CIB-file named like cibname instead of the live CIB

    Example:

    .. code-block:: yaml

        pcs_properties__resource_defaults_to_resource-stickiness:
            pcs.resource_defaults_to:
                - default: resource-stickiness
                - value: 100
                - cibname: cib_for_cluster_settings
    �resourcer8N�defaults�r4r:r;r<r0r1rFrr})r4�defaultrYrFrrrr�resource_defaults_to�s�r�c
Cs*t|d|�d|��dddgddg||d�S)az
    Ensure a resource operation default in the cluster is set to a given value

    Should be run on one cluster node only
    (there may be races)
    Can only be run on a node with a functional pacemaker/corosync

    name
        Irrelevant, not used (recommended: pcs_properties__resource_op_defaults_to_{{op_default}})
    op_default
        name of the operation default resource property
    value
        value of the operation default resource property
    extra_args
        additional options for the pcs command
    cibname
        use a cached CIB-file named like cibname instead of the live CIB

    Example:

    .. code-block:: yaml

        pcs_properties__resource_op_defaults_to_monitor-interval:
            pcs.resource_op_defaults_to:
                - op_default: monitor-interval
                - value: 60s
                - cibname: cib_for_cluster_settings
    rr8N�opr�r�r})r4Z
op_defaultrYrFrrrr�resource_op_defaults_to�s�r�cC�t|d||||d�S)a�
    Ensure that a fencing resource is created

    Should be run on one cluster node only
    (there may be races)
    Can only be run on a node with a functional pacemaker/corosync

    name
        Irrelevant, not used (recommended: pcs_stonith__created_{{stonith_id}})
    stonith_id
        name for the stonith resource
    stonith_device_type
        name of the stonith agent fence_eps, fence_xvm f.e.
    stonith_device_options
        additional options for creating the stonith resource
    cibname
        use a cached CIB-file named like cibname instead of the live CIB

    Example:

    .. code-block:: yaml

        pcs_stonith__created_eps_fence:
            pcs.stonith_present:
                - stonith_id: eps_fence
                - stonith_device_type: fence_eps
                - stonith_device_options:
                    - 'pcmk_host_map=node1.example.org:01;node2.example.org:02'
                    - 'ipaddr=myepsdevice.example.org'
                    - 'power_wait=5'
                    - 'verbose=1'
                    - 'debug=/var/log/pcsd/eps_fence.log'
                    - 'login=hidden'
                    - 'passwd=hoonetorg'
                - cibname: cib_for_stonith
    Zstonith�r4r:r;r<rFrr})r4Z
stonith_idZstonith_device_typeZstonith_device_optionsrrrr�stonith_present%s'�r�cCr�)a�
    Ensure that a resource is created

    Should be run on one cluster node only
    (there may be races)
    Can only be run on a node with a functional pacemaker/corosync

    name
        Irrelevant, not used (recommended: {{formulaname}}__resource_present_{{resource_id}})
    resource_id
        name for the resource
    resource_type
        resource type (f.e. ocf:heartbeat:IPaddr2 or VirtualIP)
    resource_options
        additional options for creating the resource
    cibname
        use a cached CIB-file named like cibname instead of the live CIB

    Example:

    .. code-block:: yaml

        mysql_pcs__resource_present_galera:
            pcs.resource_present:
                - resource_id: galera
                - resource_type: "ocf:heartbeat:galera"
                - resource_options:
                    - 'wsrep_cluster_address=gcomm://node1.example.org,node2.example.org,node3.example.org'
                    - '--master'
                - cibname: cib_for_galera
    rr�r})r4Zresource_idZ
resource_typeZresource_optionsrrrr�resource_presentVs"�r�c	Cst|d||d||d�S)ag
    Ensure that a constraint is created

    Should be run on one cluster node only
    (there may be races)
    Can only be run on a node with a functional pacemaker/corosync

    name
        Irrelevant, not used (recommended: {{formulaname}}__constraint_present_{{constraint_id}})
    constraint_id
        name for the constraint (try first to create manually to find out the autocreated name)
    constraint_type
        constraint type (location, colocation, order)
    constraint_options
        options for creating the constraint
    cibname
        use a cached CIB-file named like cibname instead of the live CIB

    Example:

    .. code-block:: yaml

        haproxy_pcs__constraint_present_colocation-vip_galera-haproxy-clone-INFINITY:
            pcs.constraint_present:
                - constraint_id: colocation-vip_galera-haproxy-clone-INFINITY
                - constraint_type: colocation
                - constraint_options:
                    - 'add'
                    - 'vip_galera'
                    - 'with'
                    - 'haproxy-clone'
                - cibname: cib_for_haproxy
    r9Nr|r})r4Z
constraint_idZconstraint_typeZconstraint_optionsrrrr�constraint_present�s$�r�)r0r1NN)r[r[N)rbNr[r[NF)N)NN)�__doc__�loggingr
Zsalt.utils.filesrZsalt.utils.pathZsalt.utils.stringutils�	getLogger�__name__rr	rrrrr#r&r/rZrarmrorxryr~r�r�r�r�r�rrrr�<module>sV*
						
�
~e
�


l

S
'
)*
�2
�-�