/openbsd_gcp

Create OpenBSD images to run in Google Cloud Platform

Primary LanguageHCL

  1. If the packer-vmm package is prior to 1.7.3
    1. git clone https://github.com/double-p/packer-builder-openbsd-vmm
    2. cd packer-builder-openbsd-vmm
    3. make install
    4. Once the the port is updated, you can rm ~/.packer.d/plugins/packer-builder-openbsd-vmm (or make uninstall which does about the same thing).
  2. Run ansible-playbook packer.yml -CD to ensure the are will be acceptable then run ansible-playbook packer.yml -D to make the changes. There are a few variables to customize the built image.
    • hostname: (default openbsd) Hostname for the image.
    • root_password: (default *************) Password for root (plaintext or encrypted). As this will be used with autoinstall(8), 13 * disables password logins.
    • username: (default username of the user running ansible) Username of the user to setup during install. Blank to disable.
    • user_password: (default *************) Password for the user (plaintext or encrypted). As this will be used with autoinstall(8), 13 * disables password logins.
    • user_pubkey: (default: contents of ~/.ssh/ed_25519.pub) The public key for the user.
    • timezone: (default: UTC) Timezone for the image.
  3. Allow the VM to talk to the host. Since the interface is created on VM start and destroyed after stop, add pass quick on tap to pf.conf and reload as you can't skip on the specific interface.
  4. Setup an account.json credentials file.
    1. Create a service account
    2. Grant at least the following permissions (if you want to grant just these permissions, you'll need to create a custom role).
      • compute.globalOperations.get
      • compute.images.create
      • storage.objects.create
      • storage.objects.delete
      • storage.objects.get
    3. Under actions, Manage keys and Create a new key.
    4. Save it as account.json.
  5. Create var file defining project_id and bucket.
    project_id = "example"
    bucket     = "example"
    
  6. Run packer init openbsd.pkr.hcl.
  7. Run packer build -var-file openbsd.pkrvars.hcl openbsd.pkr.hcl.
  8. Put your system back to normal.
    1. Remove packer and packer-vmm (possibly with make uninstall as mentioned in step 1).
    2. Remove /etc/hostname.veb0, /etc/hostname.vport0, and /etc/vm.conf (or set those back to their prior state).
    3. Reset pf.conf to its prior state.
    4. Disable vmd.
    5. Remove the GCP service account.