Files creation

This commit is contained in:
2021-12-27 21:28:04 +01:00
parent 5e10f76a1a
commit b3524c0b1a
2 changed files with 242 additions and 0 deletions

39
data/20.04.pkrvars.hcl Normal file
View File

@@ -0,0 +1,39 @@
username = "proxmox_user"
password = "tvowyfv9gh23sdfAERtLWav2674"
proxmox_url = "https://192.168.111.34:8006/api2/json"
node = "grosnoeud"
iso_file = ""
os_version = "20.04"
os_family = "ubuntu"
guest_os_type = "ubuntu64Guest"
os_iso_path = "[SATAStorage] ISO/ubuntu-20.04-legacy-server-amd64.iso"
os_iso_url = "http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/ubuntu-20.04-legacy-server-amd64.iso"`
iso_checksum = "36f15879bd9dfd061cd588620a164a82972663fdd148cce1f70d57d314c21b73"
root_disk_size = 24000
connection_username = "vagrant"
connection_password = "vagrant"
boot_command = [
"<esc><wait>",
"<esc><wait>",
"<enter><wait>",
"/install/vmlinuz",
" auto=true",
" url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",
" locale=en_US<wait>",
" console-setup/ask_detect=false<wait>",
" console-setup/layoutcode=us<wait>",
" console-setup/modelcode=pc105<wait>",
" debconf/frontend=noninteractive<wait>",
" debian-installer=en_US<wait>",
" fb=false<wait>",
" initrd=/install/initrd.gz<wait>",
" kbd-chooser/method=us<wait>",
" keyboard-configuration/layout=USA<wait>",
" keyboard-configuration/variant=USA<wait>",
" netcfg/get_domain=vm<wait>",
" netcfg/get_hostname=packer<wait>",
" grub-installer/bootdev=/dev/sda<wait>",
" noapic<wait>",
" -- <wait>",
"<enter><wait>"
]

203
data/Linux.pkr.hcl Normal file
View File

@@ -0,0 +1,203 @@
source "proxmox-iso" "windows" {
# vCenter settings
vcenter_server = var.vcenter_server
username = var.vcenter_username
password = var.vcenter_password
insecure_connection = true #TODO: Add ca to docker
cluster = var.vcenter_cluster
datacenter = var.vcenter_datacenter
host = var.vcenter_host
datastore = var.vcenter_datastore
convert_to_template = true
folder = var.vcenter_folder
# VM Settings
ip_wait_timeout = "45m"
communicator = "winrm"
winrm_username = var.connection_username
winrm_password = var.connection_password
winrm_timeout = "12h"
winrm_port = "5985"
shutdown_command = "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\""
shutdown_timeout = "15m"
vm_version = var.vm_hardware_version
iso_paths = [
var.os_iso_path
]
iso_checksum = var.iso_checksum
vm_name = "server-${ var.os_version }-{{ isotime \"2006-01-02\" }}"
guest_os_type = var.guest_os_type
disk_controller_type = ["pvscsi"] # Windows requires vmware tools drivers for pvscsi to work
network_adapters {
# For windows, the vmware tools network drivers are required to be connected by floppy before tools is installed
network = var.vm_network
network_card = var.nic_type
}
storage {
disk_size = var.root_disk_size
disk_thin_provisioned = true
}
CPUs = var.num_cpu
cpu_cores = var.num_cores
CPU_hot_plug = true
RAM = var.vm_ram
RAM_hot_plug = true
floppy_files = [
"./boot_config/${var.os_version}/Autounattend.xml",
"./scripts/winrm.bat",
"./scripts/Install-VMWareTools.ps1",
"./drivers/"
]
}
source "proxmox-iso" "ubuntu" {
# vCenter settings
vcenter_server = var.vcenter_server
username = var.vcenter_username
password = var.vcenter_password
insecure_connection = true #TODO: Add ca to docker
cluster = var.vcenter_cluster
datacenter = var.vcenter_datacenter
host = var.vcenter_host
datastore = var.vcenter_datastore
convert_to_template = true
folder = var.vcenter_folder
# VM Settings
ip_wait_timeout = "45m"
ssh_username = var.connection_username
ssh_password = var.connection_password
ssh_timeout = "12h"
ssh_port = "22"
ssh_handshake_attempts = "20"
shutdown_timeout = "15m"
vm_version = var.vm_hardware_version
iso_paths = [var.os_iso_path]
iso_checksum = var.iso_checksum
vm_name = "${ var.os_family }-${ var.os_version }-{{ isotime \"2006-01-02\" }}"
guest_os_type = var.guest_os_type
disk_controller_type = ["pvscsi"]
network_adapters {
network = var.vm_network
network_card = var.nic_type
}
storage {
disk_size = var.root_disk_size
disk_thin_provisioned = true
}
CPUs = var.num_cpu
cpu_cores = var.num_cores
CPU_hot_plug = true
RAM = var.vm_ram
RAM_hot_plug = true
boot_wait = "5s"
boot_command = var.boot_command
}
source "proxmox-iso" "centos" {
# vCenter settings
vcenter_server = var.vcenter_server
username = var.vcenter_username
password = var.vcenter_password
insecure_connection = true #TODO: Add ca to docker
cluster = var.vcenter_cluster
datacenter = var.vcenter_datacenter
host = var.vcenter_host
datastore = var.vcenter_datastore
convert_to_template = true
folder = var.vcenter_folder
# VM Settings
ip_wait_timeout = "45m"
ssh_username = var.connection_username
ssh_password = var.connection_password
ssh_timeout = "12h"
ssh_port = "22"
ssh_handshake_attempts = "20"
shutdown_timeout = "15m"
vm_version = var.vm_hardware_version
iso_paths = [var.os_iso_path]
iso_checksum = var.iso_checksum
vm_name = "${ var.os_family }-${ var.os_version }-{{ isotime \"2006-01-02\" }}"
guest_os_type = var.guest_os_type
disk_controller_type = ["pvscsi"]
network_adapters {
network = var.vm_network
network_card = var.nic_type
}
storage {
disk_size = var.root_disk_size
disk_thin_provisioned = true
}
CPUs = var.num_cpu
cpu_cores = var.num_cores
CPU_hot_plug = true
RAM = var.vm_ram
RAM_hot_plug = true
boot_wait = "5s"
boot_command = var.boot_command
}
build {
# Windows builds
sources = [
"source.proxmox-iso.windows",
]
provisioner "powershell" {
elevated_user = var.connection_username
elevated_password = var.connection_password
scripts = [
"scripts/Disable-UAC.ps1" # I re-enable UAC with ansible post deployment
]
}
provisioner "windows-update" { # This requires windows-update-provisioner https://github.com/rgl/packer-provisioner-windows-update
pause_before = "30s"
filters = [
"exclude:$_.Title -like '*VMware*'",
"exclude:$_.Title -like '*Preview*'",
"exclude:$_.Title -like '*Defender*'",
"include:$true"
]
}
provisioner "powershell" {
elevated_user = var.connection_username
elevated_password = var.connection_password
scripts = [
"scripts/Remove-UpdateCache.ps1",
"scripts/Invoke-Defrag.ps1",
"scripts/Reset-EmptySpace.ps1"
]
}
}
build {
sources = [
"source.proxmox-iso.ubuntu",
]
provisioner "shell" {
execute_command = "echo '${var.connection_password}' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'" # This runs the scripts with sudo
scripts = [
"scripts/apt.sh",
"scripts/cleanup.sh",
"scripts/python.sh",
"scripts/ansible.sh",
"scripts/ubuntu-prep.sh",
"scripts/clean-ssh-hostkeys.sh"
]
}
}
build {
sources = [
"source.proxmox-iso.centos",
]
provisioner "shell" {
execute_command = "echo '${var.connection_password}' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'" # This runs the scripts with sudo
scripts = [
"scripts/ansible-centos.sh",
"scripts/vmware-centos.sh",
"scripts/yum-update.sh",
"scripts/cleanup-centos.sh",
"scripts/clean-ssh-hostkeys.sh"
]
}
}