�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
m Z d d l m
Z
d d
l m Z d d d d d g Z d e f d � � YZ d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys�
---
module: zfs_facts
short_description: Gather facts about ZFS datasets.
description:
- Gather facts from ZFS dataset properties.
version_added: "2.3"
author: Adam Števko (@xen0l)
options:
name:
description:
- ZFS dataset name.
required: yes
aliases: [ "ds", "dataset" ]
recurse:
description:
- Specifies if properties for any children should be recursively
displayed.
type: bool
default: 'no'
parsable:
description:
- Specifies if property values should be displayed in machine
friendly format.
type: bool
default: 'no'
properties:
description:
- Specifies which dataset properties should be queried in comma-separated format.
For more information about dataset properties, check zfs(1M) man page.
default: all
aliases: [ "props" ]
type:
description:
- Specifies which datasets types to display. Multiple values have to be
provided in comma-separated form.
choices: [ 'all', 'filesystem', 'volume', 'snapshot', 'bookmark' ]
default: all
depth:
description:
- Specifies recursion depth.
sp
- name: Gather facts about ZFS dataset rpool/export/home
zfs_facts:
dataset: rpool/export/home
- name: Report space usage on ZFS filesystems under data/home
zfs_facts:
name: data/home
recurse: yes
type: filesystem
- debug:
msg: 'ZFS dataset {{ item.name }} consumes {{ item.used }} of disk space.'
with_items: '{{ ansible_zfs_datasets }}'
su
name:
description: ZFS dataset name
returned: always
type: str
sample: rpool/var/spool
parsable:
description: if parsable output should be provided in machine friendly format.
returned: if 'parsable' is set to True
type: bool
sample: True
recurse:
description: if we should recurse over ZFS dataset
returned: if 'recurse' is set to True
type: bool
sample: True
zfs_datasets:
description: ZFS dataset facts
returned: always
type: str
sample:
{
"aclinherit": "restricted",
"aclmode": "discard",
"atime": "on",
"available": "43.8G",
"canmount": "on",
"casesensitivity": "sensitive",
"checksum": "on",
"compression": "off",
"compressratio": "1.00x",
"copies": "1",
"creation": "Thu Jun 16 11:37 2016",
"dedup": "off",
"devices": "on",
"exec": "on",
"filesystem_count": "none",
"filesystem_limit": "none",
"logbias": "latency",
"logicalreferenced": "18.5K",
"logicalused": "3.45G",
"mlslabel": "none",
"mounted": "yes",
"mountpoint": "/rpool",
"name": "rpool",
"nbmand": "off",
"normalization": "none",
"org.openindiana.caiman:install": "ready",
"primarycache": "all",
"quota": "none",
"readonly": "off",
"recordsize": "128K",
"redundant_metadata": "all",
"refcompressratio": "1.00x",
"referenced": "29.5K",
"refquota": "none",
"refreservation": "none",
"reservation": "none",
"secondarycache": "all",
"setuid": "on",
"sharenfs": "off",
"sharesmb": "off",
"snapdir": "hidden",
"snapshot_count": "none",
"snapshot_limit": "none",
"sync": "standard",
"type": "filesystem",
"used": "4.41G",
"usedbychildren": "4.41G",
"usedbydataset": "29.5K",
"usedbyrefreservation": "0",
"usedbysnapshots": "0",
"utf8only": "off",
"version": "5",
"vscan": "off",
"written": "29.5K",
"xattr": "on",
"zoned": "off"
}
( t defaultdict( t
AnsibleModule( t iteritemst allt
filesystemt volumet snapshott bookmarkt ZFSFactsc B` s# e Z d � Z d � Z d � Z RS( c C` s� | | _ | j d | _ | j d | _ | j d | _ | j d | _ | j d | _ | j d | _ t t � | _
g | _ d S( Nt namet recurset parsablet
propertiest typet depth( t modulet paramsR R R R R R R t dictt _datasetst facts( t selfR ( ( sI /usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_facts.pyt __init__� s c C` se | j j d � g } | j d � | j | j � | j j | � \ } } } | d k r] t St Sd S( Nt zfst listi ( R t get_bin_patht appendR t run_commandt Truet False( R t cmdt rct outt err( ( sI /usr/lib/python2.7/site-packages/ansible/modules/storage/zfs/zfs_facts.pyt dataset_exists� s
c C` s� | j j d � g } | j d � | j d � | j rH | j d � n | j ra | j d � n t | j � d k r� | j d � | j d | j � n | j r� | j d � | j | j � n | j d
� | j d � | j | j � | j | j � | j j
| � \ } } } | d k r�xG | j � D]9 } | j d � \ } } } | j
| j i | | 6� q1WxA t | j
� D]0 \ } }
|
j i | d
6� | j j |
� q~Wi | j d 6S| j j d d | j d | d | � d S( NR t gets -Hs -ps -ri s -ds %ss -ts -os name,property,values R t ansible_zfs_datasetst msgs5 Error while trying to get facts about ZFS dataset: %st stderrR&