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_device_certificate.pyo

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlmZdd
l
mZddlmZyDddlmZddlmZddlmZddlmZWnQek
r1ddlmZddlmZddlmZddlmZnXdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd ��YZd!efd"��YZ d#efd$��YZ!d%�Z"e#d&kre"�ndS('i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	certifiedtsupported_bys

---
module: bigip_device_certificate
short_description: Manage self-signed device certificates
description:
  - Module used to create and/or renew self-signed device certificates for BIG-IP.
version_added: 2.9
options:
  days_valid:
    description:
      - Specifies the interval for which the self-signed certificate is valid.
      - "The maximum value is 25 years: C(9125) days"
    type: int
    required: True
  cert_name:
    description:
      - Specifies the full name of the certificate file.
      - If the name is not default C(server.crt), the module will configure C(httpd) to use them
        prior to restarting the C(httpd) daemon.
    type: str
    default: server.crt
  key_name:
    description:
      - Specifies the full name of the key file.
      - If the name is not default C(server.key), the module will configure C(httpd) to use them
        prior to restarting the C(httpd) daemon.
    type: str
    default: server.key
  key_size:
    description:
      - Specifies the desired key size in bits.
      - Mandatory option when generating a new certificate.
    type: int
    choices:
      - 512
      - 1024
      - 2048
      - 4096
    default: 2048
  issuer:
    description:
      - Certificate properties, required when generating new certificates.
    suboptions:
      country:
        description:
         - Specifies the Country name attribute for the certificate.
        type: str
      state:
        description:
          - Specifies the State or Province attribute for the certificate.
        type: str
      locality:
        description:
          - Specifies the city or town name for the certificate.
        type: str
      organization:
        description:
          - Specifies the Organization attribute for the certificate.
        type: str
      division:
        description:
          - Specifies the department name attribute for the certificate.
        type: str
      common_name:
        description:
          - Specifies Common Name attribute for the certificate.
        type: str
      email:
        description:
          - "Specifies the domain administrator's email address."
        type: str
    type: dict
  add_to_trusted:
    description:
      - Specified if the certificate should be added to the trusted client and server certificate files.
    type: bool
    default: no
  new_cert:
    description:
      - Specified if the module should generate new certificate.
      - When C(yes) the device certificate and key will be replaced
    type: bool
    default: no
  force:
    description:
      - When C(yes), will update or overwrite the existing certificate when it is not expired device.
      - When C(no), the certificate will only be updated/overwritten if expired.
      - Generally should be C(yes) only in cases where you need to update certificate that is about to expire.
      - This option is also needed when generating new certificate to replace non expired one.
    type: bool
    default: no
  transport:
    description:
      - Configures the transport connection to use when connecting to the
        remote device.
      - This module currently supports only connectivity to the device over cli (ssh).
    required: True
    choices:
        - cli
    default: cli
extends_documentation_fragment: f5
author:
  - Wojciech Wypior (@wojtek0806)
sl
- name: Update expired certificate
  bigip_device_certificate:
    days_valid: 365
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
      transport: cli
      server_port: 22
  delegate_to: localhost

- name: Update expired certificate non-default names
  bigip_device_certificate:
    days_valid: 60
    cert_name: custom.crt
    key_name: custom.key
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
      transport: cli
      server_port: 22
  delegate_to: localhost

- name: Force update not expired certificate
  bigip_device_certificate:
    days_valid: 365
    force: yes
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
      transport: cli
      server_port: 22
  delegate_to: localhost

- name: Create a new certificate to replace expired certificate
  bigip_device_certificate:
    days_valid: 365
    new_cert: yes
    issuer:
      country: US
      state: WA
      common_name: foobar.foo.local
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
      transport: cli
      server_port: 22
  delegate_to: localhost

- name: Force create a new custom named certificate to replace not expired certificate
  bigip_device_certificate:
    days_valid: 365
    cert_name: custom.crt
    key_name: custom.key
    new_cert: yes
    force: yes
    issuer:
      country: US
      state: WA
      common_name: foobar.foo.local
    key_size: 2048
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
      transport: cli
      server_port: 22
  delegate_to: localhost
s"
days_valid:
  description: The interval for which the self-signed certificate is valid.
  returned: changed
  type: int
  sample: 365
issuer:
  description: Specifies certificate properties.
  type: complex
  returned: changed
  contains:
    country:
      description: The Country name attribute of the certificate.
      returned: changed
      type: str
      sample: US
    state:
      description: The State or Province attribute of the certificate.
      returned: changed
      type: str
      sample: WA
    locality:
      description: The city or town name attribute of the certificate.
      returned: changed
      type: str
      sample: Seattle
    organization:
      description: The Organization attribute of the certificate.
      returned: changed
      type: str
      sample: F5
    division:
      description: The department name attribute of the certificate.
      returned: changed
      type: str
      sample: IT
    common_name:
      description: The Common Name attribute of the certificate.
      returned: changed
      type: str
      sample: foo.bar.local
    email:
      description: "The domain administrator's email address."
      returned: changed
      type: str
      sample: [email protected]
