ansible 之 mount

mount

用途:配置 /etc/fstab 文件

官方文档


[root@ansible ~]# ansible-doc mount
> MOUNT    (/usr/lib/python2.7/site-packages/ansible-2.8.0.dev0-py2.7.egg/ansible/modules/system/mount.py)

        This module controls active and configured mount points in `/etc/fstab'.

  * This module is maintained by The Ansible Core Team
OPTIONS (= is mandatory):

- backup
        Create a backup file including the timestamp information so you can get the
        original file back if you somehow clobbered it incorrectly.
        [Default: no]
        type: bool
        version_added: 2.5

- boot
        Determines if the filesystem should be mounted on boot.
        Only applies to Solaris systems.
        [Default: yes]
        type: bool
        version_added: 2.2

- dump
        Dump (see fstab(5)). Note that if set to `null' and `state' set to `present', it
        will cease to work and duplicate entries will be made with subsequent runs.
        Has no effect on Solaris systems.
        [Default: 0]

- fstab
        File to use instead of `/etc/fstab'. You shouldn't 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.
        [Default: /etc/fstab (/etc/vfstab on Solaris)]

- fstype
        Filesystem type. Required when `state' is `present' or `mounted'.
        [Default: (null)]

- opts
        Mount options (see fstab(5), or vfstab(4) on Solaris).
        [Default: (null)]

- passno
        Passno (see fstab(5)). Note that if set to `null' and `state' set to `present',
        it will cease to work and duplicate entries will be made with subsequent runs.
        Deprecated on Solaris systems.
        [Default: 0]

= path
        Path to the mount point (e.g. `/mnt/files').
        Before 2.3 this option was only usable as `dest', `destfile' and `name'.
        (Aliases: name)

- src
        Device to be mounted on `path'. Required when `state' set to `present' or
        `mounted'.
        [Default: (null)]

= state
        If `mounted', the device will be actively mounted and appropriately configured
        in `fstab'. If the mount point is not present, the mount point will be created.
        If `unmounted', the device will be unmounted without changing `fstab'.
        `present' only specifies that the device is to be configured in `fstab' and does
        not trigger or require a mount.
        `absent' specifies that the device mount's entry will be removed from `fstab'
        and will also unmount the device and remove the mount point.
        (Choices: absent, mounted, present, unmounted)


NOTES:
      * As of Ansible 2.3, the `name' option has been changed to `path' as
        default, but `name' still works as well.

AUTHOR: Ansible Core Team, Seth Vidal (@skvidal)
        METADATA:
          status:
          - preview
          supported_by: core
        

EXAMPLES:
# 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

参数解释

  • backup
    默认值:no
    类型:bool
    修改之前备份配置文件

  • boot
    默认值:no
    类型:bool
    决定文件系统是否挂载在 boot

  • dump
    默认值:0

  • fatab
    默认值: /etc/fastab

  • fstype
    默认值:null
    statepresentmounted时,可设置文件系统类型

  • opts
    默认值:null
    挂载点

  • passno
    默认值:0

= path
别名:name
挂载点路径

  • src
    statepresentmounted时,可配置设备挂载在哪个路径上

= state
选项:absent, mounted, present, unmounted

posted @ 2018-12-06 14:57  McSiberiaWolf  阅读(1040)  评论(0编辑  收藏  举报