Sample Header Ad - 728x90

What is the best practice to change variables in automations

0 votes
1 answer
85 views
I am trying to create auto install Ubuntu OS with packer on Hyper-V and I have project like this:
packer-main/
|
|--->http/
|       |--->user-data
|
|--->templates/
|        |--->build.pkr.hcl
|
|--->variables
|         |--->pkrvars.hcl
content in user-data
#cloud-config
autoinstall:
  version: 1
  identity:
   hostname: jammy-daily
   username: ubuntu
content of pkrvars.hcl
hostname = "jammy-daily"
username = "ubuntu"
and build.pkr.hcl
...

ssh_username = "${var.username}"
vm_name = "${var.hostname}"

...
My challenge lies in the need to dynamically modify variables within the user-data before initiating the build process. While I am aware that PowerShell scripts or Bash scripts can serve this purpose, I am curious if there are specialized tools available for streamlining such automations. I am also interested in learning about best practices for creating automated infrastructures.
Asked by robotiaga (111 rep)
Sep 12, 2023, 11:50 AM
Last activity: Sep 13, 2023, 01:52 AM