Skip to content

Commit d2c89f5

Browse files
deynekasKatarzynaRu
authored andcommitted
[jamf][ubuntu] add ami support for ubuntu
[jamf][ubuntu] Refactor packer templates based on upstream [jamf][ubuntu] set volume type to gp3 [jamf][ubuntu] add ami support for ubuntu 24 [jamf][ubuntu] do not install miniconda due to license issues [jamf][ubuntu] add amazon required plugin [jamf][ubuntu] refactor script [jamf][ubuntu] packer fmt [jamf]ubuntu] add amazon-ebs.ubuntu-base-2204 source [jamf][ubuntu] waagent specific provisioner to be run only on azure-arm.build_image [jamf][ubuntu] move azure-arm specific configuration into configure-environment-azure-arm.sh Updating readme file for ubuntu24 version 20250330.1.1
1 parent 416418d commit d2c89f5

File tree

9 files changed

+161
-19
lines changed

9 files changed

+161
-19
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash -e
2+
################################################################################
3+
## File: configure-environment.sh
4+
## Desc: Configure system and environment for azure build target
5+
################################################################################
6+
7+
# Change waagent entries to use /mnt for swapfile
8+
sed -i -e 's/ResourceDisk.Format=n/ResourceDisk.Format=y/g' \
9+
-e 's/ResourceDisk.EnableSwap=n/ResourceDisk.EnableSwap=y/g' \
10+
-e 's/ResourceDisk.SwapSizeMB=0/ResourceDisk.SwapSizeMB=4096/g' /etc/waagent.conf

images/ubuntu/scripts/build/configure-environment.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ set_etc_environment_variable "ACCEPT_EULA" "Y"
1919
mkdir -p /etc/skel/.config/configstore
2020
set_etc_environment_variable "XDG_CONFIG_HOME" '$HOME/.config'
2121

22-
# Change waagent entries to use /mnt for swap file
23-
sed -i 's/ResourceDisk.Format=n/ResourceDisk.Format=y/g' /etc/waagent.conf
24-
sed -i 's/ResourceDisk.EnableSwap=n/ResourceDisk.EnableSwap=y/g' /etc/waagent.conf
25-
sed -i 's/ResourceDisk.SwapSizeMB=0/ResourceDisk.SwapSizeMB=4096/g' /etc/waagent.conf
26-
2722
# Add localhost alias to ::1 IPv6
2823
sed -i 's/::1 ip6-localhost ip6-loopback/::1 localhost ip6-localhost ip6-loopback/g' /etc/hosts
2924

