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
|
- name: Create the mount point
|
||||||
file:
|
file:
|
||||||
state: directory
|
state: directory
|
||||||
|
|
@ -272,36 +279,48 @@
|
||||||
src: /tmp/myfs.img
|
src: /tmp/myfs.img
|
||||||
fstype: ext2
|
fstype: ext2
|
||||||
state: mounted
|
state: mounted
|
||||||
|
|
||||||
- name: Get the last write time
|
- name: Get the last write time
|
||||||
shell: 'dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i last write time: |cut -d: -f2-'
|
shell: 'dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i last write time: |cut -d: -f2-'
|
||||||
register: last_write_time
|
register: last_write_time
|
||||||
|
|
||||||
- name: Wait 2 second
|
- name: Wait 2 second
|
||||||
pause:
|
pause:
|
||||||
seconds: 2
|
seconds: 2
|
||||||
|
|
||||||
- name: Test if the FS is remounted
|
- name: Test if the FS is remounted
|
||||||
mount:
|
mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
state: remounted
|
state: remounted
|
||||||
|
|
||||||
- name: Get again the last write time
|
- name: Get again the last write time
|
||||||
shell: 'dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i last write time: |cut -d: -f2-'
|
shell: 'dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i last write time: |cut -d: -f2-'
|
||||||
register: last_write_time2
|
register: last_write_time2
|
||||||
|
|
||||||
- name: Fail if they are the same
|
- name: Fail if they are the same
|
||||||
fail:
|
fail:
|
||||||
msg: Filesytem was not remounted, testing of the module failed!
|
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
|
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)
|
- name: Remount filesystem with different opts using remounted option (Linux only)
|
||||||
mount:
|
mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
state: remounted
|
state: remounted
|
||||||
opts: rw,noexec
|
opts: rw,noexec
|
||||||
|
when: ansible_system == 'Linux'
|
||||||
|
|
||||||
- name: Get remounted options (Linux only)
|
- name: Get remounted options (Linux only)
|
||||||
shell: mount | grep myfs | grep -E -w 'noexec' | wc -l
|
shell: mount | grep myfs | grep -E -w 'noexec' | wc -l
|
||||||
register: remounted_options
|
register: remounted_options
|
||||||
|
when: ansible_system == 'Linux'
|
||||||
|
|
||||||
- name: Make sure the filesystem now has the new opts after using remounted (Linux only)
|
- name: Make sure the filesystem now has the new opts after using remounted (Linux only)
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'1' in remounted_options.stdout"
|
- "'1' in remounted_options.stdout"
|
||||||
- "1 == remounted_options.stdout_lines | length"
|
- "1 == remounted_options.stdout_lines | length"
|
||||||
|
when: ansible_system == 'Linux'
|
||||||
|
|
||||||
- name: Mount the FS again to test backup
|
- name: Mount the FS again to test backup
|
||||||
mount:
|
mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
|
|
@ -310,10 +329,12 @@
|
||||||
state: mounted
|
state: mounted
|
||||||
backup: yes
|
backup: yes
|
||||||
register: mount_backup_out
|
register: mount_backup_out
|
||||||
|
|
||||||
- name: ensure backup_file in returned output
|
- name: ensure backup_file in returned output
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'backup_file' in mount_backup_out"
|
- "'backup_file' in mount_backup_out"
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Umount the test FS
|
- name: Umount the test FS
|
||||||
mount:
|
mount:
|
||||||
|
|
@ -321,6 +342,7 @@
|
||||||
src: /tmp/myfs.img
|
src: /tmp/myfs.img
|
||||||
opts: loop
|
opts: loop
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Remove the test FS
|
- name: Remove the test FS
|
||||||
file:
|
file:
|
||||||
path: '{{ item }}'
|
path: '{{ item }}'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue