Anons79 Mini Shell

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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlm
Z
d
ZdZdZdZy/ddlZddlmZe
ej�ZWn#ek
r�ej�ZeZnXeZdZy?ddlZddlmZddl m!Z"e
ej�Z#Wn#ek
rWej�ZeZ$nXeZ$ddl%mZ&ddl'm(Z(m)Z)ddl*m+Z+m,Z,de&j-fd��YZ.de&j/fd��YZ0d�Z1e2dkr�e1�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: openssl_publickey
version_added: "2.3"
short_description: Generate an OpenSSL public key from its private key.
description:
    - This module allows one to (re)generate OpenSSL public keys from their private keys.
    - Keys are generated in PEM or OpenSSH format.
    - The module can use the cryptography Python library, or the pyOpenSSL Python
      library. By default, it tries to detect which one is available. This can be
      overridden with the I(select_crypto_backend) option. When I(format) is C(OpenSSH),
      the C(cryptography) backend has to be used. Please note that the PyOpenSSL backend
      was deprecated in Ansible 2.9 and will be removed in Ansible 2.13."
requirements:
    - Either cryptography >= 1.2.3 (older versions might work as well)
    - Or pyOpenSSL >= 16.0.0
    - Needs cryptography >= 1.4 if I(format) is C(OpenSSH)
author:
    - Yanis Guenane (@Spredzy)
    - Felix Fontein (@felixfontein)
