Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the USERCUSTOMIZATION class and allow User-defined classes #107

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.iso
SEAPATH_COMMON.var
usercustomization/
build_tmp/
grub.cfg
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@ However please checkout the Customization section first. There are some things t

## Customization
Some customization you will want to make before building.
First, copy the srv_fai_config/class/SEAPATH_COMMON.var.defaults file to srv_fai_config/class/SEAPATH_COMMON.var
You will make your changes in this new file.
For that you can add all the files you need in the build_debian_iso/usercustomization hierarchy, using the USERCUSTOMIZATION class name:
- add your variables in the build_debian_iso/usercustomization/class/USERCUSTOMIZATION.var file
- add your debconf parameters to build_debian_iso/usercustomization/debconf/USERCUSTOMIZATION file
- add your disk config to build_debian_iso/usercustomization/disk_config/USERCUSTOMIZATION file
- add your files to build_debian_iso/usercustomization/files/ hierarchy using USERCUSTOMIZATION as the class name (for example build_debian_iso/usercustomization/files/etc/motd/USERCUSTOMIZATION)
- add your hooks to build_debian_iso/usercustomization/hooks/ using USERCUSTOMIZATION as the class name (for example build_debian_iso/usercustomization/hooks/install.USERCUSTOMIZATION)
- add your package_config to build_debian_iso/usercustomization/package_config/USERCUSTOMIZATION file
- add your scripts to build_debian_iso/usercustomization/scripts using USERCUSTOMIZATION as the class name (for example build_debian_iso/usercustomization/scripts/USERCUSTOMIZATION/88-myscript)

Both folders "build_debian_iso/usercustomization and build_debian_iso/srv_fai_config will be merged into build_debian_iso/build_tmp when building).


### Mandatory
**change the authorized_keys files (user and root) with your own**
Expand Down Expand Up @@ -69,6 +78,13 @@ The possibles flags to create a grub menu item are:

If you want an "english, no debug, no raid, no cockpit, no kerberos, standalone" installation, then you need to uncheck everything, which will result in a fake "noflag" grub menu item being added. This is normal.

** User-defined classes **
The user can manage his own classes by:
- adding the class in the user_classes.conf file
- dealing with a numbered script in usercustomization/class/ folder (for example usercustomization/class/99-custom, chmod 755) to use the class (see srv_fai_config/class/99-seapath script for reference)
- adding all the files related to the classes in the usercustomization hierarchy (for example usercustomization/package_config/USERCLASS1)


## Build a Virtual Machine image

To build a basic VM for the SEAPATH project, simply launch the script `build_qcow2.sh` from the directory where you want the .qcow2 file to be stored (the build host must use UEFI).
Expand Down
12 changes: 10 additions & 2 deletions build_iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ if [ ! -f "$wd"/etc_fai/grub.cfg ]; then
cp "$wd"/etc_fai/grub_base.cfg "$wd"/etc_fai/grub.cfg
fi

rm -rf "$wd"/build_tmp/*
cp -r "$wd/srv_fai_config/"* "$wd/build_tmp"
cp -r "$wd/usercustomization/"* "$wd/build_tmp"

finalClasses="SEAPATH_CLUSTER,SEAPATH_DBG,SEAPATH_KERBEROS,SEAPATH_COCKPIT,"

if [ "$1" == "--custom" ]; then
Expand Down Expand Up @@ -148,13 +152,16 @@ $COMPOSECMD -f "$wd"/docker-compose.yml run --rm fai-setup bash -c "\
$COMPOSECMD -f "$wd"/docker-compose.yml up --no-start fai-setup

# Adding the SEAPATH workspace
docker cp "$wd"/srv_fai_config/. fai-setup:/ext/srv/fai/config/
docker cp "$wd"/build_tmp/. fai-setup:/ext/srv/fai/config/

# Stopping the container after having added stuff in it
$COMPOSECMD -f "$wd"/docker-compose.yml down

# List user defined Classes
userClasses=$(grep -Ev "^#|^$" "$wd"/user_classes.conf | tr '\n' ',' | sed -e "s/,$//")

# Creating the mirror
CLASSES="FAIBASE,DEBIAN,GRUB_EFI,SEAPATH_COMMON,${finalClasses}LAST"
CLASSES="FAIBASE,DEBIAN,GRUB_EFI,SEAPATH_COMMON,${finalClasses}USERCUSTOMIZATION,${userClasses},LAST"
$COMPOSECMD -f "$wd"/docker-compose.yml run --rm fai-setup bash -c "\
cp /etc/fai/apt/keys/* /etc/apt/trusted.gpg.d/ &&\
fai-mirror -c $CLASSES /ext/mirror"
Expand All @@ -169,3 +176,4 @@ $COMPOSECMD -f "$wd"/docker-compose.yml down --remove-orphans

# Removing the volume
docker volume rm build_debian_iso_ext
rm -rf "$wd"/build_tmp/*
9 changes: 7 additions & 2 deletions build_qcow2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ docker volume rm build_debian_iso_ext 2>/dev/null

set -ex

rm -rf "$wd"/build_tmp/*
cp -r "$wd/srv_fai_config/"* "$wd/build_tmp"
cp -r "$wd/usercustomization/"* "$wd/build_tmp"

# Create the default config space
$COMPOSECMD -f "$wd"/docker-compose.yml run --rm fai-setup \
fai-mk-configspace
Expand All @@ -28,14 +32,14 @@ $COMPOSECMD -f "$wd"/docker-compose.yml run --rm fai-setup \
$COMPOSECMD -f "$wd"/docker-compose.yml up --no-start fai-setup

# Adding the SEAPATH config
docker cp "$wd"/srv_fai_config/. fai-setup:ext/srv/fai/config/
docker cp "$wd"/build_tmp/. fai-setup:ext/srv/fai/config/

# Stopping the container after having added stuff in it
$COMPOSECMD -f "$wd"/docker-compose.yml down

# Creating the VM
# patches /sbin/install_packages (bug in the process of being corrected upstream)
CLASSES="DEBIAN,FAIBASE,FRENCH,BOOKWORM64,SEAPATH_COMMON,SEAPATH_VM,GRUB_EFI,LAST"
CLASSES="DEBIAN,FAIBASE,FRENCH,BOOKWORM64,SEAPATH_COMMON,SEAPATH_VM,GRUB_EFI,USERCUSTOMIZATION,LAST"
$COMPOSECMD -f "$wd"/docker-compose.yml run fai-cd bash -c "\
sed -i -e \"s|-f \\\"\\\$FAI_ROOT/usr/sbin/apt-cache|-f \\\"\\\$FAI_ROOT/usr/bin/apt-cache|\" /sbin/install_packages && \
sed -i -e \"s/ --allow-change-held-packages//\" /sbin/install_packages && \
Expand All @@ -49,3 +53,4 @@ $COMPOSECMD -f "$wd"/docker-compose.yml down --remove-orphans

# Removing the volume
docker volume rm build_debian_iso_ext
rm -rf "$wd"/build_tmp/*
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#!/bin/bash

# do not use this if a menu will be presented
[ "$flag_menu" ] && exit 0
Expand All @@ -14,4 +14,6 @@ echo DEBIAN FAIBASE BOOKWORM64 SEAPATH_COMMON SEAPATH_HOST
[ "$flag_kerberos" ] && echo "SEAPATH_KERBEROS"
[ "$flag_cockpit" ] && echo "SEAPATH_COCKPIT"

echo "USERCUSTOMIZATION"

exit 0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# default values for installation. You can override them in your *.var files
# default values for installation. You can override them in your usercustomization/class/USERCUSTOMIZATION.var file

HOSTNAME=debian

Expand Down Expand Up @@ -31,8 +31,8 @@ USERPW='$y$j9T$s.szNr.QzTLk8h5qMYDpo0$YMaC8.04FilI/1AguyofvbV4FH1me6Nc7SHP4hyefZ
usernameansible=ansible

myrootkey='ssh-rsa XXX'
myuserkey='ssh-rsa XXX'
ansiblekey='ssh-rsa XXX'
myuserkey='ssh-rsa YYY'
ansiblekey='ssh-rsa ZZZ'

#APTPROXY=http://proxy:3128
apt_cdn=http://ftp.fr.debian.org
Expand Down
4 changes: 4 additions & 0 deletions user_classes.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# list user defined classes, one class per line
# exemple :
# USERCLASS1
# USERCLASS2