mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-12 23:55:19 +01:00
fix intendation mess up
Signed-off-by: Adam Miller <admiller@redhat.com>
This commit is contained in:
parent
8b53cf594e
commit
1138e6132a
1 changed files with 148 additions and 148 deletions
|
|
@ -516,182 +516,182 @@
|
|||
ephemeral_fstab: /etc/fstab
|
||||
when: ansible_system == 'OpenBSD'
|
||||
|
||||
##### FORMAT FS ON LINUX
|
||||
##### FORMAT FS ON LINUX
|
||||
|
||||
- name: Block to format FS on Linux
|
||||
when: ansible_system == 'Linux'
|
||||
block:
|
||||
- name: Format FS A on Linux
|
||||
community.general.filesystem:
|
||||
fstype: ext3
|
||||
dev: /tmp/myfs_A.img
|
||||
- name: Block to format FS on Linux
|
||||
when: ansible_system == 'Linux'
|
||||
block:
|
||||
- name: Format FS A on Linux
|
||||
community.general.filesystem:
|
||||
fstype: ext3
|
||||
dev: /tmp/myfs_A.img
|
||||
|
||||
- name: Format FS B on Linux
|
||||
community.general.filesystem:
|
||||
fstype: ext3
|
||||
dev: /tmp/myfs_B.img
|
||||
- name: Format FS B on Linux
|
||||
community.general.filesystem:
|
||||
fstype: ext3
|
||||
dev: /tmp/myfs_B.img
|
||||
|
||||
##### FORMAT FS ON SOLARIS AND BSD
|
||||
##### FORMAT FS ON SOLARIS AND BSD
|
||||
|
||||
- name: Create loop devices on Solaris and BSD
|
||||
ansible.builtin.command: "{{ ephemeral_create_loop_dev_cmd }}"
|
||||
changed_when: true
|
||||
when: ephemeral_create_loop_dev_cmd is defined
|
||||
- name: Create loop devices on Solaris and BSD
|
||||
ansible.builtin.command: "{{ ephemeral_create_loop_dev_cmd }}"
|
||||
changed_when: true
|
||||
when: ephemeral_create_loop_dev_cmd is defined
|
||||
|
||||
- name: Format FS A and B on Solaris and BSD
|
||||
ansible.builtin.command: "{{ ephemeral_format_fs_cmd }}"
|
||||
changed_when: true
|
||||
when: ephemeral_format_fs_cmd is defined
|
||||
- name: Format FS A and B on Solaris and BSD
|
||||
ansible.builtin.command: "{{ ephemeral_format_fs_cmd }}"
|
||||
changed_when: true
|
||||
when: ephemeral_format_fs_cmd is defined
|
||||
|
||||
##### TESTS
|
||||
##### TESTS
|
||||
|
||||
- name: Create fstab if it does not exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ ephemeral_fstab }}"
|
||||
state: touch
|
||||
mode: "0644"
|
||||
- name: Create fstab if it does not exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ ephemeral_fstab }}"
|
||||
state: touch
|
||||
mode: "0644"
|
||||
|
||||
- name: Get checksum of /etc/fstab before mounting anything
|
||||
ansible.builtin.stat:
|
||||
path: "{{ ephemeral_fstab }}"
|
||||
register: fstab_stat_before_mount
|
||||
- name: Get checksum of /etc/fstab before mounting anything
|
||||
ansible.builtin.stat:
|
||||
path: "{{ ephemeral_fstab }}"
|
||||
register: fstab_stat_before_mount
|
||||
|
||||
- name: Mount the FS A with ephemeral state
|
||||
ansible.posix.mount:
|
||||
path: /tmp/myfs
|
||||
src: "{{ ephemeral_device_a }}"
|
||||
fstype: "{{ ephemeral_fstype }}"
|
||||
opts: rw
|
||||
state: ephemeral
|
||||
register: ephemeral_mount_info
|
||||
- name: Mount the FS A with ephemeral state
|
||||
ansible.posix.mount:
|
||||
path: /tmp/myfs
|
||||
src: "{{ ephemeral_device_a }}"
|
||||
fstype: "{{ ephemeral_fstype }}"
|
||||
opts: rw
|
||||
state: ephemeral
|
||||
register: ephemeral_mount_info
|
||||
|
||||
- name: Put something in the directory so we can do additional checks later on
|
||||
ansible.builtin.copy:
|
||||
content: Testing
|
||||
dest: /tmp/myfs/test_file
|
||||
mode: "0644"
|
||||
- name: Put something in the directory so we can do additional checks later on
|
||||
ansible.builtin.copy:
|
||||
content: Testing
|
||||
dest: /tmp/myfs/test_file
|
||||
mode: "0644"
|
||||
|
||||
- name: Get checksum of /etc/fstab after an ephemeral mount
|
||||
ansible.builtin.stat:
|
||||
path: "{{ ephemeral_fstab }}"
|
||||
register: fstab_stat_after_mount
|
||||
- name: Get checksum of /etc/fstab after an ephemeral mount
|
||||
ansible.builtin.stat:
|
||||
path: "{{ ephemeral_fstab }}"
|
||||
register: fstab_stat_after_mount
|
||||
|
||||
- name: Get mountinfo
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
||||
executable: /bin/bash
|
||||
register: check_mountinfo
|
||||
changed_when: false
|
||||
- name: Get mountinfo
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
||||
executable: /bin/bash
|
||||
register: check_mountinfo
|
||||
changed_when: false
|
||||
|
||||
- name: Assert the mount occured and the fstab is unchanged
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- check_mountinfo.stdout|int == 1
|
||||
- ephemeral_mount_info['changed']
|
||||
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_mount['stat']['checksum']
|
||||
- name: Assert the mount occured and the fstab is unchanged
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- check_mountinfo.stdout|int == 1
|
||||
- ephemeral_mount_info['changed']
|
||||
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_mount['stat']['checksum']
|
||||
|
||||
- name: Get first mount record
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | grep '/tmp/myfs'
|
||||
executable: /bin/bash
|
||||
register: ephemeral_mount_record_1
|
||||
changed_when: false
|
||||
- name: Get first mount record
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | grep '/tmp/myfs'
|
||||
executable: /bin/bash
|
||||
register: ephemeral_mount_record_1
|
||||
changed_when: false
|
||||
|
||||
- name: Try to mount FS A where FS A is already mounted (should trigger remount and changed)
|
||||
ansible.posix.mount:
|
||||
path: /tmp/myfs
|
||||
src: "{{ ephemeral_device_a }}"
|
||||
fstype: "{{ ephemeral_fstype }}"
|
||||
opts: ro
|
||||
state: ephemeral
|
||||
register: ephemeral_mount_info
|
||||
- name: Try to mount FS A where FS A is already mounted (should trigger remount and changed)
|
||||
ansible.posix.mount:
|
||||
path: /tmp/myfs
|
||||
src: "{{ ephemeral_device_a }}"
|
||||
fstype: "{{ ephemeral_fstype }}"
|
||||
opts: ro
|
||||
state: ephemeral
|
||||
register: ephemeral_mount_info
|
||||
|
||||
- name: Get second mount record (should be different than the first)
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | grep '/tmp/myfs'
|
||||
executable: /bin/bash
|
||||
register: ephemeral_mount_record_2
|
||||
changed_when: false
|
||||
- name: Get second mount record (should be different than the first)
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | grep '/tmp/myfs'
|
||||
executable: /bin/bash
|
||||
register: ephemeral_mount_record_2
|
||||
changed_when: false
|
||||
|
||||
- name: Get mountinfo
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
||||
executable: /bin/bash
|
||||
register: check_mountinfo
|
||||
changed_when: false
|
||||
- name: Get mountinfo
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
||||
executable: /bin/bash
|
||||
register: check_mountinfo
|
||||
changed_when: false
|
||||
|
||||
- name: Assert the FS A is still mounted, the options changed and the fstab unchanged
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- check_mountinfo.stdout|int == 1
|
||||
- ephemeral_mount_record_1.stdout != ephemeral_mount_record_2.stdout
|
||||
- ephemeral_mount_info['changed']
|
||||
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_mount['stat']['checksum']
|
||||
- name: Assert the FS A is still mounted, the options changed and the fstab unchanged
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- check_mountinfo.stdout|int == 1
|
||||
- ephemeral_mount_record_1.stdout != ephemeral_mount_record_2.stdout
|
||||
- ephemeral_mount_info['changed']
|
||||
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_mount['stat']['checksum']
|
||||
|
||||
- name: Try to mount file B on file A mountpoint (should fail)
|
||||
ansible.posix.mount:
|
||||
path: /tmp/myfs
|
||||
src: "{{ ephemeral_device_b }}"
|
||||
fstype: "{{ ephemeral_fstype }}"
|
||||
state: ephemeral
|
||||
register: ephemeral_mount_b_info
|
||||
ignore_errors: true
|
||||
- name: Try to mount file B on file A mountpoint (should fail)
|
||||
ansible.posix.mount:
|
||||
path: /tmp/myfs
|
||||
src: "{{ ephemeral_device_b }}"
|
||||
fstype: "{{ ephemeral_fstype }}"
|
||||
state: ephemeral
|
||||
register: ephemeral_mount_b_info
|
||||
ignore_errors: true
|
||||
|
||||
- name: Get third mount record (should be the same than the second)
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | grep '/tmp/myfs'
|
||||
executable: /bin/bash
|
||||
register: ephemeral_mount_record_3
|
||||
changed_when: false
|
||||
- name: Get third mount record (should be the same than the second)
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | grep '/tmp/myfs'
|
||||
executable: /bin/bash
|
||||
register: ephemeral_mount_record_3
|
||||
changed_when: false
|
||||
|
||||
- name: Get mountinfo
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
||||
executable: /bin/bash
|
||||
register: check_mountinfo
|
||||
changed_when: false
|
||||
- name: Get mountinfo
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
||||
executable: /bin/bash
|
||||
register: check_mountinfo
|
||||
changed_when: false
|
||||
|
||||
- name: Try to stat our test file
|
||||
ansible.builtin.stat:
|
||||
path: /tmp/myfs/test_file
|
||||
register: test_file_stat
|
||||
- name: Try to stat our test file
|
||||
ansible.builtin.stat:
|
||||
path: /tmp/myfs/test_file
|
||||
register: test_file_stat
|
||||
|
||||
- name: Assert that mounting FS B over FS A failed
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- check_mountinfo.stdout|int == 1
|
||||
- ephemeral_mount_record_2.stdout == ephemeral_mount_record_3.stdout
|
||||
- test_file_stat['stat']['exists']
|
||||
- ephemeral_mount_b_info is failed
|
||||
- name: Assert that mounting FS B over FS A failed
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- check_mountinfo.stdout|int == 1
|
||||
- ephemeral_mount_record_2.stdout == ephemeral_mount_record_3.stdout
|
||||
- test_file_stat['stat']['exists']
|
||||
- ephemeral_mount_b_info is failed
|
||||
|
||||
- name: Unmount FS with state = unmounted
|
||||
ansible.posix.mount:
|
||||
path: /tmp/myfs
|
||||
state: unmounted
|
||||
- name: Unmount FS with state = unmounted
|
||||
ansible.posix.mount:
|
||||
path: /tmp/myfs
|
||||
state: unmounted
|
||||
|
||||
- name: Get fstab checksum after unmounting an ephemeral mount with state = unmounted
|
||||
ansible.builtin.stat:
|
||||
path: "{{ ephemeral_fstab }}"
|
||||
register: fstab_stat_after_unmount
|
||||
- name: Get fstab checksum after unmounting an ephemeral mount with state = unmounted
|
||||
ansible.builtin.stat:
|
||||
path: "{{ ephemeral_fstab }}"
|
||||
register: fstab_stat_after_unmount
|
||||
|
||||
- name: Get mountinfo
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
||||
executable: /bin/bash
|
||||
register: check_mountinfo
|
||||
changed_when: false
|
||||
- name: Get mountinfo
|
||||
ansible.builtin.shell:
|
||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
||||
executable: /bin/bash
|
||||
register: check_mountinfo
|
||||
changed_when: false
|
||||
|
||||
- name: Try to stat our test file
|
||||
ansible.builtin.stat:
|
||||
path: /tmp/myfs/test_file
|
||||
register: test_file_stat
|
||||
- name: Try to stat our test file
|
||||
ansible.builtin.stat:
|
||||
path: /tmp/myfs/test_file
|
||||
register: test_file_stat
|
||||
|
||||
- name: Assert that fstab is unchanged after unmounting an ephemeral mount with state = unmounted
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- check_mountinfo.stdout|int == 0
|
||||
- not test_file_stat['stat']['exists']
|
||||
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_unmount['stat']['checksum']
|
||||
- name: Assert that fstab is unchanged after unmounting an ephemeral mount with state = unmounted
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- check_mountinfo.stdout|int == 0
|
||||
- not test_file_stat['stat']['exists']
|
||||
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_unmount['stat']['checksum']
|
||||
|
||||
always:
|
||||
- name: Unmount potential failure relicas
|
||||
|
|
|
|||
Loading…
Reference in a new issue