Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/nxos/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pyc

�
�Udac@szidd6dgd6dd6ZdZdZdZd	d
lZd	dlmZd	dlmZd	d
l	m
Z
mZmZd	dl	m
Z
d	dlmZd	dlmZmZd	dlmZmZddddddddddddddd d!d"d#d$d%gZd&�Zd'�Zd(�Zd)�Zd*�Zd+�Zd,�Zd-�Zd.�Zd/�Z e!d0krve �nd
S(1s1.1tmetadata_versiontpreviewtstatustnetworktsupported_bys
---
module: nxos_user
extends_documentation_fragment: nxos
version_added: "2.3"
author: "Peter Sprygada (@privateip)"
short_description: Manage the collection of local users on Nexus devices
description:
  - This module provides declarative management of the local usernames
    configured on Cisco Nexus devices.  It allows playbooks to manage
    either individual usernames or the collection of usernames in the
    current running config.  It also supports purging usernames from the
    configuration that are not explicitly defined.
options:
  aggregate:
    description:
      - The set of username objects to be configured on the remote
        Cisco Nexus device.  The list entries can either be the username
        or a hash of username and properties.  This argument is mutually
        exclusive with the C(name) argument.
    aliases: ['users', 'collection']
    version_added: "2.4"
  name:
    description:
      - The username to be configured on the remote Cisco Nexus
        device.  This argument accepts a string value and is mutually
        exclusive with the C(aggregate) argument.
  configured_password:
    description:
      - The password to be configured on the network device. The
        password needs to be provided in cleartext and it will be encrypted
        on the device.
        Please note that this option is not same as C(provider password).
    version_added: "2.4"
  update_password:
    description:
      - Since passwords are encrypted in the device running config, this
        argument will instruct the module when to change the password.  When
        set to C(always), the password will always be updated in the device
        and when set to C(on_create) the password will be updated only if
        the username is created.
    default: always
    choices: ['on_create', 'always']
  role:
    description:
      - The C(role) argument configures the role for the username in the
        device running configuration.  The argument accepts a string value
        defining the role name.  This argument does not check if the role
        has been configured on the device.
    aliases: ['roles']
  sshkey:
    description:
      - The C(sshkey) argument defines the SSH public key to configure
        for the username.  This argument accepts a valid SSH key value.
  purge:
    description:
      - The C(purge) argument instructs the module to consider the
        resource definition absolute.  It will remove any previously
        configured usernames on the device with the exception of the
        `admin` user which cannot be deleted per nxos constraints.
    type: bool
    default: 'no'
  state:
    description:
      - The C(state) argument configures the state of the username definition
        as it relates to the device operational configuration.  When set
        to I(present), the username(s) should be configured in the device active
        configuration and when set to I(absent) the username(s) should not be
        in the device active configuration
    default: present
    choices: ['present', 'absent']
sE
- name: create a new user
  nxos_user:
    name: ansible
    sshkey: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
    state: present

- name: remove all users except admin
  nxos_user:
    purge: yes

- name: set multiple users role
  aggregate:
    - name: netop
    - name: netend
  role: network-operator
  state: present
s
commands:
  description: The list of configuration mode commands to send to the device
  returned: always
  type: list
  sample:
    - name ansible
    - name ansible password password
start:
  description: The time the job started
  returned: always
  type: str
  sample: "2016-11-16 10:38:15.126146"
end:
  description: The time the job ended
  returned: always
  type: str
  sample: "2016-11-16 10:38:25.595612"
delta:
  description: The time elapsed to perform all operations
  returned: always
  type: str
  sample: "0:00:10.469466"
i����N(tdeepcopy(tpartial(trun_commandstload_configt
get_config(tnxos_argument_spec(t
AnsibleModule(tstring_typest	iteritems(tremove_default_spectto_lists
network-adminsnetwork-operators	vdc-adminsvdc-operatorspriv-15spriv-14spriv-13spriv-12spriv-11spriv-10spriv-9spriv-8spriv-7spriv-6spriv-5spriv-4spriv-3spriv-2spriv-1spriv-0cCs%tjdt|ddg�tj�S(Ns^role name (\S+)tflagss| include '^role name'(tretfindallR	tM(tmodule((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytget_custom_roles�scCsDtt|�}x-|D]%}||kr|jdd�qqWdS(Ntmsgsinvalid role specified(t
BUILTIN_ROLESRt	fail_json(tvalueRtvalid_rolestitem((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytvalidate_roles�s
cslt��|jd}|jd}xB|D]:}|\����fd�}��fd����fd������fd�}�ddkr��jd�d	�q*nt}�dd
kr��r�|�}|s��jd�d	�q�n|d�r3|d
ks�r3�d�d�q3n|d�rT�d�d�n|s*|�q*q*W�S(Ntstatetupdate_passwordcs+�j|�o*�j|��j|�kS(N(tget(tx(thavetwant(sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytneeds_update�scs�jd�d|f�S(Nsusername %s %stname(tappend(R (tcommandsR"(sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytadd�scs�jd�d|f�S(Nsno username %s %sR$(R%(R (R&R"(sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytremove�scs��dr��rx3t�d�j�d�D]}�d|�q.WxYt�d�j�d�D]}�d|�qdWn#x �dD]}�d|�q�WtStS(Ntrolessrole %s(tsett
differencetTruetFalse(R(R'R!R(R"(sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytconfigure_roles�s
$$tabsentsno username %sR$tpresentsusername %stconfigured_passwordtalwaysspassword %stsshkeys	sshkey %s(tlisttparamsR%R-(tupdatesRRRtupdateR#R.troles_configured((R'R&R!R(R"sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytmap_obj_to_commands�s2	


	cCs|jd�sdSdS(Ntremote_logins
<PASSWORD>(R(tdata((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytparse_password�scCsfd}d|kr(|jd�d}nt�}|rbx(t|�D]}|j|d�qDWn|S(Nt
TABLE_roletROW_roletrole(tNoneRR4RR%(R;tconfigured_rolesR)R((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytparse_roles�s	cCs�t|dg�}|d}t�}xet|dd�D]O}|ji|dd6t|�d6|jd�d	6t|�d
6dd6�q:W|S(
Nsshow user-account | jsonitTABLE_templatetROW_templatetusr_nameR$R1tsshkey_infoR3R)R0R(RR4RR%R<RRB(RtoutR;tobjectsR((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytmap_config_to_objs
		

cCsa|j|�s|j|}n>|j|jdd�}|j|}|||�||}|S(Nttypetstr(RR5t
argument_spect _CHECK_ARGUMENT_TYPES_DISPATCHER(tkeyRRRt
value_typettype_checker((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytget_param_values

c	Cs�|jd}|so|jdr5|jdr5t�S|jdsU|jdd�q�i|jdd6g}nlt�}x`|D]X}t|t�s�|ji|d6�qd|kr�|jdd�q|j|�qWt�}x�|D]�}ttd|d|�}|ji|d	�d	6|d
�d
6|d�d6|d�d6�x[t	|�D]M\}}|rWt
�jd
|�}t||f�r�|||�q�qWqWW|j|�q�W|S(Nt	aggregateR$tpurgeRsusername is requiredsname is requiredRRR1R3R)Rsvalidate_%s(
R5R4Rt
isinstancetdictR%RRQR7R
tglobalsRtall(	RRRt
collectionRRHt	get_valueRNRt	validator((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytmap_params_to_obj&s:

	
	
	


cs�t�}x�|D]��t�fd�|D�d�}t|dk�ddkf�rm|j�if�q|rxIt��D]8\}}|r�|||kr�|j�|f�q�q�WqqW|S(Nc3s)|]}|d�dkr|VqdS(R$N((t.0ti(tentry(sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pys	<genexpr>SsRR0(R4tnextR@RWR%R
(R"R!R6RRNR((R^sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytupdate_objectsPs	
"!cCs�tdt�dtdt�dtdddddg�d	td
ddd
g�dt�dtdddddg��}t|�}t|�tdtd
dddd|dddg�dtd
ddt��}|j|�|jt�d+g}td|d|dt�}t�}|j	drI|j	drI|j
dd�nitd 6}||d!<t|�}t|�}t
t||�|�}	|j	dr,g|D]}
|
d^q�}g|D]}
|
d^q�}xRt|�j|�D]8}
|
d"kr�|
jd#d$�}
|	j
d%|
�q�q�Wn|	|d&<d'|	krU|jd(d)�n|	r�|jstt||	�nt|d <n|j|�d*S(,s+ main entry point for module execution
    R$R1tno_logRtdefaultR2tchoicest	on_createR)RJR4taliasesR?R3RR0R/RRtelementsRUtoptionsRXtusersRStboolRLtmutually_exclusivetsupports_check_modetpasswordsHThe "password" argument is used to authenticate the current connection. s9To set a user password use "configured_password" instead.tchangedtwarningstadmins\s\\sno username %sR&sno username adminRs!cannot delete the `admin` accountN(R$RR(RUR,RRR-R7R
RR4R5R%R[RIR9R`R*R+treplaceRt
check_modeRt	exit_json(telement_spectaggregate_specRLRjRRntresultR"R!R&R t
want_userst
have_usersR((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pytmain]sV		
'

			



	
t__main__("tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRtcopyRt	functoolsRt&ansible.module_utils.network.nxos.nxosRRR	R
tansible.module_utils.basicRtansible.module_utils.sixRR
t)ansible.module_utils.network.common.utilsRRRRRR9R<RBRIRQR[R`Rxt__name__(((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_user.pyt<module>sZ


J				7					*	
	E

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