init commit

This commit is contained in:
2025-09-14 14:22:00 -07:00
commit 0fcf53e525
14 changed files with 1065 additions and 0 deletions

206
tasks/build_iso.yaml Normal file
View File

@ -0,0 +1,206 @@
---
# https://gist.github.com/zuzzas/a1695344162ac7fa124e15855ce0768f
# http://askubuntu.com/questions/6684/preseeding-ubuntu-server
###############################################
# Install packages needed for ISO Building
###############################################
- name: Build ISO - APT - Install Packages
apt:
name:
- "{{ item }}"
state: present
loop: "{{ iso_packages }}"
when: not refresh_only or iso_only | bool
###############################################
# DEB13 Source ISO Extract
# Download the most recent ISO from debian
# Extract contents to local folder
###############################################
- name: Build ISO - Extract Source - Check ISO Directory
file:
path: "{{ iso_share }}"
state: directory
mode: '0755'
- name: Build ISO - Extract Source - Check Temp Directory
file:
path: "{{ deb13_pxe }}"
state: directory
mode: '0644'
- name: Build ISO - Extract Source - Check Extraction Directory
file:
path: "{{ deb13_iso }}"
state: directory
mode: '0644'
- name: Build ISO - Extract Source - Check Source Directory
file:
path: "{{ deb13_src }}"
state: directory
mode: '0644'
- name: Build ISO - Get Recent Debian Version
shell: |
curl -s https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/ | \
grep netinst | grep iso | grep -v -e edu -e mac | cut -d '"' -f 6
register: recent_version
- name: Build ISO - Display Recent Version
debug:
msg: "Current Debian ISO name: {{ recent_version.stdout_lines[0] }}"
- name: Build ISO - Extract Source - Download ISO
get_url:
url: "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/{{ recent_version.stdout_lines[0] }}"
dest: "{{ iso_share }}/deb13-master.iso"
mode: '0644'
register: deb13_iso_download
- name: show iso size
debug:
msg: "Debian Net ISO Size is {{ (deb13_iso_download.size | float ) / 1048576 }}MB"
- name: Build ISO - Extract Source - Mount ISO
shell: "mount -o loop {{ iso_share }}/deb13-master.iso {{ deb13_iso }}"
- name: Build ISO - Extract Source - Copy ISO data
shell: "rsync -a -H --exclude=TRANS.TBL {{ deb13_iso }}/ {{ deb13_src }}"
- name: Build ISO - Extract Source - Unmount ISO
shell: "umount {{ deb13_iso }}"
###############################################
# Copy Matt-Cloud Init Script et. al.
###############################################
###############################################
# DEB13 Source modify
# Copy preseed file to source
# copy cosmos-init data to source
# Add preseed to initrd
# Recompute checksums
###############################################
- name: Build ISO - Modify Source - Correct Permissions
shell: "chmod -R 755 {{ deb13_src }}"
- name: Build ISO - Modify Source - Copy Preseed
template:
src: preseed-usb.cfg.j2
dest: "{{ deb13_src }}/preseed.cfg"
mode: 0644
# Create cosmos folder
#
# copy files for preseed
# jenkins_key
# update_issue.sh
# permitrootlogin
# .bashrc
# stat.sh
# cosmos-client.conf
- name: Build ISO - Modify Source - Create Cosmos Folder
file:
path: "{{ deb13_src }}/cosmos"
state: directory
mode: '0755'
- name: build archive if needed
when: not archive_fresh | bool
ansible.builtin.archive:
path: "/var/jenkins_home/ansible/roles/pxe_server/files/init"
dest: "/var/jenkins_home/ansible/roles/pxe_server/files/cosmos-init.tar"
format: "tar"
delegate_to: localhost
# Copy Archive to Target
- name: Files - Copy cosmos-init.tar to target
copy:
src: /var/jenkins_home/ansible/roles/pxe_server/files/cosmos-init.tar
dest: "{{ deb13_src }}/cosmos/cosmos-init.tar"
mode: 0644
- name: Check archive size
shell: "ls -lah {{ deb13_src }}/cosmos/cosmos-init.tar | cut -d ' ' -f 5 "
register: archive_size_output
- name: Show archive size
debug:
msg: "cosmos-init.tar archive is {{ archive_size_output.stdout_lines[0] }}"
- name: Build ISO - Modify Source - remove GUI install option
shell: |
sed -i '/menuentry --hotkey=g '\''Graphical install'\'' {/,/^}/d' {{ deb13_src }}/boot/grub/grub.cfg
- name: Build ISO - Modify Source - edit isolinux/txt.cfg
shell: >
sed 's/initrd.gz/initrd.gz file=\/cdrom\/preseed.cfg/' -i /opt/cosmos/deb13-source/isolinux/txt.cfg
- name: Build ISO - Modify Source - add preseed to initrd
shell: |
ISODIR_WRITE={{ deb13_src }}/
mkdir $ISODIR_WRITE/irmod
cd $ISODIR_WRITE/irmod
gzip -d < $ISODIR_WRITE/install.amd/initrd.gz | \
cpio --extract --make-directories --no-absolute-filenames
cp $ISODIR_WRITE/preseed.cfg preseed.cfg
chown root:root preseed.cfg
chmod o+w $ISODIR_WRITE/install.amd/initrd.gz
find . | cpio -H newc --create | \
gzip -9 > $ISODIR_WRITE/install.amd/initrd.gz
chmod o-w $ISODIR_WRITE/install.amd/initrd.gz
cd $ISODIR_WRITE/
rm -fr $ISODIR_WRITE/irmod/
- name: Build ISO - Modify Source - fixing MD5 checksums
shell: |
cd {{ deb13_src }}/
md5sum $(find -type f) > {{ deb13_src }}/md5sum.txt
###############################################
# DEB12 Build ISO * 'burn' script
###############################################
- name: Build ISO - Build Deb13-MC.iso
shell: |
xorriso -as mkisofs \
-r \
-V "Deb13_MC" \
-o "{{ iso_share }}/Deb13-MC.iso" \
-J \
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
-partition_offset 16 \
-A "Debian 13 Matt-Cloud ISO" \
-b isolinux/isolinux.bin \
-c isolinux/boot.cat \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
-eltorito-alt-boot \
-e boot/grub/efi.img \
-no-emul-boot \
-isohybrid-gpt-basdat \
-append_partition 2 0xef {{ deb13_src }}/boot/grub/efi.img \
{{ deb13_src }}
- name: get iso size
shell: "ls -lah {{ iso_share }}/Deb13-MC.iso | cut -d ' ' -f 5"
register: iso_size_output
- name: show iso size
debug:
msg: "Deb13-MC.iso is {{ iso_size_output.stdout_lines[0] }}."
- name: Build ISO - Build 'burn' script
shell: "echo dd if={{ iso_share }}/Deb13-MC.iso of=CHANGE_TO_USB bs=16M status=progress oflag=sync > {{ iso_share }}/burn_deb.sh"
- name: Build ISO - Make 'burn' script executable
shell: "chmod +x {{ iso_share }}/burn_deb.sh"
...