Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/f5/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyc

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
mZdd
l
mZytddlmZddlmZddlmZddlmZddlmZddlmZddlmZWn�ek
r�ddlmZddlmZddlmZddlmZddlmZddlmZddlmZnXyddlmZWn!ek
r�ddlmZnXdefd��YZ de fd��YZ!de fd��YZ"de fd��YZ#de#fd��YZ$d e#fd!��YZ%d"e&fd#��YZ'd$e&fd%��YZ(d&e&fd'��YZ)d(�Z*e+d)kr�e*�ndS(*i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontstableinterfacetstatust	certifiedtsupported_bysI
---
module: bigip_ssl_certificate
short_description: Import/Delete certificates from BIG-IP
description:
  - This module will import/delete SSL certificates on BIG-IP LTM.
    Certificates can be imported from certificate and key files on the local
    disk, in PEM format.
version_added: 2.2
options:
  content:
    description:
      - Sets the contents of a certificate directly to the specified value.
        This is used with lookup plugins or for anything with formatting or
      - C(content) must be provided when C(state) is C(present).
    type: str
    aliases: ['cert_content']
  state:
    description:
      - Certificate state. This determines if the provided certificate
        and key is to be made C(present) on the device or C(absent).
    type: str
    choices:
      - present
      - absent
    default: present
  name:
    description:
      - SSL Certificate Name. This is the cert name used when importing a certificate
        into the F5. It also determines the filenames of the objects on the LTM.
    type: str
    required: True
  issuer_cert:
    description:
      - Issuer certificate used for OCSP monitoring.
      - This parameter is only valid on versions of BIG-IP 13.0.0 or above.
    type: str
    version_added: 2.5
  partition:
    description:
      - Device partition to manage resources on.
    type: str
    default: Common
    version_added: 2.5
notes:
  - This module does not behave like other modules that you might include in
    roles where referencing files or templates first looks in the role's
    files or templates directory. To have it behave that way, use the Ansible
    file or template lookup (see Examples). The lookups behave as expected in
    a role context.
extends_documentation_fragment: f5
requirements:
  - BIG-IP >= v12
author:
  - Tim Rupp (@caphrim007)
  - Wojciech Wypior (@wojtek0806)
s
- name: Use a file lookup to import PEM Certificate
  bigip_ssl_certificate:
    name: certificate-name
    state: present
    content: "{{ lookup('file', '/path/to/cert.crt') }}"
    provider:
      server: lb.mydomain.com
      user: admin
      password: secret
  delegate_to: localhost

- name: Use a file lookup to import CA certificate chain
  bigip_ssl_certificate:
    name: ca-chain-name
    state: present
    content: "{{ lookup('file', '/path/to/ca-chain.crt') }}"
    provider:
      server: lb.mydomain.com
      user: admin
      password: secret
  delegate_to: localhost

- name: Delete Certificate
  bigip_ssl_certificate:
    name: certificate-name
    state: absent
    provider:
      server: lb.mydomain.com
      user: admin
      password: secret
  delegate_to: localhost
s@
cert_name:
  description: The name of the certificate that the user provided
  returned: created
  type: str
  sample: cert1
filename:
  description:
    - The name of the SSL certificate.
  returned: created
  type: str
  sample: cert1.crt
checksum:
  description: SHA1 checksum of the cert that was provided.
  returned: changed and created
  type: str
  sample: f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0
source_path:
  description: Path on BIG-IP where the source of the certificate is stored.
  returned: created
  type: str
  sample: /var/config/rest/downloads/cert1.crt
