From f2e2337d07aa8d2acb65be3fffb949d819ac6a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gross?= Date: Mon, 21 Jul 2014 18:30:59 +0200 Subject: [PATCH 1/2] [mount] Add documentation for fstab option --- library/system/mount | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 library/system/mount diff --git a/library/system/mount b/library/system/mount old mode 100644 new mode 100755 index a2e0dc84171..db85f972110 --- a/library/system/mount +++ b/library/system/mount @@ -69,7 +69,14 @@ options: required: true choices: [ "present", "absent", "mounted", "unmounted" ] 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: [] requirements: [] author: Seth Vidal From 48128ec0ab442546d1058b0fea8523401823986a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gross?= Date: Mon, 21 Jul 2014 18:32:02 +0200 Subject: [PATCH 2/2] [mount] make sure fstab exists This is mainly to prevent from failing with no such file or directory during module execution. --- library/system/mount | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/system/mount b/library/system/mount index db85f972110..9d5cdd8b06b 100755 --- a/library/system/mount +++ b/library/system/mount @@ -267,6 +267,13 @@ def main(): if module.params['fstab'] is not None: 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 # unmounted == do not change fstab state, but unmount # present == add to fstab, do not change mount state