diff options
author | Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org> | 2014-07-21 18:32:02 +0200 |
---|---|---|
committer | Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org> | 2014-07-21 18:32:02 +0200 |
commit | 48128ec0ab442546d1058b0fea8523401823986a (patch) | |
tree | 63ba9bc8ccb936104301ac2923cd76c25f70ad96 /library/system/mount | |
parent | f2e2337d07aa8d2acb65be3fffb949d819ac6a3d (diff) | |
download | ansible-48128ec0ab442546d1058b0fea8523401823986a.tar.gz |
[mount] make sure fstab exists
This is mainly to prevent from failing with no such file or directory
during module execution.
Diffstat (limited to 'library/system/mount')
-rwxr-xr-x | library/system/mount | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/library/system/mount b/library/system/mount index db85f97211..9d5cdd8b06 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 |