From e8d6c9ecb090c1dc8d80e51bbea8af7c495a8cd2 Mon Sep 17 00:00:00 2001 From: Ravi kumar Veeramally Date: Tue, 13 Jun 2023 23:42:19 +0300 Subject: [PATCH] test_data: Simplify default configuration for local testing Script `create-cloud-init.sh" uses the same cloud init data as the the CI but this means it is somewhat overloaded with unhelpful network configuration entries and scripts that are only needed for the CI. For local testing data kept in test_data/cloud-init/ubuntu/local folder. This contains minimum configuration data for user to test it locally. Script assigns default IP address using "network-config" details with --net "tap=" option. The default network interface will be "ens4". Signed-off-by: Ravi kumar Veeramally --- README.md | 5 ++++- scripts/create-cloud-init.sh | 6 +++--- test_data/cloud-init/ubuntu/local/meta-data | 2 ++ test_data/cloud-init/ubuntu/local/network-config | 7 +++++++ test_data/cloud-init/ubuntu/local/user-data | 10 ++++++++++ 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 test_data/cloud-init/ubuntu/local/meta-data create mode 100644 test_data/cloud-init/ubuntu/local/network-config create mode 100644 test_data/cloud-init/ubuntu/local/user-data diff --git a/README.md b/README.md index 31b7eef9b..27b3f1d2b 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,10 @@ The Ubuntu cloud images do not ship with a default password so it necessary to use a `cloud-init` disk image to customise the image on the first boot. A basic `cloud-init` image is generated by this [script](scripts/create-cloud-init.sh). This seeds the image with a default username/password of `cloud/cloud123`. It -is only necessary to add this disk image on the first boot. +is only necessary to add this disk image on the first boot. Script also assigns +default IP address using `test_data/cloud-init/ubuntu/local/network-config` details +with `--net "mac=12:34:56:78:90:ab,tap="` option. Then the matching mac address +interface will be enabled as per `network-config` details. ```shell $ sudo setcap cap_net_admin+ep ./cloud-hypervisor diff --git a/scripts/create-cloud-init.sh b/scripts/create-cloud-init.sh index 9045afde8..2022c0cb2 100755 --- a/scripts/create-cloud-init.sh +++ b/scripts/create-cloud-init.sh @@ -3,7 +3,7 @@ set -x rm -f /tmp/ubuntu-cloudinit.img mkdosfs -n CIDATA -C /tmp/ubuntu-cloudinit.img 8192 -mcopy -oi /tmp/ubuntu-cloudinit.img -s test_data/cloud-init/ubuntu/user-data :: -mcopy -oi /tmp/ubuntu-cloudinit.img -s test_data/cloud-init/ubuntu/meta-data :: -mcopy -oi /tmp/ubuntu-cloudinit.img -s test_data/cloud-init/ubuntu/network-config :: +mcopy -oi /tmp/ubuntu-cloudinit.img -s test_data/cloud-init/ubuntu/local/user-data :: +mcopy -oi /tmp/ubuntu-cloudinit.img -s test_data/cloud-init/ubuntu/local/meta-data :: +mcopy -oi /tmp/ubuntu-cloudinit.img -s test_data/cloud-init/ubuntu/local/network-config :: diff --git a/test_data/cloud-init/ubuntu/local/meta-data b/test_data/cloud-init/ubuntu/local/meta-data new file mode 100644 index 000000000..bf8691957 --- /dev/null +++ b/test_data/cloud-init/ubuntu/local/meta-data @@ -0,0 +1,2 @@ +instance-id: cloud +local-hostname: cloud diff --git a/test_data/cloud-init/ubuntu/local/network-config b/test_data/cloud-init/ubuntu/local/network-config new file mode 100644 index 000000000..99df95a77 --- /dev/null +++ b/test_data/cloud-init/ubuntu/local/network-config @@ -0,0 +1,7 @@ +version: 2 +ethernets: + ens4: + match: + macaddress: 12:34:56:78:90:ab + addresses: [192.168.249.2/24] + gateway4: 192.168.249.1 diff --git a/test_data/cloud-init/ubuntu/local/user-data b/test_data/cloud-init/ubuntu/local/user-data new file mode 100644 index 000000000..b064234bc --- /dev/null +++ b/test_data/cloud-init/ubuntu/local/user-data @@ -0,0 +1,10 @@ +#cloud-config +users: + - name: cloud + passwd: $6$7125787751a8d18a$sHwGySomUA1PawiNFWVCKYQN.Ec.Wzz0JtPPL1MvzFrkwmop2dq7.4CYf03A5oemPQ4pOFCCrtCelvFBEle/K. + sudo: ALL=(ALL) NOPASSWD:ALL + lock_passwd: False + inactive: False + shell: /bin/bash + +ssh_pwauth: True