libvirt_cloud/roles/ansible-gentoo_install/tasks/chroot.yml

58 lines
1.3 KiB
YAML
Raw Permalink Normal View History

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:
2024-01-05 11:12:55 +00:00
src: "/{{item}}"
dest: "{{AGI_NBD_MP}}/{{item}}"
mode: '0644'
2023-12-29 19:40:31 +00:00
remote_src: yes
2024-01-05 11:12:55 +00:00
with_items: "{{AGI_bootstrap_files}}"
2023-12-29 19:40:31 +00:00
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