Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/junos/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/junos/junos_user.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlm
Z
dd
lmZddlmZddlmZddlmZddlmZmZmZddlmZmZddlmZmZddlmZyddl m!Z!m"Z"Wn'e#k
rMddl$m!Z!m"Z"nXddddgZ%e&Z'd�Z(d�Z)d�Z*d�Z+d�Z,e-dkr�e,�nd S(!i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatustnetworktsupported_bys�
---
module: junos_user
version_added: "2.3"
author: "Peter Sprygada (@privateip)"
short_description: Manage local user accounts on Juniper JUNOS devices
description:
  - This module manages locally configured user accounts on remote
    network devices running the JUNOS operating system.  It provides
    a set of arguments for creating, removing and updating locally
    defined accounts
extends_documentation_fragment: junos
options:
  aggregate:
    description:
      - The C(aggregate) argument defines a list of users to be configured
        on the remote device.  The list of users will be compared against
        the current users and only changes will be added or removed from
        the device configuration.  This argument is mutually exclusive with
        the name argument.
    version_added: "2.4"
    aliases: ['users', 'collection']
  name:
    description:
      - The C(name) argument defines the username of the user to be created
        on the system.  This argument must follow appropriate usernaming
        conventions for the target device running JUNOS.  This argument is
        mutually exclusive with the C(aggregate) argument.
  full_name:
    description:
      - The C(full_name) argument provides the full name of the user
        account to be created on the remote device.  This argument accepts
        any text string value.
  role:
    description:
      - The C(role) argument defines the role of the user account on the
        remote system.  User accounts can have more than one role
        configured.
    choices: ['operator', 'read-only', 'super-user', 'unauthorized']
  sshkey:
    description:
      - The C(sshkey) argument defines the public SSH key to be configured
        for the user account on the remote system.  This argument must
        be a valid SSH key
  encrypted_password:
    description:
      - The C(encrypted_password) argument set already hashed password
        for the user account on the remote system.
    version_added: "2.8"
  purge:
    description:
      - The C(purge) argument instructs the module to consider the
        users definition absolute.  It will remove any previously configured
        users on the device with the exception of the current defined
        set of aggregate.
    type: bool
    default: 'no'
  state:
    description:
      - The C(state) argument configures the state of the user definitions
        as it relates to the device operational configuration.  When set
        to I(present), the user should be configured in the device active
        configuration and when set to I(absent) the user should not be
        in the device active configuration
    default: present
    choices: ['present', 'absent']
  active:
    description:
      - Specifies whether or not the configuration is active or deactivated
    type: bool
    default: 'yes'
    version_added: "2.4"
requirements:
  - ncclient (>=v0.5.2)
notes:
  - This module requires the netconf system service be enabled on
    the remote device being managed.
  - Tested against vSRX JUNOS version 15.1X49-D15.4, vqfx-10000 JUNOS Version 15.1X53-D60.4.
  - Recommended connection is C(netconf). See L(the Junos OS Platform Options,../network/user_guide/platform_junos.html).
  - This module also works with C(local) connections for legacy playbooks.
s�
- name: create new user account
  junos_user:
    name: ansible
    role: super-user
    sshkey: "{{ lookup('file', '~/.ssh/ansible.pub') }}"
    state: present

- name: remove a user account
  junos_user:
    name: ansible
    state: absent

- name: remove all user accounts except ansible
  junos_user:
    aggregate:
    - name: ansible
    purge: yes

- name: set user password
  junos_user:
    name: ansible
    role: super-user
    encrypted_password: "{{ 'my-password' | password_hash('sha512') }}"
    state: present

- name: Create list of users
  junos_user:
    aggregate:
      - {name: test_user1, full_name: test_user2, role: operator, state: present}
      - {name: test_user2, full_name: test_user2, role: read-only, state: present}

- name: Delete list of users
  junos_user:
    aggregate:
      - {name: test_user1, full_name: test_user2, role: operator, state: absent}
      - {name: test_user2, full_name: test_user2, role: read-only, state: absent}
sH
diff.prepared:
  description: Configuration difference before and after applying change.
  returned: when configuration is changed and diff option is enabled.
  type: str
  sample: >
          [edit system login]
          +    user test-user {
          +        uid 2005;
          +        class read-only;
          +    }
