File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/panos.cpython-310.pyc
o
�N�g�� � @ s| d Z ddlZddlm mZ ddlm mZ e�
e�Zdd� Z
d:dd�Zdd � Zd
d� Zdd
� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Z d;dd�Z d<dd �Zd=d!d"�Zd#d$� Zd>d%d&�Zd?d'd(�Zd=d)d*�Zd@d+d,�Z d-d.� Z!d=d/d0�Z" 1 dAd2d3�Z# dBd4d5�Z$ d<d6d7�Z%d=d8d9�Z&dS )Ca[
A state module to manage Palo Alto network devices.
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
About
=====
This state module was designed to handle connections to a Palo Alto based
firewall. This module relies on the Palo Alto proxy module to interface with the devices.
This state module is designed to give extreme flexibility in the control over XPATH values on the PANOS device. It
exposes the core XML API commands and allows state modules to chain complex XPATH commands.
Below is an example of how to construct a security rule and move to the top of the policy. This will take a config
lock to prevent execution during the operation, then remove the lock. After the XPATH has been deployed, it will
commit to the device.
.. code-block:: yaml
panos/takelock:
panos.add_config_lock
panos/service_tcp_22:
panos.set_config:
- xpath: /config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/service
- value: <entry name='tcp-22'><protocol><tcp><port>22</port></tcp></protocol></entry>
- commit: False
panos/create_rule1:
panos.set_config:
- xpath: /config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules
- value: '
<entry name="rule1">
<from><member>trust</member></from>
<to><member>untrust</member></to>
<source><member>10.0.0.1</member></source>
<destination><member>10.0.1.1</member></destination>
<service><member>tcp-22</member></service>
<application><member>any</member></application>
<action>allow</action>
<disabled>no</disabled>
</entry>'
- commit: False
panos/moveruletop:
panos.move_config:
- xpath: /config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules/entry[@name='rule1']
- where: top
- commit: False
panos/removelock:
panos.remove_config_lock
panos/commit:
panos.commit_config
Version Specific Configurations
===============================
Palo Alto devices running different versions will have different supported features and different command structures. In
order to account for this, the proxy module can be leveraged to check if the panos device is at a specific revision
level.
The proxy['panos.is_required_version'] method will check if a panos device is currently running a version equal or
greater than the passed version. For example, proxy['panos.is_required_version']('7.0.0') would match both 7.1.0 and
8.0.0.
.. code-block:: jinja
{% if proxy['panos.is_required_version']('8.0.0') %}
panos/deviceconfig/system/motd-and-banner:
panos.set_config:
- xpath: /config/devices/entry[@name='localhost.localdomain']/deviceconfig/system/motd-and-banner
- value: |
<banner-header>BANNER TEXT</banner-header>
<banner-header-color>color2</banner-header-color>
<banner-header-text-color>color18</banner-header-text-color>
<banner-header-footer-match>yes</banner-header-footer-match>
- commit: False
{% endif %}
.. seealso::
:py:mod:`Palo Alto Proxy Module <salt.proxy.panos>`
� Nc C s dt v rdS dS )N�panos.commitT)Fz panos module could not be loaded)�__salt__� r r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/panos.py�__virtual__] s r Fc C sH t | t�r|r
d| v r
dS d}| D ]
}|d|� d�7 }q|S d| � d�S )z>
Builds a member formatted string for XML operation.
�anyz<member>any</member>� z<member>z </member>)�
isinstance�list)�membersZanycheck�response�mr r r �_build_membersc s
r c C s | i dddd�}|S )z+
Set the default response values.
NFr )�name�changes�commit�result�commentr �r �retr r r �_default_retu s r c C �"