Mount Overview
Mount Overview
Mount refers to the process of making a filesystem or device available for use at a specified location, known as the mount point. The module can perform actions such as mounting, unmounting, and listing mounted filesystems. It supports various options like specifying the directory path to mount/unmount
directory/filesystem/device
/etc/filesystems
Mount Function
The mount
The mount
read-only
def mount(module):
"""
Mount the specified device/filesystem
arguments:
module (dict): Ansible module argument spec.
note:
Exits with fail_json in case of error
return:
none
"""
cmd = "/usr/sbin/mount "
alternate_fs = module.params['alternate_fs']
if alternate_fs:
cmd += f"-F {alternate_fs} "
if module.params['removable_fs']:
cmd += "-p "
if module.params['read_only']:
cmd += "-r "
vfsname = module.params['vfsname']
if vfsname:
Unmount Function
The umount
The umount
def umount(module):
"""
Unmount the specified device/filesystem
arguments:
module (dict): Ansible module argument spec.
note:
Exits with fail_json in case of error
return:
none
"""
mount_all = module.params['mount_all']
fs_type = module.params['fs_type']
mount_over_dir = module.params['mount_over_dir']
node = module.params['node']
force = module.params['force']
cmd = "/usr/sbin/umount "
if force:
cmd += "-f "
if fs_type:
List Mounted Filesystems
The fs_list
The fs_list
def fs_list(module):
"""
List mounted filesystems
arguments:
module (dict): Ansible module argument spec.
note:
Exits with fail_json in case of error
return:
none
"""
cmd = "/usr/sbin/mount"
rc, stdout, stderr = module.run_command(cmd)
result['cmd'] = cmd
result['rc'] = rc
result['stdout'] = stdout
result['stderr'] = stderr
if rc != 0:
result['msg'] = "Failed to list mounted filesystems."
module.fail_json(**result)
Usage Example
Examples of how to use the mount module to list, mount, and unmount filesystems.
This section provides examples of using the mount module to list mounted filesystems, mount filesystems, and mount filesystems provided by a node.
EXAMPLES = r'''
- name: List mounted filesystems
ibm.power_aix.mount:
state: show
- name: Mount filesystems
ibm.power_aix.mount:
state: mount
mount_dir: /mnt/tesfs
- name: Mount filesystems provided by a node
ibm.power_aix.mount:
state: mount
node: ansible-test1
mount_dir: /mnt/servnfs
mount_over_dir: /mnt/clientnfs
options: "vers=4"
- name: Mount all filesystems from the 'local' mount group
ibm.power_aix.mount:
state: mount
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human