mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 15:15:26 +01:00
Update main.yml
This commit is contained in:
parent
6d51660be4
commit
23fadc9f02
1 changed files with 22 additions and 0 deletions
|
|
@ -1,3 +1,10 @@
|
|||
- name: System details
|
||||
debug: msg="{{ item }}"
|
||||
with_items:
|
||||
- "{{ ansible_distribution }}"
|
||||
- "{{ ansible_system }}"
|
||||
|
||||
|
||||
- name: Create the mount point
|
||||
file:
|
||||
state: directory
|
||||
|
|
@ -272,36 +279,48 @@
|
|||
src: /tmp/myfs.img
|
||||
fstype: ext2
|
||||
state: mounted
|
||||
|
||||
- name: Get the last write time
|
||||
shell: 'dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i last write time: |cut -d: -f2-'
|
||||
register: last_write_time
|
||||
|
||||
- name: Wait 2 second
|
||||
pause:
|
||||
seconds: 2
|
||||
|
||||
- name: Test if the FS is remounted
|
||||
mount:
|
||||
path: /tmp/myfs
|
||||
state: remounted
|
||||
|
||||
- name: Get again the last write time
|
||||
shell: 'dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i last write time: |cut -d: -f2-'
|
||||
register: last_write_time2
|
||||
|
||||
- name: Fail if they are the same
|
||||
fail:
|
||||
msg: Filesytem was not remounted, testing of the module failed!
|
||||
when: last_write is defined and last_write_time2 is defined and last_write_time.stdout == last_write_time2.stdout
|
||||
|
||||
- name: Remount filesystem with different opts using remounted option (Linux only)
|
||||
mount:
|
||||
path: /tmp/myfs
|
||||
state: remounted
|
||||
opts: rw,noexec
|
||||
when: ansible_system == 'Linux'
|
||||
|
||||
- name: Get remounted options (Linux only)
|
||||
shell: mount | grep myfs | grep -E -w 'noexec' | wc -l
|
||||
register: remounted_options
|
||||
when: ansible_system == 'Linux'
|
||||
|
||||
- name: Make sure the filesystem now has the new opts after using remounted (Linux only)
|
||||
assert:
|
||||
that:
|
||||
- "'1' in remounted_options.stdout"
|
||||
- "1 == remounted_options.stdout_lines | length"
|
||||
when: ansible_system == 'Linux'
|
||||
|
||||
- name: Mount the FS again to test backup
|
||||
mount:
|
||||
path: /tmp/myfs
|
||||
|
|
@ -310,10 +329,12 @@
|
|||
state: mounted
|
||||
backup: yes
|
||||
register: mount_backup_out
|
||||
|
||||
- name: ensure backup_file in returned output
|
||||
assert:
|
||||
that:
|
||||
- "'backup_file' in mount_backup_out"
|
||||
|
||||
always:
|
||||
- name: Umount the test FS
|
||||
mount:
|
||||
|
|
@ -321,6 +342,7 @@
|
|||
src: /tmp/myfs.img
|
||||
opts: loop
|
||||
state: absent
|
||||
|
||||
- name: Remove the test FS
|
||||
file:
|
||||
path: '{{ item }}'
|
||||
|
|
|
|||
Loading…
Reference in a new issue