diff --git a/image-builder/Makefile b/image-builder/Makefile index 82d2026..9d15a49 100644 --- a/image-builder/Makefile +++ b/image-builder/Makefile @@ -26,10 +26,14 @@ DISTRO ?= ubuntu_focal WORKDIR ?= ./config # Specify if you want to specify qcow config directories manually instead of using default naming conventions QCOW_CONF_DIRS ?= -# Set to true if you want to skip multistrap build step for testing +# Set to true to skip multistrap.sh script. Useful for testing SKIP_MULTISTRAP ?= -# Set to true if you want to skip the other playsbooks except osconfig for osconfig playbook testing -OSCONFIG_TEST ?= +# Set to true to skip multistrap playbook. Useful for testing +SKIP_MULTI_ROLE ?= +# Set to true to skip osconfig playbook. Useful for testing +SKIP_OSCONFIG_ROLE ?= +# Set to true to skip livecdcontent playbook. Useful for testing +SKIP_LIVECDCONTENT_ROLE ?= IMAGE ?= ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}-${DISTRO} QCOW_IMAGE ?= ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${QCOW_IMAGE_NAME}:${IMAGE_TAG}-${DISTRO} PROXY ?= diff --git a/image-builder/README.md b/image-builder/README.md index 878b75a..2089efc 100644 --- a/image-builder/README.md +++ b/image-builder/README.md @@ -45,7 +45,7 @@ sudo make IMAGE_TYPE=qcow cut_image In the above example, set ``IMAGE_TYPE`` to ``iso`` or ``qcow`` as appropriate. This will be passed into the container to instruct it which type of image to build. Also include ``DOCKER_REGISTRY`` override if you wish to use a local docker image as described in the previous section. -This makefile target uses config files provided in the images/image-builder/config directory. Modify these files as needed in order to customize your iso and qcow generation. +This makefile target uses config files provided in the `images/image-builder/config` directory. **Modify these files as needed in order to customize your iso and qcow generation.** This provides a good place for adding and testing customizations to build parameters, without needing to modify the ansible playbooks themselves. # Building behind a proxy @@ -63,6 +63,16 @@ sudo make DOCKER_REGISTRY=mylocalreg PROXY=http://proxy.example.com:8080 IMAGE_T sudo make DOCKER_REGISTRY=mylocalreg PROXY=http://proxy.example.com:8080 IMAGE_TYPE=qcow cut_image ``` +# Useful testing flags + +The `SKIP_MULTI_ROLE` build flag is useful if you would like to test local updates to the `osconfig` playbook, or updates to custom configs for this playbook. This saves time since you do not need to rebuild the target filesystem. For example: + +``` +sudo make SKIP_MULTI_ROLE=true build +``` + +Similiarly, osconfig and livecdcontent roles can be skipped using `SKIP_OSCONFIG_ROLE` and `SKIP_LIVECDCONTENT_ROLE` respectively. `SKIP_LIVECDCONTENT_ROLE` may be useful in combination with `SKIP_MULTI_ROLE` if you want to test out playbook changes to `osconfig` (however, it won't show up in the final bootable ISO image unless you don't skip `SKIP_LIVECDCONTENT_ROLE`). + # Division of Configuration Management responsibilities Configuration management of the base OS is divided into several realms, each with their own focus: @@ -87,3 +97,8 @@ Configuration management of the base OS is divided into several realms, each wit # Supported OSes - Ubuntu 20.04 LTS + +# FAQ + +Q: Why is the build target slow? +A: There is a `mksquashfs` command which runs as part of the build target, and performs slowly if your build environment lacks certain CPU flags which accelerate compression. Use "host-passthrough" or equivalent in your build environment to pass through these CPU flags. In libvirt domain XML, you would change your `cpu` mode element as follows: `` diff --git a/image-builder/assets/playbooks/roles/multistrap/defaults/main.yaml b/image-builder/assets/playbooks/roles/multistrap/defaults/main.yaml index d6d9e1f..1d6d679 100644 --- a/image-builder/assets/playbooks/roles/multistrap/defaults/main.yaml +++ b/image-builder/assets/playbooks/roles/multistrap/defaults/main.yaml @@ -3,7 +3,7 @@ rootfs_arch: amd64 k8s_version: 1.18.6-00 kernel_base_pkg: linux-image-generic kernel_headers_pkg: linux-headers-generic -systemd_nic_names_policy: keep kernel database onboard path slot +systemd_nic_names_policy: kernel database onboard path slot systemd_nic_alternative_names_policy: database onboard path slot ubuntu_packages: - apparmor diff --git a/image-builder/tools/multistrap.sh b/image-builder/tools/multistrap.sh index 0180e73..3bff65e 100755 --- a/image-builder/tools/multistrap.sh +++ b/image-builder/tools/multistrap.sh @@ -113,7 +113,7 @@ cp assets/playbooks/inventory.yaml $build_dir/opt/assets/playbooks/inventory.yam cp assets/playbooks/base-chroot.yaml $build_dir/opt/assets/playbooks/base-chroot.yaml cp -r assets/playbooks/roles/multistrap $build_dir/opt/assets/playbooks/roles # Run multistrap -if [ -z $OSCONFIG_TEST ]; then +if [ -z $SKIP_MULTI_ROLE ]; then sudo -E ansible-playbook -i assets/playbooks/inventory.yaml assets/playbooks/base-chroot.yaml -vv fi @@ -126,13 +126,15 @@ else mkdir -p $build_dir/config fi cp -r $workdir/scripts $build_dir/config/ -sudo -E ansible-playbook -i assets/playbooks/inventory.yaml assets/playbooks/base-osconfig.yaml --extra-vars "run_context=common" -vv +if [ -z "$SKIP_OSCONFIG_ROLE" ]; then + sudo -E ansible-playbook -i assets/playbooks/inventory.yaml assets/playbooks/base-osconfig.yaml --extra-vars "run_context=common" -vv +fi umount_chroot cp assets/playbooks/base-livecdcontent.yaml $build_dir/opt/assets/playbooks/base-livecdcontent.yaml cp -r assets/playbooks/roles/livecdcontent $build_dir/opt/assets/playbooks/roles -if [ -z $OSCONFIG_TEST ]; then +if [ -z "$SKIP_LIVECDCONTENT_ROLE" ]; then sudo -E ansible-playbook -i assets/playbooks/inventory.yaml assets/playbooks/base-livecdcontent.yaml -vv fi