cert_name:
  description: The full name of the certificate file.
  returned: changed
  type: str
  sample: common.crt
key_name:
  description: The full name of the key file.
  returned: changed
  type: str
  sample: common.key
key_size:
  description: The desired key size in bits.
  returned: changed
  type: int
  sample: 2048
N(tdatetime(t
AnsibleModule(texec_command(t
F5ModuleError(tAnsibleF5Parameters(tf5_argument_spec(tis_clit
ParameterscB`s&eZdddddgZdgZRS(t
days_validtissuertkey_sizet	cert_nametkey_name(t__name__t
__module__treturnablest
updatables(((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRs	t
ApiParameterscB`seZRS((RR(((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyR"stModuleParameterscB`s]eZidd6dd6dd6dd6dd	6d
d6dd
6Zed��Zed��ZRS(tCtcountrytSTtstatetLtlocalitytOtorganizationtOURtCNtcommon_nametemailAddresstemailc`s��jddkrdSt�fd��jdj�D��}g|j�D]\}}dj||�^qM}ddj|�d}|S(NRc3`s4|]*\}}|dk	r�j||fVqdS(N(tNonet
issuer_map(t.0tktv(tself(sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pys	<genexpr>5ss{0}={1}t/(t_valuesR(tdicttitemstformattjoin(R-tfilteredR+R,tto_parsetresult((R-sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyR1s)1cC`s>d|jdkodknr.|jdStd��dS(NiRi�#s2Valid 'days_valid' must be in range 1 - 9125 days.(R/R(R-((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyR:s#(RRR)tpropertyRR(((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyR&s
	tChangescB`seZd�ZRS(cC`sXi}y:x$|jD]}t||�||<qW|j|�}Wntk
rSnX|S(N(Rtgetattrt_filter_paramst	Exception(R-R6t
returnable((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyt	to_returnDs
(RRR=(((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyR8Cst
UsableChangescB`seZRS((RR(((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyR>OstReportableChangescB`sNeZidd6dd6dd6dd6dd	6d
d6dd
6Zed��ZRS(RRRRR RR"R!RR#R%R$R'R&c`sx�jddkrdSg�jdjd�jd�D]}t|jd��^q7}t�fd�|D��}|S(NRR.t=c3`s(|]\}}�j||fVqdS(N(R)(R*R+R,(R-(sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pys	<genexpr>cs(R/R(tstriptsplitttupleR0(R-titemtto_dictR6((R-sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyR^s
A(RRR)R7R(((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyR?Ss
t
DifferencecB`s&eZdd�Zd�Zd�ZRS(cC`s||_||_dS(N(twantthave(R-RGRH((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyt__init__hs	cC`s9yt||�}|SWntk
r4|j|�SXdS(N(R9tAttributeErrort_Difference__default(R-tparamR6((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pytcomparels

cC`sQt|j|�}y&t|j|�}||kr7|SWntk
rL|SXdS(N(R9RGRHRJ(R-RLtattr1tattr2((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyt	__defaultss
N(RRR(RIRMRK(((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRFgs	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`sI|jdd�|_td|jj�|_t�|_t�|_	dS(Ntmoduletparams(
tgetR(RRRRSRGRRHR>tchanges(R-targstkwargs((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRI~scC`sji}xBtjD]7}t|j|�dk	rt|j|�||<qqW|rftd|�|_ndS(NRS(RRR9RGR(R>RU(R-tchangedtkey((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyt_set_changed_options�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(NRS(RFRGRHRRR0RMR(t
isinstancetupdateR>RUtTruetFalse(R-tdiffRRXR+tchange((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyt_update_changed_options�s		
cC`s~t|j�std��nt�}|j�}td|jj��}|j�}|j|�|jtd|��|S(NsAModule can only be run via SSH, set the transport property to CLIRSRX(	RRRRR0tpresentR?RUR=R\(R-R6RXt
reportableRU((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pytexec_module�s	
cC`sx|j�r4|jjr&|j�tS|j�tS|jjrZ|jjrZ|j�tS|jjrt|j�tStS(N(texpiredRGtnew_certtcreateR]R\tforceR^(R-((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRb�s



cC`s(|j�|jjrtS|j�tS(N(RZRRt
check_modeR]tgenerate_new(R-((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRg�s


cC`s||j�|jjrtS|j�|jjdksH|jjdkrU|j�n|j	�|jj
rx|j�ntS(Ns
server.crts
server.key(RaRRRiR]tupdate_certificateRGRRtconfigure_new_certtrestart_daemontadd_to_trustedtcopy_files_to_trusted(R-((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyR\�s

$


cC`sA|j�|_ttj�j��}||jjkr=tStS(N(	tread_current_certificateRHtintRtnowt	timestamptepochR]R^(R-t
current_epoch((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRe�s
cC`sb|j�|jjdks.|jjdkr;|j�n|j�|jjr^|j�ntS(Ns
server.crts
server.key(	tgenerate_cert_keyRGRRRlRmRnRoR](R-((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRj�s
$


cC`svdjd|jj|jj|jj|jj|jj�}t|j|�\}}}|dkrrt	|��ndS(Nskopenssl req -x509 -nodes -days {3} -newkey rsa:{4} -keyout {0}/ssl.key/{2} -out {0}/ssl.crt/{1} -subj "{5}"s/config/httpd/confi(
R2RGRRRRRR
RRR(R-tcmdtrctoutterr((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRv�s!cC`stdjd|jj|jjtjj|jj�d�}t|j|�\}}}|dkrpt	|��ndS(Ns]openssl x509 -x509toreq -in {0}/ssl.crt/{1} -out {0}/ssl.csr/{3}.csr -signkey {0}/ssl.key/{2}s/config/httpd/confi(
R2RGRRtostpathtsplitextR
RRR(R-RwRxRyRz((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyt
create_csr�s
4cC`s�|j�djd|jj|jjtjj|jj�d|jj�}t	|j
|�\}}}|dkr�t|��ndS(Nsaopenssl x509 -req -in {0}/ssl.csr/{3}.csr -signkey {0}/ssl.key/{2} -days {4} -out {0}/ssl.crt/{1}s/config/httpd/confi(R~R2RGRRR{R|R}RR
RRR(R-RwRxRyRz((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRk�s
(cC`s�dj|jj|jj�}d}t|j|�\}}}|dkrZt|��nt|j|�\}}}|dkr�t|��ndS(Nsotmsh modify sys httpd ssl-certkeyfile /config/httpd/conf/ssl.key/{1}ssl-certfile /config/httpd/conf/ssl.crt/{0}s$tmsh save /sys config partitions alli(R2RGRRR
RRR(R-tcmd1tcmd2RxRyRz((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRl�scC`s@d}t|j|�\}}}|dkr<t|��ndS(Nstmsh restart /sys service httpdi(R
RRR(R-RwRxRyRz((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRmscC`s�dj|jj�}dj|jj�}t|j|�\}}}|dkr`t|��nt|j|�\}}}|dkr�t|��ndS(Ns>cat /config/httpd/conf/ssl.crt/{0} >> /config/big3d/client.crts<cat /config/httpd/conf/ssl.crt/{0} >> /config/gtm/server.crti(R2RGRR
RRR(R-RR�RxRyRz((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRoscC`sht�}dj|jj�}t|j|�\}}}|dkr[|j|�|d<ntd|�S(NsEopenssl x509 -in /config/httpd/conf/ssl.crt/{0} -dates -issuer -nooutiRtRS(R0R2RGRR
RRt_parse_cert_dateR(R-R6tcommandRxRyRz((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRps	cC`s3|jd�djd�d}tj|�}|S(Ns
iR@(RBtssltcert_time_to_seconds(R-R5tc_timeR6((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyR�s (RRRIRZRaRdRbRgR\ReRjRvR~RkRlRmRoRpR�(((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRQ}s"																		
	tArgumentSpeccB`seZd�ZRS(cC`s�t|_tdtdddddddgd	d�d
td	d�dtd	d
�dtdddt�dtdddtdt�dt�dt�dt�dt�dt�dt��ddddddddgg�dtddd	d�dtddd	d�dtddd	d�d tdd!d	d"dd"g��	}i|_|jjt�|jj|�dd#dddggg|_dS($NRttypeRqtchoicesiiiitdefaultRs
server.crtRs
server.keyRtrequiredRR0toptionsRRR R"RR%R'trequired_one_ofRntbooltnoRfRht	transporttstrtclityes(R]tsupports_check_modeR0t
argument_specR\R
trequired_if(R-R�((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyRI%sR											!				(RRRI(((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyR�$scC`s�t�}td|jd|jd|j�}y,td|�}|j�}|j|�Wn)tk
r�}|j	dt
|��nXdS(NR�R�R�RRtmsg(R�R	R�R�R�RQRdt	exit_jsonRt	fail_jsonR�(tspecRRtmmtresultstex((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pytmainas			t__main__($t
__future__RRRR�t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR{R�Rtansible.module_utils.basicR	tansible.module_utils.connectionR
t&library.module_utils.network.f5.commonRRR
RtImportErrort&ansible.module_utils.network.f5.commonRRRR8R>R?tobjectRFRQR�R�R(((sW/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_device_certificate.pyt<module>sD


iJ?
�=	

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