(tpartial(tdeepcopy(tto_text(t
AnsibleModule(tConnectionError(tremove_default_spec(tjunos_argument_spectget_connectionttostring(tcommit_configurationtdiscard_changes(tload_configt
locked_config(t	iteritems(tElementt
SubElementtoperators	read-onlys
super-usertunauthorizedcC`s*g|D]}|d^q}td�}t|d�}t|�}y%|jttd��dt�}Wn/tk
r�}|jdt|dd��nX|j	d	�}	|	rx`|	D]U}|j
}
|
|kr�|
d
kr�t|didd
6�}|
t|d�_
q�q�Wn|j	d�r&|SdS(Ntnametsystemtloginsget-configurationtignore_warningtmsgterrorstsurrogate_then_replaces$configuration/system/login/user/nametroottusertdeletet	operations/system/login/user/name(RRRtexecute_rpcRtFalseRt	fail_jsonR
txpathttext(tmoduletwanttitemt
want_userstelementRtconntreplytexctusersRR"((sL/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_user.pythandle_purge�s"% 
	c	C`s�td�}t|d�}xn|D]f}|ddkrd|ddkr[|jdd�nd	}nd
}|ddkr�t|di|d6�}|dt|d�_nt|d
i|d6�}}|d
kr"|ddkr|ds|ds|dr|jdd�n|dr4|jdd�n|jdd�|drg|dt|d�_n|jd�r�|dt|d�_n|jd�rNt|d�}d|dkr�t|d�}nfd|dkr�t|d�}nDd|dkrt|d�}n"d|dkr5t|d�}n|dt|d�_n|jd�r�t|d�}|dt|d�_q�q"q"W|S(NRRtstatetpresentRR!Rs!cannot delete the 'root' account.R#tmergeR"R$sroot-authenticationtactivetrolet	full_namesJ'root' account cannot be deactivated or be assigned a role and a full nametinactivetclasss	full-nametsshkeytauthenticationsssh-rsasssh-dsssssh-dsas
ecdsa-sha2s	ssh-ecdsasssh-ed25519tencrypted_passwordsencrypted-password(RRR'R)tsettget(	R*R+R.RR,R$R"tauthtssh_rsa((sL/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_user.pytmap_obj_to_ele�sJ
	/

 cC`s�|j|�s|j|}n>|j|jdd�}|j|}|||�||}t�jd|�}t||f�r�|||�n|S(Nttypetstrsvalidate_%s(R@tparamst
argument_spect _CHECK_ARGUMENT_TYPES_DISPATCHERtglobalstall(tkeyR,R*tvaluet
value_typettype_checkert	validator((sL/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_user.pytget_param_value�s

c	C`s�|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|d
�d
6|d�d6�xRt	|�D]D\}}t
�jd|�}t||f�rq|||�qqqqW|j|�q�W|S(Nt	aggregateRtpurgeRsmissing required argument: nametusernameR,R*R9R8R>R<R4R7svalidate_%s(
RFtlistR't
isinstancetdicttappendRRPtupdateRRIR@RJ(	R*RQt
collectionR,tobjectst	get_valueRKRLRO((sL/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_user.pytmap_params_to_obj	s<

	
	
	




cC`s?tdt�dt�dtdt�dtdt�dt�dtdd	d
gdd	�dtd
ddt��}t|�}tdt�|d<t|�tdtd
dddd|dddg�dtdtd
d��}|j|�|jt�ddgg}td|d|dt�}t	�}itd6|d6}t
|�}t||�}d#}	|j
dr�t||�}	nt|���|	r�t|t|	�|dd�nt|t|�|dd �}
|j}|
r(|r�t|�n
t|�t|d<|jr(i|
d!6|d"<q(nWd#QX|j|�d#S($s+ main entry point for module execution
    RR9R8tchoicesR>tno_logR<R4R5tabsenttdefaultR7RDtbooltrequiredRQRTtelementsRVtoptionstaliasesRYR2RRRGtmutually_exclusivetsupports_check_modetchangedtwarningstactiontreplaceR6tpreparedtdiffN(RVtROLEStTrueR	R
R&RXRRRTR\RCtNoneRFR3RRRt
check_modeRRt_difft	exit_json(telement_spectaggregate_specRGRfR*RitresultR+telet
purge_requestRmtcommit((sL/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_user.pytmain4sP			
'

		





	t__main__N(.t
__future__RRRRDt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNt	functoolsRtcopyR	tansible.module_utils._textR
tansible.module_utils.basicRtansible.module_utils.connectionRt)ansible.module_utils.network.common.utilsR
t(ansible.module_utils.network.junos.junosRRRRRRRtansible.module_utils.sixRt
lxml.etreeRRtImportErrortxml.etree.ElementTreeRnRotUSE_PERSISTENT_CONNECTIONR3RCRPR\Rzt__name__(((sL/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_user.pyt<module>s<


S'

		4		+	>

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