INDEX
2024-02-22 12:20 - Hashicorp Testing Going to be testing things like Packer and Vagrant to automate some of the VM work I've done # Wrote a compose file wtih hashicorp/packer:latest # Defaults to running packer so need to pass in arguments docker compose run packer version # Run commands from docker # Copied sample packer file from tutorials/docker-get-started # Set "working_dir: /data" in compose to run in a specific folder, with the packer files packer init . # Seems to install plugins - needs container to be persistent Need to have the image be persisent or next steps won't work Changed compose file to use "command: tail -F /dev/null" - old entrypoint is "bin/packer" # (in) compose.yml entrypoint: "/bin/sh" command: tail -F /dev/null docker compose up -d docker compose exec packer sh -c "COMMAND" # Run commands this way as entrypoint empty packer fmt . # Check formatting of files packer validate . # Check script works (requires init to have been run) packer build FILE # Builds a certain image - not working currently # Likely failing as docker is not itself running in docker - will try another kind of image If I make a qcow2 file I can essentially make arbitrary cloud images for other projects # Requires the qemu plugin "github.com/hashicorp/qemu" - then reinit # Again just testing the demo script from dev docs: qemu/latest/components/builder/qemu # This image is alpine to how can I install qemu apk search qemu # For future reference apk install qemu qemu-img qemu-system-x84_64 # Install required packages # Now the build command actually runs (will need a Dockerfile to automate) but fails after # Downloading from http://debian-iso.mirror.anlx.net/current/amd64/iso-cd/ instead # Seems to download file but fails to run qemu - I imagine due to being in docker PACKER_LOG=1 ... # Runs with full logging - need to see how to run qemu in docker I think what I need to do is make a dockerfile based on the qemu image then add packer to it Testing by running https://github.com/qemus/qemu-docker - uses novnc which seems way better If I use this same container to try out packer it should work as I want Combining this with packer docker image to install packer properly Seems like trying to download packer in debian sid is a pain - just going to get binary file Okay now packer is installed strip the codebase of everything unrelated docker compose build docker compose run -it qemu /bin/bash packer init .; packer build . Okay it fully builds and works now but "waiting for SSH to become available" Maybe I should try connecting to vnc - exposed vnc port - seeing if that works Running with new build script from wiki.alpinelinux.org Seems to fail to even run the "root" command - try running without that Trying: https://github.com/hashicorp/packer-plugin-qemu/blob/main/example/source.pkr.hcl