Skip to content

Commit cb88cba

Browse files
author
satken2
committed
Add umask option for mount module
1 parent 7abf9d4 commit cb88cba

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

plugins/modules/mount.py

+1
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ def main():
804804

805805
dirs_created = []
806806
if not os.path.exists(name) and not module.check_mode:
807+
old_umask = None
807808
if umask is not None:
808809
if not isinstance(umask, int):
809810
try:

tests/integration/targets/mount/tasks/main.yml

+24-4
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,24 @@
343343
file:
344344
state: directory
345345
path: /tmp/mount_source
346-
- name: Bind mount a filesystem (Linux)
346+
- name: Bind mount a filesystem with umask
347347
mount:
348348
src: /tmp/mount_source
349-
name: /tmp/mount_dest
349+
path: /tmp/mount_dest
350350
state: mounted
351351
fstype: None
352352
opts: bind
353353
umask: 0777
354+
when: ansible_system != 'FreeBSD'
355+
- name: Bind mount a filesystem with umask(FreeBSD)
356+
mount:
357+
src: /tmp/mount_source
358+
path: /tmp/mount_dest
359+
state: mounted
360+
fstype: nullfs
361+
opts: bind
362+
umask: 0777
363+
when: ansible_system == 'FreeBSD'
354364
- name: Unmount FS to access underlying directory
355365
command: |
356366
umount /tmp/mount_dest
@@ -366,14 +376,24 @@
366376
file:
367377
path: /tmp/mount_dest
368378
state: absent
369-
- name: Mount the FS to non existent directory with string umask
379+
- name: Bind mount a filesystem with string umask
370380
mount:
371381
src: /tmp/mount_source
372-
name: /tmp/mount_dest
382+
path: /tmp/mount_dest
373383
state: mounted
374384
fstype: None
375385
opts: bind
376386
umask: "0777"
387+
when: ansible_system != 'FreeBSD'
388+
- name: Bind mount a filesystem with string umask(FreeBSD)
389+
mount:
390+
src: /tmp/mount_source
391+
path: /tmp/mount_dest
392+
state: mounted
393+
fstype: nullfs
394+
opts: bind
395+
umask: "0777"
396+
when: ansible_system == 'FreeBSD'
377397
- name: Unmount FS to access underlying directory
378398
command: |
379399
umount /tmp/mount_dest

0 commit comments

Comments
 (0)