diff --git a/.gitignore b/.gitignore index 73c084e..5563b5e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ bootstrap_capo/capo-ephemeral image-builder/config/*.iso image-builder/config/*.qcow2 image-builder/config/*.md5sum +image-builder/assets/playbooks/roles/multistrap/vars/main.yaml diff --git a/.zuul.yaml b/.zuul.yaml index 0e375be..da17f3a 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -20,6 +20,7 @@ http: "" https: "" noproxy: "" + image_config_dir: config check: jobs: - airship-images-functional diff --git a/image-builder/Makefile b/image-builder/Makefile index 73dbcab..d1bc829 100644 --- a/image-builder/Makefile +++ b/image-builder/Makefile @@ -40,6 +40,8 @@ help: ## This help. images: build generate_iso package_qcow build: + # Apply any user-defined overrides to multistrap playbook + cp $(WORKDIR)/rootfs/multistrap-vars.yaml assets/playbooks/roles/multistrap/vars/main.yaml ifneq ($(PROXY), ) sudo -E ./tools/docker_proxy.sh $(PROXY) $(NO_PROXY) export http_proxy=$(PROXY) diff --git a/image-builder/assets/playbooks/roles/multistrap/vars/README.md b/image-builder/assets/playbooks/roles/multistrap/vars/README.md new file mode 100644 index 0000000..385420f --- /dev/null +++ b/image-builder/assets/playbooks/roles/multistrap/vars/README.md @@ -0,0 +1,3 @@ +Do not make updates here. + +See image-builder/config/rootfs/multistrap-vars.yaml diff --git a/image-builder/assets/playbooks/roles/osconfig/defaults/main.yaml b/image-builder/assets/playbooks/roles/osconfig/defaults/main.yaml index 6d4d553..ee514a9 100644 --- a/image-builder/assets/playbooks/roles/osconfig/defaults/main.yaml +++ b/image-builder/assets/playbooks/roles/osconfig/defaults/main.yaml @@ -42,6 +42,26 @@ limits: type: 'hard' item: 'core' value: 0 + - name: nofile-root-soft + domain: 'root' + type: 'soft' + item: 'nofile' + value: '65536' + - name: nofile-root-hard + domain: 'root' + type: 'hard' + item: 'nofile' + value: '1048576' + - name: nofile-all-soft + domain: '*' + type: 'soft' + item: 'nofile' + value: '65536' + - name: nofile-all-hard + domain: '*' + type: 'hard' + item: 'nofile' + value: '1048576' sysctl: - name: net.bridge.bridge-nf-call-ip6tables diff --git a/image-builder/assets/playbooks/roles/multistrap/vars/main.yaml b/image-builder/config/rootfs/multistrap-vars.yaml similarity index 85% rename from image-builder/assets/playbooks/roles/multistrap/vars/main.yaml rename to image-builder/config/rootfs/multistrap-vars.yaml index 474aece..7bc3c7d 100644 --- a/image-builder/assets/playbooks/roles/multistrap/vars/main.yaml +++ b/image-builder/config/rootfs/multistrap-vars.yaml @@ -1,9 +1,9 @@ -# Overrides to the playbook default variables may be defined in this file. +# Overrides to the multistrap playbook defaults may be defined in this file. # # The following are examples that show you how to override variables. # # Example 1: The following usage will *overwrite* the list of repos & packages -# defined under defaults/main.yaml with the list here: +# defined under multistrap/defaults/main.yaml with the list here: #repos: # - register_repo_with_rootfs: true # name: Ubuntu @@ -20,7 +20,7 @@ # everything, including the package list(s) for each mirror. # # Example 2: The following usage will *append* to the list of default repos -# defined under defaults/main.yaml with the list here: +# defined under multistrap/defaults/main.yaml with the list here: #repos_append: # - register_repo_with_rootfs: true # name: DellUtilsRepo @@ -38,7 +38,8 @@ # the community Ubuntu mirrors. # # Example 3: The following usage will *append* to the list of default packages -# installed from the default Ubuntu mirror defined in defaults/main.yaml: +# installed from the default Ubuntu mirror defined in +# multistrap/defaults/main.yaml: #ubuntu_packages_append: # - package1 # - package2 diff --git a/image-builder/tools/cut_image.sh b/image-builder/tools/cut_image.sh index a9367e9..f8a1135 100755 --- a/image-builder/tools/cut_image.sh +++ b/image-builder/tools/cut_image.sh @@ -45,7 +45,10 @@ install_pkg(){ dpkg -l $1 2> /dev/null | grep ^ii > /dev/null || sudo -E apt-get -y install $1 } -sudo -E apt -y update +if [ ! -f /var/lib/apt/periodic/update-success-stamp ] || \ + sudo find /var/lib/apt/periodic/update-success-stamp -mtime +1 | grep update-success-stamp; then + sudo -E apt -y update +fi install_pkg qemu-kvm install_pkg virtinst @@ -110,9 +113,9 @@ outputFileName: $img_name" > ${qcow_config} --env NO_PROXY=$noproxy \ ${image} < ${qcow_config} cloud_init_config_dir='assets/tests/qcow/cloud-init' - sudo -E cloud-localds -v --network-config="${cloud_init_config_dir}/network-config" "${workdir}/airship-ubuntu_config.iso" "${cloud_init_config_dir}/user-data" "${cloud_init_config_dir}/meta-data" + sudo -E cloud-localds -v --network-config="${cloud_init_config_dir}/network-config" "${workdir}/${img_name}_config.iso" "${cloud_init_config_dir}/user-data" "${cloud_init_config_dir}/meta-data" disk1="--disk path=${workdir}/${img_name}" - disk2="--disk path=${workdir}/airship-ubuntu_config.iso,device=cdrom" + disk2="--disk path=${workdir}/${img_name}_config.iso,device=cdrom" else echo Unknown build type: $build_type, exiting. exit 1 diff --git a/image-builder/tools/multistrap.sh b/image-builder/tools/multistrap.sh index 598fc35..8b5a1a2 100755 --- a/image-builder/tools/multistrap.sh +++ b/image-builder/tools/multistrap.sh @@ -44,7 +44,10 @@ umount_chroot(){ } # Install pre-requisites -sudo -E apt -y update +if [ ! -f /var/lib/apt/periodic/update-success-stamp ] || \ + sudo find /var/lib/apt/periodic/update-success-stamp -mtime +1 | grep update-success-stamp; then + sudo -E apt -y update +fi install_pkg efivar # required for building UEFI image @@ -73,7 +76,9 @@ pip3 show ansible >& /dev/null || sudo -E pip3 install --upgrade ansible if [[ $1 = clean ]]; then umount_chroot - sudo chattr -i $build_dir/etc/kernel/postinst.d/kdump-tools + if [ -f $build_dir/etc/kernel/postinst.d/kdump-tools ]; then + sudo chattr -i $build_dir/etc/kernel/postinst.d/kdump-tools + fi if [[ -d $build_dir ]]; then sudo rm -rf $build_dir fi diff --git a/playbooks/airship-images-build.yaml b/playbooks/airship-images-build.yaml index f266cda..354a57b 100644 --- a/playbooks/airship-images-build.yaml +++ b/playbooks/airship-images-build.yaml @@ -38,4 +38,5 @@ params: COMMIT: "{{ zuul.newrev | default('') }}" PUSH_IMAGE: "false" + WORKDIR: "{{ image_config_dir | default('config') }}" become: True diff --git a/playbooks/airship-images-publish.yaml b/playbooks/airship-images-publish.yaml index 5a30a0f..d2405d7 100644 --- a/playbooks/airship-images-publish.yaml +++ b/playbooks/airship-images-publish.yaml @@ -43,4 +43,5 @@ DOCKER_REGISTRY: "{{ docker_registry }}" GCP_SDK: "{{ gcp_sdk }}" AZ_SDK: "{{ az_sdk }}" + WORKDIR: "{{ image_config_dir | default('config') }}" become: True