Skip to content

Commit

Permalink
add ubuntu example (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxtof authored Feb 27, 2023
1 parent 3c1c5e9 commit ecc1216
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Then, run [`packer init`](https://www.packer.io/docs/commands/init).
packer {
required_plugins {
nutanix = {
version = ">= 0.1.3"
version = ">= 0.5.0"
source = "github.com/nutanix-cloud-native/nutanix"
}
}
Expand Down
5 changes: 4 additions & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
Validate Manifests:
packer validate .

Creating from Image and running Provisioner:
Creating CentOS from local Image and running Provisioner:
packer build -only nutanix.centos .

Creating Ubuntu from Upstream Image and running Provisioner:
packer build -only nutanix.ubuntu .

Creating from ISO with Kickstart-File:
packer build -only nutanix.centos-kickerstart .

Expand Down
17 changes: 7 additions & 10 deletions example/build.centos.pkr.hcl → example/build.nutanix.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,28 @@ build {
"source.nutanix.centos"
]

source "nutanix.ubuntu" {
name = "ubuntu"
}

source "nutanix.centos-kickstart" {
name = "centos-kickstart"
}

source "nutanix.windows" {
name = "windows"
}

provisioner "shell" {
only = ["nutanix.centos"]
only = ["nutanix.centos", "nutanix.centos-kickstart" ,"nutanix.ubuntu"]
environment_vars = [
"FOO=hello world",
]
inline = [
"echo \"FOO is $FOO\" > example.txt",
]
}
provisioner "shell" {
only = ["nutanix.centos-kickstart"]
environment_vars = [
"FOO=hello world",
]
inline = [
"echo \"FOO is $FOO\" > example2.txt",
]
}

provisioner "powershell" {
only = ["nutanix.windows"]
scripts = ["scripts/win-update.ps1"]
Expand Down
2 changes: 1 addition & 1 deletion example/init/plugin.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
packer {
required_plugins {
nutanix = {
version = ">= 0.1.0"
version = ">= 0.5.0"
source = "github.com/nutanix-cloud-native/nutanix"
}
}
Expand Down
29 changes: 29 additions & 0 deletions example/source.nutanix.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,35 @@ source "nutanix" "centos" {
ssh_username = "centos"
}

source "nutanix" "ubuntu" {
nutanix_username = var.nutanix_username
nutanix_password = var.nutanix_password
nutanix_endpoint = var.nutanix_endpoint
nutanix_port = var.nutanix_port
nutanix_insecure = var.nutanix_insecure
cluster_name = var.nutanix_cluster
os_type = "Linux"

vm_disks {
image_type = "DISK_IMAGE"
source_image_uri = var.ubuntu_disk_image_name
disk_size_gb = 40
}

vm_nics {
subnet_name = var.nutanix_subnet
}

image_name = "ubuntu-packer-image"
force_deregister = true
user_data = "I2Nsb3VkLWNvbmZpZwp1c2VyczoKICAtIG5hbWU6IGJ1aWxkZXIKICAgIHN1ZG86IFsnQUxMPShBTEwpIE5PUEFTU1dEOkFMTCddCmNocGFzc3dkOgogIGxpc3Q6IHwKICAgIGJ1aWxkZXI6cGFja2VyCiAgZXhwaXJlOiBGYWxzZQpzc2hfcHdhdXRoOiBUcnVl"

shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
shutdown_timeout = "2m"
ssh_password = "packer"
ssh_username = "builder"
}

source "nutanix" "centos-kickstart" {
nutanix_username = var.nutanix_username
nutanix_password = var.nutanix_password
Expand Down
4 changes: 4 additions & 0 deletions example/variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ variable "centos_disk_image_name" {
type = string
}

variable "ubuntu_disk_image_name" {
type = string
}

variable "windows_2016_iso_image_name" {
type = string
}
Expand Down

0 comments on commit ecc1216

Please sign in to comment.