Files
MyMasters/data/masters.pkr.hcl
2022-01-19 15:59:46 +01:00

147 lines
4.3 KiB
HCL

packer {
}
source "proxmox" "rocky" {
template_name = "rocky"
template_description = "Rocky Linux Server template"
proxmox_url = "https://192.168.111.34:8006/api2/json"
node = "grosnoeud"
#iso_file = "ISOS:iso/Rocky-8.5-x86_64-minimal.iso"
iso_file = "ISOS:iso/Rocky-8.5-x86_64-dvd1.iso"
iso_checksum = "f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98"
insecure_skip_tls_verify = true
pool = "Linux-VM"
vm_name = "PackerTest"
vm_id = 664
memory = 2048
cores = 1
sockets = 2
os = "l26"
http_port_min = 4990
http_port_max = 4999
http_directory = "redhat"
username = "root@pam"
password = "bzzYpm8koNtPKFYjpjXSyjFY"
ssh_username = "root"
ssh_password = "M0ukreneIsVeryGood!"
ssh_timeout = "15m"
#username = "packer_build@pam"
#password = "tvowyfv9gh23sdfAERtLWav2674"
#ssh_username = "packer_build"
#ssh_password = "tvowyfv9gh23sdfAERtLWav2674"
network_adapters {
model = "virtio"
bridge = "vmbr111"
}
qemu_agent = true
scsi_controller = "virtio-scsi-pci"
disks {
type = "scsi"
disk_size = "55G"
storage_pool = "FAST"
storage_pool_type = "lvm-thin"
format = "raw"
}
boot_wait = "5s"
boot_command = ["<wait2><up><wait1><tab><wait1> inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/redhat.kix<wait1s><enter>"]
}
source "proxmox" "ubuntu" {
template_name = "UBU2004"
template_description = "Ubuntu 20.04 Server template"
proxmox_url = "https://192.168.111.34:8006/api2/json"
node = "grosnoeud"
iso_file = "ISOS:iso/ubuntu-20.04.3-live-server-amd64.iso"
iso_checksum = "f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98"
insecure_skip_tls_verify = true
pool = "Linux-VM"
vm_name = "PackerTest"
vm_id = 654
memory = 2048
cores = 1
sockets = 2
os = "l26"
http_port_min = 4990
http_port_max = 4999
http_directory = "ubuntu-20.04"
username = "root@pam"
password = "bzzYpm8koNtPKFYjpjXSyjFY"
ssh_username = "firstuser"
ssh_password = "firstuser"
ssh_timeout = "10m"
#username = "packer_build@pam"
#password = "tvowyfv9gh23sdfAERtLWav2674"
#ssh_username = "packer_build"
#ssh_password = "tvowyfv9gh23sdfAERtLWav2674"
network_adapters {
model = "virtio"
bridge = "vmbr111"
}
qemu_agent = true
scsi_controller = "virtio-scsi-pci"
disks {
type = "scsi"
disk_size = "55G"
storage_pool = "FAST"
storage_pool_type = "lvm-thin"
format = "raw"
}
boot_wait = "5s"
boot_command = [
"<enter><wait2><enter><wait2><f6><esc><wait2> ",
"autoinstall ds=nocloud-net;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/",
"<wait><enter>"
]
#boot_command = [
# "<enter><wait2><enter><wait2><f6><esc><wait2> ",
# "autoinstall<wait2> ds=nocloud;",
# "<wait><enter>"
#]
}
build {
sources = [ "source.proxmox.ubuntu" ]
provisioner "shell" {
pause_before = "20s"
environment_vars = [
"DEBIAN_FRONTEND=noninteractive",
]
inline = [
"sleep 30",
"sudo apt-get update",
"sudo apt-get -y upgrade",
"sudo apt-get -y dist-upgrade",
"sudo apt-get -y install linux-generic linux-headers-generic linux-image-generic",
"sudo apt-get -y install wget curl",
"sudo apt-get -y autoremove",
"sudo apt-get -y autoclean",
# DHCP Server assigns same IP address if machine-id is preserved, new machine-id will be generated on first boot
"sudo truncate -s 0 /etc/machine-id",
"exit 0",
]
}
}
build {
sources = [ "source.proxmox.rocky" ]
provisioner "ansible" {
pause_before = "20s"
ansible_env_vars= [
"ANSIBLE_HOST_KEY_CHECKING=False",
"ANSIBLE_SSH_ARGS='-o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s'",
"ANSIBLE_NOCOLOR=True"
]
extra_arguments= [
"-e templating=true"
]
playbook_file = "../../../Ansible/playbooks/MyLinuxServers.yaml"
}
}