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

�N�g��@s0dZddlZddlZddlZdd�Zdd�ZdS)aO

Apache state

.. versionadded:: 2014.7.0

Allows for inputting a yaml dictionary into a file for apache configuration
files.

The variable ``this`` is special and signifies what should be included with
the above word between angle brackets (<>).

.. code-block:: yaml

    /etc/httpd/conf.d/website.com.conf:
      apache.configfile:
        - config:
          - VirtualHost:
              this: '*:80'
              ServerName:
                - website.com
              ServerAlias:
                - www.website.com
                - dev.website.com
              ErrorLog: logs/website.com-error_log
              CustomLog: logs/website.com-access_log combined
              DocumentRoot: /var/www/vhosts/website.com
              Directory:
                this: /var/www/vhosts/website.com
                Order: Deny,Allow
                Deny from: all
                Allow from:
                  - 127.0.0.1
                  - 192.168.100.0/24
                Options:
                  - Indexes
                  - FollowSymlinks
                AllowOverride: All

.. versionchanged:: 2018.3.0

Allows having the same section container multiple times (e.g. <Directory /path/to/dir>).

YAML structure stays the same only replace dictionary with a list.

When a section container does not have mandatory attribute, such as <Else>,
it still needs keyword ``this`` with empty string (or "" if nicer output is required - without space).

.. code-block:: yaml

    /etc/httpd/conf.d/website.com.conf:
      apache.configfile:
        - config:
          - VirtualHost:
              - this: '*:80'
              - ServerName:
                - website.com
              - DocumentRoot: /var/www/vhosts/website.com
              - Directory:
                  this: /var/www/vhosts/website.com
                  Order: Deny,Allow
                  Deny from: all
                  Allow from:
                    - 127.0.0.1
                    - 192.168.100.0/24
                  Options:
                    - Indexes
                    - FollowSymlinks
                  AllowOverride: All
              - Directory:
                - this: /var/www/vhosts/website.com/private
                - Order: Deny,Allow
                - Deny from: all
                - Allow from:
                  - 127.0.0.1
                  - 192.168.100.0/24
                - If:
                    this: some condition
                    do: something
                - Else:
                    this:
                    do: something else
                - Else:
                    this: ""
                    do: another thing
�NcCsdtvrdSdS)N�
apache.configT)Fz!apache module could not be loaded)�__salt__�rr�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/apache.py�__virtual__]src
Cs`|iddd�}td||dd�}d}tj�|�r8tjj�|��}tjj�	|�
��}Wd�n1s3wY|��|��krJd|d<d|d	<|Std
r_d|d	<||d�|d
<d|d<|Sz5tjj�|d��}t
tjj�|�|d�Wd�n1s~wY||d�|d
<d|d<d|d	<W|Sty�}zd|d<d|d	<WYd}~|Sd}~ww)N�)�name�changes�result�commentrF)ZeditTr
zConfiguration is up to date.r�testzConfiguration will update.)�old�newr	�w)�filez#Successfully created configuration.z&Failed to create apache configuration.)r�os�path�exists�salt�utils�filesZfopenZstringutilsZ
to_unicode�read�stripZ__opts__�printZto_str�	Exception)rZconfig�retZconfigsZcurrent_configsZconfig_file�excrrr�
configfilecs<��
���r)�__doc__rZsalt.utils.filesrZsalt.utils.stringutilsrrrrrr�<module>sV