canonical / packer-maas

Packer templates to create MAAS deployable images
Other
258 stars 158 forks source link

Refactor rocky8 #201

Closed GR360RY closed 5 months ago

GR360RY commented 5 months ago

Relates to #197

Remove reliance on make when building the Rocky 8 image.

GR360RY commented 5 months ago

@alexsander-souza , please check out the changes for rocky8. This is similar to what we did with centos7. On the same note: we rely on make to remove output-rocky8 directory when cleaning up the build. There is a better way to address it - use artifice post processor.

Do you ever use uncompressed qcow files to verify the build ?

ubuntu@maas-builder-01:~/upstream/packer-maas/rocky8$ file output-rocky8/packer-rocky8
output-rocky8/packer-rocky8: QEMU QCOW2 Image (v3), 4294967296 bytes

If not, this can be addressed with the following stanza:

  post-processors {
    post-processor "shell-local" {
      inline = [
        "SOURCE=rocky8",
        "OUTPUT=${var.filename}",
        "source ../scripts/fuse-nbd",
        "source ../scripts/fuse-tar-root"
      ]
      inline_shebang = "/bin/bash -e"
    }
    post-processor "artifice" {
      files = ["rocky8.tar.gz"]
    }
  }
alexsander-souza commented 5 months ago

No, we don't need the qcow image after create the tarball. You can update this PR with this change if you want.

GR360RY commented 5 months ago

@alexsander-souza, all looks good now. No reliance on make. We can run packer build . in rocky8 multiple times without cleaning up artifacts with make.

Changes summary:

  1. Run gzip with --force to override tar.gz if exists
  2. Remove output directory in shell-local post processor

artifice post processor is not removing artifacts. Use shell-local with rm -rf output-${source.name} instead.

GR360RY commented 5 months ago

@alexsander-souza , please merge/comment so I could move forward to the next distro. If possible, please also merge https://github.com/canonical/packer-maas/pull/200