Anons79 Mini Shell

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

�
�Udac@`s�ddlmZmZmZeZidgd6dd6dd6ZdZd	Zd
Z	ddl
mZddlm
Z
d
efd��YZd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functiontpreviewtstatust	communitytsupported_bys1.1tmetadata_versions�
---
module: zfs_delegate_admin
short_description: Manage ZFS delegated administration (user admin privileges)
description:
  - Manages ZFS file system delegated administration permissions, which allow unprivileged users to perform ZFS
    operations normally restricted to the superuser.
  - See the C(zfs allow) section of C(zfs(1M)) for detailed explanations of options.
  - This module attempts to adhere to the behavior of the command line tool as much as possible.
requirements:
  - "A ZFS/OpenZFS implementation that supports delegation with `zfs allow`, including: Solaris >= 10, illumos (all
    versions), FreeBSD >= 8.0R, ZFS on Linux >= 0.7.0."
version_added: '2.8'
options:
  name:
    description:
      - File system or volume name e.g. C(rpool/myfs).
    required: true
    type: str
  state:
    description:
      - Whether to allow (C(present)), or unallow (C(absent)) a permission.
      - When set to C(present), at least one "entity" param of I(users), I(groups), or I(everyone) are required.
      - When set to C(absent), removes permissions from the specified entities, or removes all permissions if no entity params are specified.
    required: true
    choices: [ absent, present ]
    default: present
  users:
    description:
      - List of users to whom permission(s) should be granted.
    type: list
  groups:
    description:
      - List of groups to whom permission(s) should be granted.
    type: list
  everyone:
    description:
      - Apply permissions to everyone.
    type: bool
    default: no
  permissions:
    description:
      - The list of permission(s) to delegate (required if C(state) is C(present)).
    type: list
    choices: [ allow, clone, create, destroy, diff, hold, mount, promote, readonly, receive, release, rename, rollback, send, share, snapshot, unallow ]
  local:
    description:
      - Apply permissions to C(name) locally (C(zfs allow -l)).
    type: bool
  descendents:
    description:
      - Apply permissions to C(name)'s descendents (C(zfs allow -d)).
    type: bool
  recursive:
    description:
      - Unallow permissions recursively (ignored when C(state) is C(present)).
    type: bool
    default: no
author:
- Nate Coraor (@natefoo)
s�
- name: Grant `zfs allow` and `unallow` permission to the `adm` user with the default local+descendents scope
  zfs_delegate_admin:
    name: rpool/myfs
    users: adm
    permissions: allow,unallow

- name: Grant `zfs send` to everyone, plus the group `backup`
  zfs_delegate_admin:
    name: rpool/myvol
    groups: backup
    everyone: yes
    permissions: send

- name: Grant `zfs send,receive` to users `foo` and `bar` with local scope only
  zfs_delegate_admin:
    name: rpool/myfs
    users: foo,bar
    permissions: send,receive
    local: yes

- name: Revoke all permissions from everyone (permissions specifically assigned to users and groups remain)
- zfs_delegate_admin:
    name: rpool/myfs
    everyone: yes
    state: absent
t
(tproduct(t
AnsibleModuletZfsDelegateAdmincB`s\eZd�Zd�Zed��Zddd�Zd�Zd�Z	d�Z
d�ZRS(	cC`s�||_|jjd�|_|jjd�|_|jjd�|_|jjd�|_|jjd�|_|jjd�|_d|_
t|_d|_
d|_g|_|j|_|j|�dS(Ntnametstatetuserstgroupsteveryonetpermissionstallow(tmoduletparamstgetRR
RRRtpermstNonetscopetFalsetchangedt
initial_permst
subcommandt
recursive_opttupdatet
run_methodtsetup(tselfR((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_delegate_admin.pyt__init__ss						cC`s7|jdkr<d|_|jjd�r<dg|_q<n|jjd�}|jjd�}|rl|sz|r�|r�d|_n7|r�d|_n%|r�d	|_n|jjd
d�|jp�|j	p�|j
s|jdkr�|jjd
d
�q|jdkr|j|_qn|j
dt�|_dS(s- Validate params and set up for run.
        tabsenttunallowt	recursives-rtlocaltdescendentstldtltdtmsgs*Impossible value for local and descendentstpresents3One of `users`, `groups`, or `everyone` must be settzfsN(R
RRRRRRt	fail_jsonRRRtclearRtget_bin_pathtTruetzfs_path(R!RR&R'((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_delegate_admin.pyR �s&	c	C`s}|jdd�}iiid6id6gd6d6iid6id6gd6d6iid6id6gd6d6}idd	6dd
6dd6}d}x�|j�D]�}|j||�}|s�q�ny�|jd�s�|jd
�r|j�\}}}|jd�|||d|<n3|jd�rI|j�djd�||d<nWq�tk
rt|jjdd|�q�Xq�W|S(sQ Parse the output of `zfs allow <name>` to retrieve current permissions.
        RRtutgteR)R*R(sLocal permissions:sDescendent permissions:sLocal+Descendent permissions:s	user s	group t,is
	everyone iR+s>Cannot parse user/group permission output by `zfs allow`: '%s'N(	trun_zfs_rawRt
splitlinesRt
startswithtsplitt
ValueErrorRR.(	R!toutRtlinemapRtlinetent_typetentt	cur_perms((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_delegate_admin.pyt
current_perms�s.
"(
cC`sz|j|p|jg|pg|jg}|jj|�\}}}|rv|jjdddj|�|f�n|S(s/ Run a raw zfs command, fail on error.
        R+sCommand `%s` failed: %st (R2RRRtrun_commandR.tjoin(R!RtargstcmdtrcR<terr((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_delegate_admin.pyR7�s
,)cC`sP|jd|jg|}|jr@|jdj|j��n|jd|�S(sQ Run zfs allow/unallow with appropriate options as per module arguments.
        t-R6RF(RRRtappendRER7(R!RF((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_delegate_admin.pytrun_zfs�s	cC`s�t}d}xbtd
d�D]Q\}}xB|j||j�D])}||jd||g�7}t}q@WqWx>dD]6}|j|drx||jd	g�7}t}qxqxW||fS(
s3 Called by run() to clear all permissions.
        tR(R)R*R3R4s-%sR5s-e(sldR)R*(R3R4(sldR)R*(RR	RtkeysRLR1(R!RtstdoutRR?R@((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_delegate_admin.pyR/�s

cC`s�d}x[d|jfd|jffD];\}}|r%||jd|dj|�g�7}q%q%W|jr�||jdg�7}n|j|jk|fS(s5 Update permissions as per module arguments.
        RMR3R4s-%sR6s-e(RRRLRERRRB(R!ROR?tentities((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_delegate_admin.pyR�s+-	cC`sgi|jd6}|j|_|j�\|d<}|drSd|d<||d<n|jj|�dS(s7 Run an operation, return results for Ansible.
        R
Rs'ZFS delegated admin permissions updatedR+RON(R
RBRRRt	exit_json(R!t	exit_argsRO((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_delegate_admin.pytrun�s


N(t__name__t
__module__R"R tpropertyRBRR7RLR/RRS(((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_delegate_admin.pyRrs						c#C`s+tdtdtdddt�dtddddd	d
dg�dtdd�d
tdd�dtdddt�dtddd	dddddddddddddddd d!g�d"tdd�d#tdd�d$tdddt��	d%td&dddgfg�}t|�}|j�dS('Nt
argument_specRttypetstrtrequiredR
tdefaultR,tchoicesR#RtlistRRtboolRRtclonetcreatetdestroytdifftholdtmounttpromotetreadonlytreceivetreleasetrenametrollbacktsendtsharetsnapshotR$R&R'R%tsupports_check_modetrequired_if(R
tdictR1RRRS(Rtzfs_delegate_admin((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_delegate_admin.pytmain�s$!t__main__N(t
__future__RRRRXt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNt	itertoolsR	tansible.module_utils.basicR
tobjectRRrRT(((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_delegate_admin.pyt<module>s

>�	

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