|
335 | 335 |
|
336 | 336 | - name: Block to test umask option
|
337 | 337 | block:
|
338 |
| - - name: Create empty file |
339 |
| - community.general.filesize: |
340 |
| - path: /tmp/myfs2.img |
341 |
| - size: 20M |
342 |
| - - name: Format FS |
343 |
| - community.general.filesystem: |
344 |
| - fstype: ext2 |
345 |
| - dev: /tmp/myfs2.img |
346 | 338 | - name: Make sure that mount point does not exist
|
347 | 339 | file:
|
348 |
| - path: /tmp/myfs2_mountpoint |
| 340 | + path: /tmp/mount_dest |
349 | 341 | state: absent
|
350 |
| - - name: Mount the FS to non existent directory with raw umask |
| 342 | + - name: Create a directory to bind mount |
| 343 | + file: |
| 344 | + state: directory |
| 345 | + path: /tmp/mount_source |
| 346 | + - name: Bind mount a filesystem (Linux) |
351 | 347 | mount:
|
352 |
| - path: /tmp/myfs2_mountpoint |
353 |
| - src: /tmp/myfs2.img |
354 |
| - fstype: ext2 |
| 348 | + src: /tmp/mount_source |
| 349 | + name: /tmp/mount_dest |
355 | 350 | state: mounted
|
| 351 | + fstype: None |
| 352 | + opts: bind |
356 | 353 | umask: 0777
|
357 | 354 | - name: Unmount FS to access underlying directory
|
358 | 355 | command: |
|
359 |
| - umount /tmp/myfs2.img |
| 356 | + umount /tmp/mount_dest |
360 | 357 | - name: Stat mount point directory
|
361 | 358 | stat:
|
362 |
| - path: /tmp/myfs2_mountpoint |
| 359 | + path: /tmp/mount_dest |
363 | 360 | register: mount_point_stat
|
364 | 361 | - name: Assert that the mount point has right permission
|
365 | 362 | assert:
|
366 | 363 | that:
|
367 | 364 | - mount_point_stat['stat']['mode'] == '0000'
|
368 | 365 | - name: Cleanup directory
|
369 | 366 | file:
|
370 |
| - path: /tmp/myfs2_mountpoint |
| 367 | + path: /tmp/mount_dest |
371 | 368 | state: absent
|
372 | 369 | - name: Mount the FS to non existent directory with string umask
|
373 | 370 | mount:
|
374 |
| - path: /tmp/myfs2_mountpoint |
375 |
| - src: /tmp/myfs2.img |
376 |
| - fstype: ext2 |
| 371 | + src: /tmp/mount_source |
| 372 | + name: /tmp/mount_dest |
377 | 373 | state: mounted
|
| 374 | + fstype: None |
| 375 | + opts: bind |
378 | 376 | umask: "0777"
|
379 | 377 | - name: Unmount FS to access underlying directory
|
380 | 378 | command: |
|
381 |
| - umount /tmp/myfs2.img |
| 379 | + umount /tmp/mount_dest |
382 | 380 | - name: Stat mount point directory
|
383 | 381 | stat:
|
384 |
| - path: /tmp/myfs2_mountpoint |
| 382 | + path: /tmp/mount_dest |
385 | 383 | register: mount_point_stat
|
386 | 384 | - name: Assert that the mount point has right permission
|
387 | 385 | assert:
|
388 | 386 | that:
|
389 | 387 | - mount_point_stat['stat']['mode'] == '0000'
|
390 |
| - - name: Cleanup directory |
391 |
| - file: |
392 |
| - path: /tmp/myfs2_mountpoint |
393 |
| - state: absent |
394 |
| - - name: Remount the FS to non existent directory with symbolic umask expression |
395 |
| - mount: |
396 |
| - path: /tmp/myfs2_mountpoint |
397 |
| - src: /tmp/myfs2.img |
398 |
| - fstype: ext2 |
399 |
| - state: mounted |
400 |
| - umask: "u+rw,g-wx,o-rwx" |
401 |
| - - name: Unmount FS to access underlying directory |
402 |
| - command: | |
403 |
| - umount /tmp/myfs2.img |
404 |
| - - name: Stat mount point directory |
405 |
| - stat: |
406 |
| - path: /tmp/myfs2_mountpoint |
407 |
| - register: mount_point_stat |
408 |
| - - name: Assert that the mount point has right permission |
409 |
| - assert: |
410 |
| - that: |
411 |
| - - mount_point_stat['stat']['mode'] == '0640' |
412 |
| - - name: Cleanup directory |
413 |
| - file: |
414 |
| - path: /tmp/myfs2_mountpoint |
415 |
| - state: absent |
416 |
| - - name: Remount the FS to non existent directory with symbolic umask expression |
417 |
| - mount: |
418 |
| - path: /tmp/myfs2_mountpoint |
419 |
| - src: /tmp/myfs2.img |
420 |
| - fstype: ext2 |
421 |
| - state: mounted |
422 |
| - umask: "u=rw,g=r,o=r" |
423 |
| - - name: Unmount FS to access underlying directory |
424 |
| - command: | |
425 |
| - umount /tmp/myfs2.img |
426 |
| - - name: Stat mount point directory |
427 |
| - stat: |
428 |
| - path: /tmp/myfs2_mountpoint |
429 |
| - register: mount_point_stat |
430 |
| - - name: Assert that the mount point has right permission |
431 |
| - assert: |
432 |
| - that: |
433 |
| - - mount_point_stat['stat']['mode'] == '0644' |
434 | 388 | - name: Remove the test FS
|
435 | 389 | file:
|
436 |
| - path: '{{ item }}' |
| 390 | + path: /tmp/mount_dest |
437 | 391 | state: absent
|
438 |
| - loop: |
439 |
| - - /tmp/myfs2.img |
440 |
| - - /tmp/myfs2_mountpoint |
0 commit comments