Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/system/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/system/mount.pyo

�
�Udac@`s$ddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	ddl
mZmZddl
mZdd
lmZddlmZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd
d
d�Zdd�Zd�Zedkr e�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatustcoretsupported_bys

---
module: mount
short_description: Control active and configured mount points
description:
  - This module controls active and configured mount points in C(/etc/fstab).
author:
  - Ansible Core Team
  - Seth Vidal (@skvidal)
version_added: "0.6"
options:
  path:
    description:
      - Path to the mount point (e.g. C(/mnt/files)).
      - Before Ansible 2.3 this option was only usable as I(dest), I(destfile) and I(name).
    type: path
    required: true
    aliases: [ name ]
  src:
    description:
      - Device to be mounted on I(path).
      - Required when I(state) set to C(present) or C(mounted).
    type: path
  fstype:
    description:
      - Filesystem type.
      - Required when I(state) is C(present) or C(mounted).
    type: str
  opts:
    description:
      - Mount options (see fstab(5), or vfstab(4) on Solaris).
    type: str
  dump:
    description:
      - Dump (see fstab(5)).
      - Note that if set to C(null) and I(state) set to C(present),
        it will cease to work and duplicate entries will be made
        with subsequent runs.
      - Has no effect on Solaris systems.
    type: str
    default: 0
  passno:
    description:
      - Passno (see fstab(5)).
      - Note that if set to C(null) and I(state) set to C(present),
        it will cease to work and duplicate entries will be made
        with subsequent runs.
      - Deprecated on Solaris systems.
    type: str
    default: 0
  state:
    description:
      - If C(mounted), the device will be actively mounted and appropriately
        configured in I(fstab). If the mount point is not present, the mount
        point will be created.
      - If C(unmounted), the device will be unmounted without changing I(fstab).
      - C(present) only specifies that the device is to be configured in
        I(fstab) and does not trigger or require a mount.
      - C(absent) specifies that the device mount's entry will be removed from
        I(fstab) and will also unmount the device and remove the mount
        point.
      - C(remounted) specifies that the device will be remounted for when you
        want to force a refresh on the mount itself (added in 2.9). This will
        always return changed=true.
    type: str
    required: true
    choices: [ absent, mounted, present, unmounted, remounted ]
  fstab:
    description:
      - File to use instead of C(/etc/fstab).
      - You should not use this option unless you really know what you are doing.
      - This might be useful if you need to configure mountpoints in a chroot environment.
      - OpenBSD does not allow specifying alternate fstab files with mount so do not
        use this on OpenBSD with any state that operates on the live filesystem.
      - This parameter defaults to /etc/fstab or /etc/vfstab on Solaris.
    type: str
  boot:
    description:
      - Determines if the filesystem should be mounted on boot.
      - Only applies to Solaris systems.
    type: bool
    default: yes
    version_added: '2.2'
  backup:
    description:
      - Create a backup file including the timestamp information so you can get
        the original file back if you somehow clobbered it incorrectly.
    type: bool
    default: no
    version_added: '2.5'
notes:
  - As of Ansible 2.3, the I(name) option has been changed to I(path) as
    default, but I(name) still works as well.
s�
# Before 2.3, option 'name' was used instead of 'path'
- name: Mount DVD read-only
  mount:
    path: /mnt/dvd
    src: /dev/sr0
    fstype: iso9660
    opts: ro,noauto
    state: present

- name: Mount up device by label
  mount:
    path: /srv/disk
    src: LABEL=SOME_LABEL
    fstype: ext4
    state: present

- name: Mount up device by UUID
  mount:
    path: /home
    src: UUID=b3e48f45-f933-4c8e-a700-22a159ec9077
    fstype: xfs
    opts: noatime
    state: present

- name: Unmount a mounted volume
  mount:
    path: /tmp/mnt-pnt
    state: unmounted

- name: Mount and bind a volume
  mount:
    path: /system/new_volume/boot
    src: /boot
    opts: bind
    state: mounted
    fstype: none
N(t
AnsibleModuletget_platform(tismount(t	iteritems(t	to_nativecC`sb|jdr|j|�nt|d�}x|D]}|j|�q3W|j�|j�dS(Ntbackuptw(tparamstbackup_localtopentwritetflushtclose(tmoduletlinestpathtfs_wtl((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pytwrite_fstab�s


cC`s?t|t�r|S|jdd�jdd�jdd�SdS(shEscape invalid characters in fstab fields.

    space (040)
    ampersand (046)
    backslash (134)
    s\s\134t s\040t&s\046N(t
isinstancetinttreplace(tv((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pyt
_escape_fstab�scC`s9g}t}t}tgt|�D]\}}|t|�f^q"�}d}t�dkrgd}nxzt|dd�j�D]_}	|	j�s�|j|	�q�n|	j�j	d�r�|j|	�q�n|	j
�}
t�dkr�t|
�dks=t�dkrt|
�dks=t�dkrPt|
�dkrP|j|	�q�ni}t�dkr�|
\|d<}|d
<|d<|d<|d<|d<nWdd
ddddg}
d|d<d|d<x(t|
�D]\}}|||
|<q�W|d
|d
ksFd|krY|d
dkrY|ddkrY|d|dkrY|j|	�q�nt
}d}t�dkr}d}nx9|D]1}||||kr�||||<t
}q�q�W|r�|j||�q�|j|	�q�W|s|j||�t
}n|r+|jr+t|||d�n|d
|fS(s+Set/change a mount point location in fstab.s9%(src)s %(name)s %(fstype)s %(opts)s %(dump)s %(passno)s
tSunOSs;%(src)s - %(name)s %(fstype)s %(passno)s %(boot)s %(opts)s
tfstabtrt#itLinuxiiitsrctnametfstypetpassnotboottoptstdumpitnonetswap(iii(R"R&(ssrcsfstypesoptssdumpspassno(ssrcsfstypespassnosbootsopts(tFalsetdictRR!R	Rt	readlineststriptappendt
startswithtsplittlent	enumeratetTruet
check_modeR(Rtargstto_writetexiststchangedtkR tescaped_argstnew_linetlinetfieldstldtdasht
fields_labelstitfieldt
args_to_checktt((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pyt	set_mount�sh7	 

!!!
	6


	

	c
C`s
g}t}t|d�}x�t|dd�j�D]�}|j�s[|j|�q6n|j�jd�r�|j|�q6nt�dkr�t|j	��dks�t�dkr�t|j	��dkr�|j|�q6ni}t�dkr5|j	�\|d<}|d<|d	<|d
<|d<|d<n6|j	�\|d<|d<|d	<|d<|d
<|d
<|d|ks�d|kr�|ddkr�|d	dkr�|d|dkr�|j|�q6nt
}q6W|r�|jr�t|||d�n|d|fS(s Remove a mount point from fstab.R(R#R$R%R"iiR'R)R*R+R,R-R.R/(
R0R!RR2R3R4R5R	R7R6R9R:R(RR;R<R>tescaped_nameRBRDRE((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pytunset_mount!s: 

''
	<	6

cC`svg}|rr|dkrrt�j�dkrrt�j�jd�rU|jd�n
|jd�|j|�n|S(Ns
/etc/fstabtsunostbsds-Fs-T(R	tlowertendswithR4(t
fstab_filetresult((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pyt_set_fstab_argses
cC`s�|jddt�}|d}|g}t�j�dkrf|jdd
k	rz|jdd�qzn|t|d�7}||g7}|j|�\}}}|dkr�dS|||fSd
S(s%Mount up a path or remount if needed.tmounttrequiredR(topenbsdR#tmsgsdOpenBSD does not support alternate fstab files. Do not specify the fstab parameter for OpenBSD hostsitN(iRY(	tget_bin_pathR9R	RPRtNonet	fail_jsonRTtrun_command(RR;t	mount_binR(tcmdtrctoutterr((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pyRUvs
		

cC`s[|jddt�}||g}|j|�\}}}|dkrIdS|||fSdS(sUnmount a path.tumountRViRYN(iRY(RZR9R](RRt
umount_binR_R`RaRb((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pyRc�scC`s�|jddt�}|g}t�j�jd�rF|dg7}n|ddg7}t�j�dkr�|jddk	r�|jd	d
�q�n|t|d�7}||dg7}d}}y=t�j�jd�r�d
}n|j	|�\}}}Wnt
k
rd
}nXd}|dkrv||}t||d�\}}|dkrvt||�\}}qvn||fS(sCTry to use 'remount' first and fallback to (u)mount if unsupported.RURVROs-us-otremountRWR#RXsdOpenBSD does not support alternate fstab files. Do not specify the fstab parameter for OpenBSD hostsR(RYiiN(
RZR9R	RPRQRR[R\RTR]t	ExceptionRcRU(RR;R^R_RaRbR`RX((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pyRe�s2		

	


cC`sNt}t�dkrk|d
k	rk|d
krE||krht}qhqJ||krJ||d|k}qJn�|jddt�}d|}|j|�\}}	}
g}t|	�r�t|	�j�j	d�}nxu|D]m}|j	�}
|
d|ks|d
kr<|
d|kr<|
d	|ks3|d
kr<t}n|r�Pq�q�W|S(s�Return whether the dest is bind mounted

    :arg module: The AnsibleModule (used for helper functions)
    :arg dest: The directory to be mounted under. This is the primary means
        of identifying whether the destination is mounted.
    :kwarg src: The source directory. If specified, this is used to help
        ensure that we are detecting that the correct source is mounted there.
    :kwarg fstype: The filesystem type. If specified this is also used to
        help ensure that we are detecting the right mount.
    :kwarg linux_mounts: Cached list of mounts for Linux.
    :returns: True if the dest is mounted with src otherwise False.
    R&R'RURVs%s -ls
iiiN(
R0R	R[R9RZR]R7RR3R6(Rtlinux_mountstdestR'R)t
is_mountedtbin_pathR_R`RaRbtmountstmntt	arguments((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pytis_bind_mounted�s,

	s/proc/self/mountinfocC`s$yt|�}Wntk
r$dSXttj|j��}y|j�Wn%tk
rr|jdd|�nXi}x�|D]}|j�}it	|d�d6t	|d�d6|dd	6|d
d6|dd
6|dd6|dd6}|||d<q�Wi}x|j
�D]}	|	ddkr�|	d|kr�||	d}
t|
d	�dkr�|	d	jd|
d	�r�|	d	t|
d	�|	d	<n|
ddkr�d|
d|	d	f|	d	<n|	d	}n
|	d}i|	dd6|d6|	d
d
6|	dd6}|||	d<qW|S(sGather mount informationNRXsCannot close file %sitidit	parent_iditrootitdstiR,i����tfsi����R's%s/t/s%s%s(
RtIOErrortmaptstrR3R2RR\R6RtvaluesR7R5(Rtmntinfo_filetfRtmntinfoRBRCtrecordRkRltmR'((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pytget_linux_mountssN


 

c
!C`s;tdtdtdddt�dtdd�dtdd�d	tdd�d
tdd
dtdd
g�dtdd�dtdd�dtdd
�dtdddt�dtdddtddddddg��
dtddddd	ggdddd	ggf�}t�j�dkrxtd
|jd
ddddd|jddd�}|ddkr�d|d<q�nntd
|jd
dddd dd d|jd�}|ddkr�d!|d<nt�d"kr�d#|d<ng}t�d$kr#t|�}|dkr#d%|d&<q#nx5d1D]-}|j|dk	r*|j|||<q*q*Wt	j
j|d�s�t	j
jt	j
j|d��s�t	j
t	j
j|d��nt|dd'�j�n|jd}|jd
}t}|dkr�t||�\}}|r$|jr$t|�s<t|||�rwt||�\}}|rw|jd(d)||f�qwnt	j
j|�r�yt	j|�Wq�ttfk
r�}	|jd(d*|t|	�f�q�Xq�q$nE|dkrYt|�s	t|||�r$|jsMt||�\}}|rM|jd(d)||f�qMnt}q$n�|dkr�t	j
j|�r�|jr�yt	j
|�Wq�ttfk
r�}	|jd(d+|t|	�f�q�Xnt||�\}}d,}t|�st||||d|d	�rJ|rq|jrqt||�\}}t}qqn't}|jsqt||�\}}n|r$|jd(d-||f�q$n�|dkr�t||�\}}ni|dkr|jst||�\}}|r|jd(d.||f�qnt}n|jd(d/�|jd0||�dS(2Nt
argument_specR+ttypetbooltdefaultR-RwR#R)RRVtaliasesR(R,R*R'R
tstatetchoicestabsenttmountedtpresentt	unmountedt	remountedtsupports_check_modetrequired_ifRNt-tyess/etc/vfstabtdefaultst0s
/etc/fstabtFreeBSDtrwR&sKCannot open file /proc/self/mountinfo. Bind mounts might be misinterpreted.twarningstaRXsError unmounting %s: %ssError rmdir %s: %ssError making dir %s: %sisError mounting %s: %ssError remounting %s: %ssUnexpected position reachedR>(R'R)R*R,R-R#(RR1R9R0R	RPRR[R~tosRR=tdirnametmakedirsRRRMR:R
RnRcR\trmdirtOSErrorRuRRKReRUt	exit_json(
RR;RgtkeyR�R(R>tresRXte((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pytmainOs�-


	



" 

	-				 	 	t__main__( t
__future__RRRR�t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESR�tansible.module_utils.basicRR	tansible.module_utils.ismountR
tansible.module_utils.sixRtansible.module_utils._textRRR!RKRMRTRURcReR[RnR~R�t__name__(((s@/usr/lib/python2.7/site-packages/ansible/modules/system/mount.pyt<module>	s0


_'	
		c	D				61H	�

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