The cloud-init file used to initialize the multipass VM

It is extracted from the snapd code here:

Note that there’s a part of the content needs to be manually replaced

#cloud-config
manage_etc_hosts: true
package_update: false
growpart:
    mode: growpart
    devices: ["/"]
    ignore_growroot_disabled: false
runcmd:
    - ["ln", "-s", "../usr/share/zoneinfo/REPLACE/THIS/PART/WITH/THE/CONTENT/OF/YOUR/ETC/LOCALTIME", "/etc/localtime"]
write_files:
    -   path: /root/.bashrc
        permissions: 0644
        content: |
            export SNAPCRAFT_BUILD_ENVIRONMENT=managed-host
            export PS1="\h \$(/bin/_snapcraft_prompt)# "
            export PATH=/snap/bin:$PATH
    -   path: /bin/_snapcraft_prompt
        permissions: 0755
        content: |
            #!/bin/bash
            if [[ "$PWD" =~ ^$HOME.* ]]; then
                path="${PWD/#$HOME/\ ..}"
                if [[ "$path" == " .." ]]; then
                    ps1=""
                else
                    ps1="$path"
                fi
            else
                ps1="$PWD"
            fi
            echo -n $ps1

Is there any way to customize the cloud-init yaml contents?
We need to preconfigure our multipass VM’s for different locations/environments.

Thanks,
Mike

1 Like