generated from hashicorp/packer-plugin-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Packer template in hcl format? #256
Comments
I tried converting the json to hcl script and fixed few minor issues in the file and could able to use the template, you can use the from this link for the same. My sample generated file looks like post fix packer {
required_plugins {
docker = {
version = ">= 0.2.7"
source = "github.com/ppc64le-cloud/powervs"
}
}
}
# This file was autogenerated by the 'packer hcl2_upgrade' command. We
# recommend double checking that everything is correct before going forward. We
# also recommend treating this file as disposable. The HCL2 blocks in this
# file can be moved to other files. For example, the variable blocks could be
# moved to their own 'variables.pkr.hcl' file, etc. Those files need to be
# suffixed with '.pkr.hcl' to be visible to Packer. To use multiple files at
# once they also need to be in the same folder. 'packer inspect folder/'
# will describe to you what is in that folder.
# Avoid mixing go templating calls ( for example ```{{ upper(`string`) }}``` )
# and HCL2 calls (for example '${ var.string_value_example }' ). They won't be
# executed together and the outcome will be unknown.
# All generated input variables will be of 'string' type as this is how Packer JSON
# views them; you can change their type later on. Read the variables type
# constraints documentation
# https://www.packer.io/docs/templates/hcl_templates/variables#type-constraints for more info.
variable "access_key" {
type = string
default = "MY_SECRET_ACCESS_KEY"
}
variable "apikey" {
type = string
default = "MY_SECRET_API_KEY"
}
variable "extra_arguments" {
type = string
default = ""
}
variable "playbook_file" {
type = string
default = ""
}
variable "secret_key" {
type = string
default = "MY_SECRET_SECRET_KEY"
}
variable "shellpath" {
type = string
default = "packages.sh"
}
# "timestamp" template function replacement
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
# source blocks are generated from your builders; a source can be referenced in
# build blocks. A build block runs provisioner and post-processors on a
# source. Read the documentation for source blocks here:
# https://www.packer.io/docs/templates/hcl_templates/blocks/source
source "powervs" "autogenerated_1" {
account_id = "7cfbd5381a434af7a09289e795840d4e"
api_key = "${var.apikey}"
capture {
cos {
access_key = "${var.access_key}"
bucket = "prow-cos-demo"
region = "jp-tok"
secret_key = "${var.secret_key}"
}
name = "target-image-1"
}
debug = true
instance_name = "packer-build-${local.timestamp}"
key_pair_name = "mkumatag-pub-key"
service_instance_id = "da3ce444-1b08-439b-8223-dd526257b5f0"
source {
name = "CentOS-Stream-9"
}
ssh_private_key_file = "/home/cloudusr/.ssh/id_rsa"
ssh_timeout = "30m"
ssh_username = "root"
subnet_id = "a31d66d7-14df-4731-83cb-e8fa02cd5555"
zone = "us-south"
}
# a build block invokes sources and runs provisioning steps on them. The
# documentation for build blocks can be found here:
# https://www.packer.io/docs/templates/hcl_templates/blocks/build
build {
sources = ["source.powervs.autogenerated_1"]
provisioner "shell" {
script = "${var.shellpath}"
}
} |
I will keep this issue open to enhance the doc to include the hcl type of sample file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Our project uses hcl templates for image building, I'm wondering if it's possible to use this format with packer-plugin-powervs?
The text was updated successfully, but these errors were encountered: