Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/net_tools/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyo

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	dd
l
Z
dd
lZdd
lZddl
mZmZddlmZdd
lmZddlmZddlmZdefd��YZd�Zedkre�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysW
---
module: dnsmadeeasy
version_added: "1.3"
short_description: Interface with dnsmadeeasy.com (a DNS hosting service).
description:
   - >
     Manages DNS records via the v2 REST API of the DNS Made Easy service.  It handles records only; there is no manipulation of domains or
     monitor/account support yet. See: U(https://www.dnsmadeeasy.com/integration/restapi/)
options:
  account_key:
    description:
      - Account API Key.
    required: true

  account_secret:
    description:
      - Account Secret Key.
    required: true

  domain:
    description:
      - Domain to work with. Can be the domain name (e.g. "mydomain.com") or the numeric ID of the domain in DNS Made Easy (e.g. "839989") for faster
        resolution
    required: true

  sandbox:
    description:
      - Decides if the sandbox API should be used. Otherwise (default) the production API of DNS Made Easy is used.
    type: bool
    default: 'no'
    version_added: 2.7

  record_name:
    description:
      - Record name to get/create/delete/update. If record_name is not specified; all records for the domain will be returned in "result" regardless
        of the state argument.

  record_type:
    description:
      - Record type.
    choices: [ 'A', 'AAAA', 'CNAME', 'ANAME', 'HTTPRED', 'MX', 'NS', 'PTR', 'SRV', 'TXT' ]

  record_value:
    description:
      - >
        Record value. HTTPRED: <redirection URL>, MX: <priority> <target name>, NS: <name server>, PTR: <target name>,
        SRV: <priority> <weight> <port> <target name>, TXT: <text value>"
      - >
        If record_value is not specified; no changes will be made and the record will be returned in 'result'
        (in other words, this module can be used to fetch a record's current id, type, and ttl)

  record_ttl:
    description:
      - record's "Time to live".  Number of seconds the record remains cached in DNS servers.
    default: 1800

  state:
    description:
      - whether the record should exist or not
    required: true
    choices: [ 'present', 'absent' ]

  validate_certs:
    description:
      - If C(no), SSL certificates will not be validated. This should only be used
        on personally controlled sites using self-signed certificates.
    type: bool
    default: 'yes'
    version_added: 1.5.1

  monitor:
    description:
      - If C(yes), add or change the monitor.  This is applicable only for A records.
    type: bool
    default: 'no'
    version_added: 2.4

  systemDescription:
    description:
      - Description used by the monitor.
    required: true
    default: ''
    version_added: 2.4

  maxEmails:
    description:
      - Number of emails sent to the contact list by the monitor.
    required: true
    default: 1
    version_added: 2.4

  protocol:
    description:
      - Protocol used by the monitor.
    required: true
    default: 'HTTP'
    choices: ['TCP', 'UDP', 'HTTP', 'DNS', 'SMTP', 'HTTPS']
    version_added: 2.4

  port:
    description:
      - Port used by the monitor.
    required: true
    default: 80
    version_added: 2.4

  sensitivity:
    description:
      - Number of checks the monitor performs before a failover occurs where Low = 8, Medium = 5,and High = 3.
    required: true
    default: 'Medium'
    choices: ['Low', 'Medium', 'High']
    version_added: 2.4

  contactList:
    description:
      - Name or id of the contact list that the monitor will notify.
      - The default C('') means the Account Owner.
    required: true
    default: ''
    version_added: 2.4

  httpFqdn:
    description:
      - The fully qualified domain name used by the monitor.
    version_added: 2.4

  httpFile:
    description:
      - The file at the Fqdn that the monitor queries for HTTP or HTTPS.
    version_added: 2.4

  httpQueryString:
    description:
      - The string in the httpFile that the monitor queries for HTTP or HTTPS.
    version_added: 2.4

  failover:
    description:
      - If C(yes), add or change the failover.  This is applicable only for A records.
    type: bool
    default: 'no'
    version_added: 2.4

  autoFailover:
    description:
      - If true, fallback to the primary IP address is manual after a failover.
      - If false, fallback to the primary IP address is automatic after a failover.
    type: bool
    default: 'no'
    version_added: 2.4

  ip1:
    description:
      - Primary IP address for the failover.
      - Required if adding or changing the monitor or failover.
    version_added: 2.4

  ip2:
    description:
      - Secondary IP address for the failover.
      - Required if adding or changing the failover.
    version_added: 2.4

  ip3:
    description:
      - Tertiary IP address for the failover.
    version_added: 2.4

  ip4:
    description:
      - Quaternary IP address for the failover.
    version_added: 2.4

  ip5:
    description:
      - Quinary IP address for the failover.
    version_added: 2.4

notes:
  - The DNS Made Easy service requires that machines interacting with the API have the proper time and timezone set. Be sure you are within a few
    seconds of actual time by using NTP.
  - This module returns record(s) and monitor(s) in the "result" element when 'state' is set to 'present'.
    These values can be be registered and used in your playbooks.
  - Only A records can have a monitor or failover.
  - To add failover, the 'failover', 'autoFailover', 'port', 'protocol', 'ip1', and 'ip2' options are required.
  - To add monitor, the 'monitor', 'port', 'protocol', 'maxEmails', 'systemDescription', and 'ip1' options are required.
  - The monitor and the failover will share 'port', 'protocol', and 'ip1' options.

requirements: [ hashlib, hmac ]
author: "Brice Burgess (@briceburg)"
s/
# fetch my.com domain records
- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
  register: response

# create / ensure the presence of a record
- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1

# update the previously created record
- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_value: 192.0.2.23

# fetch a specific record
- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
  register: response

# delete a record / ensure it is absent
- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    record_type: A
    state: absent
    record_name: test

# Add a failover
- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    failover: True
    ip1: 127.0.0.2
    ip2: 127.0.0.3

- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    failover: True
    ip1: 127.0.0.2
    ip2: 127.0.0.3
    ip3: 127.0.0.4
    ip4: 127.0.0.5
    ip5: 127.0.0.6

# Add a monitor
- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    monitor: yes
    ip1: 127.0.0.2
    protocol: HTTP  # default
    port: 80  # default
    maxEmails: 1
    systemDescription: Monitor Test A record
    contactList: my contact list

# Add a monitor with http options
- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    monitor: yes
    ip1: 127.0.0.2
    protocol: HTTP  # default
    port: 80  # default
    maxEmails: 1
    systemDescription: Monitor Test A record
    contactList: 1174  # contact list id
    httpFqdn: http://my.com
    httpFile: example
    httpQueryString: some string

# Add a monitor and a failover
- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    failover: True
    ip1: 127.0.0.2
    ip2: 127.0.0.3
    monitor: yes
    protocol: HTTPS
    port: 443
    maxEmails: 1
    systemDescription: monitoring my.com status
    contactList: emergencycontacts

# Remove a failover
- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    failover: no

# Remove a monitor
- dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    monitor: no
N(tstrftimetgmtime(t
AnsibleModule(t	fetch_url(t	urlencode(tstring_typestDME2cB`s�eZd�Zd�Zd�Zd�Zdd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cC`s�||_||_||_|rGd|_|jjdd|j�n	d|_t|�|_d|_d|_	d|_
d|_d|_|jj
�s�|j|j�d|_ndt|j�d|_d|_d	|_dS(
Ns)https://api.sandbox.dnsmadeeasy.com/V2.0/twarnings;Sandbox is enabled. All actions are made against the URL %ss!https://api.dnsmadeeasy.com/V2.0/tidsdns/managed/s/recordstmonitortcontactList(tmoduletapitsecrettbaseurltwarntstrtdomaintNonet
domain_mapt
record_maptrecordstall_recordstcontactList_maptisdigittgetDomainByNamet
record_urltmonitor_urltcontactList_url(tselftapikeyRRtsandboxR((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyt__init__}s$											cC`sD|j�}|j|�}i|jd6|d6|d6dd6}|S(Nsx-dnsme-apiKeysx-dnsme-hmacsx-dnsme-requestDatesapplication/jsonscontent-type(t	_get_datet_create_hashR(R%tcurrTimet
hashstringtheaders((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyt_headers�s

cC`s#tjtjd�tdt��S(NtCs%a, %d %b %Y %H:%M:%S GMT(tlocalet	setlocaletLC_TIMERR	(R%((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyR)�scC`s+tj|jj�|j�tj�j�S(N(thmactnewRtencodethashlibtsha1t	hexdigest(R%trightnow((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyR*�sc
C`s�|j|}|r2t|t�r2t|�}nt|j|d|d|d|j��\}}|dd
kr�|jjdd	||d|df�nytj	|�SWnt
k
r�iSXdS(NtdatatmethodR-Ri�i�i�tmsgs%s returned %s, with body: %s(i�i�i�(Rt
isinstanceR
RRRR.t	fail_jsontjsontloadt	Exception(R%tresourceR;R:turltresponsetinfo((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pytquery�s
0+
cC`s,|js|jd�n|jj|t�S(NR(Rt_instMaptdomainstgettFalse(R%t	domain_id((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyt	getDomain�s	cC`s5|js|jd�n|j|jj|d��S(NRi(RRGRLRI(R%tdomain_name((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyR!�s	cC`s|jdd�dS(Nsdns/managedtGETR:(RF(R%((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyt
getDomains�scC`s,|js|jd�n|jj|t�S(Ntrecord(RRGRRIRJ(R%t	record_id((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyt	getRecord�s	cC`s|js|j�|_n|dkrcx5|jD]*}|d|kr1|d|kr1|Sq1WtS|dkrx�|jD]�}|d	kr�|jd
�d}n(|dkr�|jd
�d}n|}|d|kry|d|kry|d|kry|SqyWtStd��dS(NtCNAMEtANAMEtHTTPREDtPTRtnamettypetAtAAAAtMXtNStTXTtSRVt iitvaluesrecord_type not yet supported(RSRTRURV(RYRZR[R\R]R^(Rt
getRecordsRJtsplitRA(R%trecord_nametrecord_typetrecord_valuetresultR`((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pytgetMatchingRecord�s$	 0cC`s|j|jd�dS(NRNR:(RFR"(R%((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyRa�scC`s�i}i}xHt|d|j�d��D]&}|d||d<|||d<q-Wt||d|�t||d|�dS(NRItsRRWt_map(tgetattrttitletsetattr(R%RXtmaptresultsRf((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyRG�s'cC`stj|dd�S(Nt
separatorst,t:(RpRq(R?tdumps(R%R:((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyt
prepareRecord�scC`s|j|jd|�S(NtPOST(RFR"(R%R:((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pytcreateRecord�scC`s$|j|jdt|�d|�S(Nt/tPUT(RFR"R(R%RQR:((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pytupdateRecordscC`s!|j|jdt|�d�S(NRvtDELETE(RFR"R(R%RQ((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pytdeleteRecordscC`s!|j|jdt|�d�S(NRvRN(RFR#R(R%RQ((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyt
getMonitor	scC`s$|j|jdt|�d|�S(NRvRw(RFR#R(R%RQR:((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyt
updateMonitorscC`stj|dd�S(NRoRpRq(RpRq(R?Rr(R%R:((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pytprepareMonitorscC`s,|js|jd�n|jj|t�S(NR(RRGtcontactListsRIRJ(R%tcontact_list_id((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pytgetContactLists	cC`s|j|jd�dS(NRNR:(RFR$(R%((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pytgetContactlistsscC`s5|js|jd�n|j|jj|d��S(NRi(RRGR�RI(R%RW((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pytgetContactListByNames	N(t__name__t
__module__R(R.R)R*RRFRLR!RORRRgRaRGRsRuRxRzR{R|R}R�R�R�(((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyR{s,																					c=C`s�tdtdtdt�dtdtdt�dtdt�dtdd	d
d�dtdtd
ddg�dtdt�dtdtd
ddddddddddg
�dtdt�dtdtddd
d�d tdd	d
d�d!tdd"�d#tdd$d
d�d%tdd&d
d'd(d&d)d*d+g�d,tdd-d
d�d.tdd/d
d0d/d1g�d2tdd�d3tdt�d4tdt�d5tdt�d6tdd	d
d�d7tdd	d
d�d8tdt�d9tdt�d:tdt�d;tdt�d<tdt�d=tdd>d
d��d?dddggd@d6td7d,d%d8d9ggd td,d%d#d!d8ggg�}td'd$d(dAd&dBd)dCd*dDd+dE�}td0dFd/dDd1dB�}t|jd|jd|jd|jd|�}|jd}|jd}|jd}|jd}|dkr�|j�}|si|jdGdH�n|j	dItdJ|�n|j
|||�}	i|dK6}
xHdddgD]7}|j|dk	r�|j||
|tdL�<q�q�W|
d
dkr8|
dMjdN�dO|
dP<|
dMjdN�d$|
dM<n|
d
dkr�|
dMjdN�dO|
dQ<|
dMjdN�d$|
dR<|
dMjdN�dA|
d,<|
dMjdN�dB|
dM<nt�}t�}
|	r�|	d
dkr�|j
|	dS�}nx5d d!d%d,d.d#d2d3d4d5d6d7d8d9d:d;d<gD]�}|j|dk	r/|d%krl||j||
dT<q)|d.kr�||j||
|<q)|d2kr|j|}|j�r|d"kr|j|�}|s�|jdGdUj|��n|jdSd"�}n||
dV<q)|j||
|<q/q/Wt}|	r�x7|
D]/}t|	|�t|
|�kr@t}q@q@Wt|	dS�|
dS<nt}|r�x?|
D]4}t|j|��t|
|�kr�t}q�q�Wn|dkr[dM|
krB|	s|jdGdW||jdf�n|j	dItdJtdX|	d |��n|	s�|j|j|
��}|j|dS|j|
��}|j	dItdJtdX|d |��nt}|r�|j|	dS|j|
��t}n|r|j|dY|j|
��t}n|r3|j	dItdJtdX|
d |
��n|j	dItdJtdX|	d |��nc|dkr�t}|	r�|j|	dS�|j	dIt�n|j	dI|�n|jdGdZ|�dS([Nt
argument_spectaccount_keytrequiredtaccount_secrettno_logRR'tdefaulttnoRXtbooltstatetchoicestpresenttabsentRcRdRYRZRSRTRUR[R\RVR^R]Ret
record_ttlitintRtsystemDescriptiontt	maxEmailsitprotocoltHTTPtTCPtUDPtDNStSMTPtHTTPStportiPtsensitivitytMediumtLowtHighRthttpFqdnthttpFilethttpQueryStringtfailovertautoFailovertip1tip2tip3tip4tip5tvalidate_certstyestrequired_togethertrequired_ifiiiiiiR<sYThe requested domain name is not accessible with this api_key; try using its ID if known.tchangedRfRWtrecord_R`R_itmxLeveltprioritytweightRt
protocolIdsContact list {0} does not existt
contactListIds7A record with name '%s' does not exist for domain '%s.'RPtrecordIds/'%s' is an unknown value for the state argument(R
tdicttTrueRJRRtparamsRaR>t	exit_jsonRgtlenRbR{R R�tformatRIRRuRsR|R}RxRz(Rt	protocolst
sensitivitiestDMER�RcRdRetdomain_recordstcurrent_recordt
new_recordtitcurrent_monitortnew_monitorRtcontact_listtrecord_changedtmonitor_changedRPRtupdatedR�((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pytmain&s�''$-!



	

"		


 

%	((		((	t__main__(t
__future__RRRRXt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESR?R6R3R0ttimeRR	tansible.module_utils.basicR
tansible.module_utils.urlsRt+ansible.module_utils.six.moves.urllib.parseRtansible.module_utils.sixR
tobjectRR�R�(((sI/usr/lib/python2.7/site-packages/ansible/modules/net_tools/dnsmadeeasy.pyt<module>s&


���	�

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