o
    Œ }i¡
  ã                   @   s(   d Z ddlZdd„ Zdd„ Zdd„ ZdS )	a	  
Manage Apache Confs

.. versionadded:: 2016.3.0

Enable and disable apache confs.

.. code-block:: yaml

    Enable security conf:
      apache_conf.enabled:
        - name: security

    Disable security conf:
      apache_conf.disabled:
        - name: security
é    Nc                   C   s   dt v rtjj d¡rdS dS )z-
    Only load if a2enconf is available.
    úapache.a2enconfZa2enconfZapache_conf)Fz!apache module could not be loaded)Ú__salt__ÚsaltÚutilsÚpathÚwhich© r   r   úD/opt/saltstack/salt/extras-3.10/saltext/apache/states/apache_conf.pyÚ__virtual__   s   r
   c                 C   sô   | ddi dœ}t d | ƒ}|sqtd r/d| › d�}||d< d	|d
 d< | |d
 d< d	|d< |S t d | ƒd }t|tƒrRd|v rRd|d< d	|d
 d< | |d
 d< |S d|d< d| › d�|d< t|tƒro|d d|› d� |d< |S | › d�|d< |S )zU
    Ensure an Apache conf is enabled.

    name
        Name of the Apache conf
    TÚ ©ÚnameÚresultÚcommentÚchangesúapache.check_conf_enabledÚtestúApache conf z is set to be enabled.r   Nr   ÚoldÚnewr   r   ÚStatusÚenabledFzFailed to enable ú Apache confú (ú)z already enabled.©r   Z__opts__Ú
isinstanceÚstr©r   ÚretÚ
is_enabledÚmsgÚstatusr   r   r	   r      ó.   	ù
r   c                 C   sô   | ddi dœ}t d | ƒ}|rqtd r/d| › d�}||d< | |d	 d
< d|d	 d< d|d< |S t d | ƒd }t|tƒrRd|v rRd|d< | |d	 d
< d|d	 d< |S d|d< d| › d�|d< t|tƒro|d d|› d� |d< |S | › d�|d< |S )zV
    Ensure an Apache conf is disabled.

    name
        Name of the Apache conf
    Tr   r   r   r   r   z is set to be disabled.r   r   r   Nr   r   zapache.a2disconfr   ÚdisabledFzFailed to disable r   r   r   z already disabled.r   r   r   r   r	   r$   A   r#   r$   )Ú__doc__Zsalt.utils.pathr   r
   r   r$   r   r   r   r	   Ú<module>   s
    	"