options:
    state:
        description:
            - Whether the public key should exist or not, taking action if the state is different from what is stated.
        type: str
        default: present
        choices: [ absent, present ]
    force:
        description:
            - Should the key be regenerated even it it already exists.
        type: bool
        default: no
    format:
        description:
            - The format of the public key.
        type: str
        default: PEM
        choices: [ OpenSSH, PEM ]
        version_added: "2.4"
    path:
        description:
            - Name of the file in which the generated TLS/SSL public key will be written.
        type: path
        required: true
    privatekey_path:
        description:
            - Path to the TLS/SSL private key from which to generate the public key.
            - Required if I(state) is C(present).
        type: path
    privatekey_passphrase:
        description:
            - The passphrase for the private key.
        type: str
        version_added: "2.4"
    backup:
        description:
            - Create a backup file including a timestamp so you can get the original
              public key back if you overwrote it with a different one by accident.
        type: bool
        default: no
        version_added: "2.8"
    select_crypto_backend:
        description:
            - Determines which crypto backend to use.
            - The default choice is C(auto), which tries to use C(cryptography) if available, and falls back to C(pyopenssl).
            - If set to C(pyopenssl), will try to use the L(pyOpenSSL,https://pypi.org/project/pyOpenSSL/) library.
            - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
        type: str
        default: auto
        choices: [ auto, cryptography, pyopenssl ]
        version_added: "2.9"
extends_documentation_fragment:
- files
seealso:
- module: openssl_certificate
- module: openssl_csr
- module: openssl_dhparam
- module: openssl_pkcs12
- module: openssl_privatekey
s�
- name: Generate an OpenSSL public key in PEM format
  openssl_publickey:
    path: /etc/ssl/public/ansible.com.pem
    privatekey_path: /etc/ssl/private/ansible.com.pem

- name: Generate an OpenSSL public key in OpenSSH v2 format
  openssl_publickey:
    path: /etc/ssl/public/ansible.com.pem
    privatekey_path: /etc/ssl/private/ansible.com.pem
    format: OpenSSH

- name: Generate an OpenSSL public key with a passphrase protected private key
  openssl_publickey:
    path: /etc/ssl/public/ansible.com.pem
    privatekey_path: /etc/ssl/private/ansible.com.pem
    privatekey_passphrase: ansible

- name: Force regenerate an OpenSSL public key if it already exists
  openssl_publickey:
    path: /etc/ssl/public/ansible.com.pem
    privatekey_path: /etc/ssl/private/ansible.com.pem
    force: yes

- name: Remove an OpenSSL public key
  openssl_publickey:
    path: /etc/ssl/public/ansible.com.pem
    privatekey_path: /etc/ssl/private/ansible.com.pem
    state: absent
s4
privatekey:
    description: Path to the TLS/SSL private key the public key was generated from.
    returned: changed or success
    type: str
    sample: /etc/ssl/private/ansible.com.pem
format:
    description: The format of the public key (PEM, OpenSSH, ...).
    returned: changed or success
    type: str
    sample: PEM
filename:
    description: Path to the generated TLS/SSL public key file.
    returned: changed or success
    type: str
    sample: /etc/ssl/public/ansible.com.pem
fingerprint:
    description:
    - The fingerprint of the public key. Fingerprint will be generated for each hashlib.algorithms available.
    - Requires PyOpenSSL >= 16.0 for meaningful output.
    returned: changed or success
    type: dict
    sample:
      md5: "84:75:71:72:8d:04:b5:6c:4d:37:6d:66:83:f5:4c:29"
      sha1: "51:cc:7c:68:5d:eb:41:43:88:7e:1a:ae:c7:f8:24:72:ee:71:f6:10"
      sha224: "b1:19:a6:6c:14:ac:33:1d:ed:18:50:d3:06:5c:b2:32:91:f1:f1:52:8c:cb:d5:75:e9:f5:9b:46"
      sha256: "41:ab:c7:cb:d5:5f:30:60:46:99:ac:d4:00:70:cf:a1:76:4f:24:5d:10:24:57:5d:51:6e:09:97:df:2f:de:c7"
      sha384: "85:39:50:4e:de:d9:19:33:40:70:ae:10:ab:59:24:19:51:c3:a2:e4:0b:1c:b1:6e:dd:b3:0c:d9:9e:6a:46:af:da:18:f8:ef:ae:2e:c0:9a:75:2c:9b:b3:0f:3a:5f:3d"
      sha512: "fd:ed:5e:39:48:5f:9f:fe:7f:25:06:3f:79:08:cd:ee:a5:e7:b3:3d:13:82:87:1f:84:e1:f5:c7:28:77:53:94:86:56:38:69:f0:d9:35:22:01:1e:a6:60:...:0f:9b"
backup_file:
    description: Name of backup file created.
    returned: changed and if I(backup) is C(yes)
    type: str
    sample: /path/to/publickey.pem.2019-03-09@11:22~
N(tLooseVersions16.0.0s1.2.3s1.4(tcrypto(tdefault_backend(t
serialization(t	to_nativetto_bytes(t
AnsibleModuletmissing_required_libtPublicKeyErrorcB`seZRS((t__name__t
__module__(((sL/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_publickey.pyR�st	PublicKeycB`sAeZd�Zd�Zd�Zed�Zd�Zd�ZRS(cC`s�tt|�j|jd|jd|jd|j�|jd|_|jd|_|jd|_d|_	i|_
||_|jd|_d|_
dS(Ntpathtstatetforcetformattprivatekey_pathtprivatekey_passphrasetbackup(tsuperRt__init__tparamst
check_modeRRRtNonet
privatekeytfingerprinttbackendRtbackup_file(tselftmoduleR"((sL/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_publickey.pyR�s



			cC`s�tj|j|jd|j�|_|jdkr�|jdkrg|jj�jt	j
jt	jj�S|jj�jt	j
j
t	jj�Sn<ytjtj|j�SWntk
r�}td��nXdS(NR"tcryptographytOpenSSHs:You need to have PyOpenSSL>=16.0.0 to generate public keys(tcrypto_utilstload_privatekeyRRR"R Rt
public_keytpublic_bytestcrypto_serializationtEncodingR'tPublicFormattPEMtSubjectPublicKeyInfoR	tdump_publickeytFILETYPE_PEMtAttributeErrorR(R$R%tdummy((sL/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_publickey.pyt_create_publickey�s 		
	cC`s>tjj|j�s+td|j��n|j|dt�sJ|jr�yM|j|�}|j	r}|j
|j�|_ntj
||�t|_Wq�tjk
r�}t|��q�ttfk
r�}t|��q�Xntj|jd|jd|j�|_|j|j�}|j|t�r:t|_ndS(sGenerate the public key.s!The private key %s does not existtperms_requiredt
passphraseR"N(tosRtexistsRRtchecktFalseRR5Rtbackup_localR#R(t
write_filetTruetchangedtOpenSSLBadPassphraseErrortIOErrortOSErrortget_fingerprintRR"R!tload_file_common_argumentsRtset_fs_attributes_if_different(R$R%tpublickey_contenttexct	file_args((sL/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_publickey.pytgenerate�s*	
		c`s>tt��j�|�}��fd�}|s7|S|�S(s,Ensure the resource is in its desired state.c`sQtjj�j�stSy�t�jd��}|j�}WdQX�jdkr��jdkr�t	j
|dt��}|jt	j
jt	jj�}q�t	j|dt��}|jt	j
jt	jj�}n$tjtjtjtj|��}Wntk
r}tSXy�j��}Wn"tjk
rF}t|��nX||kS(NtrbR&R'R"(R8RR9RR;topentreadR"RR,tload_ssh_public_keyR
R+R-R'R.tload_pem_public_keyR/R0R	R1R2tload_publickeyt	ExceptionR5R(R@R(t
public_key_fhRFtcurrent_publickeyR4tdesired_publickeyRG(R%R$(sL/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_publickey.pyt_check_privatekeys2		(RRR:(R$R%R6tstate_and_permsRT((R%R$sL/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_publickey.pyR:s
$cC`s;|jr!|j|j�|_ntt|�j|�dS(N(RR<RR#RRtremove(R$R%((sL/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_publickey.pyRVAs	cC`sUi|jd6|jd6|jd6|jd6|jd6}|jrQ|j|d<n|S(s'Serialize the object into a dictionary.R tfilenameRR?R!R#(RRRR?R!R#(R$tresult((sL/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_publickey.pytdumpFs




	(	RRRR5RIR>R:RVRY(((sL/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_publickey.pyR�s			.	c	C`stdtdtdddddddg�d	tdd
dt�dtdddt�d
tdd�dtdddddddg�dtdddt�dtdd
dt�dtddddddgdd��dtdtdddd
gfg�}t}|jddkrt}n|jd}|dkr�toLtt	|�k}t
odtt	t�k}|rvd}nJ|r�|jddkr�|j
dtdjt��dt�nd}n|dkr�|j
ddj|t��q�n|jddkr |dkr |j
dd�n|dkrpt
sZ|j
dtd jt��dt�n|jd!d"d#�n=|dkr�ts�|j
dtdj|��dt�q�ntjj|jd�p�d$}tjj|�s�|j
d%|dd&|�ny�t||�}|jdkrr|jrb|j�}|jd	pK|j|�|d'<|j|�n|j|�nO|jr�|j�}tjj|jd�|d'<|j|�n|j|�|j�}|j|�Wn,t j!k
r	}|j
dt"|��nXdS((Nt
argument_specRttypetstrtdefaulttpresenttchoicestabsentRtboolRtrequiredRRR/R'Rtno_logRtselect_crypto_backendtautot	pyopensslR&tsupports_check_modetadd_file_common_argstrequired_iftmsgscryptography >= {0}t	exceptions]Can't detect any of the required Python libraries cryptography (>= {0}) or PyOpenSSL (>= {1})s1Format OpenSSH requires the cryptography backend.spyOpenSSL >= {0}sKThe module is using the PyOpenSSL backend. This backend has been deprecatedtversions2.13t.tnames@The directory '%s' does not exist or the file is not a directoryR?(#RtdictR;R>tMINIMAL_CRYPTOGRAPHY_VERSIONRt$MINIMAL_CRYPTOGRAPHY_VERSION_OPENSSHtCRYPTOGRAPHY_FOUNDtCRYPTOGRAPHY_VERSIONRtPYOPENSSL_FOUNDtPYOPENSSL_VERSIONtMINIMAL_PYOPENSSL_VERSIONt	fail_jsonRRtCRYPTOGRAPHY_IMP_ERRtPYOPENSSL_IMP_ERRt	deprecateR8RtdirnametisdirRRRRYR:t	exit_jsonRIR9RVR(tOpenSSLObjectErrorR(	R%tminimal_cryptography_versionR"tcan_use_cryptographytcan_use_pyopenssltbase_dirR*RXRG((sL/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_publickey.pytmainVs�!!'	
		
	

		!	
t__main__(3t
__future__RRRR[t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR8t	tracebacktdistutils.versionRRvRpRqRRytOpenSSLR	t__version__RutImportErrort
format_excR;RtR>RxR&tcryptography.hazmat.backendsR
tcryptography.hazmat.primitivesRR,RsRrtansible.module_utilsR(tansible.module_utils._textRR
tansible.module_utils.basicRRR~Rt
OpenSSLObjectRR�R(((sL/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_publickey.pyt<module>sP


Q$



�	Z

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