images/ubuntu/scripts/docs-gen/Generate-SoftwareReport.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ $packageManagement = $installedSoftware.AddHeader("Package Management")
6161
$packageManagement.AddToolVersion("cpan", $(Get-CpanVersion))
6262
$packageManagement.AddToolVersion("Helm", $(Get-HelmVersion))
6363
$packageManagement.AddToolVersion("Homebrew", $(Get-HomebrewVersion))
64-
$packageManagement.AddToolVersion("Miniconda", $(Get-MinicondaVersion))
6564
$packageManagement.AddToolVersion("Npm", $(Get-NpmVersion))
6665
if (-not $(Test-IsUbuntu24)) {
6766
$packageManagement.AddToolVersion("NuGet", $(Get-NuGetVersion))

images/ubuntu/scripts/tests/Tools.Tests.ps1

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Describe "Rust" {
3737
It "Rustfmt is installed" {
3838
"rustfmt --version" | Should -ReturnZeroExitCode
3939
}
40-
40+
4141
It "cargo" {
4242
"cargo --version" | Should -ReturnZeroExitCode
4343
}
@@ -291,12 +291,6 @@ Describe "Leiningen" -Skip:((-not (Test-IsUbuntu22))) {
291291
}
292292
}
293293

294-
Describe "Conda" {
295-
It "conda" {
296-
"conda --version" | Should -ReturnZeroExitCode
297-
}
298-
}
299-
300294
Describe "Packer" {
301295
It "packer" {
302296
"packer --version" | Should -ReturnZeroExitCode

images/ubuntu/templates/build.ubuntu-22_04.pkr.hcl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
build {
2-
sources = ["source.azure-arm.image"]
32
name = "ubuntu-22_04"
3+
sources = var.sources
44

55
provisioner "shell" {
66
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
@@ -76,6 +76,13 @@ build {
7676
scripts = ["${path.root}/../scripts/build/configure-environment.sh"]
7777
}
7878

79+
provisioner "shell" {
80+
only = ["azure-arm.image"]
81+
environment_vars = ["IMAGE_VERSION=${var.image_version}", "IMAGE_OS=${var.image_os}", "HELPER_SCRIPTS=${var.helper_script_folder}"]
82+
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
83+
scripts = ["${path.root}/../scripts/build/configure-environment-azure-arm.sh"]
84+
}
85+
7986
provisioner "shell" {
8087
environment_vars = ["DEBIAN_FRONTEND=noninteractive", "HELPER_SCRIPTS=${var.helper_script_folder}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}"]
8188
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
@@ -128,7 +135,6 @@ build {
128135
"${path.root}/../scripts/build/install-kubernetes-tools.sh",
129136
"${path.root}/../scripts/build/install-oc-cli.sh",
130137
"${path.root}/../scripts/build/install-leiningen.sh",
131-
"${path.root}/../scripts/build/install-miniconda.sh",
132138
"${path.root}/../scripts/build/install-mono.sh",
133139
"${path.root}/../scripts/build/install-kotlin.sh",
134140
"${path.root}/../scripts/build/install-mysql.sh",
@@ -249,6 +255,7 @@ build {
249255
}
250256

251257
provisioner "shell" {
258+
only = ["azure-arm.image"]
252259
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
253260
inline = ["sleep 30", "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"]
254261
}

images/ubuntu/templates/build.ubuntu-24_04.pkr.hcl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
build {
2-
sources = ["source.azure-arm.image"]
32
name = "ubuntu-24_04"
3+
sources = var.sources
44

55
provisioner "shell" {
66
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
@@ -76,6 +76,14 @@ build {
7676
scripts = ["${path.root}/../scripts/build/configure-environment.sh"]
7777
}
7878

79+
provisioner "shell" {
80+
only = ["azure-arm.image"]
81+
environment_vars = ["IMAGE_VERSION=${var.image_version}", "IMAGE_OS=${var.image_os}", "HELPER_SCRIPTS=${var.helper_script_folder}"]
82+
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
83+
scripts = ["${path.root}/../scripts/build/configure-environment-azure-arm.sh"]
84+
}
85+
86+
7987
provisioner "shell" {
8088
environment_vars = ["DEBIAN_FRONTEND=noninteractive", "HELPER_SCRIPTS=${var.helper_script_folder}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}"]
8189
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
@@ -124,7 +132,6 @@ provisioner "shell" {
124132
"${path.root}/../scripts/build/install-haskell.sh",
125133
"${path.root}/../scripts/build/install-java-tools.sh",
126134
"${path.root}/../scripts/build/install-kubernetes-tools.sh",
127-
"${path.root}/../scripts/build/install-miniconda.sh",
128135
"${path.root}/../scripts/build/install-kotlin.sh",
129136
"${path.root}/../scripts/build/install-mysql.sh",
130137
"${path.root}/../scripts/build/install-nginx.sh",
@@ -228,6 +235,7 @@ provisioner "shell" {
228235
}
229236

230237
provisioner "shell" {
238+
only = ["azure-arm.image"]
231239
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
232240
inline = ["sleep 30", "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"]
233241
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
packer {
2+
required_plugins {
3+
azure = {
4+
source = "github.com/hashicorp/azure"
5+
version = "2.2.1"
6+
}
7+
amazon = {
8+
source = "github.com/hashicorp/amazon"
9+
version = "1.3.2"
10+
}
11+
}
12+
}

images/ubuntu/templates/source.ubuntu.pkr.hcl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,50 @@ source "azure-arm" "image" {
4747
}
4848
}
4949
}
50+
51+
source "amazon-ebs" "ubuntu" {
52+
ami_name = "${var.aws_ami_name}"
53+
ami_regions = var.aws_ami_regions # all known AWS regions
54+
55+
deprecate_at = timeadd(timestamp(), "${var.aws_deprecate_after}")
56+
57+
run_tags = var.aws_run_tags
58+
tags = var.aws_tags
59+
60+
instance_type = "${var.aws_instance_type}"
61+
62+
force_deregister = var.aws_force_deregister
63+
force_delete_snapshot = var.aws_force_delete_snapshot
64+
65+
region = "${var.aws_region}"
66+
vpc_id = "${var.aws_vpc_id}"
67+
subnet_id = "${var.aws_subnet_id}"
68+
69+
launch_block_device_mappings {
70+
device_name = "/dev/sda1"
71+
volume_size = var.aws_volume_size
72+
delete_on_termination = true
73+
}
74+
75+
run_volume_tags = var.aws_run_volume_tags
76+
77+
associate_public_ip_address = var.aws_associate_public_ip_address
78+
ssh_username = "ubuntu"
79+
80+
metadata_options {
81+
instance_metadata_tags = "enabled"
82+
}
83+
84+
source_ami_filter {
85+
# See https://ubuntu.com/server/docs/cloud-images/amazon-ec2
86+
filters = {
87+
virtualization-type = "hvm"
88+
name = var.aws_ami_filter_name
89+
root-device-type = "ebs"
90+
architecture = "x86_64"
91+
}
92+
93+
owners = ["099720109477"] # this is Canonical (official)
94+
most_recent = true
95+
}
96+
}

images/ubuntu/templates/variable.ubuntu.pkr.hcl

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,73 @@
1+
// AWS support related variables
2+
variable "sources" {
3+
type = list(string)
4+
default = ["source.azure-arm.build_image"]
5+
}
6+
variable "aws_ami_name" {
7+
type = string
8+
default = "github-runner"
9+
}
10+
variable "aws_ami_filter_name" {
11+
type = string
12+
default = "ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"
13+
}
14+
variable "aws_ami_regions" {
15+
type = list(string)
16+
default = ["eu-west-1"]
17+
}
18+
variable "aws_instance_type" {
19+
type = string
20+
default = "m5.large"
21+
}
22+
variable "aws_run_tags" {
23+
type = map(string)
24+
default = {}
25+
}
26+
variable "aws_tags" {
27+
type = map(string)
28+
default = {}
29+
}
30+
variable "aws_force_deregister" {
31+
type = bool
32+
default = false
33+
}
34+
variable "aws_force_delete_snapshot" {
35+
type = bool
36+
default = false
37+
}
38+
variable "aws_region" {
39+
type = string
40+
default = "${env("AWS_REGION")}"
41+
}
42+
variable "aws_vpc_id" {
43+
type = string
44+
default = "${env("AWS_VPC_ID")}"
45+
}
46+
variable "aws_subnet_id" {
47+
type = string
48+
default = "${env("AWS_SUBNET_ID")}"
49+
}
50+
variable "aws_volume_size" {
51+
type = number
52+
default = 150
53+
}
54+
variable "aws_run_volume_tags" {
55+
type = map(string)
56+
default = {}
57+
}
58+
variable "aws_associate_public_ip_address" {
59+
type = bool
60+
default = false
61+
}
62+
variable "aws_ssh_username" {
63+
type = string
64+
default = "ubuntu"
65+
}
66+
variable "aws_deprecate_after" {
67+
type = string
68+
default = "4380h" # 4380 hours = 6 months
69+
}
70+
171
// Authentication related variables
272
variable "client_cert_path" {
373
type = string
@@ -127,8 +197,8 @@ variable "vm_size" {
127197
default = "Standard_D4s_v4"
128198
}
129199
variable "winrm_username" { // The username used to connect to the VM via WinRM
130-
type = string // Also applies to the username used to create the VM
131-
default = "packer"
200+
type = string // Also applies to the username used to create the VM
201+
default = "packer"
132202
}
133203

134204
// Image related variables

0 commit comments

Comments
 (0)