Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/web_infrastructure/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/web_infrastructure/htpasswd.pyo

�
�Udac@`sgddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	dd
l
Z
dd
lZddlm
Z
ddlmZmZdd
lmZd
Zy6ddlmZmZddlmZdd
lZWn#ek
rej�ZeZnXeZddddgZ d�Z!d�Z"d�Z#d�Z$d�Z%e&dkrce%�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysb
module: htpasswd
version_added: "1.3"
short_description: manage user files for basic authentication
description:
  - Add and remove username/password entries in a password file using htpasswd.
  - This is used by web servers such as Apache and Nginx for basic authentication.
options:
  path:
    required: true
    aliases: [ dest, destfile ]
    description:
      - Path to the file that contains the usernames and passwords
  name:
    required: true
    aliases: [ username ]
    description:
      - User name to add or remove
  password:
    required: false
    description:
      - Password associated with user.
      - Must be specified if user does not exist yet.
  crypt_scheme:
    required: false
    choices: ["apr_md5_crypt", "des_crypt", "ldap_sha1", "plaintext"]
    default: "apr_md5_crypt"
    description:
      - Encryption scheme to be used.  As well as the four choices listed
        here, you can also use any other hash supported by passlib, such as
        md5_crypt and sha256_crypt, which are linux passwd hashes.  If you
        do so the password file will not be compatible with Apache or Nginx
  state:
    required: false
    choices: [ present, absent ]
    default: "present"
    description:
      - Whether the user entry should be present or not
  create:
    required: false
    type: bool
    default: "yes"
    description:
      - Used with C(state=present). If specified, the file will be created
        if it does not already exist. If set to "no", will fail if the
        file does not exist
notes:
  - "This module depends on the I(passlib) Python library, which needs to be installed on all target systems."
  - "On Debian, Ubuntu, or Fedora: install I(python-passlib)."
  - "On RHEL or CentOS: Enable EPEL, then install I(python-passlib)."
requirements: [ passlib>=1.6 ]
author: "Ansible Core Team"
extends_documentation_fragment: files
s�
# Add a user to a password file and ensure permissions are set
- htpasswd:
    path: /etc/nginx/passwdfile
    name: janedoe
    password: '9s36?;fyNp'
    owner: root
    group: www-data
    mode: 0640

# Remove a user from a password file
- htpasswd:
    path: /etc/apache2/passwdfile
    name: foobar
    state: absent

# Add a user to a password file suitable for use by libpam-pwdfile
- htpasswd:
    path: /etc/mail/passwords
    name: alex
    password: oedu2eGh
    crypt_scheme: md5_crypt
N(tLooseVersion(t
AnsibleModuletmissing_required_lib(t	to_native(tHtpasswdFilethtpasswd_context(tCryptContextt
apr_md5_cryptt	des_cryptt	ldap_sha1t	plaintextcC`s8tjj|�}tjj|�s4tj|�ndS(N(tostpathtdirnametexiststmakedirs(tdesttdestpath((sO/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/htpasswd.pytcreate_missing_directoriesusc	C`s"|tkrt}ntd|gt�}tjj|�s!|sVtd|��n|rjd|tfSt|�t	t
j�t	d�kr�t|dtd|d|�}nt|dt
d	|d|�}t|d
d�r�|j||�n|j||�|j�d||ftfSt	t
j�t	d�kr]t|dt
d|d|�}nt|d	|d|�}d}t|dd�r�|j||�}n|j||�}|r�d
|t
fS|st|d
d�r�|j||�n|j||�|j�nd|tfSdS(s5 Ensures user is present

    Returns (msg, changed) tschemessDestination %s does not exists	Create %ss1.6tnewtdefault_schemetcontexttautoloadtdefaulttset_passwordsCreated %s and added %stcheck_passwords%s already presents
Add/update %sN(t
apache_hashesR
RRRRt
ValueErrortTrueRRtpasslibt__version__RtFalsetgetattrtNoneR!tupdatetsaveR"tverify(	Rtusernametpasswordtcrypt_schemetcreatet
check_modeRthttfound((sO/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/htpasswd.pytpresent{s@	
!
!
cC`s�ttj�td�kr0t|dt�}nt|�}||j�kr\d|tfS|s||j|�|j�nd|tfSdS(s4 Ensures user is absent

    Returns (msg, changed) s1.6Rs%s not presents	Remove %sN(	RR&R'RR(tuserstdeleteR,R%(RR.R2R3((sO/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/htpasswd.pytabsent�s

cC`sT|j|j�}|j|t�rJ|r7|d7}nt}|d7}n||fS(Ns and s,ownership, perms or SE linux context changed(tload_file_common_argumentstparamstset_fs_attributes_if_differentR(R%(tmoduletchangedtmessaget	file_args((sO/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/htpasswd.pytcheck_file_attrs�s

cC`stdtdtdddg�dtdtddg�dtdtd	dd
t�dtdtd	d�d
tdtd	d�dtddd	d��}td|dtdt�}|jd}|jd}|jd}|jd}|jd
}|jd}|j}ts-|jdt	d�dt
�nyt|d�}	Wntk
rYd}	n�Xz|	j
�}
Wd|	j�Xt}x$|
D]}|j�s�t}Pq�q�W|r|r�tj�}
|
j}nt|d�}	z0g|
D]!}|j�r�|	j|�^q�Wd|	j�Xny�|dkrLt||||||�\}}nt|dkr�tjj|�s�|jdd|dd|dt�nt|||�\}}n|jdd |�t|||�|jd|d|�Wn)tk
r}|jdt|��nXdS(!NRtrequiredtaliasesRtdestfiletnameR.R/R tno_logR0RtstateR5R1ttypetbooltyest
argument_spectadd_file_common_argstsupports_check_modetmsgR&t	exceptiontrtwR8s%s not presenttwarningss%s does not existR=sInvalid state: %s(tdictR%R(R*R	R:R2tpasslib_installedt	fail_jsonR
tPASSLIB_IMP_ERRtopentIOErrort	readlinestclosetstripttempfiletNamedTemporaryFileRDtwriteR5RRRt	exit_jsonR8R@t	ExceptionR(targ_specR<RR.R/R0RFR1R2tftlinesRZtlinettempRMR=te((sO/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/htpasswd.pytmain�sh	





	


0$t__main__('t
__future__RRRRGt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESRR[t	tracebacktdistutils.versionRtansible.module_utils.basicR	R
tansible.module_utils._textRR*RUtpasslib.apacheRR
tpasslib.contextRR&tImportErrort
format_excR(RSR%R#RR5R8R@Rft__name__(((sO/usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/htpasswd.pyt<module>s:


8

		0		
	H

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