mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-12 07:35:31 +01:00
2022-05-26-00
This commit is contained in:
parent
0c1953d313
commit
4dc6df2cd9
1 changed files with 164 additions and 164 deletions
|
|
@ -242,167 +242,167 @@
|
||||||
# - optional_fields_update['changed']
|
# - optional_fields_update['changed']
|
||||||
# - ''' 0 0'' in optional_fields_content.stdout'
|
# - ''' 0 0'' in optional_fields_content.stdout'
|
||||||
# - 1 == optional_fields_content.stdout_lines | length
|
# - 1 == optional_fields_content.stdout_lines | length
|
||||||
|
#
|
||||||
- name: Create empty file
|
# - name: Create empty file
|
||||||
community.general.filesize:
|
# community.general.filesize:
|
||||||
path: /tmp/myfs.img
|
# path: /tmp/myfs.img
|
||||||
size: 20M
|
# size: 20
|
||||||
|
#
|
||||||
- name: Format FS
|
# - name: Format FS
|
||||||
community.general.filesystem:
|
# community.general.filesystem:
|
||||||
fstype: ext3
|
# fstype: ext3
|
||||||
dev: /tmp/myfs.img
|
# dev: /tmp/myfs.img
|
||||||
|
#
|
||||||
- name: Mount the FS for the first time
|
# - name: Mount the FS for the first time
|
||||||
mount:
|
# mount:
|
||||||
path: /tmp/myfs
|
# path: /tmp/myfs
|
||||||
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
|
||||||
|
#
|
||||||
- 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
|
||||||
|
#
|
||||||
- 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"
|
||||||
|
#
|
||||||
- name: Mount the FS again to test backup
|
# - name: Mount the FS again to test backup
|
||||||
mount:
|
# mount:
|
||||||
path: /tmp/myfs
|
# path: /tmp/myfs
|
||||||
src: /tmp/myfs.img
|
# src: /tmp/myfs.img
|
||||||
fstype: ext2
|
# fstype: ext2
|
||||||
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:
|
||||||
path: /tmp/myfs
|
# path: /tmp/myfs
|
||||||
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 }}'
|
||||||
state: absent
|
# state: absent
|
||||||
loop:
|
# loop:
|
||||||
- /tmp/myfs.img
|
# - /tmp/myfs.img
|
||||||
- /tmp/myfs
|
# - /tmp/myfs
|
||||||
when: ansible_system in ('Linux')
|
# when: ansible_system in ('Linux')
|
||||||
|
#
|
||||||
- name: Block to test boot option for Linux
|
#- name: Block to test boot option for Linux
|
||||||
block:
|
# block:
|
||||||
- name: Create empty file
|
# - name: Create empty file
|
||||||
community.general.filesize:
|
# community.general.filesize:
|
||||||
path: /tmp/myfs.img
|
# path: /tmp/myfs.img
|
||||||
size: 20M
|
# size: 20M
|
||||||
|
#
|
||||||
- name: Format FS
|
# - name: Format FS
|
||||||
community.general.filesystem:
|
# community.general.filesystem:
|
||||||
fstype: ext3
|
# fstype: ext3
|
||||||
dev: /tmp/myfs.img
|
# dev: /tmp/myfs.img
|
||||||
|
#
|
||||||
- name: Mount the FS with noauto option
|
# - name: Mount the FS with noauto option
|
||||||
mount:
|
# mount:
|
||||||
path: /tmp/myfs
|
# path: /tmp/myfs
|
||||||
src: /tmp/myfs.img
|
# src: /tmp/myfs.img
|
||||||
fstype: ext3
|
# fstype: ext3
|
||||||
state: mounted
|
# state: mounted
|
||||||
boot: no
|
# boot: no
|
||||||
opts: rw,user,async
|
# opts: rw,user,async
|
||||||
register: mount_info
|
# register: mount_info
|
||||||
|
#
|
||||||
- name: assert the mount without noauto was successful
|
# - name: assert the mount without noauto was successful
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- mount_info['opts'] == 'rw,user,async,noauto'
|
# - mount_info['opts'] == 'rw,user,async,noauto'
|
||||||
|
#
|
||||||
- name: Unmount FS
|
# - name: Unmount FS
|
||||||
mount:
|
# mount:
|
||||||
path: /tmp/myfs
|
# path: /tmp/myfs
|
||||||
state: absent
|
# state: absent
|
||||||
|
#
|
||||||
- name: Remove the test FS
|
# - name: Remove the test FS
|
||||||
file:
|
# file:
|
||||||
path: '{{ item }}'
|
# path: '{{ item }}'
|
||||||
state: absent
|
# state: absent
|
||||||
loop:
|
# loop:
|
||||||
- /tmp/myfs.img
|
# - /tmp/myfs.img
|
||||||
- /tmp/myfs
|
# - /tmp/myfs
|
||||||
when: ansible_system in ('Linux')
|
# when: ansible_system in ('Linux')
|
||||||
|
#
|
||||||
- name: Block to test missing newline at the EOF of fstab
|
#- name: Block to test missing newline at the EOF of fstab
|
||||||
block:
|
# block:
|
||||||
- name: Create empty file
|
# - name: Create empty file
|
||||||
community.general.filesize:
|
# community.general.filesize:
|
||||||
path: /tmp/myfs1.img
|
# path: /tmp/myfs1.img
|
||||||
size: 20M
|
# size: 20M
|
||||||
- name: Format FS
|
# - name: Format FS
|
||||||
community.general.filesystem:
|
# community.general.filesystem:
|
||||||
fstype: ext3
|
# fstype: ext3
|
||||||
dev: /tmp/myfs1.img
|
# dev: /tmp/myfs1.img
|
||||||
- name: Create custom fstab file without newline
|
# - name: Create custom fstab file without newline
|
||||||
copy:
|
# copy:
|
||||||
content: '#TEST COMMENT WITHOUT NEWLINE'
|
# content: '#TEST COMMENT WITHOUT NEWLINE'
|
||||||
dest: /tmp/test_fstab
|
# dest: /tmp/test_fstab
|
||||||
- name: Mount the FS using the custom fstab
|
# - name: Mount the FS using the custom fstab
|
||||||
mount:
|
# mount:
|
||||||
path: /tmp/myfs1
|
# path: /tmp/myfs1
|
||||||
src: /tmp/myfs1.img
|
# src: /tmp/myfs1.img
|
||||||
fstype: ext3
|
# fstype: ext3
|
||||||
state: mounted
|
# state: mounted
|
||||||
opts: defaults
|
# opts: defaults
|
||||||
fstab: /tmp/test_fstab
|
# fstab: /tmp/test_fstab
|
||||||
- name: Unmount the mount point in the custom fstab
|
# - name: Unmount the mount point in the custom fstab
|
||||||
mount:
|
# mount:
|
||||||
path: /tmp/myfs1
|
# path: /tmp/myfs1
|
||||||
state: absent
|
# state: absent
|
||||||
fstab: /tmp/test_fstab
|
# fstab: /tmp/test_fstab
|
||||||
- name: Remove the test FS and the custom fstab
|
# - name: Remove the test FS and the custom fstab
|
||||||
file:
|
# file:
|
||||||
path: '{{ item }}'
|
# path: '{{ item }}'
|
||||||
state: absent
|
# state: absent
|
||||||
loop:
|
# loop:
|
||||||
- /tmp/myfs1.img
|
# - /tmp/myfs1.img
|
||||||
- /tmp/myfs1
|
# - /tmp/myfs1
|
||||||
- /tmp/test_fstab
|
# - /tmp/test_fstab
|
||||||
when: ansible_system in ('Linux')
|
# when: ansible_system in ('Linux')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue