-
Notifications
You must be signed in to change notification settings - Fork 0
/
awx.pkr.hcl
135 lines (117 loc) · 3.27 KB
/
awx.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# AWX VM image
variable "awx_resource_dir" {
type = string
default = "/etc/awx"
}
variable "cpus" {
type = string
default = "2"
}
variable "disk_size" {
type = string
default = "6G"
}
variable "iso_checksum" {
type = string
# default = "sha256:7aa62a5739ce1edb08364384a83224475e9420442af9332f1e73bb0f56c8de8e"
}
variable "iso_url" {
type = string
default = "http://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img"
}
variable "k3s_images" {
type = list(string)
default = []
}
# K3s defaults to containerd as a CRI, but you can add Docker on top if needed.
#
# Note if you want the install to try to pre-populate the container images, then you
# need to set this to true. Not using Docker will result in a much smaller image size,
# but a longer initial startup time for AWX
variable "k3s_use_docker" {
type = bool
default = false
}
variable "k3s_version" {
type = string
default = "1.19.9"
}
variable "memory" {
type = string
default = "4096M"
}
variable "ssh_password" {
type = string
default = "ubuntu"
}
variable "ssh_username" {
type = string
default = "ubuntu"
}
variable "update_os" {
type = string
default = "true"
}
variable "upload_directory" {
type = string
default = "/tmp"
}
variable "vm_name" {
type = string
default = "focal-awx"
}
source "qemu" "build_awx" {
accelerator = "kvm"
cd_files = ["./isoData/build/*"]
cd_label = "cidata"
disk_compression = true
disk_image = true
disk_size = var.disk_size
format = "qcow2"
headless = true
iso_checksum = var.iso_checksum
iso_url = var.iso_url
output_directory = "output-${var.vm_name}"
qemuargs = [
["-m", "${var.memory}"],
["-smp", "${var.cpus}"],
["-serial", "mon:stdio"]
]
ssh_clear_authorized_keys = true # This shouldn't be needed, but just in case...
ssh_password = var.ssh_password
ssh_port = 22
ssh_timeout = "300s"
ssh_username = var.ssh_username
use_default_display = true
vm_name = "${var.vm_name}-${formatdate("YYYYMMDD", timestamp())}.qcow2"
}
build {
sources = ["source.qemu.build_awx"]
provisioner "file" {
destination = "${var.upload_directory}/"
source = "./installResources/awx.yaml"
}
provisioner "file" {
destination = "${var.upload_directory}/"
source = "./installResources/startup.sh"
}
provisioner "shell" {
environment_vars = [
"AWX_RESOURCE_DIR=${var.awx_resource_dir}",
"K3S_IMAGES=${join(" ",var.k3s_images)}", # These quotes look wrong, but it works
"K3S_USE_DOCKER=${var.k3s_use_docker}",
"K3S_VER=${var.k3s_version}",
"SSH_PASSWORD=${var.ssh_password}",
"SSH_USERNAME=${var.ssh_username}",
"UPDATE_OS=${var.update_os}",
"UPLOAD_DIR=${var.upload_directory}",
]
execute_command = "echo '${var.ssh_password}' | {{ .Vars }} sudo -S -E bash '{{ .Path }}'"
scripts = [
"scripts/updateOS.sh",
"scripts/packages.sh",
"scripts/installMain.sh",
"scripts/cleanup.sh"
]
}
}