ansible: handle mount of /sys the same way IPA does it

* Mount with -t sysfs instead of a bind mount
* Retry umounting of each directory several times.

I'm seeing occasional failures unmounting /sys, as it's still busy.
This patch should fix it.

Change-Id: I4bc6dfd6939699f7a4ed7cc59e2e503b46bbaeaf
This commit is contained in:
Dmitry Tantsur 2017-12-07 14:53:09 +01:00
parent cb31471aae
commit d4a3cb6c05
2 changed files with 12 additions and 3 deletions

View File

@ -1 +1,3 @@
tmp_rootfs_mount: /tmp/rootfs
umount_retry_count: 5
umount_retry_delay: 3

View File

@ -48,9 +48,12 @@
command: mount -o bind /{{ item }} {{ tmp_rootfs_mount }}/{{ item }}
with_items:
- dev
- sys
- proc
- name: mount /sys for chroot
become: yes
command: mount -t sysfs sysfs {{ tmp_rootfs_mount }}/sys
- block:
- name: get grub version string
become: yes
@ -70,10 +73,14 @@
become: yes
command: chroot {{ tmp_rootfs_mount }} /bin/sh -c '{{ grub_config_cmd }} -o {{ grub_config_file }}'
always:
- name: unmount dirs for chroot
- name: unmount /{{ item }} for chroot
become: yes
command: umount {{ tmp_rootfs_mount }}/{{ item }}
register: task_result
retries: '{{ umount_retry_count }}'
delay: '{{ umount_retry_delay }}'
until: task_result.rc == 0
with_items:
- dev
- sys
- proc
- dev