�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
Z
d d l m Z d
� Z
d � Z d � Z d � Z d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont stableinterfacet statust communityt supported_bys�
---
module: awall
short_description: Manage awall policies
version_added: "2.4"
author: Ted Trask (@tdtrask) <[email protected]>
description:
- This modules allows for enable/disable/activate of I(awall) policies.
- Alpine Wall (I(awall)) generates a firewall configuration from the enabled policy files
and activates the configuration on the system.
options:
name:
description:
- One or more policy names.
type: list
state:
description:
- Whether the policies should be enabled or disabled.
type: str
choices: [ disabled, enabled ]
default: enabled
activate:
description:
- Activate the new firewall rules.
- Can be run with other steps or on its own.
type: bool
default: no
s2
- name: Enable "foo" and "bar" policy
awall:
name: [ foo bar ]
state: enabled
- name: Disable "foo" and "bar" policy and activate new rules
awall:
name:
- foo
- bar
state: disabled
activate: no
- name: Activate currently enabled firewall rules
awall:
activate: yes
s # N( t
AnsibleModulec C` sR d t } | j | � \ } } } | d k r2 t S| j d d d | d | � d S( Ns %s activate --forcei t msgs could not activate new rulest stdoutt stderr( t
AWALL_PATHt run_commandt Truet fail_json( t modulet cmdt rcR
R ( ( s@ /usr/lib/python2.7/site-packages/ansible/modules/system/awall.pyt activateE s
c C` sF d t } | j | � \ } } } t j d | | t j � rB t St S( Ns %s lists
^%s\s+enabled( R R
t ret searcht MULTILINER t False( R t nameR R R
R ( ( s@ /usr/lib/python2.7/site-packages/ansible/modules/system/awall.pyt is_policy_enabledN s
c C` s g } x- | D]% } t | | � s
| j | � q
q
W| sU | j d t d d � n d j | � } | j rz d t } n d t | f } | j | � \ } } } | d k r� | j d d | d | d
| � n | r� | j r� t | � n | j d t
d d | � d S( Nt changedR s policy(ies) already enabledt s %s lists %s enable %si s failed to enable %sR
R s enabled awall policy(ies): %s( R t appendt exit_jsonR t joint
check_modeR R
R R R ( R t namest actt policiesR R R R
R ( ( s@ /usr/lib/python2.7/site-packages/ansible/modules/system/awall.pyt
enable_policyV s
#
c C` s g } x- | D]% } t | | � r
| j | � q
q
W| sU | j d t d d � n d j | � } | j rz d t } n d t | f } | j | � \ } } } | d k r� | j d d | d | d
| � n | r� | j r� t | � n | j d t
d d | � d S( NR R s policy(ies) already disabledR s %s lists
%s disable %si s failed to disable %sR
R s disabled awall policy(ies): %s( R R R R R R R R
R R R ( R R R! R"