-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Ranjandas/x86-compatibility
x86 compatibility
- Loading branch information
Showing
3 changed files
with
177 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
consul_version = "enterprise-1.18.2" | ||
nomad_version = "enterprise-1.7.7" | ||
consul_version = "1.18" | ||
nomad_version = "1.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
packer { | ||
required_plugins { | ||
qemu = { | ||
version = ">= 1.1.0" | ||
source = "github.com/hashicorp/qemu" | ||
} | ||
} | ||
} | ||
|
||
variable "consul_version" { | ||
type = string | ||
default = "1.18" | ||
description = "Consul version to install" | ||
} | ||
|
||
variable "nomad_version" { | ||
type = string | ||
default = "1.7" | ||
description = "Nomad version to install" | ||
} | ||
|
||
variable "fedora_iso_url" { | ||
type = string | ||
default = "https://fedora.mirror.digitalpacific.com.au/linux/releases/40/Cloud/x86_64/images/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2" | ||
description = "Fedora Cloud Image URL - qcow2 format" | ||
} | ||
|
||
variable "fedora_iso_checksum" { | ||
type = string | ||
default = "file:https://fedora.mirror.digitalpacific.com.au/linux/releases/40/Cloud/x86_64/images/Fedora-Cloud-40-1.14-x86_64-CHECKSUM" | ||
description = "Checksum in the packer format of the cloud image" | ||
} | ||
|
||
source "qemu" "hashibox" { | ||
iso_url = "${var.fedora_iso_url}" | ||
iso_checksum = "${var.fedora_iso_checksum}" | ||
|
||
headless = true | ||
|
||
disk_compression = true | ||
disk_size = "5G" | ||
disk_interface = "virtio" | ||
disk_image = true | ||
|
||
format = "qcow2" | ||
vm_name = "c-${var.consul_version}-n-${var.nomad_version}.qcow2" | ||
boot_command = [] | ||
net_device = "virtio-net" | ||
|
||
output_directory = ".artifacts/qemu/c-${var.consul_version}-n-${var.nomad_version}" | ||
|
||
accelerator = "hvf" | ||
|
||
cpus = 8 | ||
memory = 5120 | ||
|
||
|
||
qemuargs = [ | ||
["-cdrom", "userdata/cidata.iso"], | ||
["-monitor", "none"], | ||
["-no-user-config"] | ||
] | ||
|
||
communicator = "ssh" | ||
shutdown_command = "echo fedora | sudo -S shutdown -P now" | ||
ssh_password = "fedora" | ||
ssh_username = "fedora" | ||
ssh_timeout = "10m" | ||
} | ||
|
||
|
||
build { | ||
sources = ["source.qemu.hashibox"] | ||
|
||
provisioner "shell" { | ||
environment_vars = [ | ||
"CONSUL_VERSION=${var.consul_version}", | ||
"NOMAD_VERSION=${var.nomad_version}" | ||
] | ||
inline = [ | ||
"sudo dnf clean all", | ||
"sudo dnf install -y unzip wget", | ||
"sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo", | ||
"sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin", | ||
|
||
"sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo", | ||
"sudo dnf install -y consul-$CONSUL_VERSION* nomad-$NOMAD_VERSION* containernetworking-plugins", | ||
|
||
"sudo systemctl disable docker consul nomad" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
images: | ||
# Try to use a local image first. | ||
- location: ~/artifacts/qemu/c-1.18-n-1.7.7/c-1.18-n-1.7.7.qcow2 | ||
|
||
mounts: [] | ||
containerd: | ||
system: false | ||
user: false | ||
provision: | ||
- mode: system # configure Nomad | ||
script: | | ||
#!/bin/bash | ||
function setConfig { | ||
local mode=$1 | ||
local cluster=$2 | ||
# Set the config files accordingly | ||
if [[ $mode == "server" ]]; then | ||
cat <<-EOF > /etc/nomad.d/nomad.hcl | ||
data_dir = "/opt/nomad/data" | ||
bind_addr = "0.0.0.0" | ||
server { | ||
#license_path = "/etc/nomad.d/license.hclic" | ||
enabled = true | ||
bootstrap_expect = 1 | ||
server_join { | ||
retry_join = ["lima-$cluster-srv-01.internal"] | ||
} | ||
} | ||
datacenter = "$cluster" | ||
client { | ||
enabled = true | ||
servers = ["lima-$cluster-srv-01.internal"] | ||
} | ||
EOF | ||
elif [[ $mode == "client" ]]; then | ||
cat <<-EOF > /etc/nomad.d/nomad.hcl | ||
data_dir = "/opt/nomad/data" | ||
bind_addr = "0.0.0.0" | ||
datacenter = "$cluster" | ||
client { | ||
enabled = true | ||
servers = ["lima-$cluster-srv-01.internal"] | ||
} | ||
EOF | ||
else | ||
echo "Invalid mode for setConfig" | ||
fi | ||
} | ||
# Check if the environment variable 'MODE' is set | ||
if [[ -n $MODE ]]; then | ||
echo "MODE is set to: $MODE" | ||
else | ||
echo "MODE is not set." | ||
fi | ||
# Check if the environment variable 'CLUSTER' is set | ||
if [[ -n $CLUSTER ]]; then | ||
echo "CLUSTER is set to: $CLUSTER" | ||
else | ||
echo "CLUSTER is not set." | ||
fi | ||
setConfig $MODE $CLUSTER | ||
- mode: | ||
script: | | ||
systemctl enable --now docker | ||
systemctl enable --now nomad | ||
- mode: user | ||
script: | | ||
#!/bin/sh | ||
nomad -autocomplete-install | ||
networks: | ||
- lima: user-v2 | ||
vmType: qemu | ||
|