librenms / packer-builds

This repo is where virtual images are created and stored
MIT License
71 stars 20 forks source link

Enable cloud-init #27

Closed candlerb closed 3 years ago

candlerb commented 3 years ago

This patch enables cloud-init in the VM.

Without it, the VM has hard-coded networking (dhcp on interface enp3s0). This is problematic in environments where the network interface is called something else - e.g. ens3, which is what qemu provides. Cloud-init also permits users to provide a cloud-init data source to configure networking and/or change user/pass details at startup.

However, when there is no cloud-init data source, cloud-init will just configure the external interface with dhcp4 anyway: e.g.

$ cat /etc/netplan/50-cloud-init.yaml 
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens3:
            dhcp4: true
            match:
                macaddress: 0c:e6:24:f7:04:00
            set-name: ens3
    version: 2

(for ease of testing, I based this on top of #26. I can rebase onto master if you prefer) Now rebased, and fixed reset of cloud-init state

candlerb commented 3 years ago

It looks like the CI is running with a very old version of packer, and that's why it's failing:

1.38s$ curl -L -o packer.zip https://releases.hashicorp.com/packer/1.2.2/packer_1.2.2_linux_amd64.zip && unzip -d bin packer.zip
1.79s$ PATH=$(pwd)/bin:$PATH bundle exec rake
Validating centos-7.6-x86_64.json...
Template validated successfully.
Validating ubuntu-20.04-amd64.json...
Template validation failed. Errors are shown below.
Errors validating build 'virtualbox-iso'. 1 error(s) occurred:
* unknown configuration key: "boot_keygroup_interval"

This must have been broken, i didn't add that key. However I'll look into a fix.