mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-11 16:44:22 -07:00
Merge pull request #8223 from renard/create-fstab-if-not-exists
Create fstab if not exists
This commit is contained in:
commit
593057515c
1 changed files with 15 additions and 1 deletions
16
library/system/mount
Normal file → Executable file
16
library/system/mount
Normal file → Executable file
|
@ -69,7 +69,14 @@ options:
|
||||||
required: true
|
required: true
|
||||||
choices: [ "present", "absent", "mounted", "unmounted" ]
|
choices: [ "present", "absent", "mounted", "unmounted" ]
|
||||||
default: null
|
default: null
|
||||||
|
fstab:
|
||||||
|
description:
|
||||||
|
- file to use instead of C(/etc/fstab). You shouldn't use that option
|
||||||
|
unless you really know what you are doing. This might be useful if
|
||||||
|
you need to configure mountpoints in a chroot environment.
|
||||||
|
required: false
|
||||||
|
default: /etc/fstab
|
||||||
|
|
||||||
notes: []
|
notes: []
|
||||||
requirements: []
|
requirements: []
|
||||||
author: Seth Vidal
|
author: Seth Vidal
|
||||||
|
@ -260,6 +267,13 @@ def main():
|
||||||
if module.params['fstab'] is not None:
|
if module.params['fstab'] is not None:
|
||||||
args['fstab'] = module.params['fstab']
|
args['fstab'] = module.params['fstab']
|
||||||
|
|
||||||
|
# if fstab file does not exist, we first need to create it. This mainly
|
||||||
|
# happens when fstab optin is passed to the module.
|
||||||
|
if not os.path.exists(args['fstab']):
|
||||||
|
if not os.path.exists(os.path.dirname(args['fstab'])):
|
||||||
|
os.makedirs(os.path.dirname(args['fstab']))
|
||||||
|
open(args['fstab'],'a').close()
|
||||||
|
|
||||||
# absent == remove from fstab and unmounted
|
# absent == remove from fstab and unmounted
|
||||||
# unmounted == do not change fstab state, but unmount
|
# unmounted == do not change fstab state, but unmount
|
||||||
# present == add to fstab, do not change mount state
|
# present == add to fstab, do not change mount state
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue