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_cert.pyc

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlm
Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: java_cert
version_added: '2.3'
short_description: Uses keytool to import/remove key from java keystore (cacerts)
description:
  - This is a wrapper module around keytool, which can be used to import/remove
    certificates from a given java keystore.
options:
  cert_url:
    description:
      - Basic URL to fetch SSL certificate from.
      - One of C(cert_url) or C(cert_path) is required to load certificate.
    type: str
  cert_port:
    description:
      - Port to connect to URL.
      - This will be used to create server URL:PORT.
    type: int
    default: 443
  cert_path:
    description:
      - Local path to load certificate from.
      - One of C(cert_url) or C(cert_path) is required to load certificate.
    type: path
  cert_alias:
    description:
      - Imported certificate alias.
      - The alias is used when checking for the presence of a certificate in the keystore.
    type: str
  pkcs12_path:
    description:
      - Local path to load PKCS12 keystore from.
    type: path
    version_added: "2.4"
  pkcs12_password:
    description:
      - Password for importing from PKCS12 keystore.
    type: str
    default: ''
    version_added: "2.4"
  pkcs12_alias:
    description:
      - Alias in the PKCS12 keystore.
    type: str
    version_added: "2.4"
  keystore_path:
    description:
      - Path to keystore.
    type: path
  keystore_pass:
    description:
      - Keystore password.
    type: str
    required: true
  keystore_create:
    description:
      - Create keystore if it does not exist.
    type: bool
  keystore_type:
    description:
      - Keystore type (JCEKS, JKS).
    type: str
    version_added: "2.8"
  executable:
    description:
      - Path to keytool binary if not used we search in PATH for it.
    type: str
    default: keytool
  state:
    description:
      - Defines action which can be either certificate import or removal.
    type: str
    choices: [ absent, present ]
    default: present
author:
- Adam Hamsik (@haad)
sd
- name: Import SSL certificate from google.com to a given cacerts keystore
  java_cert:
    cert_url: google.com
    cert_port: 443
    keystore_path: /usr/lib/jvm/jre7/lib/security/cacerts
    keystore_pass: changeit
    state: present

- name: Remove certificate with given alias from a keystore
  java_cert:
    cert_url: google.com
    keystore_path: /usr/lib/jvm/jre7/lib/security/cacerts
    keystore_pass: changeit
    executable: /usr/lib/jvm/jre7/bin/keytool
    state: absent

- name: Import SSL certificate from google.com to a keystore, create it if it doesn't exist
  java_cert:
    cert_url: google.com
    keystore_path: /tmp/cacerts
    keystore_pass: changeit
    keystore_create: yes
    state: present

- name: Import a pkcs12 keystore with a specified alias, create it if it doesn't exist
  java_cert:
    pkcs12_path: "/tmp/importkeystore.p12"
    cert_alias: default
    keystore_path: /opt/wildfly/standalone/configuration/defaultkeystore.jks
    keystore_pass: changeit
    keystore_create: yes
    state: present

- name: Import SSL certificate to JCEKS keystore
  java_cert:
    pkcs12_path: "/tmp/importkeystore.p12"
    pkcs12_alias: default
    pkcs12_password: somepass
    cert_alias: default
    keystore_path: /opt/someapp/security/keystore.jceks
    keystore_type: "JCEKS"
    keystore_pass: changeit
    keystore_create: yes
    state: present
s�
msg:
  description: Output from stdout of keytool command after execution of given command.
  returned: success
  type: str
  sample: "Module require existing keystore at keystore_path '/tmp/test/cacerts'"

rc:
  description: Keytool command execution return value.
  returned: success
  type: int
  sample: "0"

cmd:
  description: Executed command to get action done.
  returned: success
  type: str
  sample: "keytool -importcert -noprompt -keystore"
N(t
AnsibleModulecC`s|rd|SdS(s7 Check that custom keystore is presented in parameters s -storetype '%s't((t
keystore_type((sD/usr/lib/python2.7/site-packages/ansible/modules/system/java_cert.pytget_keystore_type�sc	C`sKd||||t|�f}|j|�\}}}|dkrGtStS(sY Check if certificate with alias is present in keystore
        located at keystore_path s@%s -noprompt -list -keystore '%s' -storepass '%s' -alias '%s' %si(Rtrun_commandtTruetFalse(	tmodulet
executablet
keystore_patht
keystore_passtaliasR
ttest_cmdtcheck_rct_((sD/usr/lib/python2.7/site-packages/ansible/modules/system/java_cert.pytcheck_cert_present�sc
C`s�tjd�}tjd�}	d}
|dk	r�|jd�\}}d||f}
|	dk	r�|	jdd�}
tjdd	|
�}
|
d
|
7}
q�nd||
||f}d||||t|�f}|j|d
t	�\}}}|j|d|d
t
�\}}}idd6d|d6}|dkrh|jdt	d|d|d|d|d|�n"|jd|d|d|d|�dS(sD Import certificate from URL into keystore located at keystore_path thttps_proxytno_proxyR	t:s--J-Dhttps.proxyHost=%s -J-Dhttps.proxyPort=%st,t|s(^|\|)\.s\1*.s -J-Dhttp.nonProxyHosts='%s's&%s -printcert -rfc -sslserver %s %s:%dsF%s -importcert -noprompt -keystore '%s' -storepass '%s' -alias '%s' %sRtdatas
tbefores%s
tafteritchangedtmsgtrctcmdtstdouttdiffterrorN(
tostgetenvtNonetsplittreplacetretsubRRR
Rt	exit_jsont	fail_json(RRturltportRRRR
RRt
proxy_optst
proxy_hostt
proxy_porttnon_proxy_hostst	fetch_cmdt
import_cmdRt	fetch_outt	import_rct
import_outt
import_errR%((sD/usr/lib/python2.7/site-packages/ansible/modules/system/java_cert.pytimport_cert_url�s4
cC`s�d|||||t|�f}|j|dt�\}}	}
idd6d|d6}|dkr�|jdtd	|	d
|d|d|	d
|
d|�n|jd	|	d
|d|�dS(sV Import certificate from path into keystore located on
        keystore_path as alias sQ%s -importcert -noprompt -keystore '%s' -storepass '%s' -file '%s' -alias '%s' %sRs
Rs%s
RiR R!R"R#R$R&R%N(RRRR.R
R/(RRtpathRRRR
R7R9R:R;R%((sD/usr/lib/python2.7/site-packages/ansible/modules/system/java_cert.pytimport_cert_path�s	c	C`s�d||||||||t|�f	}	|j|	dt�\}
}}idd6d|d6}
|
dkr�|jdtd	|d
|
d|	d|d
|d|
�n|jd	|d
|
d|	�dS(sQ Import pkcs12 from path into keystore located on
        keystore_path as alias s�%s -importkeystore -noprompt -destkeystore '%s' -srcstoretype PKCS12 -deststorepass '%s' -destkeypass '%s' -srckeystore '%s' -srcstorepass '%s' -srcalias '%s' -destalias '%s' %sRs
Rs%s
RiR R!R"R#R$R&R%N(RRRR.R
R/(RRR=RRtpkcs12_passtpkcs12_aliasRR
R7R9R:R;R%((sD/usr/lib/python2.7/site-packages/ansible/modules/system/java_cert.pytimport_pkcs12_path�s	cC`s�d||||t|�f}|j|dt�\}}}	id|d6d
d6}
|jdtd|d|d	|d
|d|	d|
�d
S(sI Delete certificate identified with alias from keystore on keystore_path s8%s -delete -keystore '%s' -storepass '%s' -alias '%s' %sRs%s
RRR R!R"R#R$R&R%N(RRR
R)R.(RRRRRR
tdel_cmdtdel_rctdel_outtdel_errR%((sD/usr/lib/python2.7/site-packages/ansible/modules/system/java_cert.pytdelete_certscC`s|jd|dt�dS(s/ Test if keytool is actually executable or not s%sRN(RR
(RR((sD/usr/lib/python2.7/site-packages/ansible/modules/system/java_cert.pyttest_keytool scC`s\|dkrd}ntjj|�rXtjj|�rX|jdtdd|�ndS(s0 Check if we can access keystore as file or not R	R R!s6Module require existing keystore at keystore_path '%s'N(R)R'R=texiststisfileR/R(RR((sD/usr/lib/python2.7/site-packages/ansible/modules/system/java_cert.pyt
test_keystore%s	&c"C`s�tdtdd�dtdd�dtdd�dtdddt�d	tdd�d
tdd�dtddd
d�dtdd�dtdddtdt�dtddd
t�dtdd�dtddd
d�dtddd
ddddg��
}td|ddddggdddggddddggdt�}|jjd�}|jjd�}|jjd�}|jjd�}|jjdd �}|jjd	d!�}|jjd
�p�|}|jjd�}	|jjd�}
|jjd�}|jjd�}|jjd�}
|jjd�}|rj|rj|jd"td#d$|	�nt||
�|s�t||	�nt	||
|	|
||�}|dkr�|r�|j
r�|jd"t�nt||
|	|
||�n�|dkr�|r�|j
r!|jd"t�n|rLt
||
||	|
||||�	n|rqt||
||	|
||�n|r�t||
|||	|
||�q�n|jd"t�dS(%Ntcert_urlttypetstrt	cert_pathR=tpkcs12_pathtpkcs12_passwordtno_logR@t
cert_aliast	cert_porttinttdefaulti�RRtrequiredtkeystore_createtboolR
Rtkeytooltstatetpresenttchoicestabsentt
argument_spectrequired_one_oftrequired_togethertmutually_exclusivetsupports_check_modeR	t1R R!s8Using local path import from %s requires alias argument.(tdictR
RRtparamstgetR/RGRJRt
check_modeR.RFRAR>R<(R^RR0R=R1ROR?R@RRRRRWR
RRZtcert_present((sD/usr/lib/python2.7/site-packages/ansible/modules/system/java_cert.pytmain/sv$	

		t__main__(t
__future__RRRRLt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR'R,tansible.module_utils.basicRRRR<R>RARFRGRJRit__name__(((sD/usr/lib/python2.7/site-packages/ansible/modules/system/java_cert.pyt<module>s*


O/			,					
	R

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