Anons79 Mini Shell

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

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlZddl
Z
d
�Zd�Zed�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdefd��YZd�Zedkre�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysL
---
module: java_keystore
short_description: Create or delete a Java keystore in JKS format.
description:
     - Create or delete a Java keystore in JKS format for a given certificate.
version_added: "2.7"
options:
    name:
        description:
          - Name of the certificate.
        required: true
    certificate:
        description:
          - Certificate that should be used to create the key store.
        required: true
    private_key:
        description:
          - Private key that should be used to create the key store.
        required: true
    password:
        description:
          - Password that should be used to secure the key store.
        required: true
    dest:
        description:
          - Absolute path where the jks should be generated.
        required: true
    owner:
        description:
          - Name of the user that should own jks file.
        required: false
    group:
        description:
          - Name of the group that should own jks file.
        required: false
    mode:
        description:
          - Mode the file should be.
        required: false
    force:
        description:
          - Key store will be created even if it already exists.
        required: false
        type: bool
        default: 'no'
requirements: [openssl, keytool]
author: Guillaume Grossetie (@Mogztter)
s{
# Create a key store for the given certificate (inline)
- java_keystore:
    name: example
    certificate: |
      -----BEGIN CERTIFICATE-----
      h19dUZ2co2fI/ibYiwxWk4aeNE6KWvCaTQOMQ8t6Uo2XKhpL/xnjoAgh1uCQN/69
      MG+34+RhUWzCfdZH7T8/qDxJw2kEPKluaYh7KnMsba+5jHjmtzix5QIDAQABo4IB
      -----END CERTIFICATE-----
    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      DBVFTEVDVFJJQ0lURSBERSBGUkFOQ0UxFzAVBgNVBAsMDjAwMDIgNTUyMDgxMzE3
      GLlDNMw/uHyME7gHFsqJA7O11VY6O5WQ4IDP3m/s5ZV6s+Nn6Lerz17VZ99
      -----END RSA PRIVATE KEY-----
    password: changeit
    dest: /etc/security/keystore.jks

# Create a key store for the given certificate (lookup)
- java_keystore:
    name: example
    certificate: "{{lookup('file', '/path/to/certificate.crt') }}"
    private_key: "{{lookup('file', '/path/to/private.key') }}"
    password: changeit
    dest: /etc/security/keystore.jks
s
msg:
  description: Output from stdout of keytool/openssl command after execution of given command or an error.
  returned: changed and failure
  type: str
  sample: "Unable to find the current certificate fingerprint in ..."

rc:
  description: keytool/openssl command execution return value
  returned: changed and failure
  type: int
  sample: "0"

cmd:
  description: Executed command to get action done
  returned: changed and failure
  type: str
  sample: "openssl x509 -noout -in /tmp/cert.crt -fingerprint -sha256"
(t
AnsibleModuleNc	C`s�d||f}t||�\}}}|dkrV|jd|d|d|d|�Stjd|�}|s�|jdd|d|d|�S|jd	�S(
Ns*%s x509 -noout -in %s -fingerprint -sha256itmsgterrtrctcmds	=([\w:]+)s8Unable to find the current certificate fingerprint in %si(trun_commandst	fail_jsontretsearchtgroup(tmoduletopenssl_bintcertificate_patht#current_certificate_fingerprint_cmdRt#current_certificate_fingerprint_outt#current_certificate_fingerprint_errtcurrent_certificate_match((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pytread_certificate_fingerprintvs	
c
	C`s�d||||f}t||�\}}}|dkrsd||krl|jd|d|d|d|�SdSnEtjd|�}	|	s�|jdd	|d|d|�S|	jd
�SdS(Ns6%s -list -alias '%s' -keystore '%s' -storepass '%s' -vis=keytool error: java.lang.Exception: Alias <%s> does not existR	R
RRsSHA256: ([\w:]+)s7Unable to find the stored certificate fingerprint in %si(R
RtNoneRRR(
Rtkeytool_bintaliast
keystore_pathtkeystore_passwordt"stored_certificate_fingerprint_cmdRt"stored_certificate_fingerprint_outt"stored_certificate_fingerprint_errtstored_certificate_match((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pyt#read_stored_certificate_fingerprint�s 	
cC`s|j||�S(N(trun_command(RRtcheck_rc((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pyR
�scC`s)t|d��}|j|�WdQX|S(Ntw(topentwrite(tpathtcontenttf((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pytcreate_file�scC`std|jd|jd�S(Ns/tmp/%s.crttnametcertificate(R,tparams(R((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pytcreate_tmp_certificate�scC`std|jd|jd�S(Ns/tmp/%s.keyR-tprivate_key(R,R/(R((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pytcreate_tmp_private_key�sc	C`sYt|�}z8t|||�}t|||||�}||kSWdtj|�XdS(N(R0RR#tostremove(	RRRRt
keystore_passRRtcurrent_certificate_fingerprinttstored_certificate_fingerprint((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pytcert_changed�scC`s�|jr|jdt�nqt|�}t|�}z;tjj|�rYtj|�nd}tjj|�r�tj|�nd||||||f}	t	||	�\}
}}|
dkr�|j
d|d|
d|	�Sd||||||f}
t	||
�\}
}}|
dkrRt||�|jdtd|d|
d|
d	|�S|j
d|d|
d|
�SWdtj|�tj|�XdS(
Ntchangeds/tmp/keystore.p12sN%s pkcs12 -export -name '%s' -in '%s' -inkey '%s' -out '%s' -passout 'pass:%s'iR	RRs�%s -importkeystore -destkeystore '%s' -srckeystore '%s' -srcstoretype pkcs12 -alias '%s' -deststorepass '%s' -srcstorepass '%s' -noprompttstdout_lines(t
check_modet	exit_jsontTrueR0R2R3R)texistsR4R
Rtupdate_jks_perm(RR-RRRtpasswordRtprivate_key_pathtkeystore_p12_pathtexport_p12_cmdRtexport_p12_outtexport_p12_errtimport_keystore_cmdtimport_keystore_outtimport_keystore_err((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pyt
create_jks�s@	

cC`s3||jd<|j|j�}|j|t�dS(NR)(R/tload_file_common_argumentstset_fs_attributes_if_differenttFalse(RRt	file_args((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pyR?�s
cC`s|jd}|jd}|jd}|jd}|jdt�}|jdt�}tjj|�r�|r�t||||||�qt||||||�r�t||||||�q|js�t	||�n|j
dt�Snt||||||�dS(NR-R@tdesttforcetopenssltkeytoolR9(R/tget_bin_pathR=R3R)R>RIR8R;R?R<RL(RR-R@RRORR((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pytprocess_jks�s



	tArgumentSpeccB`seZd�ZRS(cC`s�t|_t|_tdtdt�dtdtdt�dtdtdt�dtdtdt�dtdt�dtdtd	td
d��}||_dS(NR-trequiredR.tno_logR1R@RNROtdefaultttypetbool(R=tsupports_check_modetadd_file_common_argstdictRLt
argument_spec(tselfR]((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pyt__init__	s		(t__name__t
__module__R_(((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pyRTscC`s;t�}td|jd|jd|j�}t|�dS(NR]R[RZ(RTRR]R[RZRS(tspecR((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pytmains			t__main__(t
__future__RRRRXt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicRR3RRR#R=R
R,R0R2R8RIR?RStobjectRTRcR`(((sH/usr/lib/python2.7/site-packages/ansible/modules/system/java_keystore.pyt<module>s0


3						
	/			


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