�
�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
m Z d d l m
Z
d d
l m Z d d l Z d d d � � YZ d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys�
---
module: rundeck_acl_policy
short_description: Manage Rundeck ACL policies.
description:
- Create, update and remove Rundeck ACL policies through HTTP API.
version_added: "2.4"
author: "Loic Blot (@nerzhul)"
options:
state:
description:
- Create or remove Rundeck project.
choices: ['present', 'absent']
default: 'present'
name:
description:
- Sets the project name.
required: True
url:
description:
- Sets the rundeck instance URL.
required: True
api_version:
description:
- Sets the API version used by module.
- API version must be at least 14.
default: 14
token:
description:
- Sets the token to authenticate against Rundeck API.
required: True
project:
description:
- Sets the project which receive the ACL policy.
- If unset, it's a system ACL policy.
policy:
description:
- Sets the ACL policy content.
- ACL policy content is a YAML object as described in http://rundeck.org/docs/man5/aclpolicy.html.
- It can be a YAML string or a pure Ansible inventory YAML object.
s8
- name: Create or update a rundeck ACL policy in project Ansible
rundeck_acl_policy:
name: "Project_01"
api_version: 18
url: "https://rundeck.example.org"
token: "mytoken"
state: present
project: "Ansible"
policy:
description: "my policy"
context:
application: rundeck
for:
project:
- allow: read
by:
group: "build"
- name: Remove a rundeck system policy
rundeck_acl_policy:
name: "Project_02"
url: "https://rundeck.example.org"
token: "mytoken"
state: absent
so
rundeck_response:
description: Rundeck response when a failure occurs.
returned: failed
type: str
before:
description: Dictionary containing ACL policy informations before modification.
returned: success
type: dict
after:
description: Dictionary containing ACL policy informations after modification.
returned: success
type: dict
( t
AnsibleModule( t fetch_url( t to_textNt RundeckACLManagerc B` sD e Z d � Z d � Z d d d � Z d � Z d � Z d � Z RS( c C` s
| | _ d S( N( t module( t selfR ( ( sY /usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/rundeck_acl_policy.pyt __init__n s c C` sd | d d k r0 | j j d d d | d � n0 | d d k r` | j j d d d | d � n d S( NR i� t msgsQ Token not allowed. Please ensure token is allowed or has the correct permissions.t rundeck_responset bodyi� s Fatal Rundeck API error.( R t fail_json( R
t infos( ( sY /usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/rundeck_acl_policy.pyt handle_http_code_if_neededq s
t GETc C` s t | j d | j j d | j j d | f d t j | � d | d i d d 6d d 6| j j d
d 6�\ } } | j | � | d k r| j � } | d k ry) t j t | d
d �� } | | f SWq t
k
r} | j j d d t | � | f � q Xqn | | f S( Ns %s/api/%d/%st urlt api_versiont datat methodt headerss application/jsons Content-Typet Acceptt tokens X-Rundeck-Auth-Tokent t errorst surrogate_or_strictR sH Rundeck response was not a valid JSON. Exception was: %s. Object was: %s(
R R t paramst jsont dumpsR t Nonet readt loadsR
t
ValueErrorR t str( R
t queryR R t respt infot json_respt e( ( sY /usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/rundeck_acl_policy.pyt request_rundeck_apix s&