Compare commits
15 Commits
b340c777ba
...
UbuntuServ
Author | SHA1 | Date | |
---|---|---|---|
73ec424030 | |||
154835d33e | |||
2c57dbcddc | |||
0f01e803f2 | |||
bd82e13fc4 | |||
2f902fa27c | |||
37ecd4a1b9 | |||
8a8cb09984 | |||
bc46b09708 | |||
d508b28213 | |||
03ed59680f | |||
40ade38c78 | |||
c89edd3ee9 | |||
e5880c222e | |||
236db40016 |
10
.drone.yml
10
.drone.yml
@@ -18,17 +18,17 @@ steps:
|
|||||||
- packer --version
|
- packer --version
|
||||||
- ansible --version
|
- ansible --version
|
||||||
- ovftool --version
|
- ovftool --version
|
||||||
- name: Ubuntu Server 20.04
|
- name: Ubuntu Server 22.04
|
||||||
image: bv11-cr01.bessems.eu/library/packer-extended
|
image: bv11-cr01.bessems.eu/library/packer-extended
|
||||||
pull: always
|
pull: always
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
sed -i -e "s/<<img-password>>/$${SSH_PASSWORD}/g" \
|
sed -i -e "s/<<img-password>>/$${SSH_PASSWORD}/g" \
|
||||||
packer/preseed/UbuntuServer20.04/user-data
|
packer/preseed/UbuntuServer22.04/user-data
|
||||||
- |
|
- |
|
||||||
yamllint -d "{extends: relaxed, rules: {line-length: disable}}" \
|
yamllint -d "{extends: relaxed, rules: {line-length: disable}}" \
|
||||||
ansible \
|
ansible \
|
||||||
packer/preseed/UbuntuServer20.04/user-data \
|
packer/preseed/UbuntuServer22.04/user-data \
|
||||||
scripts
|
scripts
|
||||||
- |
|
- |
|
||||||
packer init -upgrade \
|
packer init -upgrade \
|
||||||
@@ -36,7 +36,7 @@ steps:
|
|||||||
- |
|
- |
|
||||||
packer validate \
|
packer validate \
|
||||||
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
|
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
|
||||||
-var vm_guestos=ubuntuserver20.04 \
|
-var vm_guestos=ubuntuserver22.04 \
|
||||||
-var repo_username=$${REPO_USERNAME} \
|
-var repo_username=$${REPO_USERNAME} \
|
||||||
-var repo_password=$${REPO_PASSWORD} \
|
-var repo_password=$${REPO_PASSWORD} \
|
||||||
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
||||||
@@ -46,7 +46,7 @@ steps:
|
|||||||
packer build \
|
packer build \
|
||||||
-on-error=cleanup -timestamp-ui \
|
-on-error=cleanup -timestamp-ui \
|
||||||
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
|
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
|
||||||
-var vm_guestos=ubuntuserver20.04 \
|
-var vm_guestos=ubuntuserver22.04 \
|
||||||
-var repo_username=$${REPO_USERNAME} \
|
-var repo_username=$${REPO_USERNAME} \
|
||||||
-var repo_password=$${REPO_PASSWORD} \
|
-var repo_password=$${REPO_PASSWORD} \
|
||||||
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
||||||
|
@@ -1 +1 @@
|
|||||||
# Packer.Images [](https://ci.spamasaurus.com/djpbessems/Packer.Images)
|
# Packer.Images [](https://ci.spamasaurus.com/djpbessems/Packer.Images)
|
||||||
|
@@ -1,14 +1,27 @@
|
|||||||
|
- name: Configure 'needrestart' package
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/needrestart/needrestart.conf
|
||||||
|
regexp: "{{ item.regexp }}"
|
||||||
|
line: "{{ item.line }}"
|
||||||
|
loop:
|
||||||
|
- regexp: "^#\\$nrconf\\{restart\\} = 'i';"
|
||||||
|
line: "$nrconf{restart} = 'a';"
|
||||||
|
- regexp: "^#\\$nrconf\\{kernelhints\\} = -1;"
|
||||||
|
line: "$nrconf{kernelhints} = -1;"
|
||||||
|
|
||||||
- name: Install additional packages
|
- name: Install additional packages
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: latest
|
state: latest
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
loop: "{{ packages }}"
|
loop: "{{ packages }}"
|
||||||
|
|
||||||
- name: Upgrade all packages
|
- name: Upgrade all packages
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: "*"
|
name: "*"
|
||||||
state: latest
|
state: latest
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
autoremove: yes
|
autoremove: yes
|
||||||
|
@@ -1,2 +1,4 @@
|
|||||||
iso_url = "sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2020.04/ubuntu-20.04.2-live-server-amd64.iso"
|
iso_url = "sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2022.04/ubuntu-22.04-live-server-amd64.iso"
|
||||||
iso_checksum = "sha256:D1F2BF834BBE9BB43FAF16F9BE992A6F3935E65BE0EDECE1DEE2AA6EB1767423"
|
iso_checksum = "sha256:84AEAF7823C8C61BAA0AE862D0A06B03409394800000B3235854A6B38EB4856F"
|
||||||
|
// iso_url = "sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2020.04/ubuntu-20.04.2-live-server-amd64.iso"
|
||||||
|
// iso_checksum = "sha256:D1F2BF834BBE9BB43FAF16F9BE992A6F3935E65BE0EDECE1DEE2AA6EB1767423"
|
||||||
|
@@ -11,12 +11,14 @@ autoinstall:
|
|||||||
ethernets:
|
ethernets:
|
||||||
ens192:
|
ens192:
|
||||||
dhcp4: true
|
dhcp4: true
|
||||||
|
dhcp-identifier: mac
|
||||||
storage:
|
storage:
|
||||||
layout:
|
layout:
|
||||||
name: lvm
|
name: direct
|
||||||
identity:
|
identity:
|
||||||
hostname: packer-template
|
hostname: packer-template
|
||||||
username: ubuntu
|
username: ubuntu
|
||||||
|
# password: $6$ZThRyfmSMh9499ar$KSZus58U/l58Efci0tiJEqDKFCpoy.rv25JjGRv5.iL33AQLTY2aljumkGiDAiX6LsjzVsGTgH85Tx4S.aTfx0
|
||||||
password: $6$rounds=4096$ZKfzRoaQOtc$M.fhOsI0gbLnJcCONXz/YkPfSoefP4i2/PQgzi2xHEi2x9CUhush.3VmYKL0XVr5JhoYvnLfFwqwR/1YYEqZy/
|
password: $6$rounds=4096$ZKfzRoaQOtc$M.fhOsI0gbLnJcCONXz/YkPfSoefP4i2/PQgzi2xHEi2x9CUhush.3VmYKL0XVr5JhoYvnLfFwqwR/1YYEqZy/
|
||||||
ssh:
|
ssh:
|
||||||
install-server: yes
|
install-server: yes
|
@@ -1,173 +0,0 @@
|
|||||||
packer {
|
|
||||||
required_plugins {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
source "vsphere-iso" "ubuntuserver" {
|
|
||||||
vcenter_server = var.vcenter_server
|
|
||||||
username = var.vsphere_username
|
|
||||||
password = var.vsphere_password
|
|
||||||
insecure_connection = "true"
|
|
||||||
|
|
||||||
vm_name = "${var.vm_guestos}-${var.vm_name}"
|
|
||||||
datacenter = var.vsphere_datacenter
|
|
||||||
host = var.vsphere_host
|
|
||||||
folder = var.vsphere_folder
|
|
||||||
datastore = var.vsphere_datastore
|
|
||||||
|
|
||||||
guest_os_type = "ubuntu64Guest"
|
|
||||||
|
|
||||||
boot_order = "disk,cdrom"
|
|
||||||
boot_command = [
|
|
||||||
"<enter><wait2><enter><wait><f6><esc><wait>",
|
|
||||||
" autoinstall<wait2> ds=nocloud;",
|
|
||||||
"<wait><enter>"
|
|
||||||
]
|
|
||||||
boot_wait = "2s"
|
|
||||||
|
|
||||||
communicator = "ssh"
|
|
||||||
ssh_username = "ubuntu"
|
|
||||||
ssh_password = var.ssh_password
|
|
||||||
ssh_timeout = "20m"
|
|
||||||
ssh_handshake_attempts = "100"
|
|
||||||
ssh_pty = true
|
|
||||||
|
|
||||||
CPUs = 2
|
|
||||||
RAM = 4096
|
|
||||||
|
|
||||||
network_adapters {
|
|
||||||
network = var.vsphere_network
|
|
||||||
network_card = "vmxnet3"
|
|
||||||
}
|
|
||||||
storage {
|
|
||||||
disk_size = 20480
|
|
||||||
disk_thin_provisioned = true
|
|
||||||
}
|
|
||||||
disk_controller_type = ["pvscsi"]
|
|
||||||
usb_controller = ["xhci"]
|
|
||||||
|
|
||||||
cd_files = [
|
|
||||||
"packer/preseed/UbuntuServer20.04/user-data",
|
|
||||||
"packer/preseed/UbuntuServer20.04/meta-data"
|
|
||||||
]
|
|
||||||
cd_label = "cidata"
|
|
||||||
iso_url = local.iso_authenticatedurl
|
|
||||||
iso_checksum = var.iso_checksum
|
|
||||||
|
|
||||||
shutdown_command = "echo '${var.ssh_password}' | sudo -S shutdown -P now"
|
|
||||||
shutdown_timeout = "5m"
|
|
||||||
|
|
||||||
export {
|
|
||||||
images = false
|
|
||||||
output_directory = "/scratch/ubuntuserver"
|
|
||||||
}
|
|
||||||
remove_cdrom = true
|
|
||||||
}
|
|
||||||
source "vsphere-iso" "ubuntuserver-baremetal" {
|
|
||||||
vcenter_server = var.vcenter_server
|
|
||||||
username = var.vsphere_username
|
|
||||||
password = var.vsphere_password
|
|
||||||
insecure_connection = "true"
|
|
||||||
|
|
||||||
vm_name = "${var.vm_guestos}-${var.vm_name}-baremetal"
|
|
||||||
datacenter = var.vsphere_datacenter
|
|
||||||
host = var.vsphere_host
|
|
||||||
folder = var.vsphere_folder
|
|
||||||
datastore = var.vsphere_datastore
|
|
||||||
|
|
||||||
guest_os_type = "ubuntu64Guest"
|
|
||||||
|
|
||||||
boot_order = "disk,cdrom"
|
|
||||||
boot_command = [
|
|
||||||
"<enter><wait2><enter><wait><f6><esc><wait>",
|
|
||||||
" autoinstall<wait2> ds=nocloud;",
|
|
||||||
"<wait><enter>"
|
|
||||||
]
|
|
||||||
boot_wait = "2s"
|
|
||||||
|
|
||||||
communicator = "ssh"
|
|
||||||
ssh_username = "ubuntu"
|
|
||||||
ssh_password = var.ssh_password
|
|
||||||
ssh_timeout = "20m"
|
|
||||||
ssh_handshake_attempts = "100"
|
|
||||||
ssh_pty = true
|
|
||||||
|
|
||||||
CPUs = 2
|
|
||||||
RAM = 4096
|
|
||||||
|
|
||||||
network_adapters {
|
|
||||||
network = var.vsphere_network
|
|
||||||
network_card = "vmxnet3"
|
|
||||||
}
|
|
||||||
storage {
|
|
||||||
disk_size = 20480
|
|
||||||
disk_thin_provisioned = true
|
|
||||||
}
|
|
||||||
disk_controller_type = ["pvscsi"]
|
|
||||||
usb_controller = ["xhci"]
|
|
||||||
|
|
||||||
cd_files = [
|
|
||||||
"packer/preseed/UbuntuServer20.04/user-data",
|
|
||||||
"packer/preseed/UbuntuServer20.04/meta-data"
|
|
||||||
]
|
|
||||||
cd_label = "cidata"
|
|
||||||
iso_url = local.iso_authenticatedurl
|
|
||||||
iso_checksum = var.iso_checksum
|
|
||||||
|
|
||||||
shutdown_command = "echo '${var.ssh_password}' | sudo -S shutdown -P now"
|
|
||||||
shutdown_timeout = "5m"
|
|
||||||
|
|
||||||
export {
|
|
||||||
images = false
|
|
||||||
output_directory = "/scratch/ubuntuserver-baremetal"
|
|
||||||
}
|
|
||||||
remove_cdrom = true
|
|
||||||
}
|
|
||||||
|
|
||||||
build {
|
|
||||||
sources = [
|
|
||||||
"source.vsphere-iso.ubuntuserver",
|
|
||||||
"source.vsphere-iso.ubuntuserver-baremetal"
|
|
||||||
]
|
|
||||||
|
|
||||||
provisioner "ansible" {
|
|
||||||
only = ["source.vsphere-iso.ubuntuserver"]
|
|
||||||
|
|
||||||
playbook_file = "ansible/playbook.yml"
|
|
||||||
user = "ubuntu"
|
|
||||||
ansible_env_vars = [
|
|
||||||
"ANSIBLE_CONFIG=ansible/ansible.cfg"
|
|
||||||
]
|
|
||||||
use_proxy = "false"
|
|
||||||
extra_arguments = [
|
|
||||||
"--extra-vars", "ansible_ssh_pass=${var.ssh_password}"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
post-processor "shell-local" {
|
|
||||||
only = ["source.vsphere0iso.ubuntuserver"]
|
|
||||||
inline = [
|
|
||||||
"pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\",
|
|
||||||
" -OVFFile '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.ovf' \\",
|
|
||||||
" -Parameter @{'appliance.name'='${var.vm_guestos}';'appliance.version'='${var.vm_name}'}\"",
|
|
||||||
"pwsh -file scripts/Update-Manifest.ps1 \\",
|
|
||||||
" -ManifestFileName '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.mf'",
|
|
||||||
"ovftool --acceptAllEulas --allowExtraConfig --overwrite \\",
|
|
||||||
" '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.ovf' \\",
|
|
||||||
" /output/Ubuntu-Server-20.04.ova"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
post-processor "shell-local" {
|
|
||||||
only = ["source.vsphere0iso.ubuntuserver-baremetal"]
|
|
||||||
inline = [
|
|
||||||
"ls /scratch/ubuntuserver-baremetal -lash",
|
|
||||||
"qemu-img convert -f vmdk -o raw \",
|
|
||||||
" /scratch/ubuntuserver-baremetal/${var.vm_guestos}-${var.vm_name}-disk001.vmdk \",
|
|
||||||
" /scratch/ubuntuserver-baremetal/${var.vm_guestos}-${var.vm_name}.raw",
|
|
||||||
"ls /scratch/ubuntuserver-baremetal -lash",
|
|
||||||
"gzip -c \",
|
|
||||||
" /scratch/ubuntuserver-baremetal/${var.vm_guestos}-${var.vm_name}.raw \",
|
|
||||||
" > /output/Ubuntu-Server-20.04.raw.gz"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
100
packer/ubuntuserver22.04.pkr.hcl
Normal file
100
packer/ubuntuserver22.04.pkr.hcl
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
packer {
|
||||||
|
required_plugins {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
source "vsphere-iso" "ubuntuserver" {
|
||||||
|
vcenter_server = var.vcenter_server
|
||||||
|
username = var.vsphere_username
|
||||||
|
password = var.vsphere_password
|
||||||
|
insecure_connection = "true"
|
||||||
|
|
||||||
|
vm_name = "${var.vm_guestos}-${var.vm_name}"
|
||||||
|
datacenter = var.vsphere_datacenter
|
||||||
|
cluster = var.vsphere_cluster
|
||||||
|
host = var.vsphere_host
|
||||||
|
folder = var.vsphere_folder
|
||||||
|
datastore = var.vsphere_datastore
|
||||||
|
|
||||||
|
guest_os_type = "ubuntu64Guest"
|
||||||
|
|
||||||
|
boot_order = "disk,cdrom"
|
||||||
|
boot_command = [
|
||||||
|
"e<down><down><down><end>",
|
||||||
|
" autoinstall ds=nocloud;",
|
||||||
|
"<F10>"
|
||||||
|
]
|
||||||
|
boot_wait = "2s"
|
||||||
|
|
||||||
|
communicator = "ssh"
|
||||||
|
ssh_username = "ubuntu"
|
||||||
|
ssh_password = var.ssh_password
|
||||||
|
ssh_timeout = "20m"
|
||||||
|
ssh_handshake_attempts = "100"
|
||||||
|
ssh_pty = true
|
||||||
|
|
||||||
|
CPUs = 2
|
||||||
|
RAM = 4096
|
||||||
|
|
||||||
|
network_adapters {
|
||||||
|
network = var.vsphere_network
|
||||||
|
network_card = "vmxnet3"
|
||||||
|
}
|
||||||
|
storage {
|
||||||
|
disk_size = 20480
|
||||||
|
disk_thin_provisioned = true
|
||||||
|
}
|
||||||
|
disk_controller_type = ["pvscsi"]
|
||||||
|
usb_controller = ["xhci"]
|
||||||
|
|
||||||
|
cd_files = [
|
||||||
|
"packer/preseed/UbuntuServer22.04/user-data",
|
||||||
|
"packer/preseed/UbuntuServer22.04/meta-data"
|
||||||
|
]
|
||||||
|
cd_label = "cidata"
|
||||||
|
iso_url = local.iso_authenticatedurl
|
||||||
|
iso_checksum = var.iso_checksum
|
||||||
|
|
||||||
|
shutdown_command = "echo '${var.ssh_password}' | sudo -S shutdown -P now"
|
||||||
|
shutdown_timeout = "5m"
|
||||||
|
|
||||||
|
export {
|
||||||
|
images = false
|
||||||
|
output_directory = "/scratch/ubuntuserver"
|
||||||
|
}
|
||||||
|
remove_cdrom = true
|
||||||
|
}
|
||||||
|
|
||||||
|
build {
|
||||||
|
sources = [
|
||||||
|
"source.vsphere-iso.ubuntuserver"
|
||||||
|
]
|
||||||
|
|
||||||
|
provisioner "ansible" {
|
||||||
|
only = ["vsphere-iso.ubuntuserver"]
|
||||||
|
|
||||||
|
playbook_file = "ansible/playbook.yml"
|
||||||
|
user = "ubuntu"
|
||||||
|
ansible_env_vars = [
|
||||||
|
"ANSIBLE_CONFIG=ansible/ansible.cfg"
|
||||||
|
]
|
||||||
|
use_proxy = "false"
|
||||||
|
extra_arguments = [
|
||||||
|
"--extra-vars", "ansible_ssh_pass=${var.ssh_password}"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
post-processor "shell-local" {
|
||||||
|
only = ["vsphere-iso.ubuntuserver"]
|
||||||
|
inline = [
|
||||||
|
"pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\",
|
||||||
|
" -OVFFile '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.ovf' \\",
|
||||||
|
" -Parameter @{'appliance.name'='${var.vm_guestos}';'appliance.version'='${var.vm_name}'}\"",
|
||||||
|
"pwsh -file scripts/Update-Manifest.ps1 \\",
|
||||||
|
" -ManifestFileName '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.mf'",
|
||||||
|
"ovftool --acceptAllEulas --allowExtraConfig --overwrite \\",
|
||||||
|
" '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.ovf' \\",
|
||||||
|
" /output/Ubuntu-Server-22.04.ova"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@@ -6,6 +6,7 @@ variable "vsphere_password" {
|
|||||||
|
|
||||||
variable "vsphere_host" {}
|
variable "vsphere_host" {}
|
||||||
variable "vsphere_datacenter" {}
|
variable "vsphere_datacenter" {}
|
||||||
|
variable "vsphere_cluster" {}
|
||||||
|
|
||||||
variable "vsphere_templatefolder" {}
|
variable "vsphere_templatefolder" {}
|
||||||
variable "vsphere_folder" {}
|
variable "vsphere_folder" {}
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
vcenter_server = "bv11-vc.bessems.lan"
|
vcenter_server = "bv11-vc.bessems.lan"
|
||||||
vsphere_username = "administrator@vsphere.local"
|
vsphere_username = "administrator@vsphere.local"
|
||||||
vsphere_datacenter = "DeSchakel"
|
vsphere_datacenter = "DeSchakel"
|
||||||
|
vsphere_cluster = "Cluster.Legacy"
|
||||||
vsphere_host = "bv11-esx.bessems.lan"
|
vsphere_host = "bv11-esx.bessems.lan"
|
||||||
vsphere_datastore = "Datastore01.SSD"
|
vsphere_datastore = "ESX00.SSD01"
|
||||||
vsphere_folder = "/Packer"
|
vsphere_folder = "/Packer"
|
||||||
vsphere_templatefolder = "/Templates"
|
vsphere_templatefolder = "/Templates"
|
||||||
vsphere_network = "LAN"
|
vsphere_network = "LAN"
|
Reference in New Issue
Block a user