From 493fb4b665225397259e9e6480c6d3e951726989 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Sat, 19 Nov 2016 16:24:16 -0800 Subject: [PATCH] Test that changing the flags on a mounted filesystem works (#18552) * Test that changing the flags on a mounted filesystem works --- test/integration/targets/mount/tasks/main.yml | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/test/integration/targets/mount/tasks/main.yml b/test/integration/targets/mount/tasks/main.yml index ab3e0c5f4ab..3c0b79e11f5 100644 --- a/test/integration/targets/mount/tasks/main.yml +++ b/test/integration/targets/mount/tasks/main.yml @@ -90,7 +90,44 @@ - name: Make sure we didn't mount a second time assert: that: - - "not bind_result_linux['changed'] and not bind_result_freebsd['changed']" + - "(ansible_system == 'Linux' and not bind_result_linux['changed']) or (ansible_system == 'FreeBSD' and not bind_result_freebsd['changed'])" + when: ansible_system in ('FreeBSD', 'Linux') + +# The opts type of bind mount only works on Linux +- name: Remount filesystem with different opts (Linux) + mount: + src: "{{ outputdir }}/mount_source" + name: "{{ outputdir }}/mount_dest" + state: "mounted" + fstype: "None" + opts: "bind,ro" + when: ansible_system == 'Linux' + register: bind_result_linux + +# Nullfs is freebsd only +- name: Remount filesystem with different opts (FreeBSD) + mount: + src: "{{ outputdir }}/mount_source" + name: "{{ outputdir }}/mount_dest" + state: "mounted" + fstype: "nullfs" + opts: "ro" + when: ansible_system == 'FreeBSD' + register: bind_result_freebsd + +- name: Get mount options + shell: mount | grep mount_dest | grep -E -w '(ro|read-only)' | wc -l + register: remount_options + +- debug: var=remount_options + +- name: Make sure the filesystem now has the new opts + assert: + that: + - "(ansible_system == 'Linux' and bind_result_linux['changed']) or (ansible_system == 'FreeBSD' and bind_result_freebsd['changed'])" + - "'1' in remount_options.stdout" + - "1 == remount_options.stdout_lines | length" + when: ansible_system in ('FreeBSD', 'Linux') - name: Unmount the bind mount mount: