2023-12-29 19:40:31 +00:00
|
|
|
# -*- mode: yaml; indent-tabs-mode: nil; tab-width: 2; coding: utf-8-unix -*-
|
|
|
|
---
|
|
|
|
- name: "DEBUG: ansible-gentoo_install chroot.yml"
|
|
|
|
debug:
|
|
|
|
verbosity: 1
|
|
|
|
msg: "DEBUG: ansible-gentoo_install chroot.yml"
|
2023-12-30 22:09:49 +00:00
|
|
|
|
2023-12-29 19:40:31 +00:00
|
|
|
- name: test we are NOT in the chroot
|
|
|
|
shell: |
|
|
|
|
df | grep "{{AGI_NBD_MP}}" || exit 1
|
|
|
|
[ -n "{{AGI_NBD_MP}}" ] || exit 2
|
|
|
|
[ -d "{{AGI_NBD_MP}}" ] || exit 3
|
|
|
|
[ "{{ansible_distribution}}" == 'Gentoo' ] || \
|
|
|
|
( {{AGI_GENTOO_FROM_MP}} != '' && "{{AGI_GENTOO_FROM_MP}}" != '/' ) || \
|
|
|
|
exit 4
|
|
|
|
[ -d "{{AGI_GENTOO_FROM_MP}}" ] || exit 5
|
|
|
|
check_mode: false
|
2023-12-30 22:09:49 +00:00
|
|
|
|
2023-12-29 19:40:31 +00:00
|
|
|
- name: copy resolv.conf into chroot
|
|
|
|
copy:
|
|
|
|
src: /etc/resolv.conf
|
|
|
|
dest: "{{AGI_NBD_MP}}/etc/resolv.conf"
|
|
|
|
remote_src: yes
|
|
|
|
when: not ansible_check_mode
|
|
|
|
|
|
|
|
- name: mount /proc in chroot
|
|
|
|
mount:
|
|
|
|
name: "{{AGI_NBD_MP}}/proc"
|
|
|
|
src: proc
|
|
|
|
fstype: proc
|
|
|
|
state: mounted
|
|
|
|
check_mode: false
|
|
|
|
|
|
|
|
- name: bind-mount dirs in chroot
|
|
|
|
mount:
|
|
|
|
name: "{{AGI_NBD_MP}}/{{ item }}"
|
|
|
|
src: /{{ item }}
|
|
|
|
fstype: auto
|
|
|
|
opts: bind
|
|
|
|
state: mounted
|
|
|
|
with_items:
|
|
|
|
- sys
|
|
|
|
- dev
|
|
|
|
- dev/pts
|
|
|
|
- dev/shm
|
|
|
|
check_mode: false
|
|
|
|
|
|
|
|
- name: chroot wrapper script
|
|
|
|
template:
|
|
|
|
src: chroot_wrapper.sh
|
|
|
|
dest: "/var/tmp/chroot_wrapper.sh"
|
|
|
|
owner: 'root'
|
|
|
|
mode: '0755'
|
|
|
|
check_mode: false
|
|
|
|
|