ansible.posix/tests/integration/targets/mount/tasks/remount.yml
quidame eafd8f8935 feature: mount - implement swapon/swapoff (#106)
* Declare functions swapon() & swapoff(), is_swap() & reswap().
* Apply swapon/swapoff for states mounted, unmounted, remounted and
  absent.
* Override default opts and boot when fstype=swap.
* Do not honor 'fstab' when fstype=swap (fail instead).
* Also fail when fstype=swap and 'path' is not 'none' ('-' for Solaris).
* Update module documentation accordingly.
+ Replace all platform.system() calls by a variable.

refactor integration tests

* Improve readability/understanding of what is tested, and what OS is
  targeted.
* Move 'swap' related test cases into dedicated file (swap.yml).
* Add new test cases about swap enabling/disabling.
* Extend tests to FreeBSD when possible.
2021-03-28 01:21:08 +01:00

65 lines
1.5 KiB
YAML

---
# Tasks to validate state=remounted behaves as expected.
# Linux only.
- name: Create empty file
command:
cmd: "dd if=/dev/zero of=/tmp/myfs.img bs=1048576 count=20"
- name: Format FS
community.general.filesystem:
fstype: ext3
dev: /tmp/myfs.img
- name: Mount the FS for the first time
mount:
path: /tmp/myfs
src: /tmp/myfs.img
fstype: ext3
state: mounted
- name: Get the mount counter value
shell:
cmd: "dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i '^mount count:'"
changed_when: false
register: mount_count1
- name: Get the current mount as exposed in /proc/mounts
command:
cmd: "grep /tmp/myfs /proc/mounts"
changed_when: false
register: proc_mounts1
- name: Remount the filesystem
mount:
path: /tmp/myfs
opts: nosuid
state: remounted
- name: Get again the mount counter value
shell:
cmd: "dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i '^mount count:'"
changed_when: false
register: mount_count2
- name: Get again the current mount as exposed in /proc/mounts
command:
cmd: "grep /tmp/myfs /proc/mounts"
changed_when: false
register: proc_mounts2
- name: Assert that mount has changed despite its counter has not
assert:
that:
- mount_count1.stdout == mount_count2.stdout
- proc_mounts1.stdout != proc_mounts2.stdout
- name: Unmount the FS
mount:
path: /tmp/myfs
state: absent
- name: Remove disk image
file:
path: /tmp/myfs.img
state: absent