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

119 lines
3.2 KiB
YAML
Raw 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 copy.yml"
debug:
verbosity: 1
msg: "DEBUG: ansible-gentoo_install copy.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: resolve kernel symlink
shell: |
[ -h {{AGI_GENTOO_FROM_MP}}/usr/src/linux ] && \
echo $(readlink /usr/src/linux | sed -e 's@/$@@' ) && \
exit 0
echo linux
register: kernel_out
check_mode: false
2023-12-30 22:09:49 +00:00
2023-12-31 07:39:01 +00:00
- name: install to mp from source
delegate_to: localhost
shell: |
cd {{AGI_GENTOO_FROM_MP}}/usr/src/linux || exit 1
[ -d "{{AGI_NBD_MP}}/lib/modules" ] || mkdir "{{AGI_NBD_MP}}/lib/modules"
make INSTALL_PATH={{AGI_NBD_MP}}/boot install || exit 4
make INSTALL_MOD_PATH={{AGI_NBD_MP}} modules_install || exit 5
args:
creates: "{{AGI_NBD_MP}}/lib/modules/{{kernel_out.stdout}}"
when: AGI_use_local_kernel
2023-12-29 19:40:31 +00:00
- name: copy kernel sources
copy:
src: "{{AGI_GENTOO_FROM_MP}}/usr/src/{{kernel_out.stdout}}"
2024-01-01 01:04:40 +00:00
dest: "{{AGI_NBD_MP}}/usr/src/{{kernel_out.stdout}}"
2023-12-29 19:40:31 +00:00
remote_src: no
when:
- kernel_out.rc|default(1) == 0
- AGI_use_local_kernel
2024-01-01 01:04:40 +00:00
- false
2023-12-30 22:09:49 +00:00
2023-12-29 19:40:31 +00:00
- name: resolve kver
shell: |
kernel="{{kernel_out.stdout}}"
kver=$( echo $kernel | sed -e 's/.*-6\.\([0-9]\)/6.\1/' -e 's/-.*//' )
echo $kver
register: kver_out
check_mode: false
when:
- kernel_out.rc|default(1) == 0
- name: resolve kmods
shell: |
ls -d {{AGI_GENTOO_FROM_MP}}/lib/modules/{{kver_out.stdout}}* | head -1
register: mods_out
check_mode: false
when:
- kver_out.rc|default(1) == 0
2023-12-30 22:09:49 +00:00
2023-12-29 19:40:31 +00:00
- name: resolve vmlinux
shell: |
kver="{{kver_out.stdout}}"
ls {{AGI_GENTOO_FROM_MP}}/boot/vmlinuz-${kver}* | head -1
register: vmlinux_out
check_mode: false
when:
- kver_out.rc|default(1) == 0
2023-12-30 22:09:49 +00:00
2023-12-29 19:40:31 +00:00
- name: copy kernel vmlinux
copy:
src: "{{AGI_GENTOO_FROM_MP}}{{vmlinux_out.stdout}}"
dest: "{{AGI_NBD_MP}}/boot"
remote_src: no
when:
- AGI_use_local_kernel
check_mode: false
- name: resolve ramfs
shell: |
kver="{{kver_out.stdout}}"
ls {{AGI_GENTOO_FROM_MP}}/boot/initramfs-pentoo-x86_64-${kver}* | head -1
register: ramfs_out
check_mode: false
when:
- kver_out.rc|default(1) == 0
2023-12-30 22:09:49 +00:00
2023-12-29 19:40:31 +00:00
- name: copy kernel vmlinux
copy:
src: "{{AGI_GENTOO_FROM_MP}}{{ramfs_out.stdout}}"
dest: "{{AGI_NBD_MP}}/boot"
remote_src: no
when:
- AGI_use_local_kernel
- ramfs_out.rc|default(1) == 0
2024-01-01 01:04:40 +00:00
- false
ignore_errors: true
2023-12-29 19:40:31 +00:00
- name: make directories
shell: |
cd {{AGI_GENTOO_FROM_MP}} || exit 1
2023-12-31 07:39:01 +00:00
for dir in {{' '.join(AGI_bootstrap_dirs)}}; do
2023-12-31 03:19:26 +00:00
[ -d "{{AGI_NBD_MP}}/$dir" ] && continue
mkdir -p "{{AGI_NBD_MP}}/$dir"
2023-12-29 19:40:31 +00:00
done
2023-12-31 07:39:01 +00:00
for file in {{' '.join(AGI_bootstrap_files)}}; do
2023-12-31 03:19:26 +00:00
[ -f "{{AGI_NBD_MP}}/$file" ] && continue
cp -np "$file" "{{AGI_NBD_MP}}/$file"
2023-12-29 19:40:31 +00:00
done
2024-01-01 01:04:40 +00:00
ignore_errors: true
2023-12-30 22:09:49 +00:00
2023-12-29 19:40:31 +00:00
# dracut