Skip to content

Commit

Permalink
examples: Add usage of base64encode (#131)
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
  • Loading branch information
mjtrangoni authored Jul 17, 2023
1 parent cd3a085 commit 8098381
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
9 changes: 9 additions & 0 deletions example/scripts/cloud-init/cloud-config-centos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#cloud-config
users:
- name: centos
sudo: ['ALL=(ALL) NOPASSWD:ALL']
chpasswd:
list: |
centos:packer
expire: False
ssh_pwauth: True
9 changes: 9 additions & 0 deletions example/scripts/cloud-init/cloud-config-ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#cloud-config
users:
- name: builder
sudo: ['ALL=(ALL) NOPASSWD:ALL']
chpasswd:
list: |
builder:packer
expire: False
ssh_pwauth: True
18 changes: 9 additions & 9 deletions example/source.nutanix.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source "nutanix" "centos" {
nutanix_insecure = var.nutanix_insecure
cluster_name = var.nutanix_cluster
os_type = "Linux"

vm_disks {
image_type = "DISK_IMAGE"
source_image_name = var.centos_disk_image_name
Expand All @@ -16,7 +16,6 @@ source "nutanix" "centos" {
vm_nics {
subnet_name = var.nutanix_subnet
}


image_categories {
key = "TemplateType"
Expand All @@ -29,8 +28,9 @@ source "nutanix" "centos" {
}

image_name = "centos-packer-image"
image_export = false
force_deregister = true
user_data = "I2Nsb3VkLWNvbmZpZwp1c2VyczoKICAtIG5hbWU6IGNlbnRvcwogICAgc3VkbzogWydBTEw9KEFMTCkgTk9QQVNTV0Q6QUxMJ10KY2hwYXNzd2Q6CiAgbGlzdDogfAogICAgY2VudG9zOnBhY2tlcgogIGV4cGlyZTogRmFsc2UKc3NoX3B3YXV0aDogVHJ1ZQ=="
user_data = base64encode("scripts/cloud-init/cloud-config-centos.yaml")

shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
shutdown_timeout = "2m"
Expand Down Expand Up @@ -59,7 +59,7 @@ source "nutanix" "ubuntu" {

image_name = "ubuntu-packer-image"
force_deregister = true
user_data = "I2Nsb3VkLWNvbmZpZwp1c2VyczoKICAtIG5hbWU6IGJ1aWxkZXIKICAgIHN1ZG86IFsnQUxMPShBTEwpIE5PUEFTU1dEOkFMTCddCmNocGFzc3dkOgogIGxpc3Q6IHwKICAgIGJ1aWxkZXI6cGFja2VyCiAgZXhwaXJlOiBGYWxzZQpzc2hfcHdhdXRoOiBUcnVl"
user_data = base64encode("scripts/cloud-init/cloud-config-ubuntu.yaml")

shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
shutdown_timeout = "2m"
Expand All @@ -75,7 +75,7 @@ source "nutanix" "centos-kickstart" {
nutanix_insecure = var.nutanix_insecure
cluster_name = var.nutanix_cluster
os_type = "Linux"


vm_disks {
image_type = "ISO_IMAGE"
Expand All @@ -90,7 +90,7 @@ source "nutanix" "centos-kickstart" {
vm_nics {
subnet_name = var.nutanix_subnet
}

cd_files = ["scripts/ks.cfg"]
cd_label = "OEMDRV"

Expand All @@ -107,7 +107,7 @@ source "nutanix" "windows" {
nutanix_endpoint = var.nutanix_endpoint
nutanix_insecure = var.nutanix_insecure
cluster_name = var.nutanix_cluster

vm_disks {
image_type = "ISO_IMAGE"
source_image_name = var.windows_2016_iso_image_name
Expand All @@ -126,9 +126,9 @@ source "nutanix" "windows" {
vm_nics {
subnet_name = var.nutanix_subnet
}

cd_files = ["scripts/gui/autounattend.xml","scripts/win-update.ps1"]

image_name ="win-{{isotime `Jan-_2-15:04:05`}}"
shutdown_command = "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\""
shutdown_timeout = "3m"
Expand Down

0 comments on commit 8098381

Please sign in to comment.