Skip to content

Commit

Permalink
Verify that disk volumes are mounted by UUID in fstab
Browse files Browse the repository at this point in the history
Note that disk volumes mean filesystems directly on disks.

Currently the test fails: on first invocation the filesystem gets mounted by
device name and only on the second by UUID. This should be also aught by a real
idempotence test.

XXX this should be part of the existing verification task lists:
there is already a task called
"Verify that the device identifier appears in /etc/fstab",
but it does not check for this condition.
  • Loading branch information
pcahyna committed Oct 18, 2019
1 parent 6c33f25 commit ea5821c
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion tests/tests_change_disk_fs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
mount_location: '/opt/test'
volume_size: '5g'
fs_type_after: "{{ 'ext3' if (ansible_distribution == 'RedHat' and ansible_distribution_major_version == '6') else 'ext4' }}"

pat: "{{ '^([^#\\s]+)\\s+' + mount_location + '\\s.*' }}"
tasks:
- include_role:
name: storage
Expand All @@ -25,6 +25,23 @@
mount_point: "{{ mount_location }}"
disks: "{{ unused_disks }}"

- name: Load fstab
command: cat /etc/fstab
changed_when: false
check_mode: no
register: _test_change_disk_fs_fstab1

- name: print fstab device
debug:
msg: "device is: {{ ( _test_change_disk_fs_fstab1.stdout_lines|select('search', pat)
| map('regex_replace', pat, '\\1') | list )[0] }}"

- name: verify that we mount by UUID
assert:
that: "{{ _test_change_disk_fs_fstab1.stdout_lines|select('search', pat)
| map('regex_replace', pat, '\\1') | select('match', 'UUID=')
| list | length > 0 }}"

- include_tasks: verify-role-results.yml

- name: Change the disk device file system type to "{{ fs_type_after }}"
Expand All @@ -38,6 +55,23 @@
fs_type: "{{ fs_type_after }}"
disks: "{{ unused_disks }}"

- name: Load fstab
command: cat /etc/fstab
changed_when: false
check_mode: no
register: _test_change_disk_fs_fstab2

- name: print fstab device
debug:
msg: "device is: {{ (_test_change_disk_fs_fstab2.stdout_lines|select('search', pat)
| map('regex_replace', pat, '\\1') | list)[0] }}"

- name: verify that we mount by UUID
assert:
that: "{{_test_change_disk_fs_fstab2.stdout_lines|select('search', pat)
| map('regex_replace', pat, '\\1') | select('match', 'UUID=')
| list | length > 0 }}"

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
Expand All @@ -51,6 +85,25 @@
fs_type: "{{ fs_type_after }}"
disks: "{{ unused_disks }}"

- name: Load fstab
command: cat /etc/fstab
changed_when: false
check_mode: no
register: _test_change_disk_fs_fstab3

- name: print fstab device
debug:
msg: "device is: {{ (_test_change_disk_fs_fstab3.stdout_lines|select('search', pat)
| map('regex_replace', pat, '\\1') | list)[0] }}"

- name: verify that we mount by UUID
assert:
that: "{{ _test_change_disk_fs_fstab3.stdout_lines|select('search', pat)
| map('regex_replace', pat, '\\1') | select('match', 'UUID=' )
| list | length > 0 }}"

- pause:

- include_tasks: verify-role-results.yml

- name: Clean up
Expand Down

0 comments on commit ea5821c

Please sign in to comment.