Skip to content

Building golden images for terraform + libvirt consumption #61

@MattSnow-amd

Description

@MattSnow-amd

I have what I believe is a simple use case but am struggling to figure out a solution. I will try to explain.

context:
I have an ubuntu machine setup as a hypervisor. I use this ansible playbook as the basis.

I have this repo of terraform code that provisions several instances of Ubuntu-22.04 from a cloud-init image source (see osimage.tf ) and customized with a cloud-init config.

intended use:
I want to create a CI pipeline for building golden images that have some basic configurations like packages, CA certs, users.
I would like to take make this process an intermediate step that generates "golden" images that are used by the terraform code.

Gist of packer build HCL:
https://gist.github.com/MattSnow-amd/3b36f82364fe6105ac52cc7a68dc3812
I have tried a variety of combinations of manually deleting files generated by the packer build process and running cloud-init clean commands from the documentation.

Problem:
The terraform created VM/domain boots up, but none of the cloud-init configurations are applied and the network is not configured. I am able to communicate between virsh and the VM's qemu-guest-agent via virsh domifaddr --domain mymachinename.example.com --source agent. Sample outget from virsh domifadd:

 Name       MAC address          Protocol     Address
-------------------------------------------------------------------------------
 lo         00:00:00:00:00:00    ipv4         127.0.0.1/8
 -          -                    ipv6         ::1/128
 enp1s0     52:54:00:04:1d:01    N/A          N/A

I can also virsh console into the running domain and confirm that the cdrom at /dev/sr0 is presented in the domain, and the cidata image can be mounted and contains all of the terraform templated values in the user-data file.

Any guidance or pointers are much appreciated. Thank you for your effort in writing such a useful tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions