# -*- mode: yaml; indent-tabs-mode: nil; tab-width: 2; coding: utf-8-unix -*-
---
- name: "DEBUG: ansible-gentoo_install finish.yml"
  debug:
    verbosity: 1
    msg: "DEBUG: ansible-gentoo_install finish.yml"

- name: unmount filesystems
  mount:
    name: "{{AGI_NBD_MP}}/{{ item }}"
    state: unmounted
  with_items:
    - proc
    - sys
    - dev/pts
    - dev/shm
    - dev
    - boot
    - ''
  loop_control:
    label: "{{AGI_NBD_MP}}/{{ item }}"

- name: df umount failsafe
  shell: |
    grep /mnt/gentoo /proc/mounts|tac|while read a b c ;do sudo umount $b;done
    grep /mnt/gentoo/ /proc/mounts|tac|while read a b c ;do sudo umount $b;done
    # leave this to be done
    grep nbd /proc/mounts || true

- name: reboot
  command: reboot
  async: 0
  poll: 0
  ignore_errors: true
  when: false
