Skip to content

Commit

Permalink
Add the USERCUSTOMIZATION class to facilitate user configuration
Browse files Browse the repository at this point in the history
This commits splits the base hierarchy into 3:
- srv_fai_config is still the default SEAPATH configuration
- usercustomization is the same hierarchy but git will not track it, and the user can put custom files in it
- build_tmp is a temporary folder where the installer will merge srv_fai_config and usercustomization just before merging

srv_fai_config also includes now the new USERCUSTOMIZATION class, so that the files in the userconfiguration/ folder can implement this class and override/add any setting.

Signed-off-by: Florent CARLI <[email protected]>
  • Loading branch information
insatomcat committed Jun 17, 2024
1 parent ecbac0a commit 08d02af
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
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
13 changes: 11 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
9 changes: 7 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,13 @@ $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

# Creating the mirror
CLASSES="FAIBASE,DEBIAN,GRUB_EFI,SEAPATH_COMMON,${finalClasses}LAST"
CLASSES="FAIBASE,DEBIAN,GRUB_EFI,SEAPATH_COMMON,${finalClasses}USERCUSTOMIZATION,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 +173,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/*
2 changes: 2 additions & 0 deletions srv_fai_config/class/99-seapath
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,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

0 comments on commit 08d02af

Please sign in to comment.