mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-12 15:45:20 +01:00
simplifying the mount integration tests
Signed-off-by: Adam Miller <admiller@redhat.com>
This commit is contained in:
parent
9a616f3cc0
commit
9300f2ef60
1 changed files with 91 additions and 93 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
---
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
ansible.builtin.package:
|
ansible.builtin.package:
|
||||||
name: e2fsprogs
|
name: e2fsprogs
|
||||||
|
|
@ -8,26 +7,28 @@
|
||||||
- name: Create the mount point
|
- name: Create the mount point
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
state: directory
|
state: directory
|
||||||
path: "{{ output_dir }}/mount_dest"
|
path: '{{ output_dir }}/mount_dest'
|
||||||
mode: "0755"
|
mode: '0755'
|
||||||
|
|
||||||
- name: Create a directory to bind mount
|
- name: Create a directory to bind mount
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
state: directory
|
state: directory
|
||||||
path: "{{ output_dir }}/mount_source"
|
path: '{{ output_dir }}/mount_source'
|
||||||
mode: "0755"
|
mode: '0755'
|
||||||
|
|
||||||
- name: Put something in the directory so we see that it worked
|
- name: Put something in the directory so we see that it worked
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
content: "Testing\n"
|
content: 'Testing
|
||||||
dest: "{{ output_dir }}/mount_source/test_file"
|
|
||||||
mode: "0644"
|
'
|
||||||
|
dest: '{{ output_dir }}/mount_source/test_file'
|
||||||
|
mode: '0644'
|
||||||
register: orig_info
|
register: orig_info
|
||||||
|
|
||||||
- name: Bind mount a filesystem (Linux)
|
- name: Bind mount a filesystem (Linux)
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
src: "{{ output_dir }}/mount_source"
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: "{{ output_dir }}/mount_dest"
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
fstype: None
|
fstype: None
|
||||||
opts: bind
|
opts: bind
|
||||||
|
|
@ -36,8 +37,8 @@
|
||||||
|
|
||||||
- name: Bind mount a filesystem (FreeBSD)
|
- name: Bind mount a filesystem (FreeBSD)
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
src: "{{ output_dir }}/mount_source"
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: "{{ output_dir }}/mount_dest"
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
fstype: nullfs
|
fstype: nullfs
|
||||||
when: ansible_system == 'FreeBSD'
|
when: ansible_system == 'FreeBSD'
|
||||||
|
|
@ -45,7 +46,7 @@
|
||||||
|
|
||||||
- name: Get checksum for bind mounted file
|
- name: Get checksum for bind mounted file
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ output_dir }}/mount_dest/test_file"
|
path: '{{ output_dir }}/mount_dest/test_file'
|
||||||
when: ansible_system in ('FreeBSD', 'Linux')
|
when: ansible_system in ('FreeBSD', 'Linux')
|
||||||
register: dest_stat
|
register: dest_stat
|
||||||
|
|
||||||
|
|
@ -59,8 +60,8 @@
|
||||||
|
|
||||||
- name: Bind mount a filesystem (Linux)
|
- name: Bind mount a filesystem (Linux)
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
src: "{{ output_dir }}/mount_source"
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: "{{ output_dir }}/mount_dest"
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
fstype: None
|
fstype: None
|
||||||
opts: bind
|
opts: bind
|
||||||
|
|
@ -69,8 +70,8 @@
|
||||||
|
|
||||||
- name: Bind mount a filesystem (FreeBSD)
|
- name: Bind mount a filesystem (FreeBSD)
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
src: "{{ output_dir }}/mount_source"
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: "{{ output_dir }}/mount_dest"
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
fstype: nullfs
|
fstype: nullfs
|
||||||
when: ansible_system == 'FreeBSD'
|
when: ansible_system == 'FreeBSD'
|
||||||
|
|
@ -84,8 +85,8 @@
|
||||||
|
|
||||||
- name: Remount filesystem with different opts (Linux)
|
- name: Remount filesystem with different opts (Linux)
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
src: "{{ output_dir }}/mount_source"
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: "{{ output_dir }}/mount_dest"
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
fstype: None
|
fstype: None
|
||||||
opts: bind,ro
|
opts: bind,ro
|
||||||
|
|
@ -94,8 +95,8 @@
|
||||||
|
|
||||||
- name: Remount filesystem with different opts (FreeBSD)
|
- name: Remount filesystem with different opts (FreeBSD)
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
src: "{{ output_dir }}/mount_source"
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: "{{ output_dir }}/mount_dest"
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
fstype: nullfs
|
fstype: nullfs
|
||||||
opts: ro
|
opts: ro
|
||||||
|
|
@ -113,20 +114,20 @@
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- (ansible_system == 'Linux' and bind_result_linux['changed']) or (ansible_system == 'FreeBSD' and bind_result_freebsd['changed'])
|
- (ansible_system == 'Linux' and bind_result_linux['changed']) or (ansible_system == 'FreeBSD' and bind_result_freebsd['changed'])
|
||||||
- "'1' in remount_options.stdout"
|
- '''1'' in remount_options.stdout'
|
||||||
- 1 == remount_options.stdout_lines | length
|
- 1 == remount_options.stdout_lines | length
|
||||||
when: ansible_system in ('FreeBSD', 'Linux')
|
when: ansible_system in ('FreeBSD', 'Linux')
|
||||||
|
|
||||||
- name: Unmount the bind mount
|
- name: Unmount the bind mount
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
name: "{{ output_dir }}/mount_dest"
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: absent
|
state: absent
|
||||||
when: ansible_system in ('Linux', 'FreeBSD')
|
when: ansible_system in ('Linux', 'FreeBSD')
|
||||||
register: unmount_result
|
register: unmount_result
|
||||||
|
|
||||||
- name: Make sure the file no longer exists in dest
|
- name: Make sure the file no longer exists in dest
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ output_dir }}/mount_dest/test_file"
|
path: '{{ output_dir }}/mount_dest/test_file'
|
||||||
when: ansible_system in ('FreeBSD', 'Linux')
|
when: ansible_system in ('FreeBSD', 'Linux')
|
||||||
register: dest_stat
|
register: dest_stat
|
||||||
|
|
||||||
|
|
@ -142,7 +143,7 @@
|
||||||
block:
|
block:
|
||||||
- name: Create fstab record for the first swap file
|
- name: Create fstab record for the first swap file
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
name: falsene
|
name: none
|
||||||
src: /tmp/swap1
|
src: /tmp/swap1
|
||||||
opts: sw
|
opts: sw
|
||||||
fstype: swap
|
fstype: swap
|
||||||
|
|
@ -151,7 +152,7 @@
|
||||||
|
|
||||||
- name: Try to create fstab record for the first swap file again
|
- name: Try to create fstab record for the first swap file again
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
name: falsene
|
name: none
|
||||||
src: /tmp/swap1
|
src: /tmp/swap1
|
||||||
opts: sw
|
opts: sw
|
||||||
fstype: swap
|
fstype: swap
|
||||||
|
|
@ -166,7 +167,7 @@
|
||||||
|
|
||||||
- name: Create fstab record for the second swap file
|
- name: Create fstab record for the second swap file
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
name: falsene
|
name: none
|
||||||
src: /tmp/swap2
|
src: /tmp/swap2
|
||||||
opts: sw
|
opts: sw
|
||||||
fstype: swap
|
fstype: swap
|
||||||
|
|
@ -175,7 +176,7 @@
|
||||||
|
|
||||||
- name: Try to create fstab record for the second swap file again
|
- name: Try to create fstab record for the second swap file again
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
name: falsene
|
name: none
|
||||||
src: /tmp/swap1
|
src: /tmp/swap1
|
||||||
opts: sw
|
opts: sw
|
||||||
fstype: swap
|
fstype: swap
|
||||||
|
|
@ -190,14 +191,14 @@
|
||||||
|
|
||||||
- name: Remove the fstab record for the first swap file
|
- name: Remove the fstab record for the first swap file
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
name: falsene
|
name: none
|
||||||
src: /tmp/swap1
|
src: /tmp/swap1
|
||||||
state: absent
|
state: absent
|
||||||
register: swap1_removed
|
register: swap1_removed
|
||||||
|
|
||||||
- name: Try to remove the fstab record for the first swap file again
|
- name: Try to remove the fstab record for the first swap file again
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
name: falsene
|
name: none
|
||||||
src: /tmp/swap1
|
src: /tmp/swap1
|
||||||
state: absent
|
state: absent
|
||||||
register: swap1_removed_again
|
register: swap1_removed_again
|
||||||
|
|
@ -210,14 +211,14 @@
|
||||||
|
|
||||||
- name: Remove the fstab record for the second swap file
|
- name: Remove the fstab record for the second swap file
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
name: falsene
|
name: none
|
||||||
src: /tmp/swap2
|
src: /tmp/swap2
|
||||||
state: absent
|
state: absent
|
||||||
register: swap2_removed
|
register: swap2_removed
|
||||||
|
|
||||||
- name: Try to remove the fstab record for the second swap file again
|
- name: Try to remove the fstab record for the second swap file again
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
name: falsene
|
name: none
|
||||||
src: /tmp/swap2
|
src: /tmp/swap2
|
||||||
state: absent
|
state: absent
|
||||||
register: swap2_removed_again
|
register: swap2_removed_again
|
||||||
|
|
@ -231,7 +232,9 @@
|
||||||
- name: Create fstab record with missing last two fields
|
- name: Create fstab record with missing last two fields
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: /etc/fstab
|
dest: /etc/fstab
|
||||||
content: "//nas/photo /home/jik/pictures cifs defaults,credentials=/etc/security/nas.creds,uid=jik,gid=users,forceuid,forcegid,noserverino,_netdev\n"
|
content: '//nas/photo /home/jik/pictures cifs defaults,credentials=/etc/security/nas.creds,uid=jik,gid=users,forceuid,forcegid,noserverino,_netdev
|
||||||
|
|
||||||
|
'
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
|
||||||
- name: Try to change the fstab record with the missing last two fields
|
- name: Try to change the fstab record with the missing last two fields
|
||||||
|
|
@ -244,7 +247,7 @@
|
||||||
register: optional_fields_update
|
register: optional_fields_update
|
||||||
|
|
||||||
- name: Get the content of the fstab file
|
- name: Get the content of the fstab file
|
||||||
ansible.builtin.command: /bin/cat /etc/fstab
|
ansible.builtin.command: cat /etc/fstab
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: optional_fields_content
|
register: optional_fields_content
|
||||||
|
|
||||||
|
|
@ -252,7 +255,7 @@
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 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
|
||||||
|
|
@ -274,7 +277,8 @@
|
||||||
|
|
||||||
- name: Get the last write time
|
- name: Get the last write time
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: "set -o pipefail && dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i last write time: |cut -d: -f2-"
|
cmd: >-
|
||||||
|
set -o pipefail && dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i "last write time:" | cut -d: -f2-
|
||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: last_write_time
|
register: last_write_time
|
||||||
|
|
@ -290,7 +294,8 @@
|
||||||
|
|
||||||
- name: Get again the last write time
|
- name: Get again the last write time
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: "set -o pipefail && dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i last write time: |cut -d: -f2-"
|
cmd: >-
|
||||||
|
set -o pipefail && dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i "last write time:" |cut -d: -f2-
|
||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: last_write_time2
|
register: last_write_time2
|
||||||
|
|
@ -317,7 +322,7 @@
|
||||||
ansible.builtin.assert:
|
ansible.builtin.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
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
|
|
@ -343,7 +348,7 @@
|
||||||
|
|
||||||
- name: Remove the test FS
|
- name: Remove the test FS
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ item }}"
|
path: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- /tmp/myfs.img
|
- /tmp/myfs.img
|
||||||
|
|
@ -384,7 +389,7 @@
|
||||||
|
|
||||||
- name: Remove the test FS
|
- name: Remove the test FS
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ item }}"
|
path: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- /tmp/myfs.img
|
- /tmp/myfs.img
|
||||||
|
|
@ -403,7 +408,7 @@
|
||||||
dev: /tmp/myfs1.img
|
dev: /tmp/myfs1.img
|
||||||
- name: Create custom fstab file without newline
|
- name: Create custom fstab file without newline
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
content: "#TEST COMMENT WITHOUT NEWLINE"
|
content: '#TEST COMMENT WITHOUT NEWLINE'
|
||||||
dest: /tmp/test_fstab
|
dest: /tmp/test_fstab
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
- name: Mount the FS using the custom fstab
|
- name: Mount the FS using the custom fstab
|
||||||
|
|
@ -421,7 +426,7 @@
|
||||||
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
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ item }}"
|
path: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- /tmp/myfs1.img
|
- /tmp/myfs1.img
|
||||||
|
|
@ -431,6 +436,7 @@
|
||||||
- name: Block to test ephemeral option
|
- name: Block to test ephemeral option
|
||||||
environment:
|
environment:
|
||||||
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
when: ansible_system in ('Linux', 'SunOS', 'FreeBSD', 'NetBSD', 'OpenBSD')
|
||||||
block:
|
block:
|
||||||
- name: Create empty file A
|
- name: Create empty file A
|
||||||
community.general.filesize:
|
community.general.filesize:
|
||||||
|
|
@ -454,10 +460,10 @@
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
ephemeral_device_a: /dev/lofi/1
|
ephemeral_device_a: /dev/lofi/1
|
||||||
ephemeral_device_b: /dev/lofi/2
|
ephemeral_device_b: /dev/lofi/2
|
||||||
ephemeral_create_loop_dev_cmd: >
|
ephemeral_create_loop_dev_cmd: >-
|
||||||
lofiadm -a /tmp/myfs_A.img /dev/lofi/1 &&
|
lofiadm -a /tmp/myfs_A.img /dev/lofi/1 &&
|
||||||
lofiadm -a /tmp/myfs_B.img /dev/lofi/2
|
lofiadm -a /tmp/myfs_B.img /dev/lofi/2
|
||||||
ephemeral_remove_loop_dev_cmd: >
|
ephemeral_remove_loop_dev_cmd: >-
|
||||||
lofiadm -d /dev/lofi/1 &&
|
lofiadm -d /dev/lofi/1 &&
|
||||||
lofiadm -d /dev/lofi/2 || true
|
lofiadm -d /dev/lofi/2 || true
|
||||||
ephemeral_fstype: ufs
|
ephemeral_fstype: ufs
|
||||||
|
|
@ -468,10 +474,10 @@
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
ephemeral_device_a: /dev/md1
|
ephemeral_device_a: /dev/md1
|
||||||
ephemeral_device_b: /dev/md2
|
ephemeral_device_b: /dev/md2
|
||||||
ephemeral_create_loop_dev_cmd: >
|
ephemeral_create_loop_dev_cmd: >-
|
||||||
mdconfig -a -t vnode -f /tmp/myfs_A.img -u /dev/md1 &&
|
mdconfig -a -t vnode -f /tmp/myfs_A.img -u /dev/md1 &&
|
||||||
mdconfig -a -t vnode -f /tmp/myfs_B.img -u /dev/md2
|
mdconfig -a -t vnode -f /tmp/myfs_B.img -u /dev/md2
|
||||||
ephemeral_remove_loop_dev_cmd: >
|
ephemeral_remove_loop_dev_cmd: >-
|
||||||
mdconfig -d -u /dev/md1 &&
|
mdconfig -d -u /dev/md1 &&
|
||||||
mdconfig -d -u /dev/md2
|
mdconfig -d -u /dev/md2
|
||||||
ephemeral_fstype: ufs
|
ephemeral_fstype: ufs
|
||||||
|
|
@ -482,10 +488,10 @@
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
ephemeral_device_a: /dev/vnd1
|
ephemeral_device_a: /dev/vnd1
|
||||||
ephemeral_device_b: /dev/vnd2
|
ephemeral_device_b: /dev/vnd2
|
||||||
ephemeral_create_loop_dev_cmd: >
|
ephemeral_create_loop_dev_cmd: >-
|
||||||
vnconfig /dev/vnd1 /tmp/myfs_A.img &&
|
vnconfig /dev/vnd1 /tmp/myfs_A.img &&
|
||||||
vnconfig /dev/vnd2 /tmp/myfs_B.img
|
vnconfig /dev/vnd2 /tmp/myfs_B.img
|
||||||
ephemeral_remove_loop_dev_cmd: >
|
ephemeral_remove_loop_dev_cmd: >-
|
||||||
vnconfig -u /dev/vnd1 &&
|
vnconfig -u /dev/vnd1 &&
|
||||||
vnconfig -u /dev/vnd2
|
vnconfig -u /dev/vnd2
|
||||||
ephemeral_fstype: ufs
|
ephemeral_fstype: ufs
|
||||||
|
|
@ -494,7 +500,7 @@
|
||||||
|
|
||||||
- name: Register format fs command on Non-Linux and Non-OpenBSD
|
- name: Register format fs command on Non-Linux and Non-OpenBSD
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
ephemeral_format_fs_cmd: >
|
ephemeral_format_fs_cmd: >-
|
||||||
yes | newfs {{ ephemeral_device_a }} &&
|
yes | newfs {{ ephemeral_device_a }} &&
|
||||||
yes | newfs {{ ephemeral_device_b }}
|
yes | newfs {{ ephemeral_device_b }}
|
||||||
when: ansible_system in ('SunOS', 'FreeBSD', 'NetBSD')
|
when: ansible_system in ('SunOS', 'FreeBSD', 'NetBSD')
|
||||||
|
|
@ -503,20 +509,20 @@
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
ephemeral_device_a: /dev/vnd1c
|
ephemeral_device_a: /dev/vnd1c
|
||||||
ephemeral_device_b: /dev/vnd2c
|
ephemeral_device_b: /dev/vnd2c
|
||||||
ephemeral_create_loop_dev_cmd: >
|
ephemeral_create_loop_dev_cmd: >-
|
||||||
vnconfig vnd1 /tmp/myfs_A.img &&
|
vnconfig vnd1 /tmp/myfs_A.img &&
|
||||||
vnconfig vnd2 /tmp/myfs_B.img
|
vnconfig vnd2 /tmp/myfs_B.img
|
||||||
ephemeral_remove_loop_dev_cmd: >
|
ephemeral_remove_loop_dev_cmd: >-
|
||||||
vnconfig -u vnd1 &&
|
vnconfig -u vnd1 &&
|
||||||
vnconfig -u vnd2
|
vnconfig -u vnd2
|
||||||
ephemeral_format_fs_cmd: >
|
ephemeral_format_fs_cmd: >-
|
||||||
yes | newfs /dev/rvnd1c &&
|
yes | newfs /dev/rvnd1c &&
|
||||||
yes | newfs /dev/rvnd2c
|
yes | newfs /dev/rvnd2c
|
||||||
ephemeral_fstype: ffs
|
ephemeral_fstype: ffs
|
||||||
ephemeral_fstab: /etc/fstab
|
ephemeral_fstab: /etc/fstab
|
||||||
when: ansible_system == 'OpenBSD'
|
when: ansible_system == 'OpenBSD'
|
||||||
|
|
||||||
##### FORMAT FS ON LINUX
|
##### FORMAT FS ON LINUX
|
||||||
|
|
||||||
- name: Block to format FS on Linux
|
- name: Block to format FS on Linux
|
||||||
when: ansible_system == 'Linux'
|
when: ansible_system == 'Linux'
|
||||||
|
|
@ -531,55 +537,57 @@
|
||||||
fstype: ext3
|
fstype: ext3
|
||||||
dev: /tmp/myfs_B.img
|
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
|
- name: Create loop devices on Solaris and BSD
|
||||||
ansible.builtin.command: "{{ ephemeral_create_loop_dev_cmd }}"
|
ansible.builtin.shell:
|
||||||
|
cmd: "set -o pipefail && {{ ephemeral_create_loop_dev_cmd }}"
|
||||||
|
executable: /bin/bash
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: ephemeral_create_loop_dev_cmd is defined
|
when: ephemeral_create_loop_dev_cmd is defined
|
||||||
|
|
||||||
- name: Format FS A and B on Solaris and BSD
|
- name: Format FS A and B on Solaris and BSD
|
||||||
ansible.builtin.command: "{{ ephemeral_format_fs_cmd }}"
|
ansible.builtin.shell:
|
||||||
|
cmd: "set -o pipefail && {{ ephemeral_format_fs_cmd }}"
|
||||||
|
executable: /bin/bash
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: ephemeral_format_fs_cmd is defined
|
when: ephemeral_format_fs_cmd is defined
|
||||||
|
|
||||||
##### TESTS
|
##### TESTS
|
||||||
|
|
||||||
- name: Create fstab if it does not exist
|
- name: Create fstab if it does not exist
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ ephemeral_fstab }}"
|
path: "{{ ephemeral_fstab }}"
|
||||||
state: touch
|
state: touch
|
||||||
mode: "0644"
|
mode: '0644'
|
||||||
|
|
||||||
- name: Get checksum of /etc/fstab before mounting anything
|
- name: Get checksum of /etc/fstab before mounting anything
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ ephemeral_fstab }}"
|
path: '{{ ephemeral_fstab }}'
|
||||||
register: fstab_stat_before_mount
|
register: fstab_stat_before_mount
|
||||||
|
|
||||||
- name: Mount the FS A with ephemeral state
|
- name: Mount the FS A with ephemeral state
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
src: "{{ ephemeral_device_a }}"
|
src: '{{ ephemeral_device_a }}'
|
||||||
fstype: "{{ ephemeral_fstype }}"
|
fstype: '{{ ephemeral_fstype }}'
|
||||||
opts: rw
|
opts: rw
|
||||||
state: ephemeral
|
state: ephemeral
|
||||||
register: ephemeral_mount_info
|
register: ephemeral_mount_info
|
||||||
|
|
||||||
- name: Put something in the directory so we can do additional checks later on
|
- name: Put something in the directory so we can do additional checks later on
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
content: Testing
|
content: 'Testing'
|
||||||
dest: /tmp/myfs/test_file
|
dest: /tmp/myfs/test_file
|
||||||
mode: "0644"
|
mode: '0644'
|
||||||
|
|
||||||
- name: Get checksum of /etc/fstab after an ephemeral mount
|
- name: Get checksum of /etc/fstab after an ephemeral mount
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ ephemeral_fstab }}"
|
path: '{{ ephemeral_fstab }}'
|
||||||
register: fstab_stat_after_mount
|
register: fstab_stat_after_mount
|
||||||
|
|
||||||
- name: Get mountinfo
|
- name: Get mountinfo
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command: grep '^/tmp/myfs$' /etc/mtab -c
|
||||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
|
||||||
executable: /bin/bash
|
|
||||||
register: check_mountinfo
|
register: check_mountinfo
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
|
@ -591,32 +599,26 @@
|
||||||
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_mount['stat']['checksum']
|
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_mount['stat']['checksum']
|
||||||
|
|
||||||
- name: Get first mount record
|
- name: Get first mount record
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command: grep '/tmp/myfs' /etc/mtab
|
||||||
cmd: set -o pipefail && mount -v | grep '/tmp/myfs'
|
|
||||||
executable: /bin/bash
|
|
||||||
register: ephemeral_mount_record_1
|
register: ephemeral_mount_record_1
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Try to mount FS A where FS A is already mounted (should trigger remount and changed)
|
- name: Try to mount FS A where FS A is already mounted (should trigger remount and changed)
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
src: "{{ ephemeral_device_a }}"
|
src: '{{ ephemeral_device_a }}'
|
||||||
fstype: "{{ ephemeral_fstype }}"
|
fstype: '{{ ephemeral_fstype }}'
|
||||||
opts: ro
|
opts: ro
|
||||||
state: ephemeral
|
state: ephemeral
|
||||||
register: ephemeral_mount_info
|
register: ephemeral_mount_info
|
||||||
|
|
||||||
- name: Get second mount record (should be different than the first)
|
- name: Get second mount record (should be different than the first)
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command: grep '/tmp/myfs' /etc/mtab
|
||||||
cmd: set -o pipefail && mount -v | grep '/tmp/myfs'
|
|
||||||
executable: /bin/bash
|
|
||||||
register: ephemeral_mount_record_2
|
register: ephemeral_mount_record_2
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Get mountinfo
|
- name: Get mountinfo
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command: grep '^/tmp/myfs$' /etc/mtab -c
|
||||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
|
||||||
executable: /bin/bash
|
|
||||||
register: check_mountinfo
|
register: check_mountinfo
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
|
@ -631,23 +633,19 @@
|
||||||
- name: Try to mount file B on file A mountpoint (should fail)
|
- name: Try to mount file B on file A mountpoint (should fail)
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
src: "{{ ephemeral_device_b }}"
|
src: '{{ ephemeral_device_b }}'
|
||||||
fstype: "{{ ephemeral_fstype }}"
|
fstype: '{{ ephemeral_fstype }}'
|
||||||
state: ephemeral
|
state: ephemeral
|
||||||
register: ephemeral_mount_b_info
|
register: ephemeral_mount_b_info
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Get third mount record (should be the same than the second)
|
- name: Get third mount record (should be the same than the second)
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command: grep '/tmp/myfs' /etc/mtab
|
||||||
cmd: set -o pipefail && mount -v | grep '/tmp/myfs'
|
|
||||||
executable: /bin/bash
|
|
||||||
register: ephemeral_mount_record_3
|
register: ephemeral_mount_record_3
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Get mountinfo
|
- name: Get mountinfo
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command: grep '^/tmp/myfs$' /etc/mtab -c
|
||||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
|
||||||
executable: /bin/bash
|
|
||||||
register: check_mountinfo
|
register: check_mountinfo
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
|
@ -671,13 +669,11 @@
|
||||||
|
|
||||||
- name: Get fstab checksum after unmounting an ephemeral mount with state = unmounted
|
- name: Get fstab checksum after unmounting an ephemeral mount with state = unmounted
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ ephemeral_fstab }}"
|
path: '{{ ephemeral_fstab }}'
|
||||||
register: fstab_stat_after_unmount
|
register: fstab_stat_after_unmount
|
||||||
|
|
||||||
- name: Get mountinfo
|
- name: Get mountinfo
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command: grep '^/tmp/myfs$' /etc/mtab -c
|
||||||
cmd: set -o pipefail && mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
|
||||||
executable: /bin/bash
|
|
||||||
register: check_mountinfo
|
register: check_mountinfo
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
|
@ -700,13 +696,15 @@
|
||||||
state: unmounted
|
state: unmounted
|
||||||
|
|
||||||
- name: Remove loop devices on Solaris and BSD
|
- name: Remove loop devices on Solaris and BSD
|
||||||
when: ephemeral_remove_loop_dev_cmd is defined
|
ansible.builtin.shell:
|
||||||
ansible.builtin.command: "{{ ephemeral_remove_loop_dev_cmd }}"
|
cmd: "set -o pipefail && {{ ephemeral_remove_loop_dev_cmd }}"
|
||||||
|
executable: /bin/bash
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
when: ephemeral_remove_loop_dev_cmd is defined
|
||||||
|
|
||||||
- name: Remove the test FS
|
- name: Remove the test FS
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ item }}"
|
path: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- /tmp/myfs_A.img
|
- /tmp/myfs_A.img
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue