Examples
Examples of working recipes can be found in simple-cdd-yam-recipes.
Example recipe base
The simplest recipe that
simple-cdd-yam-recipes
features is the recipe
base
,
which is shown below.
The recipe consists of:
- A series of variables with default values, which can be overridded when
including this recipe in another recipe. Variables are used throughout the recipe using the
jinja2
notation{{variable}}
. - Profile name definition.
- A series of actions:
recipe
action. Include another recipe, where some variables are being overridden.conf
action: Set simple-CDD variables and environment variables.preseed
action: The Debian-CD configuration is controlled via preseed. files. Here, a template is used in which variables are substituted.apt
action: Install Debian packages.run
action (script
): Runs a script. Note that variables in the script also might get substituted.run
action (command
): Runs a command.overlay
action: Deploys the contents of a give directory onto the system. This can be done byroot
(default) or by a given user.
- Also note that it's possible to include more complex behavior using
jinja2
, such as if-statements as shown in this example.
base.yaml
{% set locale=locale or "en_US" -%}
{% set keyboard=keyboard or "us" -%}
{% set profile=profile or "base" -%}
{% set mirror_components=mirror_components or "main" -%}
{% set disk_type=disk_type or "DVD" -%}
{% set dist=dist or "bookworm" -%}
{% set mirror=mirror or "http://ftp.de.debian.org/debian/" -%}
{% set username=username or "user" -%}
{% set user_fullname=user_fullname or "User" -%}
{% set user_password=user_password or "user" -%}
{% set root_password=root_password or "root" -%}
{% set hostname=hostname or "base" -%}
{% set domain_name=domain_name or "domain" -%}
{% set debos=debos or false %}
profile: {{profile}}
actions:
- action: recipe
description: Recipe with debos steps
recipe: recipes/debos.yaml
variables:
dist: {{dist}}
username: {{username}}
- action: conf
description: Simple-CDD configuration settings
variables:
locale: {{locale}}
keyboard: {{keyboard}}
profiles: {{profile}}
auto_profiles: {{profile}}
mirror_components: {{mirror_components}}
env_variables:
DISKTYPE: {{disk_type}}
CODENAME: {{dist}}
DEBIAN_MIRROR: {{mirror}}
- action: preseed
description: Basic preseed file for minimum Debian system with EFI boot
preconf: preseeds/base-preseed.txt
variables:
user_fullname: {{user_fullname}}
username: {{username}}
user_password: {{user_password}}
root_password: {{root_password}}
hostname: {{hostname}}
domain: {{domain_name}}
- action: apt
description: Base packages
packages:
- adduser
- apparmor
- apt
- apt-transport-https
- apt-utils
- busybox
- ca-certificates
- dirmngr
- dos2unix
- dbus-user-session
- gnupg
- initramfs-tools
- iptables
- lsb-release
- openssh-server
- sudo
- systemd
- systemd-timesyncd
- unattended-upgrades
- zstd
- action: run
description: Add {{username}} to sudoers
variables:
username: {{username}}
script: scripts/add_sudoer.sh
- action: run
description: Add {{username}} to several groups
variables:
username: {{username}}
groups:
- admin
- adm
- dialout
- cdrom
- plugdev
- power
- audio
- dip
- video
- staff
- shared
- sudo
script: scripts/setup_user_groups.sh
{% if not debos %}
- action: run
description: Make sure debian UEFI file is registered as boot entry
command: grub-install --efi-directory /boot/efi --force-extra-removable --recheck && update-grub
- action: run
description: Configure grub (output and no menu shown)
script: scripts/configure_grub.sh
{% endif%}
- action: overlay
description: Bash settings for {{username}}
user: {{username}}
source: overlays/bash-settings
- action: overlay
description: Bash settings for root
user: root
source: overlays/bash-settings