Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/web_infrastructure/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pyc

�
�Udac@`s=ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZdZ
yddlmZWn#ek
r�ej�Z
eZnXeZd
ZdZdd�Zdefd��YZdefd��YZd�ZddlmZmZddlmZe dkr9e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys
---
module: apache2_mod_proxy
author: Olivier Boukili (@oboukili)
version_added: "2.2"
short_description: Set and/or get members' attributes of an Apache httpd 2.4 mod_proxy balancer pool
description:
  - Set and/or get members' attributes of an Apache httpd 2.4 mod_proxy balancer
    pool, using HTTP POST and GET requests. The httpd mod_proxy balancer-member
    status page has to be enabled and accessible, as this module relies on parsing
    this page. This module supports ansible check_mode, and requires BeautifulSoup
    python module.
options:
  balancer_url_suffix:
    description:
      - Suffix of the balancer pool url required to access the balancer pool
        status page (e.g. balancer_vhost[:port]/balancer_url_suffix).
    default: /balancer-manager/
  balancer_vhost:
    description:
      - (ipv4|ipv6|fqdn):port of the Apache httpd 2.4 mod_proxy balancer pool.
    required: true
  member_host:
    description:
      - (ipv4|ipv6|fqdn) of the balancer member to get or to set attributes to.
        Port number is autodetected and should not be specified here.
        If undefined, apache2_mod_proxy module will return a members list of
        dictionaries of all the current balancer pool members' attributes.
  state:
    description:
      - Desired state of the member host.
        (absent|disabled),drained,hot_standby,ignore_errors can be
        simultaneously invoked by separating them with a comma (e.g. state=drained,ignore_errors).
    choices: ["present", "absent", "enabled", "disabled", "drained", "hot_standby", "ignore_errors"]
  tls:
    description:
      - Use https to access balancer management page.
    type: bool
    default: 'no'
  validate_certs:
    description:
      - Validate ssl/tls certificates.
    type: bool
    default: 'yes'
s
# Get all current balancer pool members' attributes:
- apache2_mod_proxy:
    balancer_vhost: 10.0.0.2

# Get a specific member's attributes:
- apache2_mod_proxy:
    balancer_vhost: myws.mydomain.org
    balancer_suffix: /lb/
    member_host: node1.myws.mydomain.org

# Enable all balancer pool members:
- apache2_mod_proxy:
    balancer_vhost: '{{ myloadbalancer_host }}'
  register: result
- apache2_mod_proxy:
    balancer_vhost: '{{ myloadbalancer_host }}'
    member_host: '{{ item.host }}'
    state: present
  with_items: '{{ result.members }}'

# Gracefully disable a member from a loadbalancer node:
- apache2_mod_proxy:
    balancer_vhost: '{{ vhost_host }}'
    member_host: '{{ member.host }}'
    state: drained
  delegate_to: myloadbalancernode
- wait_for:
    host: '{{ member.host }}'
    port: '{{ member.port }}'
    state: drained
  delegate_to: myloadbalancernode
- apache2_mod_proxy:
    balancer_vhost: '{{ vhost_host }}'
    member_host: '{{ member.host }}'
    state: absent
  delegate_to: myloadbalancernode
s
member:
    description: specific balancer member information dictionary, returned when apache2_mod_proxy module is invoked with member_host parameter.
    type: dict
    returned: success
    sample:
      {"attributes":
            {"Busy": "0",
            "Elected": "42",
            "Factor": "1",
            "From": "136K",
            "Load": "0",
            "Route": null,
            "RouteRedir": null,
            "Set": "0",
            "Status": "Init Ok ",
            "To": " 47K",
            "Worker URL": null
        },
        "balancer_url": "http://10.10.0.2/balancer-manager/",
        "host": "10.10.0.20",
        "management_url": "http://10.10.0.2/lb/?b=mywsbalancer&w=http://10.10.0.20:8080/ws&nonce=8925436c-79c6-4841-8936-e7d13b79239b",
        "path": "/ws",
        "port": 8080,
        "protocol": "http",
        "status": {
            "disabled": false,
            "drained": false,
            "hot_standby": false,
            "ignore_errors": false
        }
      }
members:
    description: list of member (defined above) dictionaries, returned when apache2_mod_proxy is invoked with no member_host and state args.
    returned: success
    type: list
    sample:
      [{"attributes": {
            "Busy": "0",
            "Elected": "42",
            "Factor": "1",
            "From": "136K",
            "Load": "0",
            "Route": null,
            "RouteRedir": null,
            "Set": "0",
            "Status": "Init Ok ",
            "To": " 47K",
            "Worker URL": null
        },
        "balancer_url": "http://10.10.0.2/balancer-manager/",
        "host": "10.10.0.20",
        "management_url": "http://10.10.0.2/lb/?b=mywsbalancer&w=http://10.10.0.20:8080/ws&nonce=8925436c-79c6-4841-8936-e7d13b79239b",
        "path": "/ws",
        "port": 8080,
        "protocol": "http",
        "status": {
            "disabled": false,
            "drained": false,
            "hot_standby": false,
            "ignore_errors": false
        }
        },
        {"attributes": {
            "Busy": "0",
            "Elected": "42",
            "Factor": "1",
            "From": "136K",
            "Load": "0",
            "Route": null,
            "RouteRedir": null,
            "Set": "0",
            "Status": "Init Ok ",
            "To": " 47K",
            "Worker URL": null
        },
        "balancer_url": "http://10.10.0.2/balancer-manager/",
        "host": "10.10.0.21",
        "management_url": "http://10.10.0.2/lb/?b=mywsbalancer&w=http://10.10.0.21:8080/ws&nonce=8925436c-79c6-4841-8936-e7d13b79239b",
        "path": "/ws",
        "port": 8080,
        "protocol": "http",
        "status": {
            "disabled": false,
            "drained": false,
            "hot_standby": false,
            "ignore_errors": false}
        }
      ]
N(t
BeautifulSoups[(b=([\w\.\-]+)&w=(https?|ajp|wss?|ftp|[sf]cgi)://([\w\.\-]+):?(\d*)([/\w\.\-]*)&?[\w\-\=]*)sSERVER VERSION: APACHE/([\d.]+)icC`sYtjdt|�dt|��}|rU|j|�dkrUt|j|��SndS(sV Returns the capture group (default=1) specified in the regexp, applied to the string tstringtpatterntN(tretsearchtstrtgrouptNone(R	t_regexptgroupst
regexp_search((sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pytregexp_extraction�s
$tBalancerMembercB`sMeZdZd�Zd�Zd�Zd�Zee�Zeee�Z	RS(s\ Apache 2.4 mod_proxy LB balancer member.
    attributes:
        read-only:
            host -> member host (string),
            management_url -> member management url (string),
            protocol -> member protocol (string)
            port -> member port (string),
            path -> member location (string),
            balancer_url -> url of this member's parent balancer (string),
            attributes -> whole member attributes (dictionary)
            module -> ansible module instance (AnsibleModule object).
        writable:
            status -> status of the member (dictionary)
    cC`s�t|tt�d�|_t|�|_t|td�|_t|td�|_t|td�|_t|�|_||_	dS(Niiii(
RRt
EXPRESSIONthosttmanagement_urltprotocoltporttpathtbalancer_urltmodule(tselfRRR((sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pyt__init__�sc`s9t|j|j�}|dddkrG|jjdd|d�n�yt|d�}Wn.tk
r�|jjddt|��n�X|jd�djd	�}|djd
��xw|ddd�D]b}tj	d|j
d
t|��r�|jd��t��fd�tdt
���D��Sq�WdS(s8 Returns a dictionary of a balancer member's attributes.iRi�tmsgs<Could not get balancer_member_page, check for connectivity! is(Cannot parse balancer_member_page HTML! ttablettrtthNR
R	ttdc3`s)|]}�|j�|jfVqdS(N(R	(t.0tx(tkeystvalues(sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pys	<genexpr>s(t	fetch_urlRRt	fail_jsonRt	TypeErrorRtfindAllRR
Rtdicttrangetlen(Rtbalancer_member_pagetsouptsubsoupt	valuesset((R'R(sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pytget_member_attributes�s
!!cC`s�idd6dd6dd6dd6}i}t|jd	�}xG|j�D]9}tjd
||d|�rwt||<qHt||<qHW|S(s? Returns a dictionary of a balancer member's status attributes.tDistdisabledtDrntdrainedtStbythot_standbytIgnt
ignore_errorstStatusR
R	(Rt
attributesR'RR
tTruetFalse(Rtstatus_mappingRt
actual_statustmode((sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pytget_member_statuss


cC`s�idd6dd6dd6dd6}t|jtd	�}xW|j�D]I}|t|�ru|t||�d
}qD|t||�d}qDWt|j|jdt|��}|d	d
dkr�|jjdd|jd|d	d
�ndS(sF Sets a balancer member's status attributes amongst pre-mapped values.s&w_status_DR6s&w_status_NR8s&w_status_HR:s&w_status_IR<is=1s=0tdataRi�R s!Could not set the member status! t N(	RRRR'RR)RR*R(RR(tvalues_mappingtrequest_bodytktresponse((sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pytset_member_statuss

!(
t__name__t
__module__t__doc__RR4RDRKtpropertyR>R(((sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pyR�s					tBalancercB`s;eZdZded�Zd�Zd�Zee�Z	RS(s+ Apache httpd 2.4 mod_proxy balancer objectcC`s�|rQttd�t|��|_ttd�t|�t|��|_nHttd�t|��|_ttd�t|�t|��|_||_|j�|_|dkr�g|_ndS(Nshttps://shttp://(Rtbase_urlturlRtfetch_balancer_pagetpageRt_members(RRtsuffixRtmembersttls((sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pyR0s,)	cC`s�t|jt|j��}|dddkrW|jjddt|dd��n}|dj�}t|j�td�}|r�t	j
ddd	|�s�|jjdd
t|��n|S|jjdd�dS(
sI Returns the balancer management html page as a string for later parsing.iRi�R s3Could not get balancer page! HTTP status response: iR
s2\.4\.[\d]*R	sLThis module only acts on an Apache2 2.4+ instance, current Apache2 version: sACould not get the Apache server version from the balancer-managerN(R)RRRRR*treadRtuppertAPACHE_VERSION_EXPRESSIONRR
(RRTtcontenttapache_version((sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pyRS<s( cc`s�yt|j�}Wn1tk
rF|jjddt|j��n�Xx|jd�ddd�D]a}t|jd��}|s�|jjdd�qdtt|j	|�t|j
�|j�VqdWdS(sK Returns members of the balancer as a generator object for later iteration.R s!Cannot parse balancer page HTML! taiNthrefs+Argument 'balancer_member_suffix' is empty!(RRTR+RR*RR,tgetRRQRR(RR1telementtbalancer_member_suffix((sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pytget_balancer_membersKs
$#N(
RLRMRNRR@RRSRcRORW(((sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pyRP-s
		cC`stdtdtdtdd,dd�dtdddd�d	tdd�d
tdd�dtdtdd�d
tdtdd��dt�}ttkr�|jdtd�dt�n|j	d
d,k	rT|j	d
j
d�}t|�dkr!d|ksd|kr!|jdd�q]x9|D]%}|d-kr(|jdd�q(q(Wn	dg}t|j	d|j	dd|d|j	d�}|j	d	d,kr0g}xn|j
D]c}|ji|jd6|jd 6|jd!6|jd"6|jd#6|jd$6|jd%6|jd&6�q�W|jd'td(|�n�t}t}itd6td6td6td6}xc|j�D]U}	xL|D]D}
|	|
kr�t||	<qx|	dkrx|
dkrxt||	<qxqxWqkWx�|j
D]�}t|j�t|j	d	�kr�t}|j	d
d,k	rO|j}|js1|}|_n|}||krOt}qOni|jd6|jd 6|jd!6|jd"6|jd#6|jd$6|jd%6|jd&6}
q�q�W|r�|jd'|d)|
�n6|jdt|j	d	�d*t|j	d�d+�d,S(.s Initiates module.t
argument_spectbalancer_vhosttrequiredtdefaultttypeRtbalancer_url_suffixs/balancer-manager/tmember_hosttstateRXtbooltvalidate_certstsupports_check_modeR Rt	exceptiont,itpresenttenableds>state present/enabled is mutually exclusive with other states!tabsentR6R8R:R<syState can only take values amongst 'present', 'absent', 'enabled', 'disabled', 'drained', 'hot_standby', 'ignore_errors'.RRRRRRRR>RRtchangedRWtmembers! is not a member of the balancer t!N(RqRsRrsdisabledsdrainedshot_standbys
ignore_errors(t
AnsibleModuleR-R?RR@tHAS_BEAUTIFULSOUPR*tmissing_required_libtBEAUTIFUL_SOUP_IMP_ERRtparamstsplitR/RPRWtappendRRRRRR>RRt	exit_jsonR'Rt
check_mode(Rtstatest_statet
mybalancertjson_output_listRuRtt
member_existst
member_statusRCRktmember_status_beforetmember_status_aftertjson_output((sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pytmain\s�	*
		

	






	
"

"		






	
(RwRy(R)t__main__(!t
__future__RRRRht
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRt	tracebackRRzRtImportErrort
format_excR@RxR?RR[RtobjectRRPR�tansible.module_utils.basicRwRytansible.module_utils.urlsR)RL(((sX/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/apache2_mod_proxy.pyt<module>s4


/'[

	R/	]

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]