N(t
AnsibleModule(tenv_fallback(tF5RestClient(t
F5ModuleError(tAnsibleF5Parameters(tf5_argument_spec(tfq_name(ttransform_name(tupload_file(tStringIOt
ParameterscB`sOeZdZidd6dd6ZdddgZddddgZddgZRS(s/var/config/rest/downloadstsource_patht
sourcePathtissuer_certt
issuerCerttcontenttfilenametchecksum(t__name__t
__module__t
download_pathtapi_mapt
updatablestreturnablestapi_attributes(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR�s
		t
ApiParameterscB`s&eZed��Zed��ZRS(cC`sQ|jddkrdSd}tj||jd�}|rI|jd�SdSdS(NRsSHA1:\d+:(?P<value>[\w+]{40})tvalue(t_valuestNonetretmatchtgroup(tselftpatterntmatches((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR�s
cC`s|jdS(Ntname(R#(R(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR�s(RRtpropertyRR(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR!�stModuleParameterscB`sMeZd�Zed��Zed��Zed��Zed��ZRS(cC`s^tj�}t|�}x9trS|jd�}|s:Pn|j|jd��qW|j�S(Nisutf-8(thashlibtsha1RtTruetreadtupdatetencodet	hexdigest(R(Rtktstdata((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyt	_get_hash�s	cC`sO|jddkrdSt|j|jd�}|jd�rC|S|dSdS(NRs.crt(R#R$Rt	partitiontendswith(R(R+((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR�scC`s#|jdkrdS|j|j�S(N(RR$R8(R(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR�scC`s(|jjd�r|jS|jdSdS(Ns.crt(R+R:(R(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR�scC`s#dtjj|j|j�}|S(Nsfile://(tostpathtjoinRR(R(tresult((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR�s
(RRR8R,RRRR(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR-�s
	

tChangescB`seZd�ZRS(cC`sXi}y:x$|jD]}t||�||<qW|j|�}Wntk
rSnX|S(N(Rtgetattrt_filter_paramst	Exception(R(R>t
returnable((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyt	to_return�s
(RRRD(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR?�stReportableChangescB`seZRS((RR(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyREst
UsableChangescB`seZRS((RR(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRFst
DifferencecB`sDeZdd�Zd�Zd�Zed��Zed��ZRS(cC`s||_||_dS(N(twantthave(R(RHRI((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyt__init__
s	cC`s?yt||�}|SWn!tk
r:|j|�}|SXdS(N(R@tAttributeErrort_Difference__default(R(tparamR>((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pytcompares
cC`sQt|j|�}y&t|j|�}||kr7|SWntk
rL|SXdS(N(R@RHRIRK(R(RMtattr1tattr2((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyt	__defaults
cC`sj|jjdkrdS|jj|jjkrD|jrD|jjSn|jj|jjkrf|jjSdS(N(RHRR$RIR(R(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR"s	
cC`sA|jj|jjkr=td|jjd|jj�}|SdS(NRR(RHRRItdictR(R(R>((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR,s
N(	RRR$RJRNRLR,RR(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRGs
			
t
ModuleManagercB`s�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�ZRS(cO`s^|jdd�|_t|jj�|_td|jj�|_t�|_	t
�|_dS(Ntmoduletparams(tgetR$RTR
RUtclientR-RHR!RIRFtchanges(R(targstkwargs((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRJ7s
cC`s�t}t�}|jj}|dkr6|j�}n|dkrQ|j�}ntd|jj��}|j�}|j	|�|j	td|��|j
|�|S(NtpresenttabsentRUtchanged(tFalseRRRHtstateR[R\RERXRDR2t_announce_deprecations(R(R]R>R_t
reportableRX((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pytexec_module>s	

cC`sH|jdg�}x/|D]'}|jjd|dd|d�qWdS(Nt
__warningstmsgtversion(tpopRTt	deprecate(R(R>twarningstwarning((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR`Os


cC`s$|j�r|j�S|j�SdS(N(texistsR2tcreate(R(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR[Ws
cC`s(|j�|jjrtS|j�tS(N(t_set_changed_optionsRTt
check_modeR0tcreate_on_device(R(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRk]s


cC`s|j�}|rtStS(N(t_update_changed_optionsR0R^(R(R>((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyt
should_updatedscC`s=|j�|_|j�stS|jjr/tS|j�tS(N(tread_current_from_deviceRIRpR^RTRmR0tupdate_on_device(R(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR2js
cC`s|j�r|j�StS(N(RjtremoveR^(R(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR\ss
cC`s|jjrtS|j�tS(N(RTRmR0tremove_from_device(R(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRsxs
cC`sji}xBtjD]7}t|j|�dk	rt|j|�||<qqW|rftd|�|_ndS(NRU(RRR@RHR$RFRX(R(R]tkey((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRl~scC`s�t|j|j�}tj}t�}xX|D]P}|j|�}|dkrUq.q.t|t�rt|j	|�q.|||<q.W|r�t
d|�|_tSt
S(NRU(RGRHRIRRRRRNR$t
isinstanceR2RFRXR0R^(R(tdiffRR]R5tchange((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRo�s		
cC`s�dj|jjd|jjdt|jj|jj��}|jjj|�}y|j	�}Wnt
k
rwtSX|jdks�d|kr�|ddkr�tSt
S(Ns-https://{0}:{1}/mgmt/tm/sys/file/ssl-cert/{2}tservertserver_porti�tcode(tformatRWtproviderRRHR9RtapiRVtjsont
ValueErrorR^RR0(R(turitresptresponse((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRj�s


+cC`sddj|jjd|jjd�}yt|j|||�Wntk
r_td��nXdS(Ns1https://{0}:{1}/mgmt/shared/file-transfer/uploadsRyRzsFailed to upload the file.(R|RWR}RR(R(RR+turl((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pytupload_file_to_device�s

cC`st|jj�}|j||jj�|jj�}dj|jj	d|jj	dt
|jj|jj��}|jjj
|d|�}y|j�}Wn%tk
r�}tt|���nXd|kr|ddkrd|krt|d��qt|j��ndS(Ns-https://{0}:{1}/mgmt/tm/sys/file/ssl-cert/{2}RyRzRR{i�tmessage(RRHRR�RRXt
api_paramsR|RWR}RR9R~tputRR�Rtstr(R(RRUR�R�R�tex((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRr�s 

cC`st|jj�}|j||jj�dj|jjd|jjd�}td|jj	d|jjd|jj
�}|jjj|d|�}y|j
�}Wn%tk
r�}tt|���nXd|kr|dd
krd|kr	t|d��qt|j��n|jj�}|rdj|jjd|jjdt|jj
|jj��}|jjj|d|�}y|j
�}Wn%tk
r�}tt|���nXd|kr|dd	krd|kr�t|d��qt|j��qndS(Ns*https://{0}:{1}/mgmt/tm/sys/file/ssl-cert/RyRzRR+R9RR{i�i�R�s-https://{0}:{1}/mgmt/tm/sys/file/ssl-cert/{2}(i�i�(RRHRR�RR|RWR}RRRR9R~tpostRR�RR�R�RR�(R(RR�RUR�R�R�((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRn�sB


cC`s�dj|jjd|jjdt|jj|jj��}d}|jjj||�}y|j	�}Wn%t
k
r�}tt|���nXd|kr�|ddkr�d|kr�t|d��q�t|j
��ntd|�S(	Ns-https://{0}:{1}/mgmt/tm/sys/file/ssl-cert/{2}RyRzs?expandSubcollections=trueR{i�R�RU(R|RWR}RRHR9RR~RVRR�RR�RR!(R(R�tqueryR�R�R�((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRq�s

cC`sydj|jjd|jjdt|jj|jj��}|jjj|�}|j	dkrft
St|j��dS(Ns-https://{0}:{1}/mgmt/tm/sys/file/ssl-cert/{2}RyRzi�(
R|RWR}RRHR9RR~tdeleteRR0RR(R(R�R�((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRts

(RRRJRbR`R[RkRpR2R\RsRlRoRjR�RrRnRqRt(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRS6s"																1	tArgumentSpeccB`seZd�ZRS(cC`s�t|_tdtdt�dtddg�dtddd	d
dg�dt�dtdd
dtdgf��}i|_|jjt�|jj|�dS(NR+trequiredRtaliasestcert_contentR_tdefaultR[tchoicesR\RR9tCommontfallbacktF5_PARTITION(R0tsupports_check_modeRRR	t
argument_specR2R
(R(R�((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyRJs				(RRRJ(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyR�scC`s�t�}td|jd|j�}y,td|�}|j�}|j|�Wn)tk
r{}|jdt	|��nXdS(NR�R�RTRd(
R�RR�R�RSRbt	exit_jsonRt	fail_jsonR�(tspecRTtmmtresultsR�((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pytmain2s		t__main__(,t
__future__RRRttypet
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR.R;R%tansible.module_utils.basicRR	t%library.module_utils.network.f5.bigipR
t&library.module_utils.network.f5.commonRRR
RRt(library.module_utils.network.f5.icontrolRtImportErrort%ansible.module_utils.network.f5.bigipt&ansible.module_utils.network.f5.commont(ansible.module_utils.network.f5.icontrolRtioRR!R-R?RERFtobjectRGRSR�R�R(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ssl_certificate.pyt<module>sX


:"

+*�	

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