From a3923351af12e3f355d59fa8510b5872ed6b50a9 Mon Sep 17 00:00:00 2001 From: "bingshen.wbs" Date: Mon, 30 Jan 2023 15:21:10 +0800 Subject: [PATCH] add aliyunlinux 3 example to support cgroup v2 custom image --- examples/ack-aliyunlinux3.json | 43 ++++++++++++++++++++++++++++++++++ scripts/set-cgroupv2.sh | 11 +++++++++ 2 files changed, 54 insertions(+) create mode 100644 examples/ack-aliyunlinux3.json create mode 100644 scripts/set-cgroupv2.sh diff --git a/examples/ack-aliyunlinux3.json b/examples/ack-aliyunlinux3.json new file mode 100644 index 0000000..0e6643c --- /dev/null +++ b/examples/ack-aliyunlinux3.json @@ -0,0 +1,43 @@ +{ + "variables": { + "region": "cn-hangzhou", + "image_name": "test_image{{timestamp}}", + "source_image": "aliyun_3_x64_20G_alibase_20221102.vhd", + "instance_type": "ecs.g6.2xlarge", + "access_key": "{{env `ALICLOUD_ACCESS_KEY`}}", + "secret_key": "{{env `ALICLOUD_SECRET_KEY`}}" + }, + "builders": [ + { + "type": "alicloud-ecs", + "access_key": "{{user `access_key`}}", + "secret_key": "{{user `secret_key`}}", + "region": "{{user `region`}}", + "image_name": "{{user `image_name`}}", + "source_image": "{{user `source_image`}}", + "ssh_username": "root", + "instance_type": "{{user `instance_type`}}", + "skip_image_validation": "true", + "io_optimized": "true", + "associate_public_ip_address": "true" + } + ], + "provisioners": [ + { + "type": "shell", + "environment_vars": [ + "CGROUP_MODE={{user `cgroup_mode`}}" + ], + "scripts": [ + "scripts/set-cgroupv2.sh", + "scripts/updateKernel.sh", + "scripts/reboot.sh", + "scripts/cleanUpKerneles.sh", + "config/default.sh", + "scripts/disableTuned.sh", + "scripts/verify.sh" + ], + "expect_disconnect": true + } + ] +} diff --git a/scripts/set-cgroupv2.sh b/scripts/set-cgroupv2.sh new file mode 100644 index 0000000..af452f8 --- /dev/null +++ b/scripts/set-cgroupv2.sh @@ -0,0 +1,11 @@ +#!/bin/bash +echo $CGROUP_MODE + +if [[ ! -z $CGROUP_MODE ]] && [[ $CGROUP_MODE =~ .*[v,V]2.* ]]; then + echo "set cgroup mode to $CGROUP_MODE" + if ! grep -q 'systemd.unified_cgroup_hierarchy=1' /etc/default/grub; then + grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=1" + fi +fi + +