Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/storage/purestorage/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_user.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlm
Z
mZd
Zd�Zd�Zd�Zd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysH
---
module: purefa_user
version_added: '2.8'
short_description: Create, modify or delete FlashArray local user account
description:
- Create, modify or delete local users on a Pure Storage FlashArray.
author:
- Pure Storage Ansible Team (@sdodsley) <[email protected]>
options:
  state:
    description:
    - Create, delete or update local user account
    default: present
    type: str
    choices: [ absent, present ]
  name:
    description:
    - The name of the local user account
    type: str
  role:
    description:
    - Sets the local user's access level to the array
    type: str
    choices: [ readonly, storage_admin, array_admin ]
  password:
    description:
    - Password for the local user.
    type: str
  old_password:
    description:
    - If changing an existing password, you must provide the old password for security
    type: str
  api:
    description:
    - Define whether to create an API token for this user
    - Token can be exposed using the I(debug) module
    type: bool
    default: false
extends_documentation_fragment:
- purestorage.fa
s�
- name: Create new user ansible with API token
  purefa_user:
    name: ansible
    password: apassword
    role: storage_admin
    api: true
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
  register: result

  debug:
    msg: "API Token: {{ result['user_info']['user_api'] }}"

- name: Change role type for existing user
  purefa_user:
    name: ansible
    role: array_admin
    state: update
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Change password type for existing user (NOT IDEMPOTENT)
  purefa_user:
    name: ansible
    password: anewpassword
    old_password: apassword
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Change API token for existing user
  purefa_user:
    name: ansible
    api: true
    state: update
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
  register: result

  debug:
    msg: "API Token: {{ result['user_info']['user_api'] }}"
t
(t
AnsibleModule(t
get_systemtpurefa_argument_specs1.14cC`s^d}|j�}xEtdt|��D].}||d|jdkr(||}q(q(W|S(s!Return Local User Account or NoneitnameN(tNonetlist_adminstrangetlentparams(tmoduletarraytusertuserstacct((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_user.pytget_usernsc	
C`s�t}t||�}|jd}t}t}t}i}|s1y�|sRd}n|j|jdd|d|jd�|jdr�y"|j|jd�d|d<Wq�tk
r�|j|jd�|jdd	j|jd��q�Xnt	}Wqotk
r-|jdd	j|jd��qoXn>|jdre|jd
ret}|j
d|�n|jdr8|jd
r8|jd
r|jd|jd
kry8|j|jdd|jdd
|jd
�t	}Wq5tk
r|jddj|jd��q5Xq8|jdd
j|jd��n|jdr�y_|j|jd�ddk	r|j|jd�n|j|jd�d|d<t	}Wq�tk
r�|jddj|jd��q�Xn|jd|dkrTy+|j|jdd|jd�t	}WqTtk
rP|jddj|jd��qTXn|sf|sf|rot	}n|j
d|d|�dS(s#Create or Update Local User AccounttroletreadonlyRtpasswordtapit	api_tokentuser_apitmsgsLocal User {0}: Creation failedtold_passwordtchangeds:Local User {0}: Password reset failed. Check old password.sQLocal User Account {0}: Password change failed - Check both old and new passwordss'Local User {0}: API token change faileds#Local User {0}: Role changed failedt	user_infoN(tFalseRRtcreate_admintcreate_api_tokent	Exceptiontdelete_usert	fail_jsontformattTruet	exit_jsont	set_admint
get_api_tokenR
tdelete_api_token(	RRR RRtapi_changedtrole_changedtpasswd_changedt
user_token((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_user.pytcreate_userxsj
	
"
'

'' 


 

'!

'	cC`s~t}t||�rjy|j|jd�t}Wqjtk
rf|jddj|jd��qjXn|jd|�dS(sDelete Local User AccountRRs)Object Store Account {0}: Deletion failedR N(	R"Rtdelete_adminRR)R%R'R(R*(RRR ((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_user.pyR&�s

'cC`sWt�}|jtdtdtdd�dtdddddd	g�d
tdddddd
dg�dtdddt�dtdddt�dtdddt���t|dt�}|jd
}t|�}|j�}t	|kr|j
ddjt	��n|d
kr't||�n,|dkrCt
||�n|jdt�dS(NRtrequiredttypetstrRtchoicesRt
storage_admintarray_admintstatetdefaulttpresenttabsentRtno_logRRtbooltsupports_check_modeRsDFlashArray REST version not supported. Minimum version required: {0}R (RtupdatetdictR)R"R	RR
t_list_available_rest_versionstMIN_REQUIRED_API_VERSIONR'R(R&R2R*(t
argument_specRR:Rtapi_version((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_user.pytmain�s*	!		

t__main__N(t
__future__RRRR5t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicR	tansible.module_utils.pureR
RRDRR2R&RGt__name__(((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_user.pyt<module>s 


++	
	;		

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