445
README.md
445
README.md
@@ -6,7 +6,7 @@
|
||||
1. [Requirements](#requirements)
|
||||
1. [Download](#download)
|
||||
1. [Configuration](#configuration)
|
||||
1. [Build](#build)
|
||||
1. [Packer Machine Image Builds](#packer-machine-image-builds)
|
||||
1. [Troubleshoot](#troubleshoot)
|
||||
1. [Known Issues](#known-issues)
|
||||
1. [Unsupported Features](#unsupported-features)
|
||||
@@ -17,21 +17,28 @@
|
||||
|
||||
This repository provides opinionated infrastructure-as-code examples to automate the creation of virtual machine images and their guest operating systems on Proxmox using [HashiCorp Packer][packer] and the [Packer Plugin for Proxmox][packer-plugin-proxmox] (`proxmox-iso` builder). All examples are authored in the HashiCorp Configuration Language ("HCL2").
|
||||
|
||||
By default, the machine image artifacts are converted to templates within Proxmox after a virtual machine is built and configured according to the individual templates. With the Packer Plugin for Proxmox, a new template with a unique VMID gets created each time Packer runs successfully[^1]. This is unlike VMware, where if an item with the same name exists it will be overwritten.
|
||||
By default, the machine image artifacts are converted to templates within Proxmox after a virtual machine is built and configured according to the individual templates.
|
||||
|
||||
The following builds are available:
|
||||
|
||||
## Linux Distributions
|
||||
|
||||
| Operating System | Version |
|
||||
| :--- | :--- |
|
||||
| CentOS Stream | 9 |
|
||||
| CentOS Stream | 8 |
|
||||
| Debian | 12 |
|
||||
| Debian | 11 |
|
||||
| OpenSUSE Leap | 15.5 |
|
||||
| Ubuntu Server | 22.04 LTS |
|
||||
| Ubuntu Server | 20.04 LTS |
|
||||
| Operating System | Version | Custom Storage Config | Static IP Support | UEFI Bootloader | BIOS Bootloader |
|
||||
| :--- | :--- | :---: | :---: | :---: | :---: |
|
||||
| AlmaLinux | 9 | ✓ | ✓ | ✓ | |
|
||||
| AlmaLinux | 8 | ✓ | ✓ | ✓ | |
|
||||
| CentOS Stream | 9 | ✓ | ✓ | | |
|
||||
| Debian | 12 | ✓ | | | |
|
||||
| Debian | 11 | ✓ | | | |
|
||||
| Oracle Linux | 9 | ✓ | | | |
|
||||
| Oracle Linux | 8 | ✓ | | | |
|
||||
| Rocky Linux | 9 | ✓ | | | |
|
||||
| Rocky Linux | 8 | ✓ | | | |
|
||||
| OpenSUSE Leap | 15.6 | ✓ | | | |
|
||||
| OpenSUSE Leap | 15.5 | ✓ | | | |
|
||||
| Ubuntu Server | 24.04 LTS | ✓ | | | |
|
||||
| Ubuntu Server | 22.04 LTS | ✓ | | | |
|
||||
| Ubuntu Server | 20.04 LTS | ✓ | ✓ | ✓ | ✓ |
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -39,13 +46,13 @@ The following builds are available:
|
||||
|
||||
Operating systems and versions tested with the project:
|
||||
|
||||
- Proxmox PVE Version 8
|
||||
- Proxmox PVE Version >= 8
|
||||
- Ubuntu Server 22.04 LTS (`x86_64`)
|
||||
- CentOS Stream 9 (`x86_64`)
|
||||
|
||||
**Packer**:
|
||||
|
||||
- HashiCorp [Packer][packer-install] 1.9.4 or higher.
|
||||
- HashiCorp [Packer][packer-install] 1.11.0 or higher.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
@@ -114,8 +121,8 @@ Operating systems and versions tested with the project:
|
||||
>
|
||||
> Required plugins are automatically downloaded and initialized when using `./build.sh`. For dark sites, you may download the plugins and place these same directory as your Packer executable `/usr/local/bin` or `$HOME/.packer.d/plugins`.
|
||||
|
||||
- HashiCorp [Packer Plugin for Proxmox][packer-plugin-proxmox] 1.1.3 or later.
|
||||
- [Packer Plugin for Git][packer-plugin-git] 0.4.2 or later - a community plugin for HashiCorp Packer.
|
||||
- HashiCorp [Packer Plugin for Proxmox][packer-plugin-proxmox] 1.1.8 or later.
|
||||
- [Packer Plugin for Git][packer-plugin-git] 0.6.2 or later - a community plugin for HashiCorp Packer.
|
||||
|
||||
**Ansible**:
|
||||
|
||||
@@ -227,7 +234,20 @@ This is useful for the purposes of running machine image builds for different en
|
||||
|
||||
## Configuration Variables
|
||||
|
||||
### Build
|
||||
### Ansible Variables
|
||||
|
||||
Edit the `config/ansible.pkrvars.hcl` file to configure the credentials for the Ansible account on Linux machine images.
|
||||
|
||||
```hcl title="config/ansible.pkrvars.hcl"
|
||||
ansible_username = "ansible"
|
||||
ansible_key = "<public_key>"
|
||||
```
|
||||
|
||||
**Ansible User Password**
|
||||
|
||||
A random password is auto-generated for the Ansible user.
|
||||
|
||||
### Build Variables
|
||||
|
||||
Edit the `config/build.pkrvars.hcl` file to configure the credentials for the default account on machine images.
|
||||
|
||||
@@ -282,20 +302,7 @@ The content of the public key, `build_key`, is added the key to the `~/.ssh/auth
|
||||
>
|
||||
> If you wish to disable Password Authentication and only use Public Key Authentication, comment or remove the portion of the associated Ansible `configure` role.
|
||||
|
||||
### Ansible
|
||||
|
||||
Edit the `config/ansible.pkrvars.hcl` file to configure the credentials for the Ansible account on Linux machine images.
|
||||
|
||||
```hcl title="config/ansible.pkrvars.hcl"
|
||||
ansible_username = "ansible"
|
||||
ansible_key = "<public_key>"
|
||||
```
|
||||
|
||||
**Ansible User Password**
|
||||
|
||||
A random password is auto-generated for the Ansible user.
|
||||
|
||||
### Common
|
||||
### Common Variables
|
||||
|
||||
Edit the `config/common.pkrvars.hcl` file to configure the following common variables:
|
||||
|
||||
@@ -319,7 +326,7 @@ common_shutdown_timeout = "15m"
|
||||
common_hcp_packer_registry_enabled = false
|
||||
```
|
||||
|
||||
### Data Source
|
||||
#### Data Source
|
||||
|
||||
The default provisioning data source for Linux machine image builds is `http`. This is used to serve the kickstart files to the Linux guest operating system during the build.
|
||||
|
||||
@@ -352,7 +359,7 @@ common_data_source = "disk"
|
||||
|
||||
The Packer plugin's `cd_content` option is used when selecting `disk` unless the distribution does not support a secondary CD-ROM.
|
||||
|
||||
### HTTP Binding
|
||||
#### HTTP Binding
|
||||
|
||||
If you need to define a specific IPv4 address from your host for Packer's built-in HTTP server, modify the `common_http_ip` variable from `null` to a `string` value that matches an IP address on your Packer host.
|
||||
|
||||
@@ -360,7 +367,22 @@ If you need to define a specific IPv4 address from your host for Packer's built-
|
||||
common_http_ip = "172.16.11.254"
|
||||
```
|
||||
|
||||
### Proxmox VE
|
||||
### Network Variables
|
||||
|
||||
Configuring a static IP address under the `configs/network.pkrvars.hcl` file is supported. If you want to use DHCP for the templates then leave these variables commented out. The default is DHCP.
|
||||
|
||||
Edit the `config/network.pkrvars.hcl` file to configure the following:
|
||||
|
||||
- Static IP address settings
|
||||
|
||||
```hcl title="config/network.pkrvars.hcl"
|
||||
vm_ip_address = "192.168.101.100"
|
||||
vm_ip_netmask = 24
|
||||
vm_ip_gateway = "192.168.101.1"
|
||||
vm_dns_list = [ "8.8.8.8", "8.8.4.4" ]
|
||||
```
|
||||
|
||||
### Proxmox Variables
|
||||
|
||||
Edit the `config/proxmox.pkrvars.hcl` file to configure the following:
|
||||
|
||||
@@ -383,81 +405,10 @@ For more information, please see the [Proxmox documentation][proxmox-api-tokens]
|
||||
|
||||
For Proxmox installs that use a self-signed certificate, you will want to set `proxmox_insecure_connection` to `true`.
|
||||
|
||||
### Machine Images
|
||||
|
||||
Edit the `*.auto.pkrvars.hcl` file in each `builds/<type>/<build>` directory to configure the following virtual machine hardware settings, as required:
|
||||
|
||||
- CPUs `(int)`
|
||||
- CPU Cores `(int)`
|
||||
- Memory in MB `(int)`
|
||||
- Primary Disk in MB `(string)` (e.g. 32GB)
|
||||
- .iso Path `(string)`
|
||||
- .iso File `(string)`
|
||||
|
||||
```hcl title="builds/linux/debian/11/linux-debian.auto.pkrvars.hcl"
|
||||
// Guest Operating System Metadata
|
||||
vm_os_language = "en_US"
|
||||
vm_os_keyboard = "us"
|
||||
vm_os_timezone = "UTC"
|
||||
vm_os_family = "linux"
|
||||
vm_os_name = "debian"
|
||||
vm_os_version = "11"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "seabios"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "kvm64"
|
||||
vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_storage_pool = "vm-data"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
vm_bridge_interface = "vmbr0"
|
||||
vm_vlan_tag = "102"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
iso_file = "ubuntu-22.04-live-server-amd64.iso"
|
||||
iso_checksum = "84aeaf7823c8c61baa0ae862d0a06b03409394800000b3235854a6b38eb4856f"
|
||||
|
||||
// Boot Settings
|
||||
vm_boot = "order=virtio0;ide2;net0"
|
||||
vm_boot_wait = "5s"
|
||||
|
||||
// EFI Settings (currently an unsupported feature)
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
vm_efi_storage_pool = "vm-data"
|
||||
vm_efi_pre_enrolled_keys = false
|
||||
vm_efi_type = "4m"
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> All `variables.auto.pkrvars.hcl` default to using:
|
||||
> - VirtIO SCSI storage device
|
||||
> - VirtIO (paravirtualized) network card device
|
||||
> - BIOS boot firmware
|
||||
|
||||
The defaults use VirtIO to balance out performance, compatibility, and ease of use. Feel free to change the storage and network controllers to suit your needs. However, if you change the storage or network controllers and run into issues you should change them back to defaults and try the builds again. I won't support any builds that don't use the VirtIO drivers.
|
||||
|
||||
At this time UEFI is [not supported](#unsupported-features) so that means we are left with `seabios` as the default (and only) firmware setting. The reasons for not supporting UEFI may be boring, but the biggest reason is that Proxmox Virtual Machines that have EFI disks can't be live migrated between nodes or storage pools.
|
||||
|
||||
If you are interested in more detail - when I first started testing these packer builds in my home lab I was using `ovmf` (UEFI) firmware. During my initial testing the ZFS pool where I housed my VMs cratered and I had to rebuild the pool and restore all my VMs from backups. During the recovery of my storage pool, I changed over to LVM and had to migrate VMs between storage pools several times and each VM that had EFI disks had to be shutdown, migrated, and then powered on. Offline migration isn't *that* much of an inconvenience, however at the time I was trying to figure out my VM storage and recover all my VMs it was just one more annoyance. All that said, I think Proxmox should support live migration regardless of VM firmware type.
|
||||
|
||||
### VM Storage
|
||||
|
||||
> [!WARNING]
|
||||
> The storage config is still very much a work in progress. Suggestions are welcome, see the contributing section.
|
||||
### Storage Variables
|
||||
|
||||
Edit the `config/linux-storage.pkrvars.hcl` file to configure storage for VM templates.
|
||||
|
||||
This file is fairly lengthy and should be broken down into chunks.
|
||||
|
||||
#### Disk Device
|
||||
|
||||
```hcl
|
||||
@@ -465,90 +416,82 @@ This file is fairly lengthy and should be broken down into chunks.
|
||||
vm_disk_device = "vda"
|
||||
```
|
||||
|
||||
`vm_disk_device`:`string` - This variable depends on the disk controller used inside of the specific `.auto.pkrvars.hcl` file. By default, the builds use the `virtio-scsi-pci` disk controller and that requires the use of `vda`. If you decide to run a SCSI controller, then you'll have to change the value to `sda`. This variable only accepts `sda` or `vda` as values.
|
||||
`vm_disk_device`:`string` - This variable depends on the disk controller used inside of the specific `.auto.pkrvars.hcl` file. By default, the builds use the `virtio-scsi-pci` disk controller and that requires the use of `vda`. If you decide to use a non-virtio controller, then you'll have to change the `vm_disk_device` variable to the appropriate device.
|
||||
|
||||
#### EFI Device
|
||||
```hcl
|
||||
vm_efi_storage_pool = "pool0"
|
||||
vm_efi_type = "4m"
|
||||
vm_efi_pre_enrolled_keys = false
|
||||
```
|
||||
|
||||
#### Disk Partitions
|
||||
|
||||
`vm_disk_partitions`:`list[dict]` - Use this list to define the primary partitions that will be created when a specific build runs. Each of the builds process this list in order, so the first partition defined in the list will be the first partition created, the second one listed will be the second one created, and so on.
|
||||
|
||||
##### Automatic Partitioning (All In One) Example
|
||||
This example is the simplest way to allocate storage within your templates. It makes use of the particular Linux distribution's automatic partitioning feature in their respective automatic installers.
|
||||
> **Note**
|
||||
>
|
||||
> - All partition sizes are in MegaBytes (MB)
|
||||
> - If you want to have a partition consume all available free space, you can indicate that with `-1`
|
||||
|
||||
The three settings to note are:
|
||||
##### Partitioning Examples
|
||||
|
||||
- name `(string)`: This must be set to `autopart` to use automatic partitioning
|
||||
- size `(int)`: This needs to be set to -1 to consume all available disk space
|
||||
- fstype `(string)` (optional): This can be set to `lvm`, `simple`, or left blank. Setting this to `simple` uses a single regular partition. Setting this to `lvm` still uses a single partition, but makes use of LVM. Leaving this value blank will default to a `simple` partitioning scheme.
|
||||
|
||||
```hcl
|
||||
vm_disk_partitions = [
|
||||
{
|
||||
name = "autopart"
|
||||
size = -1,
|
||||
format = {
|
||||
label = "",
|
||||
fstype = "lvm",
|
||||
},
|
||||
mount = {
|
||||
path = "",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
##### LVM Partitioning Example
|
||||
Below is an example of a partition layout for a VM template that boots with BIOS and uses LVM. The first partition is a 1GB primary partition and is mounted as /boot, finally the second partition consumes the rest of the free space (noted by -1 for space) and is setup for LVM.
|
||||
|
||||
> [!WARNING]
|
||||
> The mount point of `/boot` is used by the templates and is required.
|
||||
|
||||
```hcl
|
||||
vm_disk_partitions = [
|
||||
{
|
||||
name = "boot"
|
||||
size = 1000,
|
||||
format = {
|
||||
label = "BOOTFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/boot",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
{
|
||||
name = "vg_root"
|
||||
size = -1,
|
||||
format = {
|
||||
label = "",
|
||||
fstype = "",
|
||||
},
|
||||
mount = {
|
||||
path = "",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "vg_root",
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
##### LVM Partitioning Example with CIS partitions
|
||||
Below is an example of a partition layout for a VM template that uses LVM and has extra partitions with mount options required by CIS for hardening a system. The first partition is a 1GB primary partition and is mounted as /boot, finally the second partition consumes the rest of the free space (noted by -1 for space) and is setup for LVM.
|
||||
|
||||
> [!WARNING]
|
||||
> The mount point of `/boot` is used by the templates and is required.
|
||||
<details>
|
||||
<summary>Single Partition Example for BIOS bootloaders</summary>
|
||||
Below is an example of a partition layout for a VM template that boots with BIOS and uses a single partition for the OS.
|
||||
|
||||
```hcl title="config/linux-storage.pkrvars.hcl"
|
||||
// VM Storage Settings
|
||||
vm_disk_device = "vda"
|
||||
vm_disk_use_swap = true
|
||||
vm_disk_partitions = [
|
||||
{
|
||||
name = "root"
|
||||
size = -1,
|
||||
format = {
|
||||
label = "ROOTFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
]
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Single Partition Example for UEFI bootloaders</summary>
|
||||
This example is similar to the above example except that it has the extra partitions needed for the UEFI (OVMF) bootloader. Note the extra variables for the EFI settings.
|
||||
|
||||
```hcl title="config/linux-storage.pkrvars.hcl"
|
||||
// VM EFI Settings
|
||||
vm_efi_storage_pool = "pool0"
|
||||
vm_efi_type = "4m"
|
||||
vm_efi_pre_enrolled_keys = false
|
||||
|
||||
// VM Storage Settings
|
||||
vm_disk_device = "vda"
|
||||
vm_disk_use_swap = true
|
||||
vm_disk_partitions = [
|
||||
{
|
||||
name = "efi"
|
||||
size = 1024,
|
||||
format = {
|
||||
label = "EFIFS",
|
||||
fstype = "fat32",
|
||||
},
|
||||
mount = {
|
||||
path = "/boot/efi",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
{
|
||||
name = "boot"
|
||||
size = 1000,
|
||||
size = 1024,
|
||||
format = {
|
||||
label = "BOOTFS",
|
||||
fstype = "ext4",
|
||||
@@ -560,7 +503,65 @@ vm_disk_partitions = [
|
||||
volume_group = "",
|
||||
},
|
||||
{
|
||||
name = "vg_root"
|
||||
name = "root"
|
||||
size = -1,
|
||||
format = {
|
||||
label = "ROOTFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
]
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>LVM Partitioning Example with CIS partitions for UEFI bootloaders</summary>
|
||||
This is a more complex example of a partition layout for a VM template that uses LVM and has volumes with mount options required by CIS for hardening a linux system.
|
||||
|
||||
|
||||
```hcl title="config/linux-storage.pkrvars.hcl"
|
||||
//VM EFI Settings
|
||||
vm_efi_storage_pool = "pool0"
|
||||
vm_efi_type = "4m"
|
||||
vm_efi_pre_enrolled_keys = false
|
||||
|
||||
// UEFI VM Storage Settings
|
||||
vm_disk_device = "vda"
|
||||
vm_disk_use_swap = true
|
||||
vm_disk_partitions = [
|
||||
{
|
||||
name = "efi"
|
||||
size = 1024,
|
||||
format = {
|
||||
label = "EFIFS",
|
||||
fstype = "fat32",
|
||||
},
|
||||
mount = {
|
||||
path = "/boot/efi",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
{
|
||||
name = "boot"
|
||||
size = 1024,
|
||||
format = {
|
||||
label = "BOOTFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/boot",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
{
|
||||
name = "sysvg"
|
||||
size = -1,
|
||||
format = {
|
||||
label = "",
|
||||
@@ -570,16 +571,16 @@ vm_disk_partitions = [
|
||||
path = "",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "vg_root",
|
||||
volume_group = "sysvg",
|
||||
},
|
||||
]
|
||||
vm_disk_lvm = [
|
||||
{
|
||||
name: "vg_root",
|
||||
name: "sysvg",
|
||||
partitions: [
|
||||
{
|
||||
name = "lv_swap",
|
||||
size = 1000,
|
||||
size = 1024,
|
||||
format = {
|
||||
label = "SWAPFS",
|
||||
fstype = "swap",
|
||||
@@ -591,7 +592,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_root",
|
||||
size = 3000,
|
||||
size = 10240,
|
||||
format = {
|
||||
label = "ROOTFS",
|
||||
fstype = "ext4",
|
||||
@@ -603,7 +604,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_home",
|
||||
size = 1000,
|
||||
size = 4096,
|
||||
format = {
|
||||
label = "HOMEFS",
|
||||
fstype = "ext4",
|
||||
@@ -615,7 +616,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_opt",
|
||||
size = 2000,
|
||||
size = 2048,
|
||||
format = {
|
||||
label = "OPTFS",
|
||||
fstype = "ext4",
|
||||
@@ -627,7 +628,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_tmp",
|
||||
size = 2000,
|
||||
size = 4096,
|
||||
format = {
|
||||
label = "TMPFS",
|
||||
fstype = "ext4",
|
||||
@@ -639,7 +640,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_var",
|
||||
size = 3000,
|
||||
size = 2048,
|
||||
format = {
|
||||
label = "VARFS",
|
||||
fstype = "ext4",
|
||||
@@ -663,7 +664,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_var_log",
|
||||
size = 1000,
|
||||
size = 4096,
|
||||
format = {
|
||||
label = "VARLOGFS",
|
||||
fstype = "ext4",
|
||||
@@ -689,17 +690,80 @@ vm_disk_lvm = [
|
||||
}
|
||||
]
|
||||
```
|
||||
</details>
|
||||
|
||||
|
||||
## Packer Machine Image Builds
|
||||
|
||||
Edit the `*.auto.pkrvars.hcl` file in each `builds/<type>/<build>` directory to configure the following virtual machine hardware settings, as required:
|
||||
|
||||
- CPUs `(int)`
|
||||
- CPU Cores `(int)`
|
||||
- Memory in MB `(int)`
|
||||
- Primary Disk in MB `(string)` (e.g. 32GB)
|
||||
- .iso Path `(string)`
|
||||
- .iso File `(string)`
|
||||
|
||||
```hcl title="builds/linux/debian/11/linux-debian.auto.pkrvars.hcl"
|
||||
// Guest Operating System Metadata
|
||||
vm_os_language = "en_US"
|
||||
vm_os_keyboard = "us"
|
||||
vm_os_timezone = "UTC"
|
||||
vm_os_family = "linux"
|
||||
vm_os_name = "ubuntu"
|
||||
vm_os_version = "22.04-lts"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
vm_cloudinit = true
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "ovmf"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "kvm64"
|
||||
vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
iso_file = "ubuntu-22.04-live-server-amd64.iso"
|
||||
// The checksum can be a URL or an actual checksum value. URL is preferred
|
||||
iso_checksum = "file:https://releases.ubuntu.com/jammy/SHA256SUMS"
|
||||
|
||||
// Boot Settings
|
||||
vm_boot = "order=virtio0;ide2;net0"
|
||||
vm_boot_wait = "5s"
|
||||
|
||||
// EFI Settings
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
```
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> All `variables.auto.pkrvars.hcl` default to using:
|
||||
> - VirtIO SCSI storage device
|
||||
> - VirtIO (paravirtualized) network card device
|
||||
> - BIOS boot firmware
|
||||
|
||||
The defaults use VirtIO to balance out performance, compatibility, and ease of use. Feel free to change the storage and network controllers to suit your needs. However, if you change the storage or network controllers and run into issues you should change them back to defaults and try the builds again. I won't support any builds that don't use the VirtIO drivers.
|
||||
|
||||
Both UEFI and BIOS booting are supported for builds. Inside the `*.auto.pkrvars.hcl` file specific to the build, you can set the `vm_bios` variable to either `seabios` for BIOS or `ovmf` for UEFI booting. The storage layouts are different for each bootloader type so you'll need to configure the storage layouts accordingly.
|
||||
|
||||
If you are interested in more detail - when I first started testing these packer builds in my home lab I was using `ovmf` (UEFI) firmware. During my initial testing the ZFS pool where I housed my VMs cratered and I had to rebuild the pool and restore all my VMs from backups. During the recovery of my storage pool, I changed over to LVM and had to migrate VMs between storage pools several times and each VM that had EFI disks had to be shutdown, migrated, and then powered on. Offline migration isn't *that* much of an inconvenience, however at the time I was trying to figure out my VM storage and recover all my VMs it was just one more annoyance. All that said, I think Proxmox should support live migration regardless of VM firmware type. Maybe this will be addressed in a future release of Proxmox?
|
||||
|
||||
### Cloud-Init
|
||||
All builds for operating systems that support [cloud-init][cloud-init] now have the option to enable it. This can be done on a per-build basis inside the `*.auto.pkrvars.hcl` files in the `builds/linux/<distro>/<version>/` directory. The default setting is `true`.
|
||||
|
||||
If a particular linux distribution ships with cloud-init (e.g. Ubuntu) and cloud-init is set to `false` in the `*.auto.pkrvars.hcl` packer file for the build, then cloud-init will be disabled in the operating system **and** within Proxmox for that specific template.
|
||||
|
||||
# Known Issues
|
||||
|
||||
## CentOS Stream 8
|
||||
- Anaconda will stop the install with a message complaining about not enough disk space. This is a known issue with kickstart on RHEL 8, however none of the fixes that have been tried have worked. If you want to build a CentOS-Stream-8 template, you will need to access the console of the machine and simply ignore the warning and continue the installation.
|
||||
- OpenSUSE does not support custom storage layouts at this time. This is planned for a future release
|
||||
|
||||
# Unsupported Features
|
||||
- UEFI firmware
|
||||
- Networking configurations other than DHCP for templates
|
||||
|
||||
# Contributing
|
||||
Contributions are welcome, please read the [CONTRIBUTING](.github/CONTRIBUTING.md) document for more details.
|
||||
@@ -711,6 +775,7 @@ The repository is modeled after the [VMware Packer Examples][packer-examples-for
|
||||
[//]: Links
|
||||
[ansible]: https://www.ansible.com
|
||||
[ansible-core]: https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#selecting-an-ansible-package-and-version-to-install
|
||||
[cloud-init]: https://cloud-init.io/
|
||||
[packer]: https://www.packer.io
|
||||
[packer-examples-for-vsphere]: https://github.com/vmware-samples/packer-examples-for-vsphere
|
||||
[packer-install]: https://developer.hashicorp.com/packer/tutorials/docker-get-started/get-started-install-cli
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[defaults]
|
||||
stdout_callback = default
|
||||
display_skipped_hosts = false
|
||||
ansible_python_interpreter = /usr/bin/python3
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
- become: "yes"
|
||||
- become: true
|
||||
become_method: sudo
|
||||
debugger: never
|
||||
gather_facts: "yes"
|
||||
gather_facts: true
|
||||
hosts: all
|
||||
roles:
|
||||
- base
|
||||
6
ansible/linux-requirements.yml
Normal file
6
ansible/linux-requirements.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
collections:
|
||||
- name: ansible.posix
|
||||
version: 1.5.4
|
||||
- name: community.general
|
||||
version: 9.1.0
|
||||
2
ansible/roles/base/defaults/main.yml
Normal file
2
ansible/roles/base/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
enable_cloudinit: false
|
||||
@@ -1,17 +1,21 @@
|
||||
---
|
||||
|
||||
- block:
|
||||
- name: "Updating the guest operating system."
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
force_apt_get: true
|
||||
name: "*"
|
||||
state: latest # noqa package-latest
|
||||
update_cache: "yes"
|
||||
|
||||
- name: "Installing additional packages."
|
||||
apt:
|
||||
name:
|
||||
- bash-completion
|
||||
- curl
|
||||
- wget
|
||||
- unzip
|
||||
- ca-certificates
|
||||
ansible.builtin.apt:
|
||||
name: "{{ additional_packages[ansible_os_family] }}"
|
||||
state: latest # noqa package-latest
|
||||
|
||||
- name: "Installing cloud-init."
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
name: cloud-init
|
||||
state: latest
|
||||
when: enable_cloudinit == 'true' and ansible_distribution_version | int >= 11
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
---
|
||||
|
||||
- name: "Getting guest operating system information."
|
||||
ansible.builtin.debug:
|
||||
msg: "OS Family: {{ ansible_os_family }} | Ansible Distribution: {{ ansible_distribution }} | Distribution Version: {{ ansible_distribution_version }}"
|
||||
|
||||
- name: Prepare the {{ ansible_facts['distribution'] }} guest operating system
|
||||
include_tasks: "{{ ansible_facts['distribution'] | lower }}.yml"
|
||||
when: "ansible_facts['distribution'] == 'Debian'"
|
||||
@@ -13,7 +17,7 @@
|
||||
when: "ansible_facts['distribution'] in ['RedHat', 'CentOS', 'Rocky', 'AlmaLinux', 'OracleLinux']"
|
||||
|
||||
- name: Prepare the {{ ansible_facts['distribution'] }} guest operating system
|
||||
include_tasks: "{{ ansible_facts['distribution'] | lower }}.yml"
|
||||
when: "ansible_facts['distribution'] == 'Suse'"
|
||||
include_tasks: suse.yml
|
||||
when: "ansible_facts['distribution'] in ['openSUSE Leap', 'Suse']"
|
||||
|
||||
...
|
||||
@@ -4,38 +4,21 @@
|
||||
ansible.builtin.shell: "subscription-manager refresh"
|
||||
when: "ansible_facts['distribution'] == 'RedHat'"
|
||||
|
||||
- block:
|
||||
- name: "Updating the guest operating system."
|
||||
ansible.builtin.dnf:
|
||||
name: "*"
|
||||
state: latest # noqa package-latest
|
||||
update_cache: "yes"
|
||||
when: "ansible_facts['distribution_major_version'] >= \"8\""
|
||||
|
||||
- name: "Installing additional packages."
|
||||
ansible.builtin.dnf:
|
||||
name:
|
||||
- curl
|
||||
- wget
|
||||
- unzip
|
||||
- ca-certificates
|
||||
state: latest # noqa package-latest
|
||||
when: "ansible_facts['distribution_major_version'] >= \"8\""
|
||||
|
||||
- name: "Updating the guest operating system."
|
||||
when: "ansible_facts['distribution_major_version'] <= \"7\""
|
||||
ansible.builtin.yum:
|
||||
name: "*"
|
||||
state: latest # noqa package-latest
|
||||
update_cache: "yes"
|
||||
|
||||
- name: "Installing additional packages."
|
||||
when: "ansible_facts['distribution_major_version'] <= \"7\""
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- curl
|
||||
- wget
|
||||
- unzip
|
||||
- ca-certificates
|
||||
name: "{{ additional_packages[ansible_os_family] }}"
|
||||
state: latest # noqa package-latest
|
||||
|
||||
...
|
||||
- name: "Installing cloud-init."
|
||||
become: true
|
||||
ansible.builtin.dnf:
|
||||
name: cloud-init
|
||||
state: latest
|
||||
when: enable_cloudinit == 'true'
|
||||
|
||||
@@ -1,9 +1,29 @@
|
||||
---
|
||||
|
||||
- block:
|
||||
- name: Updating the operating system
|
||||
ansible.builtin.zypper:
|
||||
name: "*"
|
||||
state: latest
|
||||
update_cache: true
|
||||
|
||||
...
|
||||
- name: Installing additional packages
|
||||
ansible.builtin.zypper:
|
||||
name: "{{ additional_packages[ansible_os_family] }}"
|
||||
state: latest
|
||||
|
||||
- name: "Configure cloud-init."
|
||||
block:
|
||||
- name: "Add the SUSE OSS repo."
|
||||
become: true
|
||||
community.general.zypper_repository:
|
||||
name: repo-oss
|
||||
repo: "http://download.opensuse.org/distribution/leap/$releasever/repo/oss/"
|
||||
auto_import_keys: true
|
||||
|
||||
- name: "Installing cloud-init."
|
||||
become: true
|
||||
ansible.builtin.zypper:
|
||||
name: cloud-init
|
||||
state: latest
|
||||
when: enable_cloudinit == 'true'
|
||||
|
||||
@@ -8,10 +8,5 @@
|
||||
|
||||
- name: "Installing additional packages."
|
||||
apt:
|
||||
name:
|
||||
- bash-completion
|
||||
- curl
|
||||
- wget
|
||||
- unzip
|
||||
- ca-certificates
|
||||
name: "{{ additional_packages[ansible_os_family] }}"
|
||||
state: latest # noqa package-latest
|
||||
|
||||
26
ansible/roles/base/vars/main.yml
Normal file
26
ansible/roles/base/vars/main.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
task_name: "Update the operating system and install additional packages."
|
||||
additional_packages:
|
||||
Debian:
|
||||
- bash-completion
|
||||
- ca-certificates
|
||||
- curl
|
||||
- unzip
|
||||
- wget
|
||||
RedHat:
|
||||
- ca-certificates
|
||||
- curl
|
||||
- unzip
|
||||
- wget
|
||||
Suse:
|
||||
- bash-completion
|
||||
- ca-certificates
|
||||
- curl
|
||||
- unzip
|
||||
- wget
|
||||
Ubuntu:
|
||||
- bash-completion
|
||||
- ca-certificates
|
||||
- curl
|
||||
- unzip
|
||||
- wget
|
||||
@@ -1,81 +1,93 @@
|
||||
---
|
||||
# Tasks for setting custom facts.
|
||||
- name: "Setting custom facts."
|
||||
set_fact:
|
||||
enable_cloudinit: "{{ enable_cloudinit | default('false') }}"
|
||||
|
||||
- name: Remove audit log files
|
||||
ansible.builtin.file:
|
||||
# # Tasks for removing the cloud-init package.
|
||||
# - name: "Removing the cloud-init package."
|
||||
# apt:
|
||||
# name: cloud-init
|
||||
# state: absent
|
||||
# when: ansible_distribution == 'Ubuntu' and enable_cloudinit == 'false'
|
||||
|
||||
# Tasks to clean the audit logs.
|
||||
- name: "Cleaning the audit logs."
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "/var/log/audit/audit.log"
|
||||
- "/var/log/wtmp"
|
||||
- "/var/log/lastlog"
|
||||
- /var/log/audit/audit.log
|
||||
- /var/log/auth.log
|
||||
- /var/log/btmp
|
||||
- /var/log/dpkg.log
|
||||
- /var/log/faillog
|
||||
- /var/log/kern.log
|
||||
- /var/log/lastlog
|
||||
- /var/log/syslog
|
||||
- /var/log/wtmp
|
||||
|
||||
- name: Check to see if the /var/log/audit directory exists
|
||||
ansible.builtin.stat:
|
||||
path: "/var/log/audit"
|
||||
register: audit_directory
|
||||
|
||||
- name: Ensure /var/log/audit directory exists
|
||||
ansible.builtin.file:
|
||||
path: /var/log/audit
|
||||
state: directory
|
||||
mode: "0750"
|
||||
owner: root
|
||||
group: adm
|
||||
when: audit_directory.stat.exists
|
||||
|
||||
- name: Ensure /var/log/audit/audit.log exists
|
||||
ansible.builtin.file:
|
||||
path: /var/log/audit/audit.log
|
||||
state: touch
|
||||
mode: "0640"
|
||||
owner: root
|
||||
group: adm
|
||||
when: audit_directory.stat.exists
|
||||
|
||||
- name: Ensure wtmp and lastlog exist with the correct permissions
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ item }}"
|
||||
content: ""
|
||||
mode: "0664"
|
||||
owner: root
|
||||
group: utmp
|
||||
loop:
|
||||
- "/var/log/wtmp"
|
||||
- "/var/log/lastlog"
|
||||
|
||||
- name: Cleaning persistent udev rules
|
||||
ansible.builtin.file:
|
||||
# Tasks to clean the persistent udev rules.
|
||||
- name: "Cleaning persistent udev rules."
|
||||
file:
|
||||
path: /etc/udev/rules.d/70-persistent-net.rules
|
||||
state: absent
|
||||
|
||||
- name: "Cleaning the /tmp directories"
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "/tmp/*"
|
||||
- "/var/tmp/*"
|
||||
# Tasks to find the /tmp directories.
|
||||
- name: "Finding the /tmp directories."
|
||||
find:
|
||||
paths:
|
||||
- /tmp
|
||||
- /var/tmp
|
||||
file_type: any
|
||||
register: find_tmp_directories
|
||||
|
||||
- name: "Cleaning the SSH host keys."
|
||||
shell: |
|
||||
rm -f /etc/ssh/ssh_host_*
|
||||
|
||||
- name: remove /etc/machine-id
|
||||
# Tasks to clean the /tmp directories.
|
||||
- name: "Cleaning the /tmp directories."
|
||||
file:
|
||||
path: /etc/machine-id
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop: "{{ find_tmp_directories.files }}"
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
|
||||
- name: remove /var/lib/dbus/machine-id
|
||||
# Tasks to find the SSH host keys.
|
||||
- name: "Finding the SSH host keys."
|
||||
find:
|
||||
paths: /etc/ssh
|
||||
patterns: 'ssh_host_*'
|
||||
register: find_ssh_host_keys
|
||||
|
||||
# Tasks to clean the SSH host keys.
|
||||
- name: "Cleaning the SSH host keys."
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop: "{{ find_ssh_host_keys.files }}"
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
|
||||
# Tasks to clean the machine-id.
|
||||
- name: "Cleaning the machine-id."
|
||||
block:
|
||||
- name: "Emptying the /etc/machine-id."
|
||||
community.general.filesize:
|
||||
path: /etc/machine-id
|
||||
size: 0
|
||||
- name: "Removing /var/lib/dbus/machine-id."
|
||||
file:
|
||||
path: /var/lib/dbus/machine-id
|
||||
state: absent
|
||||
- name: "Creating a symbolic link to /etc/machine-id."
|
||||
file:
|
||||
src: /etc/machine-id
|
||||
dest: /var/lib/dbus/machine-id
|
||||
state: link
|
||||
|
||||
- name: generate new machine-id
|
||||
command: systemd-machine-id-setup
|
||||
|
||||
- name: Cleaning the shell history
|
||||
shell: |
|
||||
unset HISTFILE
|
||||
history -cw
|
||||
echo > ~/.bash_history
|
||||
rm -fr /root/.bash_history
|
||||
# Tasks to clean the shell history.
|
||||
- name: "Cleaning the shell history."
|
||||
block:
|
||||
- name: "Cleaning the shell history."
|
||||
file:
|
||||
path: "{{ ansible_env.HOME }}/.bash_history"
|
||||
state: absent
|
||||
@@ -12,8 +12,8 @@
|
||||
include_tasks: redhat.yml
|
||||
when: "ansible_facts['distribution'] in ['RedHat', 'CentOS', 'Rocky', 'AlmaLinux', 'OracleLinux']"
|
||||
|
||||
- name: Prepare the {{ ansible_facts['distribution'] }} guest operating system
|
||||
include_tasks: "{{ ansible_facts['distribution'] | lower }}.yml"
|
||||
when: "ansible_facts['distribution'] == 'Suse'"
|
||||
- name: Cleaning tasks for the {{ ansible_facts['distribution'] }} guest operating system
|
||||
include_tasks: suse.yml
|
||||
when: "ansible_facts['distribution'] in ['openSUSE Leap', 'Suse']"
|
||||
|
||||
...
|
||||
@@ -1,59 +1,92 @@
|
||||
---
|
||||
|
||||
- name: "Cleaning all audit logs."
|
||||
shell: |
|
||||
if [ -f /var/log/audit/audit.log ]; then
|
||||
cat /dev/null > /var/log/audit/audit.log
|
||||
fi
|
||||
if [ -f /var/log/wtmp ]; then
|
||||
cat /dev/null > /var/log/wtmp
|
||||
fi
|
||||
if [ -f /var/log/lastlog ]; then
|
||||
cat /dev/null > /var/log/lastlog
|
||||
fi
|
||||
|
||||
- name: "Cleaning persistent udev rules."
|
||||
shell: |
|
||||
if [ -f /etc/udev/rules.d/70-persistent-net.rules ]; then
|
||||
rm /etc/udev/rules.d/70-persistent-net.rules
|
||||
fi
|
||||
|
||||
- name: "Cleaning the /tmp directories"
|
||||
shell: |
|
||||
rm -rf /tmp/*
|
||||
rm -rf /var/tmp/*
|
||||
rm -rf /var/cache/dnf/*
|
||||
|
||||
# Tasks to clean the Red Hat Subscription Manager logs.
|
||||
- name: "Cleaning the Red Hat Subscription Manager logs."
|
||||
shell: |
|
||||
rm -rf /var/log/rhsm/*
|
||||
when: "ansible_facts['distribution'] == 'RedHat'"
|
||||
ansible.builtin.file:
|
||||
path: /var/log/rhsm
|
||||
state: absent
|
||||
when: ansible_distribution == 'RedHat'
|
||||
|
||||
# Tasks to clean the audit logs.
|
||||
- name: "Cleaning the audit logs."
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- /var/log/audit/audit.log
|
||||
- /var/log/btmp
|
||||
- /var/log/boot.log
|
||||
- /var/log/cron
|
||||
- /var/log/dnf.log
|
||||
- /var/log/lastlog
|
||||
- /var/log/maillog
|
||||
- /var/log/messages
|
||||
- /var/log/secure
|
||||
- /var/log/wtmp
|
||||
- /var/log/yum.log
|
||||
|
||||
# Tasks to clean the persistent udev rules.
|
||||
- name: "Cleaning persistent udev rules."
|
||||
ansible.builtin.file:
|
||||
path: /etc/udev/rules.d/70-persistent-net.rules
|
||||
state: absent
|
||||
|
||||
# Tasks to find the /tmp directories.
|
||||
- name: "Finding the /tmp directories."
|
||||
ansible.builtin.find:
|
||||
paths:
|
||||
- /tmp
|
||||
- /var/tmp
|
||||
file_type: any
|
||||
register: find_tmp_directories
|
||||
|
||||
# Tasks to clean the /tmp directories.
|
||||
- name: "Cleaning the /tmp directories."
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop: "{{ find_tmp_directories.files }}"
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
|
||||
# Tasks to find the SSH host keys.
|
||||
- name: "Finding the SSH host keys."
|
||||
ansible.builtin.find:
|
||||
paths: /etc/ssh
|
||||
patterns: 'ssh_host_*'
|
||||
register: find_ssh_host_keys
|
||||
|
||||
# Tasks to clean the SSH host keys.
|
||||
- name: "Cleaning the SSH host keys."
|
||||
shell: |
|
||||
rm -f /etc/ssh/ssh_host_*
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop: "{{ find_ssh_host_keys.files }}"
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
|
||||
# Tasks to clean the machine-id.
|
||||
- name: "Emptying the /etc/machine-id."
|
||||
community.general.filesize:
|
||||
path: /etc/machine-id
|
||||
size: 0
|
||||
|
||||
- name: "Cleaning the machine-id."
|
||||
when: 'ansible_facts[''distribution_major_version''] <= "8"'
|
||||
shell: |
|
||||
truncate -s 0 /etc/machine-id
|
||||
rm /var/lib/dbus/machine-id
|
||||
ln -s /etc/machine-id /var/lib/dbus/machine-id
|
||||
|
||||
- name: "Cleaning the machine-id."
|
||||
when: 'ansible_facts[''distribution_major_version''] >= "9"'
|
||||
shell: |
|
||||
truncate -s 0 /etc/machine-id
|
||||
block:
|
||||
- name: "Removing /var/lib/dbus/machine-id."
|
||||
ansible.builtin.file:
|
||||
path: /var/lib/dbus/machine-id
|
||||
state: absent
|
||||
- name: "Creating a symbolic link to /etc/machine-id."
|
||||
ansible.builtin.file:
|
||||
src: /etc/machine-id
|
||||
dest: /var/lib/dbus/machine-id
|
||||
state: link
|
||||
when: ansible_distribution_major_version | int <= 8
|
||||
|
||||
# Tasks to clean the shell history.
|
||||
- name: "Cleaning the shell history."
|
||||
shell: |
|
||||
unset HISTFILE
|
||||
history -cw
|
||||
echo > ~/.bash_history
|
||||
rm -fr /root/.bash_history
|
||||
|
||||
- name: "Running a sync."
|
||||
shell: |
|
||||
sync && sync
|
||||
|
||||
...
|
||||
block:
|
||||
- name: "Cleaning the shell history."
|
||||
ansible.builtin.file:
|
||||
path: "{{ ansible_env.HOME }}/.bash_history"
|
||||
state: absent
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
# Tasks to clean the SUSE Customer Center file.
|
||||
- name: "Cleaning the SUSE Customer Center file."
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /etc/SUSEConnect
|
||||
state: absent
|
||||
when: "ansible_facts['distribution'] != 'openSUSE Leap'"
|
||||
|
||||
# Tasks to clean the audit logs.
|
||||
- name: "Cleaning the audit logs."
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
@@ -17,20 +18,19 @@
|
||||
- /var/log/lastlog
|
||||
- /var/log/mail
|
||||
- /var/log/messages
|
||||
- /var/log/secure
|
||||
- /var/log/warn
|
||||
- /var/log/wtmp
|
||||
- /var/log/zypper.log
|
||||
|
||||
# Tasks to clean the persistent udev rules.
|
||||
- name: "Cleaning persistent udev rules."
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /etc/udev/rules.d/70-persistent-net.rules
|
||||
state: absent
|
||||
|
||||
# Tasks to find the /tmp directories.
|
||||
- name: "Finding the /tmp directories."
|
||||
find:
|
||||
ansible.builtin.find:
|
||||
paths:
|
||||
- /tmp
|
||||
- /var/tmp
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
# Tasks to clean the /tmp directories.
|
||||
- name: "Cleaning the /tmp directories."
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop: "{{ find_tmp_directories.files }}"
|
||||
@@ -49,14 +49,14 @@
|
||||
|
||||
# Tasks to find the SSH host keys.
|
||||
- name: "Finding the SSH host keys."
|
||||
find:
|
||||
ansible.builtin.find:
|
||||
paths: /etc/ssh
|
||||
patterns: 'ssh_host_*'
|
||||
register: find_ssh_host_keys
|
||||
|
||||
# Tasks to clean the SSH host keys.
|
||||
- name: "Cleaning the SSH host keys."
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop: "{{ find_ssh_host_keys.files }}"
|
||||
@@ -73,7 +73,7 @@
|
||||
- name: "Cleaning the shell history."
|
||||
block:
|
||||
- name: "Cleaning the shell history."
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ ansible_env.HOME }}/.bash_history"
|
||||
state: absent
|
||||
|
||||
|
||||
@@ -1,93 +1,105 @@
|
||||
---
|
||||
# Tasks for setting custom facts.
|
||||
- name: "Setting custom facts."
|
||||
ansible.builtin.set_fact:
|
||||
enable_cloudinit: "{{ enable_cloudinit | default('false') }}"
|
||||
|
||||
- name: Remove audit log files
|
||||
# Tasks for disabling cloud-init
|
||||
- name: "Disabling cloud-init."
|
||||
block:
|
||||
- name: 'Check if /etc/cloud/ exists'
|
||||
ansible.builtin.stat:
|
||||
path: '/etc/cloud/'
|
||||
register: etc_cloud_folder
|
||||
|
||||
- name: 'Generate /etc/cloud/cloud-init.disabled'
|
||||
ansible.builtin.copy:
|
||||
dest: '/etc/cloud/cloud-init.disabled'
|
||||
content: "disabled by ansible\n"
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0644'
|
||||
when:
|
||||
- 'etc_cloud_folder.stat.exists'
|
||||
when: enable_cloudinit == 'false'
|
||||
|
||||
# Tasks to clean the audit logs.
|
||||
- name: "Cleaning the audit logs."
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "/var/log/audit/audit.log"
|
||||
- "/var/log/wtmp"
|
||||
- "/var/log/lastlog"
|
||||
- /var/log/audit/audit.log
|
||||
- /var/log/auth.log
|
||||
- /var/log/btmp
|
||||
- /var/log/dpkg.log
|
||||
- /var/log/faillog
|
||||
- /var/log/kern.log
|
||||
- /var/log/lastlog
|
||||
- /var/log/syslog
|
||||
- /var/log/wtmp
|
||||
|
||||
- name: Check to see if the /var/log/audit directory exists
|
||||
ansible.builtin.stat:
|
||||
path: "/var/log/audit"
|
||||
register: audit_directory
|
||||
|
||||
- name: Ensure /var/log/audit directory exists
|
||||
ansible.builtin.file:
|
||||
path: /var/log/audit
|
||||
state: directory
|
||||
mode: "0750"
|
||||
owner: root
|
||||
group: adm
|
||||
when: audit_directory.stat.exists
|
||||
|
||||
- name: Ensure /var/log/audit/audit.log exists
|
||||
ansible.builtin.file:
|
||||
path: /var/log/audit/audit.log
|
||||
state: touch
|
||||
mode: "0640"
|
||||
owner: root
|
||||
group: adm
|
||||
when: audit_directory.stat.exists
|
||||
|
||||
- name: Ensure wtmp and lastlog exist with the correct permissions
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ item }}"
|
||||
content: ""
|
||||
mode: "0664"
|
||||
owner: root
|
||||
group: utmp
|
||||
loop:
|
||||
- "/var/log/wtmp"
|
||||
- "/var/log/lastlog"
|
||||
|
||||
- name: Cleaning persistent udev rules
|
||||
# Tasks to clean the persistent udev rules.
|
||||
- name: "Cleaning persistent udev rules."
|
||||
ansible.builtin.file:
|
||||
path: /etc/udev/rules.d/70-persistent-net.rules
|
||||
state: absent
|
||||
|
||||
- name: "Cleaning the /tmp directories"
|
||||
# Tasks to find the /tmp directories.
|
||||
- name: "Finding the /tmp directories."
|
||||
ansible.builtin.find:
|
||||
paths:
|
||||
- /tmp
|
||||
- /var/tmp
|
||||
file_type: any
|
||||
register: find_tmp_directories
|
||||
|
||||
# Tasks to clean the /tmp directories.
|
||||
- name: "Cleaning the /tmp directories."
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "/tmp/*"
|
||||
- "/var/tmp/*"
|
||||
loop: "{{ find_tmp_directories.files }}"
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
|
||||
- name: Cleaning the SSH host keys
|
||||
shell: |
|
||||
rm -f /etc/ssh/ssh_host_*
|
||||
# Tasks to find the SSH host keys.
|
||||
- name: "Finding the SSH host keys."
|
||||
ansible.builtin.find:
|
||||
paths: /etc/ssh
|
||||
patterns: 'ssh_host_*'
|
||||
register: find_ssh_host_keys
|
||||
|
||||
- name: remove /etc/machine-id
|
||||
file:
|
||||
# Tasks to clean the SSH host keys.
|
||||
- name: "Cleaning the SSH host keys."
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop: "{{ find_ssh_host_keys.files }}"
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
|
||||
# Tasks to clean the machine-id.
|
||||
- name: "Cleaning the machine-id."
|
||||
block:
|
||||
- name: "Emptying the /etc/machine-id."
|
||||
community.general.filesize:
|
||||
path: /etc/machine-id
|
||||
state: absent
|
||||
|
||||
- name: remove /var/lib/dbus/machine-id
|
||||
file:
|
||||
size: 0
|
||||
- name: "Removing /var/lib/dbus/machine-id."
|
||||
ansible.builtin.file:
|
||||
path: /var/lib/dbus/machine-id
|
||||
state: absent
|
||||
- name: "Creating a symbolic link to /etc/machine-id."
|
||||
ansible.builtin.file:
|
||||
src: /etc/machine-id
|
||||
dest: /var/lib/dbus/machine-id
|
||||
state: link
|
||||
|
||||
- name: generate new machine-id
|
||||
command: systemd-machine-id-setup
|
||||
|
||||
- name: Clean apt
|
||||
ansible.builtin.apt:
|
||||
autoclean: yes
|
||||
autoremove: yes
|
||||
clean: yes
|
||||
|
||||
- name: Cleaning the shell history
|
||||
shell: |
|
||||
unset HISTFILE
|
||||
history -cw
|
||||
echo > ~/.bash_history
|
||||
rm -fr /root/.bash_history
|
||||
|
||||
- name: Clean cloud-init
|
||||
ansible.builtin.command: cloud-init clean
|
||||
when: cloud_init | bool
|
||||
|
||||
...
|
||||
# Tasks to clean the shell history.
|
||||
- name: "Cleaning the shell history."
|
||||
block:
|
||||
- name: "Cleaning the shell history."
|
||||
ansible.builtin.file:
|
||||
path: "{{ ansible_env.HOME }}/.bash_history"
|
||||
state: absent
|
||||
2
ansible/roles/clean/vars/main.yml
Normal file
2
ansible/roles/clean/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
task_name: "Clean the operating system."
|
||||
@@ -1,37 +1,54 @@
|
||||
---
|
||||
- name: "Configure SSH for Public Key Authentication."
|
||||
shell: |
|
||||
sudo sed -i 's/.*PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
|
||||
# Tasks for setting custom facts.
|
||||
- name: "Setting custom facts."
|
||||
set_fact:
|
||||
enable_cloudinit: "{{ enable_cloudinit | default('false') }}"
|
||||
|
||||
- name: Creating SSH key regeneration service file
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/systemd/system/regenerate_ssh_host_keys.service
|
||||
# Tasks for configuring SSH for public key authentication.
|
||||
- name: "Configuring SSH for Public Key Authentication."
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: '^PubkeyAuthentication'
|
||||
line: 'PubkeyAuthentication yes'
|
||||
|
||||
# Tasks for setting the hostname.
|
||||
- name: "Setting the hostname."
|
||||
hostname:
|
||||
name: "localhost"
|
||||
|
||||
# Tasks for restarting the SSH daemon.
|
||||
- name: "Restarting the SSH daemon."
|
||||
systemd:
|
||||
name: ssh
|
||||
state: restarted
|
||||
daemon_reload: true
|
||||
|
||||
# Tasks for disabling systemd-tmpfiles.
|
||||
- name: "Disabling systemd-tmpfiles."
|
||||
replace:
|
||||
path: /usr/lib/tmpfiles.d/tmp.conf
|
||||
regexp: '^D'
|
||||
replace: '#D'
|
||||
|
||||
# Tasks for configuring cloud-init.
|
||||
- name: "Configuring cloud-init."
|
||||
block:
|
||||
- name: "Message: Configuring cloud-init"
|
||||
ansible.builtin.debug:
|
||||
msg: "Configuring cloud-init"
|
||||
- ansible.builtin.copy:
|
||||
content: "datasource_list: [ NoCloud, ConfigDrive ]"
|
||||
dest: /etc/cloud/cloud.cfg.d/99_pve.cfg
|
||||
when: enable_cloudinit == 'true'
|
||||
|
||||
# Tasks for setting SSH keys to regenerate.
|
||||
- name: "Setting SSH keys to regenerate."
|
||||
copy:
|
||||
dest: /etc/rc.local
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Regenerate SSH host keys
|
||||
Before=ssh.service
|
||||
ConditionFileIsExecutable=/usr/bin/ssh-keygen
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStartPre=-/bin/dd if=/dev/hwrng of=/dev/urandom count=1 bs=4096
|
||||
ExecStartPre=-/bin/sh -c "/bin/rm -f -v /etc/ssh/ssh_host_*_key*"
|
||||
ExecStart=/usr/bin/ssh-keygen -A -v
|
||||
ExecStartPost=/bin/systemctl disable regenerate_ssh_host_keys
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
when: not cloud_init | bool
|
||||
|
||||
- name: Reload systemd to re-read configurations
|
||||
ansible.builtin.systemd:
|
||||
daemon-reload: true
|
||||
when: not cloud_init | bool
|
||||
|
||||
- name: Enable regenerate_ssh_host_keys service
|
||||
ansible.builtin.systemd:
|
||||
name: regenerate_ssh_host_keys
|
||||
enabled: true
|
||||
when: not cloud_init | bool
|
||||
|
||||
...
|
||||
#!/bin/bash
|
||||
if test -z "$(find /etc/ssh/ -iname 'ssh_host_*_key*')"; then
|
||||
dpkg-reconfigure openssh-server
|
||||
fi
|
||||
exit 0
|
||||
mode: 0755
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
include_tasks: redhat.yml
|
||||
when: "ansible_facts['distribution'] in ['RedHat', 'CentOS', 'Rocky', 'AlmaLinux', 'OracleLinux']"
|
||||
|
||||
- name: Prepare the {{ ansible_facts['distribution'] }} guest operating system
|
||||
include_tasks: "{{ ansible_facts['distribution'] | lower }}.yml"
|
||||
when: "ansible_facts['distribution'] == 'Suse'"
|
||||
- name: Configuration tasks for the {{ ansible_facts['distribution'] }} guest operating system
|
||||
include_tasks: suse.yml
|
||||
when: "ansible_facts['distribution'] in ['openSUSE Leap', 'Suse']"
|
||||
|
||||
...
|
||||
@@ -1,5 +1,56 @@
|
||||
---
|
||||
- name: "Configure SSH for Public Key Authentication."
|
||||
shell: |
|
||||
sudo sed -i 's/.*PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
|
||||
sudo sed -i 's/.*PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
|
||||
# Tasks for unregistering from Red Hat Subscription Manager.
|
||||
- name: "Unregistering from Red Hat Subscription Manager."
|
||||
community.general.redhat_subscription:
|
||||
state: absent
|
||||
when: ansible_distribution == 'RedHat'
|
||||
|
||||
# Tasks for configuring SSH for public key authentication.
|
||||
- name: "Configuring SSH for Public Key Authentication."
|
||||
block:
|
||||
- ansible.builtin.lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: '^PermitRootLogin'
|
||||
line: 'PermitRootLogin no'
|
||||
- ansible.builtin.lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: '^PubkeyAuthentication'
|
||||
line: 'PubkeyAuthentication yes'
|
||||
|
||||
# Tasks for setting the hostname.
|
||||
- name: "Setting the hostname."
|
||||
ansible.builtin.hostname:
|
||||
name: "localhost"
|
||||
|
||||
# Tasks for disabling SELinux.
|
||||
- name: "Disabling SELinux."
|
||||
ansible.builtin.selinux:
|
||||
state: disabled
|
||||
policy: targeted
|
||||
|
||||
# Tasks for configuring cloud-init.
|
||||
- block:
|
||||
- name: "Message: Configuring cloud-init"
|
||||
ansible.builtin.debug:
|
||||
msg: "Configuring cloud-init"
|
||||
- name: "Add Proxmox datasource"
|
||||
ansible.builtin.copy:
|
||||
content: "datasource_list: [ NoCloud, ConfigDrive ]"
|
||||
dest: /etc/cloud/cloud.cfg.d/99_pve.cfg
|
||||
- name: Enable cloud-init services
|
||||
ansible.builtin.service:
|
||||
name: "{{ item }}"
|
||||
enabled: true
|
||||
loop:
|
||||
- cloud-config
|
||||
- cloud-init
|
||||
- cloud-init-local
|
||||
- cloud-final
|
||||
when: enable_cloudinit == 'true'
|
||||
|
||||
# Tasks for restarting the SSH daemon.
|
||||
- name: "Restarting the SSH daemon."
|
||||
ansible.builtin.systemd:
|
||||
name: sshd
|
||||
state: restarted
|
||||
daemon_reload: true
|
||||
@@ -1,35 +1,57 @@
|
||||
---
|
||||
|
||||
# Tasks for setting custom facts.
|
||||
- name: "Setting custom facts."
|
||||
set_fact:
|
||||
enable_cloudinit: "{{ enable_cloudinit | default('false') }}"
|
||||
|
||||
# Tasks for unregistering from SUSE Customer Center.
|
||||
- name: "Unregistering from SUSE Customer Center."
|
||||
command:
|
||||
ansible.builtin.command:
|
||||
cmd: "{{ item }}"
|
||||
loop:
|
||||
- SUSEConnect -d
|
||||
- SUSEConnect --cleanup
|
||||
when: "ansible_facts['distribution'] != 'openSUSE Leap'"
|
||||
|
||||
# Tasks for configuring SSH for public key authentication.
|
||||
- name: "Configuring SSH for Public Key Authentication."
|
||||
block:
|
||||
- lineinfile:
|
||||
- ansible.builtin.lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: '^PermitRootLogin'
|
||||
line: 'PermitRootLogin no'
|
||||
- lineinfile:
|
||||
- ansible.builtin.lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: '^PubkeyAuthentication'
|
||||
line: 'PubkeyAuthentication yes'
|
||||
|
||||
# Tasks for setting the hostname.
|
||||
- name: "Setting the hostname."
|
||||
hostname:
|
||||
ansible.builtin.hostname:
|
||||
name: "localhost"
|
||||
|
||||
# Tasks for configuring cloud-init.
|
||||
- name: "Configuring cloud-init."
|
||||
block:
|
||||
- name: "Message: Configuring cloud-init"
|
||||
ansible.builtin.debug:
|
||||
msg: "Configuring cloud-init"
|
||||
- ansible.builtin.copy:
|
||||
content: "datasource_list: [ NoCloud, ConfigDrive ]"
|
||||
dest: /etc/cloud/cloud.cfg.d/99_pve.cfg
|
||||
- name: Enable cloud-init services
|
||||
ansible.builtin.service:
|
||||
name: "{{ item }}"
|
||||
enabled: true
|
||||
loop:
|
||||
- cloud-init
|
||||
- cloud-init-local
|
||||
when: enable_cloudinit == 'true'
|
||||
|
||||
# Tasks for restarting the SSH daemon.
|
||||
- name: "Restarting the SSH daemon."
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: sshd
|
||||
state: restarted
|
||||
daemon_reload: true
|
||||
|
||||
...
|
||||
@@ -1,87 +1,62 @@
|
||||
---
|
||||
- name: "Configure SSH for Public Key Authentication"
|
||||
shell: |
|
||||
sudo sed -i 's/.*PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
|
||||
- name: "Restarting the SSH daemon."
|
||||
shell: |
|
||||
sudo systemctl restart sshd
|
||||
# Tasks for setting custom facts.
|
||||
- name: "Setting custom facts."
|
||||
ansible.builtin.set_fact:
|
||||
enable_cloudinit: "{{ enable_cloudinit | default('false') }}"
|
||||
|
||||
- name: Remove cloud-init files
|
||||
ansible.builtin.file:
|
||||
# Tasks for configuring SSH for public key authentication.
|
||||
- name: "Configuring SSH for Public Key Authentication."
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: '^PubkeyAuthentication'
|
||||
line: 'PubkeyAuthentication yes'
|
||||
|
||||
# Tasks for setting the hostname.
|
||||
- name: "Setting the hostname."
|
||||
ansible.builtin.hostname:
|
||||
name: "localhost"
|
||||
|
||||
# Tasks for restarting the SSH daemon.
|
||||
- name: "Restarting the SSH daemon."
|
||||
ansible.builtin.systemd:
|
||||
name: ssh
|
||||
state: restarted
|
||||
daemon_reload: true
|
||||
|
||||
# Tasks for disabling systemd-tmpfiles.
|
||||
- name: "Disabling systemd-tmpfiles."
|
||||
ansible.builtin.replace:
|
||||
path: /usr/lib/tmpfiles.d/tmp.conf
|
||||
regexp: '^D'
|
||||
replace: '#D'
|
||||
|
||||
# Tasks for configuring cloud-init.
|
||||
- name: "Configuring cloud-init."
|
||||
block:
|
||||
- name: "Message: Configuring cloud-init"
|
||||
ansible.builtin.debug:
|
||||
msg: "Configuring cloud-init"
|
||||
- ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
|
||||
- /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg
|
||||
- /etc/cloud/cloud.cfg.d/curtin-preserve-sources.cfg
|
||||
- /etc/cloud/cloud.cfg.d/99-installer.cfg
|
||||
- /etc/netplan/00-installer-config.yaml
|
||||
when:
|
||||
- cloud_init | bool
|
||||
- ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04"
|
||||
- ansible.builtin.copy:
|
||||
content: "datasource_list: [ NoCloud, ConfigDrive ]"
|
||||
dest: /etc/cloud/cloud.cfg.d/99_pve.cfg
|
||||
when: enable_cloudinit == 'true'
|
||||
|
||||
- name: Disable cloud-init if configured to
|
||||
block:
|
||||
- name: Check if /etc/cloud/ exists
|
||||
ansible.builtin.stat:
|
||||
path: '/etc/cloud/'
|
||||
register: etc_cloud_folder
|
||||
|
||||
- name: 'Generate /etc/cloud/cloud-init.disabled'
|
||||
# Tasks for setting SSH keys to regenerate.
|
||||
- name: "Setting SSH keys to regenerate."
|
||||
ansible.builtin.copy:
|
||||
dest: '/etc/cloud/cloud-init.disabled'
|
||||
content: 'disabled by ansible\n'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0644'
|
||||
when:
|
||||
- 'etc_cloud_folder.stat.exists'
|
||||
when:
|
||||
- not cloud_init | bool
|
||||
- ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04"
|
||||
|
||||
- name: Copy cloud-init PVE default file
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/cloud/cloud.cfg.d/90_dpkg.cfg
|
||||
dest: /etc/rc.local
|
||||
content: |
|
||||
datasource_list: [ ConfigDrive, NoCloud ]
|
||||
when: cloud_init | bool
|
||||
#!/bin/bash
|
||||
if test -z "$(find /etc/ssh/ -iname 'ssh_host_*_key*')"; then
|
||||
dpkg-reconfigure openssh-server
|
||||
fi
|
||||
exit 0
|
||||
mode: 0755
|
||||
|
||||
- name: "Modifying GRUB."
|
||||
shell: |
|
||||
sed -i -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/" /etc/default/grub
|
||||
update-grub
|
||||
when: ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04"
|
||||
|
||||
- name: Creating SSH key regeneration service file
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/systemd/system/regenerate_ssh_host_keys.service
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Regenerate SSH host keys
|
||||
Before=ssh.service
|
||||
ConditionFileIsExecutable=/usr/bin/ssh-keygen
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStartPre=-/bin/dd if=/dev/hwrng of=/dev/urandom count=1 bs=4096
|
||||
ExecStartPre=-/bin/sh -c "/bin/rm -f -v /etc/ssh/ssh_host_*_key*"
|
||||
ExecStart=/usr/bin/ssh-keygen -A -v
|
||||
ExecStartPost=/bin/systemctl disable regenerate_ssh_host_keys
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
when: not cloud_init | bool
|
||||
|
||||
- name: Reload systemd to re-read configurations
|
||||
ansible.builtin.systemd:
|
||||
daemon-reload: true
|
||||
when: not cloud_init | bool
|
||||
|
||||
- name: Enable regenerate_ssh_host_keys service
|
||||
ansible.builtin.systemd:
|
||||
name: regenerate_ssh_host_keys
|
||||
enabled: true
|
||||
when: not cloud_init | bool
|
||||
|
||||
...
|
||||
|
||||
2
ansible/roles/configure/vars/main.yml
Normal file
2
ansible/roles/configure/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
task_name: "Configure the operating system."
|
||||
@@ -1,31 +1,46 @@
|
||||
---
|
||||
- name: "Adding authorized_keys for the default local user."
|
||||
shell: |
|
||||
sudo mkdir -p /home/{{BUILD_USERNAME}}/.ssh
|
||||
sudo tee /home/{{BUILD_USERNAME}}/.ssh/authorized_keys << EOF
|
||||
{{BUILD_SECRET}}
|
||||
EOF
|
||||
sudo chown -R {{BUILD_USERNAME}} /home/{{BUILD_USERNAME}}/.ssh
|
||||
sudo chmod 700 /home/{{BUILD_USERNAME}}/.ssh
|
||||
sudo chmod 644 /home/{{BUILD_USERNAME}}/.ssh/authorized_keys
|
||||
- name: "Adding the default local user to passwordless sudoers."
|
||||
shell: |
|
||||
sudo bash -c "echo \"""{{BUILD_USERNAME}}"" ALL=(ALL) NOPASSWD:ALL\" >> /etc/sudoers"
|
||||
- name: "Creating a local user for Ansible."
|
||||
shell: |
|
||||
sudo groupadd {{ANSIBLE_USERNAME}}
|
||||
sudo useradd -g {{ANSIBLE_USERNAME}} -m -s /bin/bash {{ANSIBLE_USERNAME}}
|
||||
sudo usermod -aG sudo {{ANSIBLE_USERNAME}}
|
||||
echo {{ANSIBLE_USERNAME}}:"$(openssl rand -base64 14)" | sudo chpasswd
|
||||
- name: "Adding authorized_keys to the local user for Ansible."
|
||||
shell: |
|
||||
sudo mkdir -p /home/{{ANSIBLE_USERNAME}}/.ssh
|
||||
sudo tee /home/{{ANSIBLE_USERNAME}}/.ssh/authorized_keys << EOF
|
||||
{{ANSIBLE_SECRET}}
|
||||
EOF
|
||||
sudo chown -R {{ANSIBLE_USERNAME}} /home/{{ANSIBLE_USERNAME}}/.ssh
|
||||
sudo chmod 700 /home/{{ANSIBLE_USERNAME}}/.ssh
|
||||
sudo chmod 644 /home/{{ANSIBLE_USERNAME}}/.ssh/authorized_keys
|
||||
- name: "Adding the local user for Ansible to passwordless sudoers."
|
||||
shell: |
|
||||
sudo bash -c "echo \"""{{ANSIBLE_USERNAME}}"" ALL=(ALL) NOPASSWD:ALL\" >> /etc/sudoers"
|
||||
# Tasks for setting custom facts.
|
||||
- name: "Setting custom facts."
|
||||
ansible.builtin.set_fact:
|
||||
enable_cloudinit: "{{ enable_cloudinit | default('false') }}"
|
||||
|
||||
# Tasks for creating the local group for Ansible.
|
||||
- name: "Creating the local group for Ansible."
|
||||
ansible.builtin.group:
|
||||
name: "{{ ansible_username }}"
|
||||
|
||||
# Tasks for creating the sudo group.
|
||||
- name: "Creating the sudo group."
|
||||
ansible.builtin.group:
|
||||
name: sudo
|
||||
|
||||
# Tasks for creating the local user for Ansible.
|
||||
- name: "Creating the local user for Ansible."
|
||||
ansible.builtin.user:
|
||||
name: "{{ ansible_username }}"
|
||||
group: "{{ ansible_username }}"
|
||||
groups: sudo
|
||||
password: '!'
|
||||
shell: /bin/bash
|
||||
|
||||
# Tasks for managing the authorized keys for the local users.
|
||||
- name: "Managing the authorized keys for the local users."
|
||||
ansible.posix.authorized_key:
|
||||
user: "{{ item.user }}"
|
||||
key: "{{ item.key }}"
|
||||
loop:
|
||||
- user: "{{ ansible_username }}"
|
||||
key: "{{ ansible_key }}"
|
||||
- user: "{{ build_username }}"
|
||||
key: "{{ build_key }}"
|
||||
no_log: true
|
||||
|
||||
# Tasks for managing sudoers.d for the local users.
|
||||
- name: "Managing sudoers.d for the local users."
|
||||
community.general.sudoers:
|
||||
name: "{{ item }}"
|
||||
user: "{{ item }}"
|
||||
commands: ALL
|
||||
loop:
|
||||
- "{{ build_username }}"
|
||||
- "{{ ansible_username }}"
|
||||
|
||||
2
ansible/roles/users/vars/main.yml
Normal file
2
ansible/roles/users/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
task_name: "Configure the operating system users."
|
||||
431
build.sh
431
build.sh
@@ -8,8 +8,8 @@ SCRIPT_PATH=$(realpath "$(dirname "$(follow_link "$0")")")
|
||||
CONFIG_PATH=$(realpath "${1:-${SCRIPT_PATH}/config}")
|
||||
|
||||
menu_option_1() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/centos/8-stream/
|
||||
echo -e "\nCONFIRM: Build a CentOS 8 Stream Template for Proxmox?"
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/almalinux/9/
|
||||
echo -e "\nCONFIRM: Build a AlmaLinux 9 Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
@@ -17,8 +17,8 @@ menu_option_1() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a CentOS 8 Stream Template for Proxmox. ###
|
||||
echo "Building a CentOS 8 Stream Template for Proxmox..."
|
||||
### Build a AlmaLinux 9 Template for Proxmox. ###
|
||||
echo "Building a AlmaLinux 9 Template for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
@@ -27,11 +27,12 @@ menu_option_1() {
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
@@ -39,6 +40,38 @@ menu_option_1() {
|
||||
}
|
||||
|
||||
menu_option_2() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/almalinux/8/
|
||||
echo -e "\nCONFIRM: Build a AlmaLinux 8 Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a AlmaLinux 8 Template for Proxmox. ###
|
||||
echo "Building a AlmaLinux 8 Template for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
packer init "$INPUT_PATH"
|
||||
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
menu_option_3() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/centos/9-stream/
|
||||
echo -e "\nCONFIRM: Build a CentOS 9 Stream Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
@@ -58,42 +91,12 @@ menu_option_2() {
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
menu_option_3() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/debian/11/
|
||||
echo -e "\nCONFIRM: Build a Debian 11 (Bullseye) Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Debian 11 (Bullseye) for Proxmox. ###
|
||||
echo "Building a Debian 11 (Bullseye) for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
packer init "$INPUT_PATH"
|
||||
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
@@ -120,11 +123,12 @@ menu_option_4() {
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
@@ -132,8 +136,8 @@ menu_option_4() {
|
||||
}
|
||||
|
||||
menu_option_5() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/20-04-lts/
|
||||
echo -e "\nCONFIRM: Build a Ubuntu Server 20.04 LTS Template for Proxmox?"
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/debian/11/
|
||||
echo -e "\nCONFIRM: Build a Debian 11 (Bullseye) Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
@@ -141,8 +145,8 @@ menu_option_5() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Ubuntu Server 20.04 LTS Template for Proxmox. ###
|
||||
echo "Building a Ubuntu Server 20.04 LTS Template for Proxmox..."
|
||||
### Build a Debian 11 (Bullseye) for Proxmox. ###
|
||||
echo "Building a Debian 11 (Bullseye) for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
@@ -151,11 +155,12 @@ menu_option_5() {
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
@@ -163,8 +168,8 @@ menu_option_5() {
|
||||
}
|
||||
|
||||
menu_option_6() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/20-04-lts/
|
||||
echo -e "\nCONFIRM: Build a Ubuntu Server 20.04 LTS (cloud-init) Template for Proxmox?"
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/opensuse/leap-15-6/
|
||||
echo -e "\nCONFIRM: Build a OpenSUSE Leap 15.6 Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
@@ -172,8 +177,8 @@ menu_option_6() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Ubuntu Server 20.04 LTS Template for Proxmox. ###
|
||||
echo "Building a Ubuntu Server 20.04 LTS (cloud-init) Template for Proxmox..."
|
||||
### Build a OpenSUSE Leap 15.6 Template for Proxmox. ###
|
||||
echo "Building a OpenSUSE Leap 15.6 Template for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
@@ -182,12 +187,12 @@ menu_option_6() {
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var "vm_cloud_init_enable=true" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
@@ -195,69 +200,6 @@ menu_option_6() {
|
||||
}
|
||||
|
||||
menu_option_7() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/22-04-lts/
|
||||
echo -e "\nCONFIRM: Build a Ubuntu Server 22.04 LTS Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Ubuntu Server 22.04 LTS Template for Proxmox. ###
|
||||
echo "Building a Ubuntu Server 22.04 LTS Template for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
packer init "$INPUT_PATH"
|
||||
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
menu_option_8() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/22-04-lts/
|
||||
echo -e "\nCONFIRM: Build a Ubuntu Server 22.04 LTS (cloud-init) Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Ubuntu Server 22.04 LTS Template for Proxmox. ###
|
||||
echo "Building a Ubuntu Server 22.04 LTS (cloud-init) Template for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
packer init "$INPUT_PATH"
|
||||
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var "vm_cloud_init_enable=true" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
menu_option_9() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/opensuse/leap-15-5/
|
||||
echo -e "\nCONFIRM: Build a OpenSUSE Leap 15.5 Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
@@ -277,11 +219,236 @@ menu_option_9() {
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
menu_option_8() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/oracle/9/
|
||||
echo -e "\nCONFIRM: Build a Oracle Linux 9 Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Oracle Linux 9 Template for Proxmox. ###
|
||||
echo "Building a Oracle Linux 9 Template for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
packer init "$INPUT_PATH"
|
||||
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
menu_option_9() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/oracle/8/
|
||||
echo -e "\nCONFIRM: Build a Oracle Linux 8 Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Oracle Linux 8 Template for Proxmox. ###
|
||||
echo "Building a Oracle Linux 8 Template for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
packer init "$INPUT_PATH"
|
||||
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
menu_option_10() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/rocky/9/
|
||||
echo -e "\nCONFIRM: Build a Rocky Linux 9 Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Rocky Linux 9 for Proxmox. ###
|
||||
echo "Building a Rocky Linux 9 for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
packer init "$INPUT_PATH"
|
||||
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
menu_option_11() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/rocky/8/
|
||||
echo -e "\nCONFIRM: Build a Rocky Linux 8 Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Rocky Linux 8 for Proxmox. ###
|
||||
echo "Building a Rocky Linux 8 for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
packer init "$INPUT_PATH"
|
||||
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
menu_option_12() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/24-04-lts/
|
||||
echo -e "\nCONFIRM: Build a Ubuntu Server 24.04 LTS Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Ubuntu Server 24.04 LTS Template for Proxmox. ###
|
||||
echo "Building a Ubuntu Server 24.04 LTS Template for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
packer init "$INPUT_PATH"
|
||||
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
menu_option_13() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/22-04-lts/
|
||||
echo -e "\nCONFIRM: Build a Ubuntu Server 22.04 LTS Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Ubuntu Server 22.04 LTS Template for Proxmox. ###
|
||||
echo "Building a Ubuntu Server 22.04 LTS Template for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
packer init "$INPUT_PATH"
|
||||
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
menu_option_14() {
|
||||
INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/20-04-lts/
|
||||
echo -e "\nCONFIRM: Build a Ubuntu Server 20.04 LTS Template for Proxmox?"
|
||||
echo -e "\nContinue? (y/n)"
|
||||
read -r REPLY
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Build a Ubuntu Server 20.04 LTS Template for Proxmox. ###
|
||||
echo "Building a Ubuntu Server 20.04 LTS Template for Proxmox..."
|
||||
|
||||
### Initialize HashiCorp Packer and required plugins. ###
|
||||
echo "Initializing HashiCorp Packer and required plugins..."
|
||||
packer init "$INPUT_PATH"
|
||||
|
||||
### Start the Build. ###
|
||||
echo "Starting the build...."
|
||||
packer build -force \
|
||||
-var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/build.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/common.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/linux-storage.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/network.pkrvars.hcl" \
|
||||
-var-file="$CONFIG_PATH/proxmox.pkrvars.hcl" \
|
||||
"$INPUT_PATH"
|
||||
|
||||
### All done. ###
|
||||
@@ -320,15 +487,20 @@ until [ "$selection" = "0" ]; do
|
||||
echo ""
|
||||
echo " Linux Distribution:"
|
||||
echo ""
|
||||
echo " 1 - CentOS 8 Stream"
|
||||
echo " 2 - CentOS 9 Stream"
|
||||
echo " 3 - Debian 11 (Bullseye)"
|
||||
echo " 4 - Debian 12 (Bookworm)"
|
||||
echo " 5 - Ubuntu Server 20.04 LTS"
|
||||
echo " 6 - Ubuntu Server 20.04 LTS (cloud-init)"
|
||||
echo " 7 - Ubuntu Server 22.04 LTS"
|
||||
echo " 8 - Ubuntu Server 22.04 LTS (cloud-init)"
|
||||
echo " 9 - OpenSUSE Leap 15.5"
|
||||
echo " 1 - AlmaLinux 9"
|
||||
echo " 2 - AlmaLinux 8"
|
||||
echo " 3 - CentOS 9 Stream"
|
||||
echo " 4 - Debian 12"
|
||||
echo " 5 - Debian 11"
|
||||
echo " 6 - OpenSUSE Leap 15.6"
|
||||
echo " 7 - OpenSUSE Leap 15.5"
|
||||
echo " 8 - Oracle Linux 9"
|
||||
echo " 9 - Oracle Linux 8"
|
||||
echo " 10 - Rocky Linux 9"
|
||||
echo " 11 - Rocky Linux 8"
|
||||
echo " 12 - Ubuntu Server 24.04 LTS"
|
||||
echo " 13 - Ubuntu Server 22.04 LTS"
|
||||
echo " 14 - Ubuntu Server 20.04 LTS"
|
||||
echo ""
|
||||
echo " Other:"
|
||||
echo ""
|
||||
@@ -347,6 +519,11 @@ until [ "$selection" = "0" ]; do
|
||||
7 ) clear ; menu_option_7 ; press_enter ;;
|
||||
8 ) clear ; menu_option_8 ; press_enter ;;
|
||||
9 ) clear ; menu_option_9 ; press_enter ;;
|
||||
10) clear ; menu_option_10 ; press_enter ;;
|
||||
11) clear ; menu_option_11 ; press_enter ;;
|
||||
12) clear ; menu_option_12 ; press_enter ;;
|
||||
13) clear ; menu_option_13 ; press_enter ;;
|
||||
14) clear ; menu_option_14 ; press_enter ;;
|
||||
[Ii] ) clear ; info ; press_enter ;;
|
||||
[Qq] ) clear ; exit ;;
|
||||
* ) clear ; incorrect_selection ; press_enter ;;
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
// Removable Media Settings
|
||||
common_iso_storage = "OS"
|
||||
|
||||
// Where to store the completed VM templates
|
||||
vm_storage_pool = "pool0"
|
||||
|
||||
// Boot and Provisioning Settings
|
||||
common_data_source = "http"
|
||||
common_http_ip = null
|
||||
|
||||
@@ -2,9 +2,43 @@
|
||||
DESCRIPTION:
|
||||
Storage variables used for Linux builds.
|
||||
- Variables are passed to and used by guest operating system configuration files (e.g., ks.cfg).
|
||||
- Only 1 group can be active (i.e. uncommented) at a time.
|
||||
- Default partition/volume sizing assumes a single 32GB VM disk.
|
||||
- All disk sizes are in MegaBytes (MB).
|
||||
- Use a size value of -1 to use all remaining space on disk.
|
||||
*/
|
||||
|
||||
vm_efi_storage_pool = "vm-data"
|
||||
/*
|
||||
// This section is an example when you want to build a VM with the BIOS bootloader
|
||||
// using a single partition that consumes the entire VM disk.
|
||||
|
||||
// VM Storage Settings
|
||||
vm_disk_device = "vda"
|
||||
vm_disk_use_swap = true
|
||||
vm_disk_partitions = [
|
||||
{
|
||||
name = "root"
|
||||
size = -1,
|
||||
format = {
|
||||
label = "ROOTFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
]
|
||||
*/
|
||||
|
||||
/*
|
||||
// This section is an example when you want to build a VM with the UEFI bootloader
|
||||
// that has the required partitons for UEFI and then a single root partition that
|
||||
// fills up the rest of the space on the VM disk.
|
||||
|
||||
// VM EFI Settings
|
||||
vm_efi_storage_pool = "pool0"
|
||||
vm_efi_type = "4m"
|
||||
vm_efi_pre_enrolled_keys = false
|
||||
|
||||
@@ -39,7 +73,44 @@ vm_disk_partitions = [
|
||||
volume_group = "",
|
||||
},
|
||||
{
|
||||
name = "vg_root"
|
||||
name = "root"
|
||||
size = -1,
|
||||
format = {
|
||||
label = "ROOTFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
]
|
||||
*/
|
||||
|
||||
/*
|
||||
// This section is an example when you want to build a VM with the BIOS bootloader
|
||||
// using LVM with a volume layout that follows CIS hardening guidelines.
|
||||
|
||||
// VM Storage Settings
|
||||
vm_disk_device = "vda"
|
||||
vm_disk_use_swap = true
|
||||
vm_disk_partitions = [
|
||||
{
|
||||
name = "boot"
|
||||
size = 1024,
|
||||
format = {
|
||||
label = "BOOTFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/boot",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
{
|
||||
name = "sysvg"
|
||||
size = -1,
|
||||
format = {
|
||||
label = "",
|
||||
@@ -49,12 +120,12 @@ vm_disk_partitions = [
|
||||
path = "",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "vg_root",
|
||||
volume_group = "sysvg",
|
||||
},
|
||||
]
|
||||
vm_disk_lvm = [
|
||||
{
|
||||
name: "vg_root",
|
||||
name: "sysvg",
|
||||
partitions: [
|
||||
{
|
||||
name = "lv_swap",
|
||||
@@ -70,7 +141,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_root",
|
||||
size = 3000,
|
||||
size = 10240,
|
||||
format = {
|
||||
label = "ROOTFS",
|
||||
fstype = "ext4",
|
||||
@@ -82,7 +153,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_home",
|
||||
size = 1200,
|
||||
size = 4096,
|
||||
format = {
|
||||
label = "HOMEFS",
|
||||
fstype = "ext4",
|
||||
@@ -106,7 +177,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_tmp",
|
||||
size = 2500,
|
||||
size = 4096,
|
||||
format = {
|
||||
label = "TMPFS",
|
||||
fstype = "ext4",
|
||||
@@ -118,7 +189,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_var",
|
||||
size = 3072,
|
||||
size = 2048,
|
||||
format = {
|
||||
label = "VARFS",
|
||||
fstype = "ext4",
|
||||
@@ -130,7 +201,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_var_tmp",
|
||||
size = 4096,
|
||||
size = 1000,
|
||||
format = {
|
||||
label = "VARTMPFS",
|
||||
fstype = "ext4",
|
||||
@@ -142,7 +213,7 @@ vm_disk_lvm = [
|
||||
},
|
||||
{
|
||||
name = "lv_var_log",
|
||||
size = 1024,
|
||||
size = 4096,
|
||||
format = {
|
||||
label = "VARLOGFS",
|
||||
fstype = "ext4",
|
||||
@@ -167,3 +238,177 @@ vm_disk_lvm = [
|
||||
],
|
||||
}
|
||||
]
|
||||
*/
|
||||
|
||||
/*
|
||||
// This section is an example when you want to build a VM with the EFI firmware
|
||||
// using LVM with a volume layout that follows CIS hardening guidelines.
|
||||
|
||||
// EFI Settings for VM
|
||||
// NOTE: This requires the vm_bios to be set to 'ovmf'!
|
||||
|
||||
//VM EFI Settings
|
||||
vm_efi_storage_pool = "pool0"
|
||||
vm_efi_type = "4m"
|
||||
vm_efi_pre_enrolled_keys = false
|
||||
|
||||
// UEFI VM Storage Settings
|
||||
vm_disk_device = "vda"
|
||||
vm_disk_use_swap = true
|
||||
vm_disk_partitions = [
|
||||
{
|
||||
name = "efi"
|
||||
size = 1024,
|
||||
format = {
|
||||
label = "EFIFS",
|
||||
fstype = "fat32",
|
||||
},
|
||||
mount = {
|
||||
path = "/boot/efi",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
{
|
||||
name = "boot"
|
||||
size = 1024,
|
||||
format = {
|
||||
label = "BOOTFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/boot",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "",
|
||||
},
|
||||
{
|
||||
name = "sysvg"
|
||||
size = -1,
|
||||
format = {
|
||||
label = "",
|
||||
fstype = "",
|
||||
},
|
||||
mount = {
|
||||
path = "",
|
||||
options = "",
|
||||
},
|
||||
volume_group = "sysvg",
|
||||
},
|
||||
]
|
||||
vm_disk_lvm = [
|
||||
{
|
||||
name: "sysvg",
|
||||
partitions: [
|
||||
{
|
||||
name = "lv_swap",
|
||||
size = 1024,
|
||||
format = {
|
||||
label = "SWAPFS",
|
||||
fstype = "swap",
|
||||
},
|
||||
mount = {
|
||||
path = "",
|
||||
options = "",
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "lv_root",
|
||||
size = 10240,
|
||||
format = {
|
||||
label = "ROOTFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/",
|
||||
options = "",
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "lv_home",
|
||||
size = 4096,
|
||||
format = {
|
||||
label = "HOMEFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/home",
|
||||
options = "nodev,nosuid",
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "lv_opt",
|
||||
size = 2048,
|
||||
format = {
|
||||
label = "OPTFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/opt",
|
||||
options = "nodev",
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "lv_tmp",
|
||||
size = 4096,
|
||||
format = {
|
||||
label = "TMPFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/tmp",
|
||||
options = "nodev,noexec,nosuid",
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "lv_var",
|
||||
size = 2048,
|
||||
format = {
|
||||
label = "VARFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/var",
|
||||
options = "nodev",
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "lv_var_tmp",
|
||||
size = 1000,
|
||||
format = {
|
||||
label = "VARTMPFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/var/tmp",
|
||||
options = "nodev,noexec,nosuid",
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "lv_var_log",
|
||||
size = 4096,
|
||||
format = {
|
||||
label = "VARLOGFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/var/log",
|
||||
options = "nodev,noexec,nosuid",
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "lv_var_audit",
|
||||
size = 500,
|
||||
format = {
|
||||
label = "AUDITFS",
|
||||
fstype = "ext4",
|
||||
},
|
||||
mount = {
|
||||
path = "/var/log/audit",
|
||||
options = "nodev,noexec,nosuid",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
]
|
||||
*/
|
||||
@@ -3,7 +3,7 @@
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# CentOS Stream 8
|
||||
# AlmaLinux 8
|
||||
|
||||
### Installs from the first attached CD-ROM/DVD on the system.
|
||||
cdrom
|
||||
@@ -26,9 +26,7 @@ keyboard ${vm_os_keyboard}
|
||||
### --device device to be activated and / or configured with the network command
|
||||
### --bootproto method to obtain networking configuration for device (default dhcp)
|
||||
### --noipv6 disable IPv6 on this device
|
||||
###
|
||||
### network --bootproto=static --ip=172.16.11.200 --netmask=255.255.255.0 --gateway=172.16.11.200 --nameserver=172.16.11.4 --hostname centos-linux-8
|
||||
network --bootproto=dhcp
|
||||
${network}
|
||||
|
||||
### Lock the root account.
|
||||
rootpw --lock
|
||||
@@ -43,7 +41,7 @@ user --name=${build_username} --iscrypted --password=${build_password_encrypted}
|
||||
firewall --enabled --ssh
|
||||
|
||||
### Sets up the authentication options for the system.
|
||||
### The SSDD profile sets sha512 to hash passwords. Passwords are shadowed by default
|
||||
### The SSSD profile sets sha512 to hash passwords. Passwords are shadowed by default
|
||||
### See the manual page for authselect-profile for a complete list of possible options.
|
||||
authselect select sssd
|
||||
|
||||
@@ -75,6 +73,9 @@ dnf makecache
|
||||
dnf install epel-release -y
|
||||
dnf makecache
|
||||
dnf install -y sudo qemu-guest-tools
|
||||
%{ if additional_packages != "" ~}
|
||||
dnf install -y ${additional_packages}
|
||||
%{ endif ~}
|
||||
echo "${build_username} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/${build_username}
|
||||
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
|
||||
%end
|
||||
5
builds/linux/almalinux/8/data/network.pkrtpl.hcl
Normal file
5
builds/linux/almalinux/8/data/network.pkrtpl.hcl
Normal file
@@ -0,0 +1,5 @@
|
||||
%{ if ip != null ~}
|
||||
network --device=${device} --bootproto=static --ip=${ip} --netmask=${cidrnetmask("${ip}/${netmask}")} --gateway=${gateway} --nameserver=${join(",", dns)}
|
||||
%{ else ~}
|
||||
network --device=${device} --bootproto=dhcp
|
||||
%{ endif ~}
|
||||
76
builds/linux/almalinux/8/data/storage.pkrtpl.hcl
Normal file
76
builds/linux/almalinux/8/data/storage.pkrtpl.hcl
Normal file
@@ -0,0 +1,76 @@
|
||||
### Sets how the boot loader should be installed.
|
||||
bootloader --location=mbr
|
||||
|
||||
### Initialize any invalid partition tables found on disks.
|
||||
zerombr
|
||||
|
||||
### Removes partitions from the system, prior to creation of new partitions.
|
||||
### By default, no partitions are removed.
|
||||
### --all Erases all partitions from the system
|
||||
### --initlabel Initializes a disk (or disks) by creating a default disk label for all disks in their respective architecture.
|
||||
clearpart --all --initlabel
|
||||
|
||||
### Modify partition sizes for the virtual machine hardware.
|
||||
### Create primary system partitions.
|
||||
%{ for partition in partitions ~}
|
||||
part
|
||||
%{~ if partition.volume_group != "" ~}
|
||||
pv.${partition.volume_group}
|
||||
%{~ else ~}
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.format.fstype != "" ~}
|
||||
--label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
|
||||
%{ endfor ~}
|
||||
%{ if vm_bios == "seabios" ~}
|
||||
part biosboot --fstype="biosboot" --ondisk=${device} --size=1
|
||||
%{ endif ~}
|
||||
### Create a logical volume management (LVM) group.
|
||||
%{ for index, volume_group in lvm ~}
|
||||
volgroup sysvg pv.${volume_group.name}
|
||||
|
||||
### Modify logical volume sizes for the virtual machine hardware.
|
||||
### Create logical volumes.
|
||||
%{ for partition in volume_group.partitions ~}
|
||||
logvol
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
--name=${partition.name} --vgname=${volume_group.name} --label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
|
||||
%{ endfor ~}
|
||||
%{ endfor ~}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
CentOS Stream 8 variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
AlmaLinux 8 variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// Guest Operating System Metadata
|
||||
@@ -8,14 +8,15 @@ vm_os_language = "en_US"
|
||||
vm_os_keyboard = "us"
|
||||
vm_os_timezone = "UTC"
|
||||
vm_os_family = "linux"
|
||||
vm_os_name = "centos-stream"
|
||||
vm_os_name = "almalinux"
|
||||
vm_os_version = "8"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
vm_cloudinit = true
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "seabios"
|
||||
vm_bios = "ovmf"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "kvm64"
|
||||
@@ -23,16 +24,13 @@ vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_storage_pool = "vm-data"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
vm_bridge_interface = "vmbr0"
|
||||
vm_vlan_tag = "102"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
iso_file = "CentOS-Stream-8-x86_64-latest-dvd1.iso"
|
||||
iso_checksum = "file:http://centos.mirror.ndchost.com/8-stream/isos/x86_64/CHECKSUM"
|
||||
iso_file = "AlmaLinux-8.10-x86_64-dvd.iso"
|
||||
iso_checksum = "file:https://repo.almalinux.org/almalinux/8.10/isos/x86_64/CHECKSUM"
|
||||
|
||||
// Boot Settings
|
||||
vm_boot = "order=virtio0;ide2;net0"
|
||||
@@ -40,6 +38,3 @@ vm_boot_wait = "10s"
|
||||
|
||||
// EFI Settings
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
vm_efi_storage_pool = "vm-data"
|
||||
vm_efi_pre_enrolled_keys = false
|
||||
vm_efi_type = "4m"
|
||||
227
builds/linux/almalinux/8/linux-almalinux.pkr.hcl
Normal file
227
builds/linux/almalinux/8/linux-almalinux.pkr.hcl
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
AlmaLinux 8 template using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: packer
|
||||
// The Packer configuration.
|
||||
|
||||
packer {
|
||||
required_version = ">= 1.11.0"
|
||||
required_plugins {
|
||||
ansible = {
|
||||
source = "github.com/hashicorp/ansible"
|
||||
version = "~> 1"
|
||||
}
|
||||
git = {
|
||||
version = ">= 0.6.2"
|
||||
source = "github.com/ethanmdavidson/git"
|
||||
}
|
||||
proxmox = {
|
||||
version = ">= 1.1.8"
|
||||
source = "github.com/hashicorp/proxmox"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BLOCK: data
|
||||
// Defines the data sources.
|
||||
|
||||
data "git-repository" "cwd" {}
|
||||
|
||||
// BLOCK: locals
|
||||
// Defines the local variables.
|
||||
|
||||
locals {
|
||||
bios_boot_command = [
|
||||
// This sends the "up arrow" key, typically used to navigate through boot menu options.
|
||||
"<up>",
|
||||
// This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options.
|
||||
"<tab>",
|
||||
"inst.text biosdevname=0 net.ifnames=0 inst.gpt",
|
||||
" ${local.data_source_command}",
|
||||
"<enter><wait>"
|
||||
]
|
||||
uefi_boot_command = [
|
||||
// This sends the "up arrow" key, typically used to navigate through boot menu options.
|
||||
"<up>",
|
||||
// This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option.
|
||||
"e",
|
||||
// This sends two "down arrow" keys, followed by the "end" key, and then waits. This is used to navigate to a specific line in the boot menu option's configuration.
|
||||
"<down><down><end><wait>",
|
||||
// This types the string "text" followed by the value of the 'data_source_command' local variable.
|
||||
// This is used to modify the boot menu option's configuration to boot in text mode and specify the kickstart data source configured in the common variables.
|
||||
"text ${local.data_source_command}",
|
||||
// This sends the "enter" key, waits, turns on the left control key, sends the "x" key, and then turns off the left control key. This is used to save the changes and exit the boot menu option's configuration, and then continue the boot process.
|
||||
"<enter><wait><leftCtrlOn>x<leftCtrlOff>"
|
||||
]
|
||||
build_by = "Built by: HashiCorp Packer ${packer.version}"
|
||||
build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" )
|
||||
build_version = data.git-repository.cwd.head
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}"
|
||||
vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda"
|
||||
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
|
||||
manifest_path = "${path.cwd}/manifests/"
|
||||
manifest_output = "${local.manifest_path}${local.manifest_date}.json"
|
||||
data_source_content = {
|
||||
"/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", {
|
||||
build_username = var.build_username
|
||||
build_password = var.build_password
|
||||
build_password_encrypted = var.build_password_encrypted
|
||||
vm_disk_type = local.vm_disk_type
|
||||
vm_os_language = var.vm_os_language
|
||||
vm_os_keyboard = var.vm_os_keyboard
|
||||
vm_os_timezone = var.vm_os_timezone
|
||||
|
||||
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
|
||||
device = var.vm_bridge_interface
|
||||
ip = var.vm_ip_address
|
||||
netmask = var.vm_ip_netmask
|
||||
gateway = var.vm_ip_gateway
|
||||
dns = var.vm_dns_list
|
||||
})
|
||||
common_data_source = var.common_data_source
|
||||
# lvm needs to be here so late commands can access vg names
|
||||
#lvm = var.vm_disk_lvm
|
||||
storage = templatefile("${abspath(path.root)}/data/storage.pkrtpl.hcl", {
|
||||
device = var.vm_disk_device
|
||||
swap = var.vm_disk_use_swap
|
||||
partitions = var.vm_disk_partitions
|
||||
lvm = var.vm_disk_lvm
|
||||
vm_bios = var.vm_bios
|
||||
})
|
||||
additional_packages = join(" ", var.additional_packages)
|
||||
})
|
||||
}
|
||||
data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks.cfg" : "inst.ks=/cdrom/ks.cfg"
|
||||
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||
boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command
|
||||
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||
}
|
||||
|
||||
// BLOCK: source
|
||||
// Defines the builder configuration blocks.
|
||||
|
||||
source "proxmox-iso" "linux-almalinux" {
|
||||
|
||||
// Proxmox Connection Settings and Credentials
|
||||
proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json"
|
||||
username = "${var.proxmox_api_token_id}"
|
||||
token = "${var.proxmox_api_token_secret}"
|
||||
insecure_skip_tls_verify = "${var.proxmox_insecure_connection}"
|
||||
|
||||
// Proxmox Settings
|
||||
node = "${var.proxmox_node}"
|
||||
|
||||
// Virtual Machine Settings
|
||||
vm_name = "${local.vm_name}"
|
||||
bios = "${var.vm_bios}"
|
||||
sockets = "${var.vm_cpu_sockets}"
|
||||
cores = "${var.vm_cpu_count}"
|
||||
cpu_type = "${var.vm_cpu_type}"
|
||||
memory = "${var.vm_mem_size}"
|
||||
os = "${var.vm_os_type}"
|
||||
scsi_controller = "${var.vm_disk_controller_type}"
|
||||
disks {
|
||||
disk_size = "${var.vm_disk_size}"
|
||||
type = "${var.vm_disk_type}"
|
||||
storage_pool = "${var.vm_storage_pool}"
|
||||
format = "${var.vm_disk_format}"
|
||||
}
|
||||
dynamic "efi_config" {
|
||||
for_each = var.vm_bios == "ovmf" ? [1] : []
|
||||
content {
|
||||
efi_storage_pool = var.vm_bios == "ovmf" ? var.vm_efi_storage_pool : null
|
||||
efi_type = var.vm_bios == "ovmf" ? var.vm_efi_type : null
|
||||
pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null
|
||||
}
|
||||
}
|
||||
unmount_iso = true
|
||||
ssh_username = "${var.build_username}"
|
||||
ssh_password = "${var.build_password}"
|
||||
ssh_timeout = "${var.timeout}"
|
||||
ssh_port = "22"
|
||||
iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}"
|
||||
iso_checksum = "${var.iso_checksum}"
|
||||
qemu_agent = true
|
||||
|
||||
network_adapters {
|
||||
bridge = "${var.vm_bridge_interface}"
|
||||
model = "${var.vm_network_card_model}"
|
||||
vlan_tag = "${var.vm_vlan_tag}"
|
||||
}
|
||||
|
||||
// Removable Media Settings
|
||||
http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null
|
||||
|
||||
// Boot and Provisioning Settings
|
||||
http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null
|
||||
http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null
|
||||
http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null
|
||||
boot = var.vm_boot
|
||||
boot_wait = var.vm_boot_wait
|
||||
boot_command = local.boot_command
|
||||
|
||||
dynamic "additional_iso_files" {
|
||||
for_each = var.common_data_source == "disk" ? [1] : []
|
||||
content {
|
||||
cd_files = var.common_data_source == "disk" ? local.data_source_content : null
|
||||
cd_label = var.common_data_source == "disk" ? "cidata" : null
|
||||
iso_storage_pool = var.common_data_source == "disk" ? "local" : null
|
||||
}
|
||||
}
|
||||
|
||||
template_name = "${local.vm_name}"
|
||||
template_description = "${local.build_description}"
|
||||
|
||||
# VM Cloud Init Settings
|
||||
cloud_init = var.vm_cloudinit
|
||||
cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null
|
||||
|
||||
}
|
||||
|
||||
# Build Definition to create the VM Template
|
||||
build {
|
||||
sources = ["source.proxmox-iso.linux-almalinux"]
|
||||
|
||||
provisioner "ansible" {
|
||||
user = "${var.build_username}"
|
||||
galaxy_file = "${path.cwd}/ansible/linux-requirements.yml"
|
||||
galaxy_force_with_deps = true
|
||||
playbook_file = "${path.cwd}/ansible/linux-playbook.yml"
|
||||
roles_path = "${path.cwd}/ansible/roles"
|
||||
ansible_env_vars = [
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
|
||||
"ANSIBLE_PYTHON_INTERPRETER=/usr/libexec/platform-python"
|
||||
]
|
||||
extra_arguments = [
|
||||
"--extra-vars", "display_skipped_hosts=false",
|
||||
"--extra-vars", "build_username=${var.build_username}",
|
||||
"--extra-vars", "build_key='${var.build_key}'",
|
||||
"--extra-vars", "ansible_username=${var.ansible_username}",
|
||||
"--extra-vars", "ansible_key='${var.ansible_key}'",
|
||||
"--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'",
|
||||
]
|
||||
}
|
||||
|
||||
post-processor "manifest" {
|
||||
output = local.manifest_output
|
||||
strip_path = true
|
||||
strip_time = true
|
||||
custom_data = {
|
||||
ansible_username = "${var.ansible_username}"
|
||||
build_username = "${var.build_username}"
|
||||
build_date = "${local.build_date}"
|
||||
build_version = "${local.build_version}"
|
||||
common_data_source = "${var.common_data_source}"
|
||||
vm_cpu_sockets = "${var.vm_cpu_sockets}"
|
||||
vm_cpu_count = "${var.vm_cpu_count}"
|
||||
vm_disk_size = "${var.vm_disk_size}"
|
||||
vm_bios = "${var.vm_bios}"
|
||||
vm_os_type = "${var.vm_os_type}"
|
||||
vm_mem_size = "${var.vm_mem_size}"
|
||||
vm_network_card_model = "${var.vm_network_card_model}"
|
||||
vm_cloudinit = "${var.vm_cloudinit}"
|
||||
}
|
||||
}
|
||||
}
|
||||
36
builds/linux/almalinux/8/variables-network.pkr.hcl
Normal file
36
builds/linux/almalinux/8/variables-network.pkr.hcl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
AlmaLinux 8 network variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// VM Network Settings
|
||||
|
||||
variable "vm_network_device" {
|
||||
type = string
|
||||
description = "The network device of the VM."
|
||||
default = "ens192"
|
||||
}
|
||||
|
||||
variable "vm_ip_address" {
|
||||
type = string
|
||||
description = "The IP address of the VM (e.g. 172.16.100.192)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_netmask" {
|
||||
type = number
|
||||
description = "The netmask of the VM (e.g. 24)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_gateway" {
|
||||
type = string
|
||||
description = "The gateway of the VM (e.g. 172.16.100.1)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_dns_list" {
|
||||
type = list(string)
|
||||
description = "The nameservers of the VM."
|
||||
default = []
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
CentOS Stream 8 storage variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
AlmaLinux 8 storage variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// VM Storage Settings
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
CentOS Stream 8 variables using the Packer Builder for Proxmox (proxmox-iso).
|
||||
AlmaLinux 8 variables using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: variable
|
||||
@@ -80,7 +80,7 @@ variable "vm_os_type" {
|
||||
variable "vm_bios" {
|
||||
type = string
|
||||
description = "The firmware type. Allowed values 'ovmf' or 'seabios'"
|
||||
default = "OVMF"
|
||||
default = "ovmf"
|
||||
|
||||
validation {
|
||||
condition = contains(["ovmf", "seabios"], var.vm_bios)
|
||||
@@ -97,16 +97,19 @@ variable "vm_firmware_path" {
|
||||
variable "vm_efi_storage_pool" {
|
||||
type = string
|
||||
description = "Set the UEFI disk storage location. (e.g. 'local-lvm')"
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "vm_efi_type" {
|
||||
type = string
|
||||
description = "Specifies the version of the OVMF firmware to be used. (e.g. '4m')"
|
||||
default = "4m"
|
||||
}
|
||||
|
||||
variable "vm_efi_pre_enrolled_keys" {
|
||||
type = bool
|
||||
description = "Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "vm_cpu_count" {
|
||||
@@ -171,7 +174,7 @@ variable "vm_vlan_tag" {
|
||||
|
||||
// Cloud-Init Settings
|
||||
|
||||
variable "vm_cloud_init_enable" {
|
||||
variable "vm_cloudinit" {
|
||||
type = bool
|
||||
description = "Enable or disable cloud-init drive in Proxmox. (e.g. false)"
|
||||
default = false
|
||||
@@ -295,3 +298,10 @@ variable "common_hcp_packer_registry_enabled" {
|
||||
default = false
|
||||
}
|
||||
|
||||
// Additional Settings
|
||||
|
||||
variable "additional_packages" {
|
||||
type = list(string)
|
||||
description = "Additional packages to install."
|
||||
default = []
|
||||
}
|
||||
85
builds/linux/almalinux/9/data/ks.pkrtpl.hcl
Normal file
85
builds/linux/almalinux/9/data/ks.pkrtpl.hcl
Normal file
@@ -0,0 +1,85 @@
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# AlmaLinux 9
|
||||
|
||||
### Installs from the first attached CD-ROM/DVD on the system.
|
||||
cdrom
|
||||
|
||||
### Performs the kickstart installation in text mode.
|
||||
### By default, kickstart installations are performed in graphical mode.
|
||||
text
|
||||
|
||||
### Accepts the End User License Agreement.
|
||||
eula --agreed
|
||||
|
||||
### Sets the language to use during installation and the default language to use on the installed system.
|
||||
lang ${vm_os_language}
|
||||
|
||||
### Sets the default keyboard type for the system.
|
||||
keyboard ${vm_os_keyboard}
|
||||
|
||||
### Configure network information for target system and activate network devices in the installer environment (optional)
|
||||
### --onboot enable device at a boot time
|
||||
### --device device to be activated and / or configured with the network command
|
||||
### --bootproto method to obtain networking configuration for device (default dhcp)
|
||||
### --noipv6 disable IPv6 on this device
|
||||
${network}
|
||||
|
||||
### Lock the root account.
|
||||
rootpw --lock
|
||||
|
||||
### The selected profile will restrict root login.
|
||||
### Add a user that can login and escalate privileges.
|
||||
user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel
|
||||
|
||||
### Configure firewall settings for the system.
|
||||
### --enabled reject incoming connections that are not in response to outbound requests
|
||||
### --ssh allow sshd service through the firewall
|
||||
firewall --enabled --ssh
|
||||
|
||||
### Sets up the authentication options for the system.
|
||||
### The SSSD profile sets sha512 to hash passwords. Passwords are shadowed by default
|
||||
### See the manual page for authselect-profile for a complete list of possible options.
|
||||
authselect select sssd
|
||||
|
||||
### Sets the state of SELinux on the installed system.
|
||||
### Defaults to enforcing.
|
||||
selinux --enforcing
|
||||
|
||||
### Sets the system time zone.
|
||||
timezone ${vm_os_timezone}
|
||||
|
||||
### Partitioning
|
||||
${storage}
|
||||
|
||||
### Modifies the default set of services that will run under the default runlevel.
|
||||
services --enabled=NetworkManager,sshd
|
||||
|
||||
### Do not configure X on the installed system.
|
||||
skipx
|
||||
|
||||
### Packages selection.
|
||||
%packages --ignoremissing --excludedocs
|
||||
@core
|
||||
-iwl*firmware
|
||||
%end
|
||||
|
||||
### Post-installation commands.
|
||||
%post
|
||||
dnf makecache
|
||||
dnf install epel-release -y
|
||||
dnf makecache
|
||||
dnf install -y sudo qemu-guest-tools
|
||||
%{ if additional_packages != "" ~}
|
||||
dnf install -y ${additional_packages}
|
||||
%{ endif ~}
|
||||
echo "${build_username} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/${build_username}
|
||||
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
|
||||
%end
|
||||
|
||||
### Reboot after the installation is complete.
|
||||
### --eject attempt to eject the media before rebooting.
|
||||
reboot --eject
|
||||
5
builds/linux/almalinux/9/data/network.pkrtpl.hcl
Normal file
5
builds/linux/almalinux/9/data/network.pkrtpl.hcl
Normal file
@@ -0,0 +1,5 @@
|
||||
%{ if ip != null ~}
|
||||
network --device=${device} --bootproto=static --ip=${ip} --netmask=${cidrnetmask("${ip}/${netmask}")} --gateway=${gateway} --nameserver=${join(",", dns)}
|
||||
%{ else ~}
|
||||
network --device=${device} --bootproto=dhcp
|
||||
%{ endif ~}
|
||||
76
builds/linux/almalinux/9/data/storage.pkrtpl.hcl
Normal file
76
builds/linux/almalinux/9/data/storage.pkrtpl.hcl
Normal file
@@ -0,0 +1,76 @@
|
||||
### Sets how the boot loader should be installed.
|
||||
bootloader --location=mbr
|
||||
|
||||
### Initialize any invalid partition tables found on disks.
|
||||
zerombr
|
||||
|
||||
### Removes partitions from the system, prior to creation of new partitions.
|
||||
### By default, no partitions are removed.
|
||||
### --all Erases all partitions from the system
|
||||
### --initlabel Initializes a disk (or disks) by creating a default disk label for all disks in their respective architecture.
|
||||
clearpart --all --initlabel
|
||||
|
||||
### Modify partition sizes for the virtual machine hardware.
|
||||
### Create primary system partitions.
|
||||
%{ for partition in partitions ~}
|
||||
part
|
||||
%{~ if partition.volume_group != "" ~}
|
||||
pv.${partition.volume_group}
|
||||
%{~ else ~}
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.format.fstype != "" ~}
|
||||
--label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
|
||||
%{ endfor ~}
|
||||
%{ if vm_bios == "seabios" ~}
|
||||
part biosboot --fstype="biosboot" --ondisk=${device} --size=1
|
||||
%{ endif ~}
|
||||
### Create a logical volume management (LVM) group.
|
||||
%{ for index, volume_group in lvm ~}
|
||||
volgroup sysvg pv.${volume_group.name}
|
||||
|
||||
### Modify logical volume sizes for the virtual machine hardware.
|
||||
### Create logical volumes.
|
||||
%{ for partition in volume_group.partitions ~}
|
||||
logvol
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
--name=${partition.name} --vgname=${volume_group.name} --label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
|
||||
%{ endfor ~}
|
||||
%{ endfor ~}
|
||||
40
builds/linux/almalinux/9/linux-almalinux.auto.pkrvars.hcl
Normal file
40
builds/linux/almalinux/9/linux-almalinux.auto.pkrvars.hcl
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
AlmaLinux 9 variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// Guest Operating System Metadata
|
||||
vm_os_language = "en_US"
|
||||
vm_os_keyboard = "us"
|
||||
vm_os_timezone = "UTC"
|
||||
vm_os_family = "linux"
|
||||
vm_os_name = "almalinux"
|
||||
vm_os_version = "9"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
vm_cloudinit = true
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "ovmf"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "x86-64-v2-AES"
|
||||
vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
iso_file = "AlmaLinux-9.4-x86_64-dvd.iso"
|
||||
iso_checksum = "file:https://repo.almalinux.org/almalinux/9.4/isos/x86_64/CHECKSUM"
|
||||
|
||||
// Boot Settings
|
||||
vm_boot = "order=virtio0;ide2;net0"
|
||||
vm_boot_wait = "10s"
|
||||
|
||||
// EFI Settings
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
227
builds/linux/almalinux/9/linux-almalinux.pkr.hcl
Normal file
227
builds/linux/almalinux/9/linux-almalinux.pkr.hcl
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
AlmaLinux 9 template using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: packer
|
||||
// The Packer configuration.
|
||||
|
||||
packer {
|
||||
required_version = ">= 1.11.0"
|
||||
required_plugins {
|
||||
ansible = {
|
||||
source = "github.com/hashicorp/ansible"
|
||||
version = "~> 1"
|
||||
}
|
||||
git = {
|
||||
version = ">= 0.6.2"
|
||||
source = "github.com/ethanmdavidson/git"
|
||||
}
|
||||
proxmox = {
|
||||
version = ">= 1.1.8"
|
||||
source = "github.com/hashicorp/proxmox"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BLOCK: data
|
||||
// Defines the data sources.
|
||||
|
||||
data "git-repository" "cwd" {}
|
||||
|
||||
// BLOCK: locals
|
||||
// Defines the local variables.
|
||||
|
||||
locals {
|
||||
bios_boot_command = [
|
||||
// This sends the "up arrow" key, typically used to navigate through boot menu options.
|
||||
"<up>",
|
||||
// This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options.
|
||||
"<tab>",
|
||||
"inst.text biosdevname=0 net.ifnames=0 inst.gpt",
|
||||
" ${local.data_source_command}",
|
||||
"<enter><wait>"
|
||||
]
|
||||
uefi_boot_command = [
|
||||
// This sends the "up arrow" key, typically used to navigate through boot menu options.
|
||||
"<up>",
|
||||
// This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option.
|
||||
"e",
|
||||
// This sends two "down arrow" keys, followed by the "end" key, and then waits. This is used to navigate to a specific line in the boot menu option's configuration.
|
||||
"<down><down><end><wait>",
|
||||
// This types the string "text" followed by the value of the 'data_source_command' local variable.
|
||||
// This is used to modify the boot menu option's configuration to boot in text mode and specify the kickstart data source configured in the common variables.
|
||||
"text ${local.data_source_command}",
|
||||
// This sends the "enter" key, waits, turns on the left control key, sends the "x" key, and then turns off the left control key. This is used to save the changes and exit the boot menu option's configuration, and then continue the boot process.
|
||||
"<enter><wait><leftCtrlOn>x<leftCtrlOff>"
|
||||
]
|
||||
build_by = "Built by: HashiCorp Packer ${packer.version}"
|
||||
build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" )
|
||||
build_version = data.git-repository.cwd.head
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}"
|
||||
vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda"
|
||||
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
|
||||
manifest_path = "${path.cwd}/manifests/"
|
||||
manifest_output = "${local.manifest_path}${local.manifest_date}.json"
|
||||
data_source_content = {
|
||||
"/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", {
|
||||
build_username = var.build_username
|
||||
build_password = var.build_password
|
||||
build_password_encrypted = var.build_password_encrypted
|
||||
vm_disk_type = local.vm_disk_type
|
||||
vm_os_language = var.vm_os_language
|
||||
vm_os_keyboard = var.vm_os_keyboard
|
||||
vm_os_timezone = var.vm_os_timezone
|
||||
|
||||
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
|
||||
device = var.vm_bridge_interface
|
||||
ip = var.vm_ip_address
|
||||
netmask = var.vm_ip_netmask
|
||||
gateway = var.vm_ip_gateway
|
||||
dns = var.vm_dns_list
|
||||
})
|
||||
common_data_source = var.common_data_source
|
||||
# lvm needs to be here so late commands can access vg names
|
||||
#lvm = var.vm_disk_lvm
|
||||
storage = templatefile("${abspath(path.root)}/data/storage.pkrtpl.hcl", {
|
||||
device = var.vm_disk_device
|
||||
swap = var.vm_disk_use_swap
|
||||
partitions = var.vm_disk_partitions
|
||||
lvm = var.vm_disk_lvm
|
||||
vm_bios = var.vm_bios
|
||||
})
|
||||
additional_packages = join(" ", var.additional_packages)
|
||||
})
|
||||
}
|
||||
data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks.cfg" : "inst.ks=/cdrom/ks.cfg"
|
||||
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||
boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command
|
||||
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||
}
|
||||
|
||||
// BLOCK: source
|
||||
// Defines the builder configuration blocks.
|
||||
|
||||
source "proxmox-iso" "linux-almalinux" {
|
||||
|
||||
// Proxmox Connection Settings and Credentials
|
||||
proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json"
|
||||
username = "${var.proxmox_api_token_id}"
|
||||
token = "${var.proxmox_api_token_secret}"
|
||||
insecure_skip_tls_verify = "${var.proxmox_insecure_connection}"
|
||||
|
||||
// Proxmox Settings
|
||||
node = "${var.proxmox_node}"
|
||||
|
||||
// Virtual Machine Settings
|
||||
vm_name = "${local.vm_name}"
|
||||
bios = "${var.vm_bios}"
|
||||
sockets = "${var.vm_cpu_sockets}"
|
||||
cores = "${var.vm_cpu_count}"
|
||||
cpu_type = "${var.vm_cpu_type}"
|
||||
memory = "${var.vm_mem_size}"
|
||||
os = "${var.vm_os_type}"
|
||||
scsi_controller = "${var.vm_disk_controller_type}"
|
||||
disks {
|
||||
disk_size = "${var.vm_disk_size}"
|
||||
type = "${var.vm_disk_type}"
|
||||
storage_pool = "${var.vm_storage_pool}"
|
||||
format = "${var.vm_disk_format}"
|
||||
}
|
||||
dynamic "efi_config" {
|
||||
for_each = var.vm_bios == "ovmf" ? [1] : []
|
||||
content {
|
||||
efi_storage_pool = var.vm_bios == "ovmf" ? var.vm_efi_storage_pool : null
|
||||
efi_type = var.vm_bios == "ovmf" ? var.vm_efi_type : null
|
||||
pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null
|
||||
}
|
||||
}
|
||||
unmount_iso = true
|
||||
ssh_username = "${var.build_username}"
|
||||
ssh_password = "${var.build_password}"
|
||||
ssh_timeout = "${var.timeout}"
|
||||
ssh_port = "22"
|
||||
iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}"
|
||||
iso_checksum = "${var.iso_checksum}"
|
||||
qemu_agent = true
|
||||
|
||||
network_adapters {
|
||||
bridge = "${var.vm_bridge_interface}"
|
||||
model = "${var.vm_network_card_model}"
|
||||
vlan_tag = "${var.vm_vlan_tag}"
|
||||
}
|
||||
|
||||
// Removable Media Settings
|
||||
http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null
|
||||
|
||||
// Boot and Provisioning Settings
|
||||
http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null
|
||||
http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null
|
||||
http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null
|
||||
boot = var.vm_boot
|
||||
boot_wait = var.vm_boot_wait
|
||||
boot_command = local.boot_command
|
||||
|
||||
dynamic "additional_iso_files" {
|
||||
for_each = var.common_data_source == "disk" ? [1] : []
|
||||
content {
|
||||
cd_files = var.common_data_source == "disk" ? local.data_source_content : null
|
||||
cd_label = var.common_data_source == "disk" ? "cidata" : null
|
||||
iso_storage_pool = var.common_data_source == "disk" ? "local" : null
|
||||
}
|
||||
}
|
||||
|
||||
template_name = "${local.vm_name}"
|
||||
template_description = "${local.build_description}"
|
||||
|
||||
# VM Cloud Init Settings
|
||||
cloud_init = var.vm_cloudinit
|
||||
cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null
|
||||
|
||||
}
|
||||
|
||||
# Build Definition to create the VM Template
|
||||
build {
|
||||
sources = ["source.proxmox-iso.linux-almalinux"]
|
||||
|
||||
provisioner "ansible" {
|
||||
user = "${var.build_username}"
|
||||
galaxy_file = "${path.cwd}/ansible/linux-requirements.yml"
|
||||
galaxy_force_with_deps = true
|
||||
playbook_file = "${path.cwd}/ansible/linux-playbook.yml"
|
||||
roles_path = "${path.cwd}/ansible/roles"
|
||||
ansible_env_vars = [
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
|
||||
"ANSIBLE_PYTHON_INTERPRETER=/usr/libexec/platform-python"
|
||||
]
|
||||
extra_arguments = [
|
||||
"--extra-vars", "display_skipped_hosts=false",
|
||||
"--extra-vars", "build_username=${var.build_username}",
|
||||
"--extra-vars", "build_key='${var.build_key}'",
|
||||
"--extra-vars", "ansible_username=${var.ansible_username}",
|
||||
"--extra-vars", "ansible_key='${var.ansible_key}'",
|
||||
"--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'",
|
||||
]
|
||||
}
|
||||
|
||||
post-processor "manifest" {
|
||||
output = local.manifest_output
|
||||
strip_path = true
|
||||
strip_time = true
|
||||
custom_data = {
|
||||
ansible_username = "${var.ansible_username}"
|
||||
build_username = "${var.build_username}"
|
||||
build_date = "${local.build_date}"
|
||||
build_version = "${local.build_version}"
|
||||
common_data_source = "${var.common_data_source}"
|
||||
vm_cpu_sockets = "${var.vm_cpu_sockets}"
|
||||
vm_cpu_count = "${var.vm_cpu_count}"
|
||||
vm_disk_size = "${var.vm_disk_size}"
|
||||
vm_bios = "${var.vm_bios}"
|
||||
vm_os_type = "${var.vm_os_type}"
|
||||
vm_mem_size = "${var.vm_mem_size}"
|
||||
vm_network_card_model = "${var.vm_network_card_model}"
|
||||
vm_cloudinit = "${var.vm_cloudinit}"
|
||||
}
|
||||
}
|
||||
}
|
||||
36
builds/linux/almalinux/9/variables-network.pkr.hcl
Normal file
36
builds/linux/almalinux/9/variables-network.pkr.hcl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
AlmaLinux 9 network variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// VM Network Settings
|
||||
|
||||
variable "vm_network_device" {
|
||||
type = string
|
||||
description = "The network device of the VM."
|
||||
default = "ens192"
|
||||
}
|
||||
|
||||
variable "vm_ip_address" {
|
||||
type = string
|
||||
description = "The IP address of the VM (e.g. 172.16.100.192)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_netmask" {
|
||||
type = number
|
||||
description = "The netmask of the VM (e.g. 24)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_gateway" {
|
||||
type = string
|
||||
description = "The gateway of the VM (e.g. 172.16.100.1)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_dns_list" {
|
||||
type = list(string)
|
||||
description = "The nameservers of the VM."
|
||||
default = []
|
||||
}
|
||||
53
builds/linux/almalinux/9/variables-storage.pkr.hcl
Normal file
53
builds/linux/almalinux/9/variables-storage.pkr.hcl
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
AlmaLinux 9 storage variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// VM Storage Settings
|
||||
|
||||
variable "vm_disk_device" {
|
||||
type = string
|
||||
description = "The device for the virtual disk. (e.g. 'sda')"
|
||||
}
|
||||
|
||||
variable "vm_disk_use_swap" {
|
||||
type = bool
|
||||
description = "Whether to use a swap partition."
|
||||
}
|
||||
|
||||
variable "vm_disk_partitions" {
|
||||
type = list(object({
|
||||
name = string
|
||||
size = number
|
||||
format = object({
|
||||
label = string
|
||||
fstype = string
|
||||
})
|
||||
mount = object({
|
||||
path = string
|
||||
options = string
|
||||
})
|
||||
volume_group = string
|
||||
}))
|
||||
description = "The disk partitions for the virtual disk."
|
||||
}
|
||||
|
||||
variable "vm_disk_lvm" {
|
||||
type = list(object({
|
||||
name = string
|
||||
partitions = list(object({
|
||||
name = string
|
||||
size = number
|
||||
format = object({
|
||||
label = string
|
||||
fstype = string
|
||||
})
|
||||
mount = object({
|
||||
path = string
|
||||
options = string
|
||||
})
|
||||
}))
|
||||
}))
|
||||
description = "The LVM configuration for the virtual disk."
|
||||
default = []
|
||||
}
|
||||
307
builds/linux/almalinux/9/variables.pkr.hcl
Normal file
307
builds/linux/almalinux/9/variables.pkr.hcl
Normal file
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
AlmaLinux 9 variables using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: variable
|
||||
// Defines the input variables.
|
||||
|
||||
// Proxmox Credentials
|
||||
|
||||
variable "proxmox_hostname" {
|
||||
type = string
|
||||
description = "The FQDN or IP address of a Proxmox node. Only one node should be specified in a cluster."
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_id" {
|
||||
type = string
|
||||
description = "The token to login to the Proxmox node/cluster. The format is USER@REALM!TOKENID. (e.g. packer@pam!packer_pve_token)"
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_secret" {
|
||||
type = string
|
||||
description = "The secret for the API token used to login to the Proxmox API."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "proxmox_insecure_connection" {
|
||||
description = "true/false to skip Proxmox TLS certificate checks."
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
// Proxmox Settings
|
||||
|
||||
variable "proxmox_node" {
|
||||
type = string
|
||||
description = "The name of the Proxmox node that Packer will build templates on."
|
||||
}
|
||||
|
||||
// Virtual Machine Settings
|
||||
|
||||
variable "vm_os_language" {
|
||||
type = string
|
||||
description = "The guest operating system language."
|
||||
default = "en_US"
|
||||
}
|
||||
|
||||
variable "vm_os_keyboard" {
|
||||
type = string
|
||||
description = "The guest operating system keyboard layout."
|
||||
default = "us"
|
||||
}
|
||||
|
||||
variable "vm_os_timezone" {
|
||||
type = string
|
||||
description = "The guest operating system timezone."
|
||||
default = "UTC"
|
||||
}
|
||||
|
||||
variable "vm_os_family" {
|
||||
type = string
|
||||
description = "The guest operating system family. Used for naming. (e.g. 'linux')"
|
||||
}
|
||||
|
||||
variable "vm_os_name" {
|
||||
type = string
|
||||
description = "The guest operating system name. Used for naming. (e.g. 'ubuntu')"
|
||||
}
|
||||
|
||||
variable "vm_os_version" {
|
||||
type = string
|
||||
description = "The guest operating system version. Used for naming. (e.g. '22-04-lts')"
|
||||
}
|
||||
|
||||
variable "vm_os_type" {
|
||||
type = string
|
||||
description = "The guest operating system type. (e.g. 'l26')"
|
||||
}
|
||||
|
||||
variable "vm_bios" {
|
||||
type = string
|
||||
description = "The firmware type. Allowed values 'ovmf' or 'seabios'"
|
||||
default = "ovmf"
|
||||
|
||||
validation {
|
||||
condition = contains(["ovmf", "seabios"], var.vm_bios)
|
||||
error_message = "The vm_bios value must be 'ovmf' or 'seabios'."
|
||||
}
|
||||
}
|
||||
|
||||
variable "vm_firmware_path" {
|
||||
type = string
|
||||
description = "The firmware file to be used. Needed for EFI"
|
||||
default = "/usr/share/ovmf/OVMF.fd"
|
||||
}
|
||||
|
||||
variable "vm_efi_storage_pool" {
|
||||
type = string
|
||||
description = "Set the UEFI disk storage location. (e.g. 'local-lvm')"
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "vm_efi_type" {
|
||||
type = string
|
||||
description = "Specifies the version of the OVMF firmware to be used. (e.g. '4m')"
|
||||
default = "4m"
|
||||
}
|
||||
|
||||
variable "vm_efi_pre_enrolled_keys" {
|
||||
type = bool
|
||||
description = "Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "vm_cpu_count" {
|
||||
type = number
|
||||
description = "The number of virtual CPUs. (e.g. '2')"
|
||||
}
|
||||
|
||||
variable "vm_cpu_sockets" {
|
||||
type = number
|
||||
description = "The number of virtual CPU sockets. (e.g. '1')"
|
||||
}
|
||||
|
||||
variable "vm_cpu_type" {
|
||||
type = string
|
||||
description = "The CPU type to emulate. See the Proxmox API documentation for the complete list of accepted values. For best performance, set this to host. Defaults to kvm64."
|
||||
}
|
||||
|
||||
variable "vm_mem_size" {
|
||||
type = number
|
||||
description = "The size for the virtual memory in MB. (e.g. '2048')"
|
||||
}
|
||||
|
||||
variable "vm_disk_controller_type" {
|
||||
type = string
|
||||
description = "The SCSI controller model to emulate. (e.g. 'virtio-scsi-pci')"
|
||||
}
|
||||
|
||||
variable "vm_disk_type" {
|
||||
type = string
|
||||
description = "The type of disk to emulate. (e.g. 'virtio')"
|
||||
}
|
||||
|
||||
variable "vm_storage_pool" {
|
||||
type = string
|
||||
description = "The name of the Proxmox storage pool to store the VM template. (e.g. 'local-lvm')"
|
||||
}
|
||||
|
||||
variable "vm_disk_size" {
|
||||
type = string
|
||||
description = "The size for the virtual disk in GB. (e.g. '32G')"
|
||||
}
|
||||
|
||||
variable "vm_disk_format" {
|
||||
type = string
|
||||
description = "The format of the file backing the disk. (e.g. 'qcow2')"
|
||||
}
|
||||
|
||||
variable "vm_network_card_model" {
|
||||
type = string
|
||||
description = "The model of the virtual network adapter to emulate. (e.g. 'virtio')"
|
||||
}
|
||||
|
||||
variable "vm_bridge_interface" {
|
||||
type = string
|
||||
description = "The name of the Proxmox bridge to attach the adapter to."
|
||||
}
|
||||
|
||||
variable "vm_vlan_tag" {
|
||||
type = string
|
||||
description = "If the adapter should tag packets, give the VLAN ID. (e.g. '102')"
|
||||
}
|
||||
|
||||
// Cloud-Init Settings
|
||||
|
||||
variable "vm_cloudinit" {
|
||||
type = bool
|
||||
description = "Enable or disable cloud-init drive in Proxmox. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
// Removable Media Settings
|
||||
|
||||
variable "common_iso_storage" {
|
||||
type = string
|
||||
description = "The name of the source Proxmox storage location for ISO images. (e.g. 'local-lvm')"
|
||||
}
|
||||
|
||||
variable "iso_path" {
|
||||
type = string
|
||||
description = "The path on the source Proxmox storage location for ISO images. (e.g. 'iso')"
|
||||
}
|
||||
|
||||
variable "iso_file" {
|
||||
type = string
|
||||
description = "The file name of the ISO image used by the vendor. (e.g. 'ubuntu-<version>-live-server-amd64.iso')"
|
||||
}
|
||||
|
||||
variable "iso_checksum" {
|
||||
type = string
|
||||
description = "The checksum value of the ISO image provided by the vendor."
|
||||
}
|
||||
|
||||
// Boot Settings
|
||||
|
||||
variable "common_data_source" {
|
||||
type = string
|
||||
description = "The provisioning data source. (e.g. 'http' or 'disk')"
|
||||
}
|
||||
|
||||
variable "common_http_bind_address" {
|
||||
type = string
|
||||
description = "Define an IP address on the host to use for the HTTP server."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "common_http_port_min" {
|
||||
type = number
|
||||
description = "The start of the HTTP port range."
|
||||
}
|
||||
|
||||
variable "common_http_port_max" {
|
||||
type = number
|
||||
description = "The end of the HTTP port range."
|
||||
}
|
||||
|
||||
variable "vm_boot" {
|
||||
type = string
|
||||
description = "The boot order for virtual machine devices. (e.g. 'order=virtio0;ide2;net0')"
|
||||
}
|
||||
|
||||
variable "vm_boot_wait" {
|
||||
type = string
|
||||
description = "The time to wait after booting the initial VM before typing the boot_command (e.g '10s')"
|
||||
}
|
||||
|
||||
variable "common_ip_wait_timeout" {
|
||||
type = string
|
||||
description = "Time to wait for guest operating system IP address response."
|
||||
}
|
||||
|
||||
variable "common_shutdown_timeout" {
|
||||
type = string
|
||||
description = "Time to wait for guest operating system shutdown."
|
||||
}
|
||||
|
||||
// Communicator Settings and Credentials
|
||||
|
||||
variable "build_username" {
|
||||
type = string
|
||||
description = "The username to login to the guest operating system. (e.g. 'ubuntu')"
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_password" {
|
||||
type = string
|
||||
description = "The password to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_password_encrypted" {
|
||||
type = string
|
||||
description = "The encrypted password to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_key" {
|
||||
type = string
|
||||
description = "The SSH public key to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "timeout" {
|
||||
description = "not sure why I need so high a timeout but here we are"
|
||||
default = "90m"
|
||||
}
|
||||
|
||||
// Ansible Credentials
|
||||
|
||||
variable "ansible_username" {
|
||||
type = string
|
||||
description = "The username for Ansible to login to the guest operating system. (e.g. 'ansible')"
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "ansible_key" {
|
||||
type = string
|
||||
description = "The public key for Ansible to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
// HCP Packer Settings
|
||||
|
||||
variable "common_hcp_packer_registry_enabled" {
|
||||
type = bool
|
||||
description = "Enable the HCP Packer registry."
|
||||
default = false
|
||||
}
|
||||
|
||||
// Additional Settings
|
||||
|
||||
variable "additional_packages" {
|
||||
type = list(string)
|
||||
description = "Additional packages to install."
|
||||
default = []
|
||||
}
|
||||
@@ -26,9 +26,7 @@ keyboard ${vm_os_keyboard}
|
||||
### --device device to be activated and / or configured with the network command
|
||||
### --bootproto method to obtain networking configuration for device (default dhcp)
|
||||
### --noipv6 disable IPv6 on this device
|
||||
###
|
||||
### network --bootproto=static --ip=172.16.11.200 --netmask=255.255.255.0 --gateway=172.16.11.200 --nameserver=172.16.11.4 --hostname centos-linux-8
|
||||
network --bootproto=dhcp
|
||||
${network}
|
||||
|
||||
### Lock the root account.
|
||||
rootpw --lock
|
||||
|
||||
5
builds/linux/centos/9-stream/data/network.pkrtpl.hcl
Normal file
5
builds/linux/centos/9-stream/data/network.pkrtpl.hcl
Normal file
@@ -0,0 +1,5 @@
|
||||
%{ if ip != null ~}
|
||||
network --device=${device} --bootproto=static --ip=${ip} --netmask=${cidrnetmask("${ip}/${netmask}")} --gateway=${gateway} --nameserver=${join(",", dns)}
|
||||
%{ else ~}
|
||||
network --device=${device} --bootproto=dhcp
|
||||
%{ endif ~}
|
||||
@@ -12,55 +12,62 @@ clearpart --all --initlabel
|
||||
|
||||
### Modify partition sizes for the virtual machine hardware.
|
||||
### Create primary system partitions.
|
||||
%{ if length(partitions) == 1 && partitions[0].name == "autopart" ~}
|
||||
%{ if partitions[0].format.fstype == "lvm" ~}
|
||||
autopart --type=lvm
|
||||
%{ endif }
|
||||
%{ if partitions[0].format.fstype == "simple" ~}
|
||||
autopart --type=plain
|
||||
%{ endif }
|
||||
%{ if partitions[0].format.fstype == "" ~}
|
||||
autopart --type=plain
|
||||
%{ endif }
|
||||
%{ else }
|
||||
%{ for partition in partitions ~}
|
||||
%{ if partition.format.fstype == "swap" ~}
|
||||
part swap --size=${partition.size}
|
||||
|
||||
part
|
||||
%{~ if partition.volume_group != "" ~}
|
||||
pv.${partition.volume_group}
|
||||
%{~ else ~}
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.format.fstype != "" ~}
|
||||
--label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
%{ if partition.mount.path == "/boot/efi" ~}
|
||||
part ${partition.mount.path} --fstype vfat --size=${partition.size} --label=${partition.format.label}
|
||||
|
||||
%{ endif ~}
|
||||
%{ if partition.mount.path != "" ~}
|
||||
part ${partition.mount.path} --fstype ${partition.format.fstype} --size=${partition.size} --label=${partition.format.label} %{~ if partition.mount.options != "" ~}--fsoptions="${partition.mount.options}"%{~ endif ~}
|
||||
|
||||
%{ endif ~}
|
||||
%{ if partition.volume_group != "" ~}
|
||||
%{ if partition.size == -1 ~}
|
||||
part pv.${partition.volume_group} --size=100 --grow
|
||||
|
||||
%{ else ~}
|
||||
part pv.${partition.volume_group} --size=${partition.size}
|
||||
|
||||
%{ endif ~}
|
||||
%{ endfor ~}
|
||||
### Create a logical volume management (LVM) group.
|
||||
### Modify logical volume sizes for the virtual machine hardware.
|
||||
%{ for index, volume_group in lvm ~}
|
||||
%{ if partition.volume_group != "" ~}
|
||||
volgroup ${volume_group.name} --pesize=4096 pv.${partition.volume_group}
|
||||
volgroup sysvg pv.${volume_group.name}
|
||||
|
||||
%{ endif ~}
|
||||
### Modify logical volume sizes for the virtual machine hardware.
|
||||
### Create logical volumes.
|
||||
%{ for partition in volume_group.partitions ~}
|
||||
%{ if partition.format.fstype == "swap" ~}
|
||||
logvol swap --fstype ${partition.format.fstype} --name=${partition.name} --vgname=${volume_group.name} --size=${partition.size} --label=${partition.format.label}
|
||||
%{ else ~}
|
||||
logvol ${partition.mount.path} %{ if partition.format.fstype == "fat32" } --fstype vfat %{ else } --fstype ${partition.format.fstype} %{ endif } %{ if partition.size != -1 } --size=${partition.size} %{ else } --size=100 --grow %{ endif } --name=${partition.name} --vgname=${volume_group.name} --label=${partition.format.label} %{ if partition.mount.options != "" ~} --fsoptions="${partition.mount.options}" %{~ endif ~}
|
||||
logvol
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
--name=${partition.name} --vgname=${volume_group.name} --label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
|
||||
%{ endif ~}
|
||||
%{ endfor ~}
|
||||
%{ endfor ~}
|
||||
%{ endif ~}
|
||||
%{ endfor ~}
|
||||
%{ endif }
|
||||
|
||||
@@ -13,9 +13,10 @@ vm_os_version = "9"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
vm_cloudinit = true
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "seabios"
|
||||
vm_bios = "ovmf"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "x86-64-v2-AES"
|
||||
@@ -23,11 +24,8 @@ vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_storage_pool = "vm-data"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
vm_bridge_interface = "vmbr0"
|
||||
vm_vlan_tag = "102"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
@@ -40,6 +38,3 @@ vm_boot_wait = "5s"
|
||||
|
||||
// EFI Settings
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
vm_efi_storage_pool = "vm-data"
|
||||
vm_efi_pre_enrolled_keys = false
|
||||
vm_efi_type = "4m"
|
||||
|
||||
@@ -33,10 +33,32 @@ data "git-repository" "cwd" {}
|
||||
// Defines the local variables.
|
||||
|
||||
locals {
|
||||
|
||||
bios_boot_command = [
|
||||
"<up><wait>",
|
||||
"<tab><wait>",
|
||||
" text ${local.data_source_command}",
|
||||
"<enter><wait>"
|
||||
]
|
||||
|
||||
uefi_boot_command = [
|
||||
// This sends the "up arrow" key, typically used to navigate through boot menu options.
|
||||
"<up>",
|
||||
// This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option.
|
||||
"e",
|
||||
// This sends two "down arrow" keys, followed by the "end" key, and then waits. This is used to navigate to a specific line in the boot menu option's configuration.
|
||||
"<down><down><end><wait>",
|
||||
// This types the string "text" followed by the value of the 'data_source_command' local variable.
|
||||
// This is used to modify the boot menu option's configuration to boot in text mode and specify the kickstart data source configured in the common variables.
|
||||
"text ${local.data_source_command}",
|
||||
// This sends the "enter" key, waits, turns on the left control key, sends the "x" key, and then turns off the left control key. This is used to save the changes and exit the boot menu option's configuration, and then continue the boot process.
|
||||
"<enter><wait><leftCtrlOn>x<leftCtrlOff>"
|
||||
]
|
||||
|
||||
build_by = "Built by: HashiCorp Packer ${packer.version}"
|
||||
build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" )
|
||||
build_version = data.git-repository.cwd.head
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloud_init_enable}"
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}"
|
||||
vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda"
|
||||
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
|
||||
manifest_path = "${path.cwd}/manifests/"
|
||||
@@ -50,6 +72,13 @@ locals {
|
||||
vm_os_language = var.vm_os_language
|
||||
vm_os_keyboard = var.vm_os_keyboard
|
||||
vm_os_timezone = var.vm_os_timezone
|
||||
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
|
||||
device = var.vm_bridge_interface
|
||||
ip = var.vm_ip_address
|
||||
netmask = var.vm_ip_netmask
|
||||
gateway = var.vm_ip_gateway
|
||||
dns = var.vm_dns_list
|
||||
})
|
||||
common_data_source = var.common_data_source
|
||||
# lvm needs to be here so late commands can access vg names
|
||||
lvm = var.vm_disk_lvm
|
||||
@@ -60,10 +89,12 @@ locals {
|
||||
lvm = var.vm_disk_lvm
|
||||
vm_bios = var.vm_bios
|
||||
})
|
||||
additional_packages = join(" ", var.additional_packages)
|
||||
})
|
||||
}
|
||||
data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks.cfg" : "inst.ks=/cdrom/ks.cfg"
|
||||
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||
boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command
|
||||
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||
}
|
||||
|
||||
@@ -128,12 +159,7 @@ source "proxmox-iso" "linux-centos-stream" {
|
||||
http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null
|
||||
boot = var.vm_boot
|
||||
boot_wait = var.vm_boot_wait
|
||||
boot_command = [
|
||||
"<up><wait>",
|
||||
"<tab><wait>",
|
||||
" text ${local.data_source_command}",
|
||||
"<enter><wait>"
|
||||
]
|
||||
boot_command = local.boot_command
|
||||
|
||||
dynamic "additional_iso_files" {
|
||||
for_each = var.common_data_source == "disk" ? [1] : []
|
||||
@@ -148,8 +174,8 @@ source "proxmox-iso" "linux-centos-stream" {
|
||||
template_description = "${local.build_description}"
|
||||
|
||||
# VM Cloud Init Settings
|
||||
cloud_init = var.vm_cloud_init_enable
|
||||
cloud_init_storage_pool = var.vm_cloud_init_enable == true ? var.vm_storage_pool : null
|
||||
cloud_init = var.vm_cloudinit
|
||||
cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null
|
||||
|
||||
}
|
||||
|
||||
@@ -159,18 +185,21 @@ build {
|
||||
|
||||
provisioner "ansible" {
|
||||
user = "${var.build_username}"
|
||||
playbook_file = "${path.cwd}/ansible/main.yml"
|
||||
galaxy_file = "${path.cwd}/ansible/linux-requirements.yml"
|
||||
galaxy_force_with_deps = true
|
||||
playbook_file = "${path.cwd}/ansible/linux-playbook.yml"
|
||||
roles_path = "${path.cwd}/ansible/roles"
|
||||
ansible_env_vars = [
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg"
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
|
||||
"ANSIBLE_PYTHON_INTERPRETER=/usr/libexec/platform-python"
|
||||
]
|
||||
extra_arguments = [
|
||||
"--extra-vars", "display_skipped_hosts=false",
|
||||
"--extra-vars", "BUILD_USERNAME=${var.build_username}",
|
||||
"--extra-vars", "BUILD_SECRET='${var.build_key}'",
|
||||
"--extra-vars", "ANSIBLE_USERNAME=${var.ansible_username}",
|
||||
"--extra-vars", "ANSIBLE_SECRET='${var.ansible_key}'",
|
||||
"--extra-vars", "cloud_init='${var.vm_cloud_init_enable}'",
|
||||
"--extra-vars", "build_username=${var.build_username}",
|
||||
"--extra-vars", "build_key='${var.build_key}'",
|
||||
"--extra-vars", "ansible_username=${var.ansible_username}",
|
||||
"--extra-vars", "ansible_key='${var.ansible_key}'",
|
||||
"--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -191,7 +220,7 @@ build {
|
||||
vm_os_type = "${var.vm_os_type}"
|
||||
vm_mem_size = "${var.vm_mem_size}"
|
||||
vm_network_card_model = "${var.vm_network_card_model}"
|
||||
vm_cloud_init_enable = "${var.vm_cloud_init_enable}"
|
||||
vm_cloudinit = "${var.vm_cloudinit}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
36
builds/linux/centos/9-stream/variables-network.pkr.hcl
Normal file
36
builds/linux/centos/9-stream/variables-network.pkr.hcl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
CentOS Stream 9 network variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// VM Network Settings
|
||||
|
||||
variable "vm_network_device" {
|
||||
type = string
|
||||
description = "The network device of the VM."
|
||||
default = "ens192"
|
||||
}
|
||||
|
||||
variable "vm_ip_address" {
|
||||
type = string
|
||||
description = "The IP address of the VM (e.g. 172.16.100.192)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_netmask" {
|
||||
type = number
|
||||
description = "The netmask of the VM (e.g. 24)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_gateway" {
|
||||
type = string
|
||||
description = "The gateway of the VM (e.g. 172.16.100.1)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_dns_list" {
|
||||
type = list(string)
|
||||
description = "The nameservers of the VM."
|
||||
default = []
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
CentOS Stream 9 variables using the Packer Builder for Proxmox (proxmox-iso).
|
||||
CentOS 9 Stream variables using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: variable
|
||||
@@ -80,7 +80,7 @@ variable "vm_os_type" {
|
||||
variable "vm_bios" {
|
||||
type = string
|
||||
description = "The firmware type. Allowed values 'ovmf' or 'seabios'"
|
||||
default = "OVMF"
|
||||
default = "ovmf"
|
||||
|
||||
validation {
|
||||
condition = contains(["ovmf", "seabios"], var.vm_bios)
|
||||
@@ -97,16 +97,19 @@ variable "vm_firmware_path" {
|
||||
variable "vm_efi_storage_pool" {
|
||||
type = string
|
||||
description = "Set the UEFI disk storage location. (e.g. 'local-lvm')"
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "vm_efi_type" {
|
||||
type = string
|
||||
description = "Specifies the version of the OVMF firmware to be used. (e.g. '4m')"
|
||||
default = "4m"
|
||||
}
|
||||
|
||||
variable "vm_efi_pre_enrolled_keys" {
|
||||
type = bool
|
||||
description = "Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "vm_cpu_count" {
|
||||
@@ -171,7 +174,7 @@ variable "vm_vlan_tag" {
|
||||
|
||||
// Cloud-Init Settings
|
||||
|
||||
variable "vm_cloud_init_enable" {
|
||||
variable "vm_cloudinit" {
|
||||
type = bool
|
||||
description = "Enable or disable cloud-init drive in Proxmox. (e.g. false)"
|
||||
default = false
|
||||
@@ -295,3 +298,10 @@ variable "common_hcp_packer_registry_enabled" {
|
||||
default = false
|
||||
}
|
||||
|
||||
// Additional Settings
|
||||
|
||||
variable "additional_packages" {
|
||||
type = list(string)
|
||||
description = "Additional packages to install."
|
||||
default = []
|
||||
}
|
||||
9
builds/linux/debian/11/data/network.pkrtpl.hcl
Normal file
9
builds/linux/debian/11/data/network.pkrtpl.hcl
Normal file
@@ -0,0 +1,9 @@
|
||||
d-i netcfg/choose_interface select ${device}
|
||||
%{ if ip != null ~}
|
||||
d-i netcfg/disable_autoconfig boolean true
|
||||
d-i netcfg/get_ipaddress string ${ip}
|
||||
d-i netcfg/get_netmask string ${cidrnetmask("${ip}/${netmask}")}
|
||||
d-i netcfg/get_gateway string ${gateway}
|
||||
d-i netcfg/get_nameservers string ${join(" ", dns)}
|
||||
d-i netcfg/confirm_static boolean true
|
||||
%{ endif ~}
|
||||
@@ -23,10 +23,7 @@ d-i grub-installer/only_debian boolean true
|
||||
${storage}
|
||||
|
||||
# Network configuration
|
||||
d-i netcfg/choose_interface select auto
|
||||
d-i netcfg/get_hostname string unassigned-hostname
|
||||
d-i netcfg/get_domain string unassigned-domain
|
||||
|
||||
${network}
|
||||
|
||||
### Apt setup
|
||||
# Choose, if you want to scan additional installation media
|
||||
@@ -63,7 +60,7 @@ d-i passwd/user-password-crypted password ${build_password_encrypted}
|
||||
|
||||
# Package Configuration
|
||||
d-i pkgsel/run_tasksel boolean false
|
||||
d-i pkgsel/include string openssh-server qemu-guest-agent python3
|
||||
d-i pkgsel/include string openssh-server qemu-guest-agent python3-apt ${additional_packages}
|
||||
|
||||
# You can choose, if your system will report back on what software you have
|
||||
# installed, and what software you use. The default is not to report back,
|
||||
|
||||
@@ -13,9 +13,10 @@ vm_os_version = "11"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
vm_cloudinit = true
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "seabios"
|
||||
vm_bios = "ovmf"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "kvm64"
|
||||
@@ -23,11 +24,8 @@ vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_storage_pool = "vm-data"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
vm_bridge_interface = "vmbr0"
|
||||
vm_vlan_tag = "102"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
@@ -40,6 +38,3 @@ vm_boot_wait = "5s"
|
||||
|
||||
// EFI Settings
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
vm_efi_storage_pool = "vm-data"
|
||||
vm_efi_pre_enrolled_keys = false
|
||||
vm_efi_type = "4m"
|
||||
|
||||
@@ -33,10 +33,51 @@ data "git-repository" "cwd" {}
|
||||
// Defines the local variables.
|
||||
|
||||
locals {
|
||||
|
||||
bios_boot_command = [
|
||||
"<wait><wait><wait><esc><wait><wait><wait>",
|
||||
"/install.amd/vmlinuz ",
|
||||
"initrd=/install.amd/initrd.gz ",
|
||||
"auto=true ",
|
||||
"${local.data_source_command} ",
|
||||
"netcfg/get_hostname=debian netcfg/get_domain=example.com ",
|
||||
"interface=auto ",
|
||||
"vga=788 noprompt quiet --<enter>"
|
||||
]
|
||||
|
||||
uefi_boot_command = [
|
||||
// This waits for 3 seconds, sends the "c" key, and then waits for another 3 seconds. In the GRUB boot loader, this is used to enter command line mode.
|
||||
"<wait3s>c<wait3s>",
|
||||
// This types a command to load the Linux kernel from the specified path.
|
||||
"linux /install.amd/vmlinuz",
|
||||
// This types a string that sets the auto-install/enable option to true. This is used to automate the installation process.
|
||||
" auto-install/enable=true",
|
||||
// This types a string that sets the debconf/priority option to critical. This is used to minimize the number of questions asked during the installation process.
|
||||
" debconf/priority=critical",
|
||||
// This types the value of the 'data_source_command' local variable. This is used to specify the kickstart data source configured in the common variables.
|
||||
" ${local.data_source_command}",
|
||||
// This types a string that sets the noprompt option and then sends the "enter" key. This is used to prevent the installer from pausing for user input.
|
||||
" noprompt --<enter>",
|
||||
// This types a command to load the initial RAM disk from the specified path and then sends the "enter" key.
|
||||
"initrd /install.amd/initrd.gz<enter>",
|
||||
// This types the "boot" command and then sends the "enter" key. This starts the boot process using the loaded kernel and initial RAM disk.
|
||||
"boot<enter>",
|
||||
// This waits for 30 seconds. This is typically used to give the system time to boot before sending more commands.
|
||||
"<wait30s>",
|
||||
// This sends the "enter" key and then waits. This is typically used to dismiss any prompts or messages that appear during boot.
|
||||
"<enter><wait>",
|
||||
// This sends the "enter" key and then waits. This is typically used to dismiss any prompts or messages that appear during boot.
|
||||
"<enter><wait>",
|
||||
// This types the value of the `mount_cdrom` local variable. This is typically used to mount the installation media.
|
||||
" ${local.mount_cdrom}",
|
||||
// This sends four "down arrow" keys and then the "enter" key. This is typically used to select a specific option in a menu.
|
||||
"<down><down><down><down><enter>"
|
||||
]
|
||||
|
||||
build_by = "Built by: HashiCorp Packer ${packer.version}"
|
||||
build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" )
|
||||
build_version = data.git-repository.cwd.head
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloud_init_enable}"
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}"
|
||||
vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda"
|
||||
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
|
||||
manifest_path = "${path.cwd}/manifests/"
|
||||
@@ -50,6 +91,15 @@ locals {
|
||||
vm_os_language = var.vm_os_language
|
||||
vm_os_keyboard = var.vm_os_keyboard
|
||||
vm_os_timezone = var.vm_os_timezone
|
||||
vm_cloudinit = var.vm_cloudinit
|
||||
common_data_source = var.common_data_source
|
||||
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
|
||||
device = var.vm_network_device
|
||||
ip = var.vm_ip_address
|
||||
netmask = var.vm_ip_netmask
|
||||
gateway = var.vm_ip_gateway
|
||||
dns = var.vm_dns_list
|
||||
})
|
||||
common_data_source = var.common_data_source
|
||||
# lvm needs to be here so late commands can access vg names
|
||||
lvm = var.vm_disk_lvm
|
||||
@@ -60,10 +110,14 @@ locals {
|
||||
lvm = var.vm_disk_lvm
|
||||
vm_bios = var.vm_bios
|
||||
})
|
||||
additional_packages = join(" ", var.additional_packages)
|
||||
})
|
||||
}
|
||||
data_source_command = var.common_data_source == "http" ? "url=http://{{.HTTPIP}}:{{.HTTPPort}}/preseed.cfg" : "file=/media/preseed.cfg"
|
||||
mount_cdrom_command = "<leftAltOn><f2><leftAltOff> <enter><wait> mount /dev/sr1 /media<enter> <leftAltOn><f1><leftAltOff>"
|
||||
mount_cdrom = var.common_data_source == "http" ? " " : local.mount_cdrom_command
|
||||
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||
boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command
|
||||
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||
}
|
||||
|
||||
@@ -128,16 +182,7 @@ source "proxmox-iso" "debian" {
|
||||
http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null
|
||||
boot = var.vm_boot
|
||||
boot_wait = var.vm_boot_wait
|
||||
boot_command = [
|
||||
"<wait><wait><wait><esc><wait><wait><wait>",
|
||||
"/install.amd/vmlinuz ",
|
||||
"initrd=/install.amd/initrd.gz ",
|
||||
"auto=true ",
|
||||
"${local.data_source_command} ",
|
||||
"netcfg/get_hostname=debian netcfg/get_domain=example.com ",
|
||||
"interface=auto ",
|
||||
"vga=788 noprompt quiet --<enter>"
|
||||
]
|
||||
boot_command = local.boot_command
|
||||
|
||||
dynamic "additional_iso_files" {
|
||||
for_each = var.common_data_source == "disk" ? [1] : []
|
||||
@@ -152,8 +197,8 @@ source "proxmox-iso" "debian" {
|
||||
template_description = "${local.build_description}"
|
||||
|
||||
# VM Cloud Init Settings
|
||||
cloud_init = var.vm_cloud_init_enable
|
||||
cloud_init_storage_pool = var.vm_cloud_init_enable == true ? var.vm_storage_pool : null
|
||||
cloud_init = var.vm_cloudinit
|
||||
cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null
|
||||
|
||||
}
|
||||
|
||||
@@ -162,19 +207,22 @@ build {
|
||||
sources = ["source.proxmox-iso.debian"]
|
||||
|
||||
provisioner "ansible" {
|
||||
user = "${var.build_username}"
|
||||
playbook_file = "${path.cwd}/ansible/main.yml"
|
||||
user = var.build_username
|
||||
galaxy_file = "${path.cwd}/ansible/linux-requirements.yml"
|
||||
galaxy_force_with_deps = true
|
||||
playbook_file = "${path.cwd}/ansible/linux-playbook.yml"
|
||||
roles_path = "${path.cwd}/ansible/roles"
|
||||
ansible_env_vars = [
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg"
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
|
||||
"ANSIBLE_PYTHON_INTERPRETER=/usr/bin/python3"
|
||||
]
|
||||
extra_arguments = [
|
||||
"--extra-vars", "display_skipped_hosts=false",
|
||||
"--extra-vars", "BUILD_USERNAME=${var.build_username}",
|
||||
"--extra-vars", "BUILD_SECRET='${var.build_key}'",
|
||||
"--extra-vars", "ANSIBLE_USERNAME=${var.ansible_username}",
|
||||
"--extra-vars", "ANSIBLE_SECRET='${var.ansible_key}'",
|
||||
"--extra-vars", "cloud_init='${var.vm_cloud_init_enable}'",
|
||||
"--extra-vars", "build_username=${var.build_username}",
|
||||
"--extra-vars", "build_key='${var.build_key}'",
|
||||
"--extra-vars", "ansible_username=${var.ansible_username}",
|
||||
"--extra-vars", "ansible_key='${var.ansible_key}'",
|
||||
"--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -195,7 +243,7 @@ build {
|
||||
vm_os_type = "${var.vm_os_type}"
|
||||
vm_mem_size = "${var.vm_mem_size}"
|
||||
vm_network_card_model = "${var.vm_network_card_model}"
|
||||
vm_cloud_init_enable = "${var.vm_cloud_init_enable}"
|
||||
vm_cloudinit = "${var.vm_cloudinit}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
36
builds/linux/debian/11/variables-network.pkr.hcl
Normal file
36
builds/linux/debian/11/variables-network.pkr.hcl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Debian Linux 11 network variables used by the Packer Plugin for VMware vSphere (vsphere-iso).
|
||||
*/
|
||||
|
||||
// VM Network Settings
|
||||
|
||||
variable "vm_network_device" {
|
||||
type = string
|
||||
description = "The network device of the VM."
|
||||
default = "ens192"
|
||||
}
|
||||
|
||||
variable "vm_ip_address" {
|
||||
type = string
|
||||
description = "The IP address of the VM (e.g. 172.16.100.192)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_netmask" {
|
||||
type = number
|
||||
description = "The netmask of the VM (e.g. 24)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_gateway" {
|
||||
type = string
|
||||
description = "The gateway of the VM (e.g. 172.16.100.1)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_dns_list" {
|
||||
type = list(string)
|
||||
description = "The nameservers of the VM."
|
||||
default = []
|
||||
}
|
||||
@@ -80,7 +80,7 @@ variable "vm_os_type" {
|
||||
variable "vm_bios" {
|
||||
type = string
|
||||
description = "The firmware type. Allowed values 'ovmf' or 'seabios'"
|
||||
default = "OVMF"
|
||||
default = "ovmf"
|
||||
|
||||
validation {
|
||||
condition = contains(["ovmf", "seabios"], var.vm_bios)
|
||||
@@ -97,16 +97,19 @@ variable "vm_firmware_path" {
|
||||
variable "vm_efi_storage_pool" {
|
||||
type = string
|
||||
description = "Set the UEFI disk storage location. (e.g. 'local-lvm')"
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "vm_efi_type" {
|
||||
type = string
|
||||
description = "Specifies the version of the OVMF firmware to be used. (e.g. '4m')"
|
||||
default = "4m"
|
||||
}
|
||||
|
||||
variable "vm_efi_pre_enrolled_keys" {
|
||||
type = bool
|
||||
description = "Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "vm_cpu_count" {
|
||||
@@ -171,7 +174,7 @@ variable "vm_vlan_tag" {
|
||||
|
||||
// Cloud-Init Settings
|
||||
|
||||
variable "vm_cloud_init_enable" {
|
||||
variable "vm_cloudinit" {
|
||||
type = bool
|
||||
description = "Enable or disable cloud-init drive in Proxmox. (e.g. false)"
|
||||
default = false
|
||||
@@ -295,3 +298,10 @@ variable "common_hcp_packer_registry_enabled" {
|
||||
default = false
|
||||
}
|
||||
|
||||
// Additional Settings
|
||||
|
||||
variable "additional_packages" {
|
||||
type = list(string)
|
||||
description = "Additional packages to install."
|
||||
default = []
|
||||
}
|
||||
9
builds/linux/debian/12/data/network.pkrtpl.hcl
Normal file
9
builds/linux/debian/12/data/network.pkrtpl.hcl
Normal file
@@ -0,0 +1,9 @@
|
||||
d-i netcfg/choose_interface select ${device}
|
||||
%{ if ip != null ~}
|
||||
d-i netcfg/disable_autoconfig boolean true
|
||||
d-i netcfg/get_ipaddress string ${ip}
|
||||
d-i netcfg/get_netmask string ${cidrnetmask("${ip}/${netmask}")}
|
||||
d-i netcfg/get_gateway string ${gateway}
|
||||
d-i netcfg/get_nameservers string ${join(" ", dns)}
|
||||
d-i netcfg/confirm_static boolean true
|
||||
%{ endif ~}
|
||||
@@ -23,10 +23,7 @@ d-i grub-installer/only_debian boolean true
|
||||
${storage}
|
||||
|
||||
# Network configuration
|
||||
d-i netcfg/choose_interface select auto
|
||||
d-i netcfg/get_hostname string unassigned-hostname
|
||||
d-i netcfg/get_domain string unassigned-domain
|
||||
|
||||
${network}
|
||||
|
||||
### Apt setup
|
||||
# Choose, if you want to scan additional installation media
|
||||
@@ -63,7 +60,7 @@ d-i passwd/user-password-crypted password ${build_password_encrypted}
|
||||
|
||||
# Package Configuration
|
||||
d-i pkgsel/run_tasksel boolean false
|
||||
d-i pkgsel/include string openssh-server qemu-guest-agent python3
|
||||
d-i pkgsel/include string openssh-server qemu-guest-agent python3-apt ${additional_packages}
|
||||
|
||||
# You can choose, if your system will report back on what software you have
|
||||
# installed, and what software you use. The default is not to report back,
|
||||
|
||||
@@ -13,9 +13,10 @@ vm_os_version = "12"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
vm_cloudinit = true
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "seabios"
|
||||
vm_bios = "ovmf"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "kvm64"
|
||||
@@ -23,11 +24,8 @@ vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_storage_pool = "vm-data"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
vm_bridge_interface = "vmbr0"
|
||||
vm_vlan_tag = "102"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
@@ -40,6 +38,3 @@ vm_boot_wait = "5s"
|
||||
|
||||
// EFI Settings
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
vm_efi_storage_pool = "vm-data"
|
||||
vm_efi_pre_enrolled_keys = false
|
||||
vm_efi_type = "4m"
|
||||
|
||||
@@ -33,10 +33,52 @@ data "git-repository" "cwd" {}
|
||||
// Defines the local variables.
|
||||
|
||||
locals {
|
||||
|
||||
bios_boot_command = [
|
||||
"<wait><wait><wait><esc><wait><wait><wait>",
|
||||
"/install.amd/vmlinuz ",
|
||||
"initrd=/install.amd/initrd.gz ",
|
||||
"auto=true ",
|
||||
"${local.data_source_command} ",
|
||||
// "hostname=${var.vm_os_name}-${var.vm_os_version} ",
|
||||
"netcfg/get_hostname=debian netcfg/get_domain=example.com ",
|
||||
"interface=auto ",
|
||||
"vga=788 noprompt quiet --<enter>"
|
||||
]
|
||||
|
||||
uefi_boot_command = [
|
||||
// This waits for 3 seconds, sends the "c" key, and then waits for another 3 seconds. In the GRUB boot loader, this is used to enter command line mode.
|
||||
"<wait3s>c<wait3s>",
|
||||
// This types a command to load the Linux kernel from the specified path.
|
||||
"linux /install.amd/vmlinuz",
|
||||
// This types a string that sets the auto-install/enable option to true. This is used to automate the installation process.
|
||||
" auto-install/enable=true",
|
||||
// This types a string that sets the debconf/priority option to critical. This is used to minimize the number of questions asked during the installation process.
|
||||
" debconf/priority=critical",
|
||||
// This types the value of the 'data_source_command' local variable. This is used to specify the kickstart data source configured in the common variables.
|
||||
" ${local.data_source_command}",
|
||||
// This types a string that sets the noprompt option and then sends the "enter" key. This is used to prevent the installer from pausing for user input.
|
||||
" noprompt --<enter>",
|
||||
// This types a command to load the initial RAM disk from the specified path and then sends the "enter" key.
|
||||
"initrd /install.amd/initrd.gz<enter>",
|
||||
// This types the "boot" command and then sends the "enter" key. This starts the boot process using the loaded kernel and initial RAM disk.
|
||||
"boot<enter>",
|
||||
// This waits for 30 seconds. This is typically used to give the system time to boot before sending more commands.
|
||||
"<wait30s>",
|
||||
// This sends the "enter" key and then waits. This is typically used to dismiss any prompts or messages that appear during boot.
|
||||
"<enter><wait>",
|
||||
// This sends the "enter" key and then waits. This is typically used to dismiss any prompts or messages that appear during boot.
|
||||
"<enter><wait>",
|
||||
// This types the value of the `mount_cdrom` local variable. This is typically used to mount the installation media.
|
||||
" ${local.mount_cdrom}",
|
||||
// This sends four "down arrow" keys and then the "enter" key. This is typically used to select a specific option in a menu.
|
||||
"<down><down><down><down><enter>"
|
||||
]
|
||||
|
||||
build_by = "Built by: HashiCorp Packer ${packer.version}"
|
||||
build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" )
|
||||
build_version = data.git-repository.cwd.head
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloud_init_enable}"
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}"
|
||||
vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda"
|
||||
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
|
||||
manifest_path = "${path.cwd}/manifests/"
|
||||
@@ -51,6 +93,13 @@ locals {
|
||||
vm_os_keyboard = var.vm_os_keyboard
|
||||
vm_os_timezone = var.vm_os_timezone
|
||||
common_data_source = var.common_data_source
|
||||
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
|
||||
device = var.vm_network_device
|
||||
ip = var.vm_ip_address
|
||||
netmask = var.vm_ip_netmask
|
||||
gateway = var.vm_ip_gateway
|
||||
dns = var.vm_dns_list
|
||||
})
|
||||
# lvm needs to be here so late commands can access vg names
|
||||
lvm = var.vm_disk_lvm
|
||||
storage = templatefile("${abspath(path.root)}/data/storage.pkrtpl.hcl", {
|
||||
@@ -60,10 +109,14 @@ locals {
|
||||
lvm = var.vm_disk_lvm
|
||||
vm_bios = var.vm_bios
|
||||
})
|
||||
additional_packages = join(" ", var.additional_packages)
|
||||
})
|
||||
}
|
||||
data_source_command = var.common_data_source == "http" ? "url=http://{{.HTTPIP}}:{{.HTTPPort}}/preseed.cfg" : "file=/media/preseed.cfg"
|
||||
mount_cdrom_command = "<leftAltOn><f2><leftAltOff> <enter><wait> mount /dev/sr1 /media<enter> <leftAltOn><f1><leftAltOff>"
|
||||
mount_cdrom = var.common_data_source == "http" ? " " : local.mount_cdrom_command
|
||||
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||
boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command
|
||||
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||
}
|
||||
|
||||
@@ -128,17 +181,7 @@ source "proxmox-iso" "debian" {
|
||||
http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null
|
||||
boot = var.vm_boot
|
||||
boot_wait = var.vm_boot_wait
|
||||
boot_command = [
|
||||
"<wait><wait><wait><esc><wait><wait><wait>",
|
||||
"/install.amd/vmlinuz ",
|
||||
"initrd=/install.amd/initrd.gz ",
|
||||
"auto=true ",
|
||||
"${local.data_source_command} ",
|
||||
// "hostname=${var.vm_os_name}-${var.vm_os_version} ",
|
||||
"netcfg/get_hostname=debian netcfg/get_domain=example.com ",
|
||||
"interface=auto ",
|
||||
"vga=788 noprompt quiet --<enter>"
|
||||
]
|
||||
boot_command = local.boot_command
|
||||
|
||||
dynamic "additional_iso_files" {
|
||||
for_each = var.common_data_source == "disk" ? [1] : []
|
||||
@@ -153,8 +196,8 @@ source "proxmox-iso" "debian" {
|
||||
template_description = "${local.build_description}"
|
||||
|
||||
# VM Cloud Init Settings
|
||||
cloud_init = var.vm_cloud_init_enable
|
||||
cloud_init_storage_pool = var.vm_cloud_init_enable == true ? var.vm_storage_pool : null
|
||||
cloud_init = var.vm_cloudinit
|
||||
cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null
|
||||
|
||||
}
|
||||
|
||||
@@ -163,19 +206,22 @@ build {
|
||||
sources = ["source.proxmox-iso.debian"]
|
||||
|
||||
provisioner "ansible" {
|
||||
user = "${var.build_username}"
|
||||
playbook_file = "${path.cwd}/ansible/main.yml"
|
||||
user = var.build_username
|
||||
galaxy_file = "${path.cwd}/ansible/linux-requirements.yml"
|
||||
galaxy_force_with_deps = true
|
||||
playbook_file = "${path.cwd}/ansible/linux-playbook.yml"
|
||||
roles_path = "${path.cwd}/ansible/roles"
|
||||
ansible_env_vars = [
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg"
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
|
||||
"ANSIBLE_PYTHON_INTERPRETER=/usr/bin/python3"
|
||||
]
|
||||
extra_arguments = [
|
||||
"--extra-vars", "display_skipped_hosts=false",
|
||||
"--extra-vars", "BUILD_USERNAME=${var.build_username}",
|
||||
"--extra-vars", "BUILD_SECRET='${var.build_key}'",
|
||||
"--extra-vars", "ANSIBLE_USERNAME=${var.ansible_username}",
|
||||
"--extra-vars", "ANSIBLE_SECRET='${var.ansible_key}'",
|
||||
"--extra-vars", "cloud_init='${var.vm_cloud_init_enable}'",
|
||||
"--extra-vars", "build_username=${var.build_username}",
|
||||
"--extra-vars", "build_key='${var.build_key}'",
|
||||
"--extra-vars", "ansible_username=${var.ansible_username}",
|
||||
"--extra-vars", "ansible_key='${var.ansible_key}'",
|
||||
"--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -196,7 +242,7 @@ build {
|
||||
vm_os_type = "${var.vm_os_type}"
|
||||
vm_mem_size = "${var.vm_mem_size}"
|
||||
vm_network_card_model = "${var.vm_network_card_model}"
|
||||
vm_cloud_init_enable = "${var.vm_cloud_init_enable}"
|
||||
vm_cloudinit = "${var.vm_cloudinit}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
36
builds/linux/debian/12/variables-network.pkr.hcl
Normal file
36
builds/linux/debian/12/variables-network.pkr.hcl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Debian Linux 11 network variables used by the Packer Plugin for VMware vSphere (vsphere-iso).
|
||||
*/
|
||||
|
||||
// VM Network Settings
|
||||
|
||||
variable "vm_network_device" {
|
||||
type = string
|
||||
description = "The network device of the VM."
|
||||
default = "ens192"
|
||||
}
|
||||
|
||||
variable "vm_ip_address" {
|
||||
type = string
|
||||
description = "The IP address of the VM (e.g. 172.16.100.192)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_netmask" {
|
||||
type = number
|
||||
description = "The netmask of the VM (e.g. 24)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_gateway" {
|
||||
type = string
|
||||
description = "The gateway of the VM (e.g. 172.16.100.1)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_dns_list" {
|
||||
type = list(string)
|
||||
description = "The nameservers of the VM."
|
||||
default = []
|
||||
}
|
||||
@@ -80,7 +80,7 @@ variable "vm_os_type" {
|
||||
variable "vm_bios" {
|
||||
type = string
|
||||
description = "The firmware type. Allowed values 'ovmf' or 'seabios'"
|
||||
default = "OVMF"
|
||||
default = "ovmf"
|
||||
|
||||
validation {
|
||||
condition = contains(["ovmf", "seabios"], var.vm_bios)
|
||||
@@ -97,16 +97,19 @@ variable "vm_firmware_path" {
|
||||
variable "vm_efi_storage_pool" {
|
||||
type = string
|
||||
description = "Set the UEFI disk storage location. (e.g. 'local-lvm')"
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "vm_efi_type" {
|
||||
type = string
|
||||
description = "Specifies the version of the OVMF firmware to be used. (e.g. '4m')"
|
||||
default = "4m"
|
||||
}
|
||||
|
||||
variable "vm_efi_pre_enrolled_keys" {
|
||||
type = bool
|
||||
description = "Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "vm_cpu_count" {
|
||||
@@ -171,7 +174,7 @@ variable "vm_vlan_tag" {
|
||||
|
||||
// Cloud-Init Settings
|
||||
|
||||
variable "vm_cloud_init_enable" {
|
||||
variable "vm_cloudinit" {
|
||||
type = bool
|
||||
description = "Enable or disable cloud-init drive in Proxmox. (e.g. false)"
|
||||
default = false
|
||||
@@ -295,3 +298,10 @@ variable "common_hcp_packer_registry_enabled" {
|
||||
default = false
|
||||
}
|
||||
|
||||
// Additional Settings
|
||||
|
||||
variable "additional_packages" {
|
||||
type = list(string)
|
||||
description = "Additional packages to install."
|
||||
default = []
|
||||
}
|
||||
@@ -17,13 +17,6 @@
|
||||
<priority t="integer">99</priority>
|
||||
<product_dir>/</product_dir>
|
||||
</listentry>
|
||||
<listentry t="map">
|
||||
<alias>repo-openh264</alias>
|
||||
<media_url>http://codecs.opensuse.org/openh264/openSUSE_Leap/</media_url>
|
||||
<name>Open H.264 Codec (openSUSE Leap)</name>
|
||||
<priority t="integer">99</priority>
|
||||
<product_dir/>
|
||||
</listentry>
|
||||
<listentry t="map">
|
||||
<alias>repo-sle-update</alias>
|
||||
<media_url>http://download.opensuse.org/update/leap/15.5/sle/</media_url>
|
||||
@@ -54,14 +47,13 @@
|
||||
<gfxmode>auto</gfxmode>
|
||||
<hiddenmenu>false</hiddenmenu>
|
||||
<os_prober>true</os_prober>
|
||||
<secure_boot>true</secure_boot>
|
||||
<secure_boot>false</secure_boot>
|
||||
<terminal>gfxterm</terminal>
|
||||
<timeout t="integer">8</timeout>
|
||||
<trusted_grub>false</trusted_grub>
|
||||
<update_nvram>true</update_nvram>
|
||||
<xen_kernel_append>vga=gfx-1024x768x16</xen_kernel_append>
|
||||
</global>
|
||||
<loader_type>grub2</loader_type>
|
||||
</bootloader>
|
||||
<kdump>
|
||||
<add_crash_kernel config:type="boolean">false</add_crash_kernel>
|
||||
@@ -451,39 +443,7 @@
|
||||
</hosts_entry>
|
||||
</hosts>
|
||||
</host>
|
||||
<networking t="map">
|
||||
<dhcp_options t="map">
|
||||
<dhclient_client_id/>
|
||||
<dhclient_hostname_option>AUTO</dhclient_hostname_option>
|
||||
</dhcp_options>
|
||||
<dns t="map">
|
||||
<dhcp_hostname t="boolean">true</dhcp_hostname>
|
||||
<hostname>localhost</hostname>
|
||||
<resolv_conf_policy>auto</resolv_conf_policy>
|
||||
</dns>
|
||||
<interfaces t="list">
|
||||
<interface t="map">
|
||||
<bootproto>dhcp</bootproto>
|
||||
<name>eth0</name>
|
||||
<startmode>auto</startmode>
|
||||
<zone>public</zone>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<ipv6 t="boolean">true</ipv6>
|
||||
<keep_install_network t="boolean">true</keep_install_network>
|
||||
<managed t="boolean">false</managed>
|
||||
<net-udev t="list">
|
||||
<rule t="map">
|
||||
<name>eth0</name>
|
||||
<rule>ATTR{address}</rule>
|
||||
<value>bc:24:11:b0:93:4b</value>
|
||||
</rule>
|
||||
</net-udev>
|
||||
<routing t="map">
|
||||
<ipv4_forward t="boolean">false</ipv4_forward>
|
||||
<ipv6_forward t="boolean">false</ipv6_forward>
|
||||
</routing>
|
||||
</networking>
|
||||
${network}
|
||||
<ntp-client t="map">
|
||||
<ntp_policy>auto</ntp_policy>
|
||||
<ntp_servers t="list"/>
|
||||
|
||||
50
builds/linux/opensuse/leap-15-5/data/network.pkrtpl.hcl
Normal file
50
builds/linux/opensuse/leap-15-5/data/network.pkrtpl.hcl
Normal file
@@ -0,0 +1,50 @@
|
||||
<networking t="map">
|
||||
<dhcp_options t="map">
|
||||
<dhclient_client_id/>
|
||||
<dhclient_hostname_option>AUTO</dhclient_hostname_option>
|
||||
</dhcp_options>
|
||||
<dns t="map">
|
||||
%{ if ip != null ~}
|
||||
<nameservers config:type="list">
|
||||
%{ for dns_server in dns ~}
|
||||
<nameserver>${dns_server}</nameserver>
|
||||
%{ endfor ~}
|
||||
</nameservers>
|
||||
%{ else ~}
|
||||
<dhcp_hostname t="boolean">true</dhcp_hostname>
|
||||
<hostname>localhost</hostname>
|
||||
%{ endif ~}
|
||||
<resolv_conf_policy>auto</resolv_conf_policy>
|
||||
</dns>
|
||||
<interfaces t="list">
|
||||
<interface t="map">
|
||||
%{ if ip != null ~}
|
||||
<bootproto>static</bootproto>
|
||||
<ipaddr>${ip}</ipaddr>
|
||||
<prefixlen>${netmask}</prefixlen>
|
||||
%{ else ~}
|
||||
<bootproto>dhcp</bootproto>
|
||||
%{ endif ~}
|
||||
<name>eth0</name>
|
||||
<startmode>auto</startmode>
|
||||
<zone>public</zone>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<ipv6 t="boolean">true</ipv6>
|
||||
<keep_install_network t="boolean">true</keep_install_network>
|
||||
<managed t="boolean">false</managed>
|
||||
<routing t="map">
|
||||
<ipv4_forward t="boolean">false</ipv4_forward>
|
||||
<ipv6_forward t="boolean">false</ipv6_forward>
|
||||
%{ if ip != null ~}
|
||||
<routes t="list">
|
||||
<route t="map">
|
||||
<destination>default</destination>
|
||||
<device>-</device>
|
||||
<gateway>${gateway}</gateway>
|
||||
<netmask>-</netmask>
|
||||
</route>
|
||||
</routes>
|
||||
%{ endif ~}
|
||||
</routing>
|
||||
</networking>
|
||||
@@ -1,63 +1,87 @@
|
||||
<partitioning t="list">
|
||||
<drive t="map">
|
||||
<device>/dev/system</device>
|
||||
<enable_snapshots t="boolean">false</enable_snapshots>
|
||||
<partitions t="list">
|
||||
<partition t="map">
|
||||
<create t="boolean">true</create>
|
||||
<filesystem t="symbol">ext4</filesystem>
|
||||
<format t="boolean">false</format>
|
||||
<lv_name>root</lv_name>
|
||||
<mount>/</mount>
|
||||
<mountby t="symbol">device</mountby>
|
||||
<pool t="boolean">false</pool>
|
||||
<resize t="boolean">false</resize>
|
||||
<size>32199671808</size>
|
||||
<!--<size>max</size>-->
|
||||
<stripes t="integer">1</stripes>
|
||||
<stripesize t="integer">0</stripesize>
|
||||
</partition>
|
||||
<partition t="map">
|
||||
<create t="boolean">true</create>
|
||||
<filesystem t="symbol">swap</filesystem>
|
||||
<format t="boolean">false</format>
|
||||
<lv_name>swap</lv_name>
|
||||
<mount>swap</mount>
|
||||
<mountby t="symbol">device</mountby>
|
||||
<pool t="boolean">false</pool>
|
||||
<resize t="boolean">false</resize>
|
||||
<size>2147483648</size>
|
||||
<!--<size>auto</size>-->
|
||||
<stripes t="integer">1</stripes>
|
||||
<stripesize t="integer">0</stripesize>
|
||||
</partition>
|
||||
</partitions>
|
||||
<pesize>4194304</pesize>
|
||||
<type t="symbol">CT_LVM</type>
|
||||
</drive>
|
||||
<drive t="map">
|
||||
<device>/dev/${device}</device>
|
||||
<disklabel>gpt</disklabel>
|
||||
<partitions t="list">
|
||||
%{ for index, partition in partitions ~}
|
||||
<partition t="map">
|
||||
<create t="boolean">true</create>
|
||||
<format t="boolean">false</format>
|
||||
<partition_id t="integer">263</partition_id>
|
||||
<partition_nr t="integer">1</partition_nr>
|
||||
<resize t="boolean">false</resize>
|
||||
<size>8388608</size>
|
||||
</partition>
|
||||
<partition t="map">
|
||||
<create t="boolean">true</create>
|
||||
<format t="boolean">false</format>
|
||||
<lvm_group>system</lvm_group>
|
||||
%{ if partition.volume_group != "" ~}
|
||||
<lvm_group>${partition.volume_group}</lvm_group>
|
||||
<partition_id t="integer">142</partition_id>
|
||||
<partition_nr t="integer">2</partition_nr>
|
||||
<format t="boolean">false</format>
|
||||
%{ else ~}
|
||||
%{ if partition.format.fstype == "swap" ~}
|
||||
<filesystem config:type="symbol">swap</filesystem>
|
||||
<partition_id t="integer">130</partition_id>
|
||||
<format t="boolean">true</format>
|
||||
%{ else ~}
|
||||
<label>${partition.format.label}</label>
|
||||
<resize t="boolean">false</resize>
|
||||
<size>34350284288</size>
|
||||
<mountby config:type="symbol">uuid</mountby>
|
||||
%{ endif ~}
|
||||
%{ if partition.format.fstype == "fat32" ~}
|
||||
<filesystem config:type="symbol">vfat</filesystem>
|
||||
%{ if partition.mount.path == "/boot/efi" ~}
|
||||
<partition_id t="integer">259</partition_id>
|
||||
<fstopt>utf8</fstopt>
|
||||
%{ else ~}
|
||||
<partition_id t="integer">12</partition_id>
|
||||
%{ endif ~}
|
||||
%{ else ~}
|
||||
<filesystem config:type="symbol">${partition.format.fstype}</filesystem>
|
||||
<partition_id t="integer">131</partition_id>
|
||||
%{ endif ~}
|
||||
<format t="boolean">true</format>
|
||||
<mount>${partition.mount.path}</mount>
|
||||
%{ endif ~}
|
||||
%{ if partition.size != -1 ~}
|
||||
<size>${partition.size}M</size>
|
||||
%{ else ~}
|
||||
<size>max</size>
|
||||
%{ endif ~}
|
||||
<!--<partition_nr t="integer">${index}</partition_nr>-->
|
||||
</partition>
|
||||
%{ endfor ~}
|
||||
</partitions>
|
||||
<type t="symbol">CT_DISK</type>
|
||||
<use>all</use>
|
||||
</drive>
|
||||
%{ for index, volume_group in lvm ~}
|
||||
<drive t="map">
|
||||
<device>/dev/${volume_group.name}</device>
|
||||
<enable_snapshots t="boolean">false</enable_snapshots>
|
||||
<partitions t="list">
|
||||
%{ for partition in volume_group.partitions ~}
|
||||
<partition t="map">
|
||||
<create t="boolean">true</create>
|
||||
%{ if partition.format.fstype == "swap" ~}
|
||||
<filesystem config:type="symbol">swap</filesystem>
|
||||
<mount>swap</mount>
|
||||
%{ else ~}
|
||||
<filesystem config:type="symbol">${partition.format.fstype}</filesystem>
|
||||
<mount>${partition.mount.path}</mount>
|
||||
%{ endif ~}
|
||||
<lv_name>${partition.name}</lv_name>
|
||||
<format t="boolean">false</format>
|
||||
<mountby t="symbol">device</mountby>
|
||||
<pool t="boolean">false</pool>
|
||||
<resize t="boolean">false</resize>
|
||||
%{ if partition.mount.options != "" ~}
|
||||
<fstopt>${partition.mount.options}</fstopt>
|
||||
%{ endif ~}
|
||||
%{ if partition.size != -1 ~}
|
||||
<size>${partition.size}M</size>
|
||||
%{ else ~}
|
||||
<size>max</size>
|
||||
%{ endif ~}
|
||||
<stripes t="integer">1</stripes>
|
||||
<stripesize t="integer">0</stripesize>
|
||||
</partition>
|
||||
%{ endfor ~}
|
||||
</partitions>
|
||||
<pesize>4194304</pesize>
|
||||
<type t="symbol">CT_LVM</type>
|
||||
</drive>
|
||||
%{ endfor ~}
|
||||
</partitioning>
|
||||
@@ -13,9 +13,10 @@ vm_os_version = "15.5"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
vm_cloudinit = true
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "seabios"
|
||||
vm_bios = "ovmf"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "x86-64-v2-AES"
|
||||
@@ -23,11 +24,8 @@ vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_storage_pool = "vm-data"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
vm_bridge_interface = "vmbr0"
|
||||
vm_vlan_tag = "102"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
@@ -40,6 +38,3 @@ vm_boot_wait = "5s"
|
||||
|
||||
// EFI Settings
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
vm_efi_storage_pool = "vm-data"
|
||||
vm_efi_pre_enrolled_keys = false
|
||||
vm_efi_type = "4m"
|
||||
|
||||
@@ -33,10 +33,37 @@ data "git-repository" "cwd" {}
|
||||
// Defines the local variables.
|
||||
|
||||
locals {
|
||||
|
||||
bios_boot_command = [
|
||||
"<esc><enter><wait>",
|
||||
"linux ",
|
||||
"biosdevname=0 ",
|
||||
"net.ifnames=0 ",
|
||||
"netdevice=eth0 ",
|
||||
"netsetup=dhcp ",
|
||||
"lang=en_US ",
|
||||
"textmode=1 ",
|
||||
"${local.data_source_command}",
|
||||
"<enter><wait>",
|
||||
]
|
||||
|
||||
uefi_boot_command = [
|
||||
// This sends the "escape" key. In the GRUB boot loader, this is used to enter command line mode.
|
||||
"<esc>",
|
||||
// This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option.
|
||||
"e",
|
||||
// This sends four "down arrow" keys and then the "end" key. This is used to navigate to a specific line in the boot menu option's configuration.
|
||||
"<down><down><down><down><end>",
|
||||
// This types the value of the 'data_source_command' local variable. This is used to specify the kickstart data source configured in the common variables.
|
||||
"${local.data_source_command}",
|
||||
// This sends the "F10" key. In the GRUB boot loader, this is used to save the changes and exit the boot menu option's configuration, and then continue the boot process.
|
||||
"<f10>"
|
||||
]
|
||||
|
||||
build_by = "Built by: HashiCorp Packer ${packer.version}"
|
||||
build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" )
|
||||
build_version = data.git-repository.cwd.head
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloud_init_enable}"
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}"
|
||||
vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda"
|
||||
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
|
||||
manifest_path = "${path.cwd}/manifests/"
|
||||
@@ -50,9 +77,16 @@ locals {
|
||||
vm_os_language = var.vm_os_language
|
||||
vm_os_keyboard = var.vm_os_keyboard
|
||||
vm_os_timezone = var.vm_os_timezone
|
||||
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
|
||||
device = var.vm_bridge_interface
|
||||
ip = var.vm_ip_address
|
||||
netmask = var.vm_ip_netmask
|
||||
gateway = var.vm_ip_gateway
|
||||
dns = var.vm_dns_list
|
||||
})
|
||||
common_data_source = var.common_data_source
|
||||
# lvm needs to be here so late commands can access vg names
|
||||
lvm = var.vm_disk_lvm
|
||||
# vm_bios needs to be here to help determine the bootloader
|
||||
vm_bios = var.vm_bios
|
||||
storage = templatefile("${abspath(path.root)}/data/storage.pkrtpl.hcl", {
|
||||
device = var.vm_disk_device
|
||||
swap = var.vm_disk_use_swap
|
||||
@@ -60,10 +94,12 @@ locals {
|
||||
lvm = var.vm_disk_lvm
|
||||
vm_bios = var.vm_bios
|
||||
})
|
||||
additional_packages = var.additional_packages
|
||||
})
|
||||
}
|
||||
data_source_command = var.common_data_source == "http" ? " autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinst.xml" : " netsetup=dhcp autoyast=device://sr1/autoinst.xml"
|
||||
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||
boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command
|
||||
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||
}
|
||||
|
||||
@@ -128,18 +164,7 @@ source "proxmox-iso" "linux-opensuse-leap" {
|
||||
http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null
|
||||
boot = var.vm_boot
|
||||
boot_wait = var.vm_boot_wait
|
||||
boot_command = [
|
||||
"<esc><enter><wait>",
|
||||
"linux ",
|
||||
"biosdevname=0 ",
|
||||
"net.ifnames=0 ",
|
||||
"netdevice=eth0 ",
|
||||
"netsetup=dhcp ",
|
||||
"lang=en_US ",
|
||||
"textmode=1 ",
|
||||
"${local.data_source_command}",
|
||||
"<enter><wait>",
|
||||
]
|
||||
boot_command = local.boot_command
|
||||
|
||||
dynamic "additional_iso_files" {
|
||||
for_each = var.common_data_source == "disk" ? [1] : []
|
||||
@@ -154,8 +179,8 @@ source "proxmox-iso" "linux-opensuse-leap" {
|
||||
template_description = "${local.build_description}"
|
||||
|
||||
# VM Cloud Init Settings
|
||||
cloud_init = var.vm_cloud_init_enable
|
||||
cloud_init_storage_pool = var.vm_cloud_init_enable == true ? var.vm_storage_pool : null
|
||||
cloud_init = var.vm_cloudinit
|
||||
cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null
|
||||
|
||||
}
|
||||
|
||||
@@ -164,7 +189,10 @@ build {
|
||||
sources = ["source.proxmox-iso.linux-opensuse-leap"]
|
||||
|
||||
provisioner "ansible" {
|
||||
playbook_file = "${path.cwd}/ansible/main.yml"
|
||||
user = "${var.build_username}"
|
||||
galaxy_file = "${path.cwd}/ansible/linux-requirements.yml"
|
||||
galaxy_force_with_deps = true
|
||||
playbook_file = "${path.cwd}/ansible/linux-playbook.yml"
|
||||
roles_path = "${path.cwd}/ansible/roles"
|
||||
ansible_env_vars = [
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
|
||||
@@ -172,10 +200,11 @@ build {
|
||||
]
|
||||
extra_arguments = [
|
||||
"--extra-vars", "display_skipped_hosts=false",
|
||||
"--extra-vars", "BUILD_USERNAME=${var.build_username}",
|
||||
"--extra-vars", "BUILD_SECRET='${var.build_key}'",
|
||||
"--extra-vars", "ANSIBLE_USERNAME=${var.ansible_username}",
|
||||
"--extra-vars", "ANSIBLE_SECRET='${var.ansible_key}'",
|
||||
"--extra-vars", "build_username=${var.build_username}",
|
||||
"--extra-vars", "build_key='${var.build_key}'",
|
||||
"--extra-vars", "ansible_username=${var.ansible_username}",
|
||||
"--extra-vars", "ansible_key='${var.ansible_key}'",
|
||||
"--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -196,7 +225,7 @@ build {
|
||||
vm_os_type = "${var.vm_os_type}"
|
||||
vm_mem_size = "${var.vm_mem_size}"
|
||||
vm_network_card_model = "${var.vm_network_card_model}"
|
||||
vm_cloud_init_enable = "${var.vm_cloud_init_enable}"
|
||||
vm_cloudinit = "${var.vm_cloudinit}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
36
builds/linux/opensuse/leap-15-5/variables-network.pkr.hcl
Normal file
36
builds/linux/opensuse/leap-15-5/variables-network.pkr.hcl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Debian Linux 11 network variables used by the Packer Plugin for VMware vSphere (vsphere-iso).
|
||||
*/
|
||||
|
||||
// VM Network Settings
|
||||
|
||||
variable "vm_network_device" {
|
||||
type = string
|
||||
description = "The network device of the VM."
|
||||
default = "ens192"
|
||||
}
|
||||
|
||||
variable "vm_ip_address" {
|
||||
type = string
|
||||
description = "The IP address of the VM (e.g. 172.16.100.192)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_netmask" {
|
||||
type = number
|
||||
description = "The netmask of the VM (e.g. 24)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_gateway" {
|
||||
type = string
|
||||
description = "The gateway of the VM (e.g. 172.16.100.1)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_dns_list" {
|
||||
type = list(string)
|
||||
description = "The nameservers of the VM."
|
||||
default = []
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
openSUSE-Leap 15.5 variables using the Packer Builder for Proxmox (proxmox-iso).
|
||||
openSUSE Leap 15.5 variables using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: variable
|
||||
@@ -80,7 +80,7 @@ variable "vm_os_type" {
|
||||
variable "vm_bios" {
|
||||
type = string
|
||||
description = "The firmware type. Allowed values 'ovmf' or 'seabios'"
|
||||
default = "OVMF"
|
||||
default = "ovmf"
|
||||
|
||||
validation {
|
||||
condition = contains(["ovmf", "seabios"], var.vm_bios)
|
||||
@@ -97,16 +97,19 @@ variable "vm_firmware_path" {
|
||||
variable "vm_efi_storage_pool" {
|
||||
type = string
|
||||
description = "Set the UEFI disk storage location. (e.g. 'local-lvm')"
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "vm_efi_type" {
|
||||
type = string
|
||||
description = "Specifies the version of the OVMF firmware to be used. (e.g. '4m')"
|
||||
default = "4m"
|
||||
}
|
||||
|
||||
variable "vm_efi_pre_enrolled_keys" {
|
||||
type = bool
|
||||
description = "Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "vm_cpu_count" {
|
||||
@@ -171,7 +174,7 @@ variable "vm_vlan_tag" {
|
||||
|
||||
// Cloud-Init Settings
|
||||
|
||||
variable "vm_cloud_init_enable" {
|
||||
variable "vm_cloudinit" {
|
||||
type = bool
|
||||
description = "Enable or disable cloud-init drive in Proxmox. (e.g. false)"
|
||||
default = false
|
||||
@@ -295,3 +298,10 @@ variable "common_hcp_packer_registry_enabled" {
|
||||
default = false
|
||||
}
|
||||
|
||||
// Additional Settings
|
||||
|
||||
variable "additional_packages" {
|
||||
type = list(string)
|
||||
description = "Additional packages to install."
|
||||
default = []
|
||||
}
|
||||
610
builds/linux/opensuse/leap-15-6/data/autoinst.pkrtpl.hcl
Normal file
610
builds/linux/opensuse/leap-15-6/data/autoinst.pkrtpl.hcl
Normal file
@@ -0,0 +1,610 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE profile>
|
||||
<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
|
||||
<add-on t="map">
|
||||
<add_on_others t="list">
|
||||
<listentry t="map">
|
||||
<alias>repo-backports-update</alias>
|
||||
<media_url>http://download.opensuse.org/update/leap/15.6/backports/</media_url>
|
||||
<name>Update repository of openSUSE Backports</name>
|
||||
<priority t="integer">99</priority>
|
||||
<product_dir>/</product_dir>
|
||||
</listentry>
|
||||
<listentry t="map">
|
||||
<alias>repo-non-oss</alias>
|
||||
<media_url>http://download.opensuse.org/distribution/leap/15.6/repo/non-oss/</media_url>
|
||||
<name>Non-OSS Repository</name>
|
||||
<priority t="integer">99</priority>
|
||||
<product_dir>/</product_dir>
|
||||
</listentry>
|
||||
<listentry t="map">
|
||||
<alias>repo-sle-update</alias>
|
||||
<media_url>http://download.opensuse.org/update/leap/15.6/sle/</media_url>
|
||||
<name>Update repository with updates from SUSE Linux Enterprise 15</name>
|
||||
<priority t="integer">99</priority>
|
||||
<product_dir>/</product_dir>
|
||||
</listentry>
|
||||
<listentry t="map">
|
||||
<alias>repo-update</alias>
|
||||
<media_url>http://download.opensuse.org/update/leap/15.6/oss</media_url>
|
||||
<name>Main Update Repository</name>
|
||||
<priority t="integer">99</priority>
|
||||
<product_dir>/</product_dir>
|
||||
</listentry>
|
||||
<listentry t="map">
|
||||
<alias>repo-update-non-oss</alias>
|
||||
<media_url>http://download.opensuse.org/update/leap/15.6/non-oss/</media_url>
|
||||
<name>Update Repository (Non-Oss)</name>
|
||||
<priority t="integer">99</priority>
|
||||
<product_dir>/</product_dir>
|
||||
</listentry>
|
||||
</add_on_others>
|
||||
</add-on>
|
||||
<bootloader t="map">
|
||||
<global t="map">
|
||||
<append>splash=silent preempt=full mitigations=auto quiet security=apparmor</append>
|
||||
<cpu_mitigations>auto</cpu_mitigations>
|
||||
<gfxmode>auto</gfxmode>
|
||||
<hiddenmenu>false</hiddenmenu>
|
||||
<os_prober>true</os_prober>
|
||||
<secure_boot>false</secure_boot>
|
||||
<terminal>gfxterm</terminal>
|
||||
<timeout t="integer">8</timeout>
|
||||
<trusted_grub>false</trusted_grub>
|
||||
<update_nvram>true</update_nvram>
|
||||
<xen_kernel_append>vga=gfx-1024x768x16</xen_kernel_append>
|
||||
</global>
|
||||
</bootloader>
|
||||
<kdump>
|
||||
<add_crash_kernel config:type="boolean">false</add_crash_kernel>
|
||||
</kdump>
|
||||
<firewall t="map">
|
||||
<default_zone>public</default_zone>
|
||||
<enable_firewall t="boolean">true</enable_firewall>
|
||||
<log_denied_packets>off</log_denied_packets>
|
||||
<start_firewall t="boolean">true</start_firewall>
|
||||
<zones t="list">
|
||||
<zone t="map">
|
||||
<description>Unsolicited incoming network packets are rejected. Incoming packets that are related to outgoing network connections are accepted. Outgoing network connections are allowed.</description>
|
||||
<interfaces t="list"/>
|
||||
<masquerade t="boolean">false</masquerade>
|
||||
<name>block</name>
|
||||
<ports t="list"/>
|
||||
<protocols t="list"/>
|
||||
<services t="list"/>
|
||||
<short>Block</short>
|
||||
<target>%%REJECT%%</target>
|
||||
</zone>
|
||||
<zone t="map">
|
||||
<description>For computers in your demilitarized zone that are publicly-accessible with limited access to your internal network. Only selected incoming connections are accepted.</description>
|
||||
<interfaces t="list"/>
|
||||
<masquerade t="boolean">false</masquerade>
|
||||
<name>dmz</name>
|
||||
<ports t="list"/>
|
||||
<protocols t="list"/>
|
||||
<services t="list">
|
||||
<service>ssh</service>
|
||||
</services>
|
||||
<short>DMZ</short>
|
||||
<target>default</target>
|
||||
</zone>
|
||||
<zone t="map">
|
||||
<description>All network connections are accepted.</description>
|
||||
<interfaces t="list">
|
||||
<interface>docker0</interface>
|
||||
</interfaces>
|
||||
<masquerade t="boolean">false</masquerade>
|
||||
<name>docker</name>
|
||||
<ports t="list"/>
|
||||
<protocols t="list"/>
|
||||
<services t="list"/>
|
||||
<short>docker</short>
|
||||
<target>ACCEPT</target>
|
||||
</zone>
|
||||
<zone t="map">
|
||||
<description>Unsolicited incoming network packets are dropped. Incoming packets that are related to outgoing network connections are accepted. Outgoing network connections are allowed.</description>
|
||||
<interfaces t="list"/>
|
||||
<masquerade t="boolean">false</masquerade>
|
||||
<name>drop</name>
|
||||
<ports t="list"/>
|
||||
<protocols t="list"/>
|
||||
<services t="list"/>
|
||||
<short>Drop</short>
|
||||
<target>DROP</target>
|
||||
</zone>
|
||||
<zone t="map">
|
||||
<description>For use on external networks. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
|
||||
<interfaces t="list"/>
|
||||
<masquerade t="boolean">true</masquerade>
|
||||
<name>external</name>
|
||||
<ports t="list"/>
|
||||
<protocols t="list"/>
|
||||
<services t="list">
|
||||
<service>ssh</service>
|
||||
</services>
|
||||
<short>External</short>
|
||||
<target>default</target>
|
||||
</zone>
|
||||
<zone t="map">
|
||||
<description>For use in home areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
|
||||
<interfaces t="list"/>
|
||||
<masquerade t="boolean">false</masquerade>
|
||||
<name>home</name>
|
||||
<ports t="list"/>
|
||||
<protocols t="list"/>
|
||||
<services t="list">
|
||||
<service>dhcpv6-client</service>
|
||||
<service>mdns</service>
|
||||
<service>samba-client</service>
|
||||
<service>ssh</service>
|
||||
</services>
|
||||
<short>Home</short>
|
||||
<target>default</target>
|
||||
</zone>
|
||||
<zone t="map">
|
||||
<description>For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.</description>
|
||||
<interfaces t="list"/>
|
||||
<masquerade t="boolean">false</masquerade>
|
||||
<name>internal</name>
|
||||
<ports t="list"/>
|
||||
<protocols t="list"/>
|
||||
<services t="list">
|
||||
<service>dhcpv6-client</service>
|
||||
<service>mdns</service>
|
||||
<service>samba-client</service>
|
||||
<service>ssh</service>
|
||||
</services>
|
||||
<short>Internal</short>
|
||||
<target>default</target>
|
||||
</zone>
|
||||
<zone t="map">
|
||||
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
|
||||
<interfaces t="list">
|
||||
<interface>eth0</interface>
|
||||
</interfaces>
|
||||
<masquerade t="boolean">false</masquerade>
|
||||
<name>public</name>
|
||||
<ports t="list"/>
|
||||
<protocols t="list"/>
|
||||
<services t="list">
|
||||
<service>dhcpv6-client</service>
|
||||
<service>ssh</service>
|
||||
</services>
|
||||
<short>Public</short>
|
||||
<target>default</target>
|
||||
</zone>
|
||||
<zone t="map">
|
||||
<description>All network connections are accepted.</description>
|
||||
<interfaces t="list"/>
|
||||
<masquerade t="boolean">false</masquerade>
|
||||
<name>trusted</name>
|
||||
<ports t="list"/>
|
||||
<protocols t="list"/>
|
||||
<services t="list"/>
|
||||
<short>Trusted</short>
|
||||
<target>ACCEPT</target>
|
||||
</zone>
|
||||
<zone t="map">
|
||||
<description>For use in work areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
|
||||
<interfaces t="list"/>
|
||||
<masquerade t="boolean">false</masquerade>
|
||||
<name>work</name>
|
||||
<ports t="list"/>
|
||||
<protocols t="list"/>
|
||||
<services t="list">
|
||||
<service>dhcpv6-client</service>
|
||||
<service>ssh</service>
|
||||
</services>
|
||||
<short>Work</short>
|
||||
<target>default</target>
|
||||
</zone>
|
||||
</zones>
|
||||
</firewall>
|
||||
<general t="map">
|
||||
<mode t="map">
|
||||
<confirm t="boolean">false</confirm>
|
||||
</mode>
|
||||
</general>
|
||||
<groups t="list">
|
||||
<group t="map">
|
||||
<gid>100</gid>
|
||||
<groupname>users</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>493</gid>
|
||||
<groupname>utmp</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>65533</gid>
|
||||
<groupname>nogroup</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>71</gid>
|
||||
<groupname>ntadmin</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>488</gid>
|
||||
<groupname>input</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>491</gid>
|
||||
<groupname>cdrom</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>475</gid>
|
||||
<groupname>polkitd</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>1</gid>
|
||||
<groupname>bin</groupname>
|
||||
<userlist>daemon</userlist>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>2</gid>
|
||||
<groupname>daemon</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>65534</gid>
|
||||
<groupname>nobody</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>36</gid>
|
||||
<groupname>kvm</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>59</gid>
|
||||
<groupname>maildrop</groupname>
|
||||
<userlist>postfix</userlist>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>477</gid>
|
||||
<groupname>sshd</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>482</gid>
|
||||
<groupname>chrony</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>489</gid>
|
||||
<groupname>disk</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>492</gid>
|
||||
<groupname>audio</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>494</gid>
|
||||
<groupname>lock</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>15</gid>
|
||||
<groupname>shadow</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>485</gid>
|
||||
<groupname>tape</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>495</gid>
|
||||
<groupname>kmem</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>5</gid>
|
||||
<groupname>tty</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>480</gid>
|
||||
<groupname>systemd-network</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>484</gid>
|
||||
<groupname>video</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>499</gid>
|
||||
<groupname>messagebus</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>486</gid>
|
||||
<groupname>sgx</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>497</gid>
|
||||
<groupname>lp</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>487</gid>
|
||||
<groupname>render</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>0</gid>
|
||||
<groupname>root</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>42</gid>
|
||||
<groupname>trusted</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>479</gid>
|
||||
<groupname>systemd-timesync</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>481</gid>
|
||||
<groupname>systemd-journal</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>51</gid>
|
||||
<groupname>postfix</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>490</gid>
|
||||
<groupname>dialout</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>483</gid>
|
||||
<groupname>audit</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>498</gid>
|
||||
<groupname>mail</groupname>
|
||||
<userlist>postfix</userlist>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>62</gid>
|
||||
<groupname>man</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>496</gid>
|
||||
<groupname>wheel</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
<group t="map">
|
||||
<gid>478</gid>
|
||||
<groupname>nscd</groupname>
|
||||
<userlist/>
|
||||
</group>
|
||||
</groups>
|
||||
<host t="map">
|
||||
<hosts t="list">
|
||||
<hosts_entry t="map">
|
||||
<host_address>127.0.0.1</host_address>
|
||||
<names t="list">
|
||||
<name>localhost</name>
|
||||
</names>
|
||||
</hosts_entry>
|
||||
<hosts_entry t="map">
|
||||
<host_address>::1</host_address>
|
||||
<names t="list">
|
||||
<name>localhost ipv6-localhost ipv6-loopback</name>
|
||||
</names>
|
||||
</hosts_entry>
|
||||
<hosts_entry t="map">
|
||||
<host_address>fe00::0</host_address>
|
||||
<names t="list">
|
||||
<name>ipv6-localnet</name>
|
||||
</names>
|
||||
</hosts_entry>
|
||||
<hosts_entry t="map">
|
||||
<host_address>ff00::0</host_address>
|
||||
<names t="list">
|
||||
<name>ipv6-mcastprefix</name>
|
||||
</names>
|
||||
</hosts_entry>
|
||||
<hosts_entry t="map">
|
||||
<host_address>ff02::1</host_address>
|
||||
<names t="list">
|
||||
<name>ipv6-allnodes</name>
|
||||
</names>
|
||||
</hosts_entry>
|
||||
<hosts_entry t="map">
|
||||
<host_address>ff02::2</host_address>
|
||||
<names t="list">
|
||||
<name>ipv6-allrouters</name>
|
||||
</names>
|
||||
</hosts_entry>
|
||||
<hosts_entry t="map">
|
||||
<host_address>ff02::3</host_address>
|
||||
<names t="list">
|
||||
<name>ipv6-allhosts</name>
|
||||
</names>
|
||||
</hosts_entry>
|
||||
</hosts>
|
||||
</host>
|
||||
<networking t="map">
|
||||
<dhcp_options t="map">
|
||||
<dhclient_client_id/>
|
||||
<dhclient_hostname_option>AUTO</dhclient_hostname_option>
|
||||
</dhcp_options>
|
||||
<dns t="map">
|
||||
<dhcp_hostname t="boolean">true</dhcp_hostname>
|
||||
<hostname>localhost</hostname>
|
||||
<resolv_conf_policy>auto</resolv_conf_policy>
|
||||
</dns>
|
||||
<interfaces t="list">
|
||||
<interface t="map">
|
||||
<bootproto>dhcp</bootproto>
|
||||
<name>eth0</name>
|
||||
<startmode>auto</startmode>
|
||||
<zone>public</zone>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<ipv6 t="boolean">true</ipv6>
|
||||
<keep_install_network t="boolean">true</keep_install_network>
|
||||
<managed t="boolean">false</managed>
|
||||
<routing t="map">
|
||||
<ipv4_forward t="boolean">false</ipv4_forward>
|
||||
<ipv6_forward t="boolean">false</ipv6_forward>
|
||||
</routing>
|
||||
</networking>
|
||||
<ntp-client t="map">
|
||||
<ntp_policy>auto</ntp_policy>
|
||||
<ntp_servers t="list"/>
|
||||
<ntp_sync>systemd</ntp_sync>
|
||||
</ntp-client>
|
||||
${storage}
|
||||
<proxy t="map">
|
||||
<enabled t="boolean">false</enabled>
|
||||
</proxy>
|
||||
<services-manager t="map">
|
||||
<default_target>multi-user</default_target>
|
||||
<services t="map">
|
||||
<enable t="list">
|
||||
<service>YaST2-Firstboot</service>
|
||||
<service>YaST2-Second-Stage</service>
|
||||
<service>apparmor</service>
|
||||
<service>auditd</service>
|
||||
<service>klog</service>
|
||||
<service>chronyd</service>
|
||||
<service>cron</service>
|
||||
<service>cups</service>
|
||||
<service>firewalld</service>
|
||||
<service>wickedd-auto4</service>
|
||||
<service>wickedd-dhcp4</service>
|
||||
<service>wickedd-dhcp6</service>
|
||||
<service>wickedd-nanny</service>
|
||||
<service>irqbalance</service>
|
||||
<service>issue-generator</service>
|
||||
<service>kbdsettings</service>
|
||||
<service>lvm2-monitor</service>
|
||||
<service>mcelog</service>
|
||||
<service>wicked</service>
|
||||
<service>nscd</service>
|
||||
<service>postfix</service>
|
||||
<service>purge-kernels</service>
|
||||
<service>rsyslog</service>
|
||||
<service>smartd</service>
|
||||
<service>sshd</service>
|
||||
<service>systemd-fsck-root</service>
|
||||
<service>systemd-pstore</service>
|
||||
<service>systemd-remount-fs</service>
|
||||
<service>qemu-guest-agent</service>
|
||||
</enable>
|
||||
</services>
|
||||
</services-manager>
|
||||
<software t="map">
|
||||
<install_recommended t="boolean">true</install_recommended>
|
||||
<instsource/>
|
||||
<packages t="list">
|
||||
<package>wicked</package>
|
||||
<package>os-prober</package>
|
||||
<package>openssh</package>
|
||||
<package>openSUSE-release</package>
|
||||
<package>lvm2</package>
|
||||
<package>kexec-tools</package>
|
||||
<package>grub2</package>
|
||||
<package>glibc</package>
|
||||
<package>firewalld</package>
|
||||
<package>e2fsprogs</package>
|
||||
<package>chrony</package>
|
||||
<package>autoyast2</package>
|
||||
<package>qemu-guest-agent</package>
|
||||
</packages>
|
||||
<patterns t="list">
|
||||
<pattern>apparmor</pattern>
|
||||
<pattern>base</pattern>
|
||||
<pattern>documentation</pattern>
|
||||
<pattern>enhanced_base</pattern>
|
||||
<pattern>minimal_base</pattern>
|
||||
<pattern>sw_management</pattern>
|
||||
<pattern>yast2_basis</pattern>
|
||||
</patterns>
|
||||
<products t="list">
|
||||
<product>Leap</product>
|
||||
</products>
|
||||
</software>
|
||||
<ssh_import t="map">
|
||||
<copy_config t="boolean">false</copy_config>
|
||||
<import t="boolean">false</import>
|
||||
</ssh_import>
|
||||
<timezone t="map">
|
||||
<timezone>${vm_os_timezone}</timezone>
|
||||
</timezone>
|
||||
<user_defaults t="map">
|
||||
<expire/>
|
||||
<group>100</group>
|
||||
<home>/home</home>
|
||||
<inactive>-1</inactive>
|
||||
<shell>/bin/bash</shell>
|
||||
<umask>022</umask>
|
||||
</user_defaults>
|
||||
<users t="list">
|
||||
<user t="map">
|
||||
<authorized_keys t="list"/>
|
||||
<encrypted t="boolean">true</encrypted>
|
||||
<fullname>Build User</fullname>
|
||||
<gid>100</gid>
|
||||
<home>/home/${build_username}</home>
|
||||
<home_btrfs_subvolume t="boolean">false</home_btrfs_subvolume>
|
||||
<password_settings t="map">
|
||||
<expire/>
|
||||
<flag/>
|
||||
<inact/>
|
||||
<max>99999</max>
|
||||
<min>0</min>
|
||||
<warn>7</warn>
|
||||
</password_settings>
|
||||
<shell>/bin/bash</shell>
|
||||
<uid>1000</uid>
|
||||
<user_password>${build_password_encrypted}</user_password>
|
||||
<username>${build_username}</username>
|
||||
</user>
|
||||
</users>
|
||||
<scripts>
|
||||
<post-scripts config:type="list">
|
||||
<script>
|
||||
<filename>post.sh</filename>
|
||||
<interpreter>shell</interpreter>
|
||||
<feedback config:type="boolean">false</feedback>
|
||||
<source><![CDATA[
|
||||
#!/bin/sh
|
||||
usermod -aG wheel ${build_username}
|
||||
echo '${build_username} ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/${build_username}
|
||||
sed -i '/NOPASSWD/s/^# //g' /etc/sudoers
|
||||
]]>
|
||||
</source>
|
||||
</script>
|
||||
</post-scripts>
|
||||
<init-scripts config:type="list">
|
||||
<script>
|
||||
<source><![CDATA[
|
||||
#!/bin/sh
|
||||
systemctl enable --now qemu-guest-agent
|
||||
]]>
|
||||
</source>
|
||||
</script>
|
||||
</init-scripts>
|
||||
</scripts>
|
||||
</profile>
|
||||
50
builds/linux/opensuse/leap-15-6/data/network.pkrtpl.hcl
Normal file
50
builds/linux/opensuse/leap-15-6/data/network.pkrtpl.hcl
Normal file
@@ -0,0 +1,50 @@
|
||||
<networking t="map">
|
||||
<dhcp_options t="map">
|
||||
<dhclient_client_id/>
|
||||
<dhclient_hostname_option>AUTO</dhclient_hostname_option>
|
||||
</dhcp_options>
|
||||
<dns t="map">
|
||||
%{ if ip != null ~}
|
||||
<nameservers config:type="list">
|
||||
%{ for dns_server in dns ~}
|
||||
<nameserver>${dns_server}</nameserver>
|
||||
%{ endfor ~}
|
||||
</nameservers>
|
||||
%{ else ~}
|
||||
<dhcp_hostname t="boolean">true</dhcp_hostname>
|
||||
<hostname>localhost</hostname>
|
||||
%{ endif ~}
|
||||
<resolv_conf_policy>auto</resolv_conf_policy>
|
||||
</dns>
|
||||
<interfaces t="list">
|
||||
<interface t="map">
|
||||
%{ if ip != null ~}
|
||||
<bootproto>static</bootproto>
|
||||
<ipaddr>${ip}</ipaddr>
|
||||
<prefixlen>${netmask}</prefixlen>
|
||||
%{ else ~}
|
||||
<bootproto>dhcp</bootproto>
|
||||
%{ endif ~}
|
||||
<name>eth0</name>
|
||||
<startmode>auto</startmode>
|
||||
<zone>public</zone>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<ipv6 t="boolean">true</ipv6>
|
||||
<keep_install_network t="boolean">true</keep_install_network>
|
||||
<managed t="boolean">false</managed>
|
||||
<routing t="map">
|
||||
<ipv4_forward t="boolean">false</ipv4_forward>
|
||||
<ipv6_forward t="boolean">false</ipv6_forward>
|
||||
%{ if ip != null ~}
|
||||
<routes t="list">
|
||||
<route t="map">
|
||||
<destination>default</destination>
|
||||
<device>-</device>
|
||||
<gateway>${gateway}</gateway>
|
||||
<netmask>-</netmask>
|
||||
</route>
|
||||
</routes>
|
||||
%{ endif ~}
|
||||
</routing>
|
||||
</networking>
|
||||
87
builds/linux/opensuse/leap-15-6/data/storage.pkrtpl.hcl
Normal file
87
builds/linux/opensuse/leap-15-6/data/storage.pkrtpl.hcl
Normal file
@@ -0,0 +1,87 @@
|
||||
<partitioning t="list">
|
||||
<drive t="map">
|
||||
<device>/dev/${device}</device>
|
||||
<disklabel>gpt</disklabel>
|
||||
<partitions t="list">
|
||||
%{ for index, partition in partitions ~}
|
||||
<partition t="map">
|
||||
<create t="boolean">true</create>
|
||||
%{ if partition.volume_group != "" ~}
|
||||
<lvm_group>${partition.volume_group}</lvm_group>
|
||||
<partition_id t="integer">142</partition_id>
|
||||
<format t="boolean">false</format>
|
||||
%{ else ~}
|
||||
%{ if partition.format.fstype == "swap" ~}
|
||||
<filesystem config:type="symbol">swap</filesystem>
|
||||
<partition_id t="integer">130</partition_id>
|
||||
<format t="boolean">true</format>
|
||||
%{ else ~}
|
||||
<label>${partition.format.label}</label>
|
||||
<resize t="boolean">false</resize>
|
||||
<mountby config:type="symbol">uuid</mountby>
|
||||
%{ endif ~}
|
||||
%{ if partition.format.fstype == "fat32" ~}
|
||||
<filesystem config:type="symbol">vfat</filesystem>
|
||||
%{ if partition.mount.path == "/boot/efi" ~}
|
||||
<partition_id t="integer">259</partition_id>
|
||||
<fstopt>utf8</fstopt>
|
||||
%{ else ~}
|
||||
<partition_id t="integer">12</partition_id>
|
||||
%{ endif ~}
|
||||
%{ else ~}
|
||||
<filesystem config:type="symbol">${partition.format.fstype}</filesystem>
|
||||
<partition_id t="integer">131</partition_id>
|
||||
%{ endif ~}
|
||||
<format t="boolean">true</format>
|
||||
<mount>${partition.mount.path}</mount>
|
||||
%{ endif ~}
|
||||
%{ if partition.size != -1 ~}
|
||||
<size>${partition.size}M</size>
|
||||
%{ else ~}
|
||||
<size>max</size>
|
||||
%{ endif ~}
|
||||
<!--<partition_nr t="integer">${index}</partition_nr>-->
|
||||
</partition>
|
||||
%{ endfor ~}
|
||||
</partitions>
|
||||
<type t="symbol">CT_DISK</type>
|
||||
<use>all</use>
|
||||
</drive>
|
||||
%{ for index, volume_group in lvm ~}
|
||||
<drive t="map">
|
||||
<device>/dev/${volume_group.name}</device>
|
||||
<enable_snapshots t="boolean">false</enable_snapshots>
|
||||
<partitions t="list">
|
||||
%{ for partition in volume_group.partitions ~}
|
||||
<partition t="map">
|
||||
<create t="boolean">true</create>
|
||||
%{ if partition.format.fstype == "swap" ~}
|
||||
<filesystem config:type="symbol">swap</filesystem>
|
||||
<mount>swap</mount>
|
||||
%{ else ~}
|
||||
<filesystem config:type="symbol">${partition.format.fstype}</filesystem>
|
||||
<mount>${partition.mount.path}</mount>
|
||||
%{ endif ~}
|
||||
<lv_name>${partition.name}</lv_name>
|
||||
<format t="boolean">false</format>
|
||||
<mountby t="symbol">device</mountby>
|
||||
<pool t="boolean">false</pool>
|
||||
<resize t="boolean">false</resize>
|
||||
%{ if partition.mount.options != "" ~}
|
||||
<fstopt>${partition.mount.options}</fstopt>
|
||||
%{ endif ~}
|
||||
%{ if partition.size != -1 ~}
|
||||
<size>${partition.size}M</size>
|
||||
%{ else ~}
|
||||
<size>max</size>
|
||||
%{ endif ~}
|
||||
<stripes t="integer">1</stripes>
|
||||
<stripesize t="integer">0</stripesize>
|
||||
</partition>
|
||||
%{ endfor ~}
|
||||
</partitions>
|
||||
<pesize>4194304</pesize>
|
||||
<type t="symbol">CT_LVM</type>
|
||||
</drive>
|
||||
%{ endfor ~}
|
||||
</partitioning>
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
openSUSE-Leap 15.6 variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// Guest Operating System Metadata
|
||||
vm_os_language = "en_US"
|
||||
vm_os_keyboard = "us"
|
||||
vm_os_timezone = "UTC"
|
||||
vm_os_family = "linux"
|
||||
vm_os_name = "opensuse-leap"
|
||||
vm_os_version = "15.6"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
vm_cloudinit = true
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "ovmf"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "x86-64-v2-AES"
|
||||
vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
iso_file = "openSUSE-Leap-15.6-DVD-x86_64-Media.iso"
|
||||
iso_checksum = "file:https://download.opensuse.org/distribution/leap/15.6/iso/openSUSE-Leap-15.6-DVD-x86_64-Media.iso.sha256"
|
||||
|
||||
// Boot Settings
|
||||
vm_boot = "order=virtio0;ide2;net0"
|
||||
vm_boot_wait = "5s"
|
||||
|
||||
// EFI Settings
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
224
builds/linux/opensuse/leap-15-6/linux-opensuse-leap.pkr.hcl
Normal file
224
builds/linux/opensuse/leap-15-6/linux-opensuse-leap.pkr.hcl
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
openSUSE-Leap 15.6 template using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: packer
|
||||
// The Packer configuration.
|
||||
|
||||
packer {
|
||||
required_version = ">= 1.9.1"
|
||||
required_plugins {
|
||||
ansible = {
|
||||
source = "github.com/hashicorp/ansible"
|
||||
version = "~> 1"
|
||||
}
|
||||
git = {
|
||||
version = ">= 0.4.2"
|
||||
source = "github.com/ethanmdavidson/git"
|
||||
}
|
||||
proxmox = {
|
||||
version = ">= 1.1.6"
|
||||
source = "github.com/hashicorp/proxmox"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BLOCK: data
|
||||
// Defines the data sources.
|
||||
|
||||
data "git-repository" "cwd" {}
|
||||
|
||||
// BLOCK: locals
|
||||
// Defines the local variables.
|
||||
|
||||
locals {
|
||||
|
||||
bios_boot_command = [
|
||||
"<esc><enter><wait>",
|
||||
"linux ",
|
||||
"biosdevname=0 ",
|
||||
"net.ifnames=0 ",
|
||||
"netdevice=eth0 ",
|
||||
"netsetup=dhcp ",
|
||||
"lang=en_US ",
|
||||
"textmode=1 ",
|
||||
"${local.data_source_command}",
|
||||
"<enter><wait>",
|
||||
]
|
||||
|
||||
uefi_boot_command = [
|
||||
// This sends the "escape" key. In the GRUB boot loader, this is used to enter command line mode.
|
||||
"<esc>",
|
||||
// This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option.
|
||||
"e",
|
||||
// This sends four "down arrow" keys and then the "end" key. This is used to navigate to a specific line in the boot menu option's configuration.
|
||||
"<down><down><down><down><end>",
|
||||
// This types the value of the 'data_source_command' local variable. This is used to specify the kickstart data source configured in the common variables.
|
||||
"${local.data_source_command}",
|
||||
// This sends the "F10" key. In the GRUB boot loader, this is used to save the changes and exit the boot menu option's configuration, and then continue the boot process.
|
||||
"<f10>"
|
||||
]
|
||||
|
||||
build_by = "Built by: HashiCorp Packer ${packer.version}"
|
||||
build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" )
|
||||
build_version = data.git-repository.cwd.head
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}"
|
||||
vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda"
|
||||
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
|
||||
manifest_path = "${path.cwd}/manifests/"
|
||||
manifest_output = "${local.manifest_path}${local.manifest_date}.json"
|
||||
data_source_content = {
|
||||
"/autoinst.xml" = templatefile("${abspath(path.root)}/data/autoinst.pkrtpl.hcl", {
|
||||
build_username = var.build_username
|
||||
build_password = var.build_password
|
||||
build_password_encrypted = var.build_password_encrypted
|
||||
vm_disk_type = local.vm_disk_type
|
||||
vm_os_language = var.vm_os_language
|
||||
vm_os_keyboard = var.vm_os_keyboard
|
||||
vm_os_timezone = var.vm_os_timezone
|
||||
common_data_source = var.common_data_source
|
||||
# vm_bios needs to be here to help determine the bootloader
|
||||
vm_bios = var.vm_bios
|
||||
storage = templatefile("${abspath(path.root)}/data/storage.pkrtpl.hcl", {
|
||||
device = var.vm_disk_device
|
||||
swap = var.vm_disk_use_swap
|
||||
partitions = var.vm_disk_partitions
|
||||
lvm = var.vm_disk_lvm
|
||||
vm_bios = var.vm_bios
|
||||
})
|
||||
additional_packages = var.additional_packages
|
||||
})
|
||||
}
|
||||
data_source_command = var.common_data_source == "http" ? " autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinst.xml" : " netsetup=dhcp autoyast=device://sr1/autoinst.xml"
|
||||
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||
boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command
|
||||
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||
}
|
||||
|
||||
// BLOCK: source
|
||||
// Defines the builder configuration blocks.
|
||||
|
||||
source "proxmox-iso" "linux-opensuse-leap" {
|
||||
|
||||
// Proxmox Connection Settings and Credentials
|
||||
proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json"
|
||||
username = "${var.proxmox_api_token_id}"
|
||||
token = "${var.proxmox_api_token_secret}"
|
||||
insecure_skip_tls_verify = "${var.proxmox_insecure_connection}"
|
||||
|
||||
// Proxmox Settings
|
||||
node = "${var.proxmox_node}"
|
||||
|
||||
// Virtual Machine Settings
|
||||
vm_name = "${local.vm_name}"
|
||||
bios = "${var.vm_bios}"
|
||||
sockets = "${var.vm_cpu_sockets}"
|
||||
cores = "${var.vm_cpu_count}"
|
||||
cpu_type = "${var.vm_cpu_type}"
|
||||
memory = "${var.vm_mem_size}"
|
||||
os = "${var.vm_os_type}"
|
||||
scsi_controller = "${var.vm_disk_controller_type}"
|
||||
disks {
|
||||
disk_size = "${var.vm_disk_size}"
|
||||
type = "${var.vm_disk_type}"
|
||||
storage_pool = "${var.vm_storage_pool}"
|
||||
format = "${var.vm_disk_format}"
|
||||
}
|
||||
dynamic "efi_config" {
|
||||
for_each = var.vm_bios == "ovmf" ? [1] : []
|
||||
content {
|
||||
efi_storage_pool = var.vm_bios == "ovmf" ? var.vm_efi_storage_pool : null
|
||||
efi_type = var.vm_bios == "ovmf" ? var.vm_efi_type : null
|
||||
pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null
|
||||
}
|
||||
}
|
||||
unmount_iso = true
|
||||
ssh_username = "${var.build_username}"
|
||||
ssh_password = "${var.build_password}"
|
||||
ssh_timeout = "${var.timeout}"
|
||||
ssh_port = "22"
|
||||
iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}"
|
||||
iso_checksum = "${var.iso_checksum}"
|
||||
qemu_agent = true
|
||||
|
||||
network_adapters {
|
||||
bridge = "${var.vm_bridge_interface}"
|
||||
model = "${var.vm_network_card_model}"
|
||||
vlan_tag = "${var.vm_vlan_tag}"
|
||||
}
|
||||
|
||||
// Removable Media Settings
|
||||
http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null
|
||||
|
||||
// Boot and Provisioning Settings
|
||||
http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null
|
||||
http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null
|
||||
http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null
|
||||
boot = var.vm_boot
|
||||
boot_wait = var.vm_boot_wait
|
||||
boot_command = local.boot_command
|
||||
|
||||
dynamic "additional_iso_files" {
|
||||
for_each = var.common_data_source == "disk" ? [1] : []
|
||||
content {
|
||||
cd_files = var.common_data_source == "disk" ? local.data_source_content : null
|
||||
cd_label = var.common_data_source == "disk" ? "cidata" : null
|
||||
iso_storage_pool = var.common_data_source == "disk" ? "local" : null
|
||||
}
|
||||
}
|
||||
|
||||
template_name = "${local.vm_name}"
|
||||
template_description = "${local.build_description}"
|
||||
|
||||
# VM Cloud Init Settings
|
||||
cloud_init = var.vm_cloudinit
|
||||
cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null
|
||||
|
||||
}
|
||||
|
||||
# Build Definition to create the VM Template
|
||||
build {
|
||||
sources = ["source.proxmox-iso.linux-opensuse-leap"]
|
||||
|
||||
provisioner "ansible" {
|
||||
user = "${var.build_username}"
|
||||
galaxy_file = "${path.cwd}/ansible/linux-requirements.yml"
|
||||
galaxy_force_with_deps = true
|
||||
playbook_file = "${path.cwd}/ansible/linux-playbook.yml"
|
||||
roles_path = "${path.cwd}/ansible/roles"
|
||||
ansible_env_vars = [
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
|
||||
"ANSIBLE_PYTHON_INTERPRETER=/usr/bin/python3"
|
||||
]
|
||||
extra_arguments = [
|
||||
"--extra-vars", "display_skipped_hosts=false",
|
||||
"--extra-vars", "build_username=${var.build_username}",
|
||||
"--extra-vars", "build_key='${var.build_key}'",
|
||||
"--extra-vars", "ansible_username=${var.ansible_username}",
|
||||
"--extra-vars", "ansible_key='${var.ansible_key}'",
|
||||
"--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'",
|
||||
]
|
||||
}
|
||||
|
||||
post-processor "manifest" {
|
||||
output = local.manifest_output
|
||||
strip_path = true
|
||||
strip_time = true
|
||||
custom_data = {
|
||||
ansible_username = "${var.ansible_username}"
|
||||
build_username = "${var.build_username}"
|
||||
build_date = "${local.build_date}"
|
||||
build_version = "${local.build_version}"
|
||||
common_data_source = "${var.common_data_source}"
|
||||
vm_cpu_sockets = "${var.vm_cpu_sockets}"
|
||||
vm_cpu_count = "${var.vm_cpu_count}"
|
||||
vm_disk_size = "${var.vm_disk_size}"
|
||||
vm_bios = "${var.vm_bios}"
|
||||
vm_os_type = "${var.vm_os_type}"
|
||||
vm_mem_size = "${var.vm_mem_size}"
|
||||
vm_network_card_model = "${var.vm_network_card_model}"
|
||||
vm_cloudinit = "${var.vm_cloudinit}"
|
||||
}
|
||||
}
|
||||
}
|
||||
36
builds/linux/opensuse/leap-15-6/variables-network.pkr.hcl
Normal file
36
builds/linux/opensuse/leap-15-6/variables-network.pkr.hcl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Debian Linux 11 network variables used by the Packer Plugin for VMware vSphere (vsphere-iso).
|
||||
*/
|
||||
|
||||
// VM Network Settings
|
||||
|
||||
variable "vm_network_device" {
|
||||
type = string
|
||||
description = "The network device of the VM."
|
||||
default = "ens192"
|
||||
}
|
||||
|
||||
variable "vm_ip_address" {
|
||||
type = string
|
||||
description = "The IP address of the VM (e.g. 172.16.100.192)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_netmask" {
|
||||
type = number
|
||||
description = "The netmask of the VM (e.g. 24)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_gateway" {
|
||||
type = string
|
||||
description = "The gateway of the VM (e.g. 172.16.100.1)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_dns_list" {
|
||||
type = list(string)
|
||||
description = "The nameservers of the VM."
|
||||
default = []
|
||||
}
|
||||
53
builds/linux/opensuse/leap-15-6/variables-storage.pkr.hcl
Normal file
53
builds/linux/opensuse/leap-15-6/variables-storage.pkr.hcl
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
openSUSE-Leap 15.6 storage variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// VM Storage Settings
|
||||
|
||||
variable "vm_disk_device" {
|
||||
type = string
|
||||
description = "The device for the virtual disk. (e.g. 'sda')"
|
||||
}
|
||||
|
||||
variable "vm_disk_use_swap" {
|
||||
type = bool
|
||||
description = "Whether to use a swap partition."
|
||||
}
|
||||
|
||||
variable "vm_disk_partitions" {
|
||||
type = list(object({
|
||||
name = string
|
||||
size = number
|
||||
format = object({
|
||||
label = string
|
||||
fstype = string
|
||||
})
|
||||
mount = object({
|
||||
path = string
|
||||
options = string
|
||||
})
|
||||
volume_group = string
|
||||
}))
|
||||
description = "The disk partitions for the virtual disk."
|
||||
}
|
||||
|
||||
variable "vm_disk_lvm" {
|
||||
type = list(object({
|
||||
name = string
|
||||
partitions = list(object({
|
||||
name = string
|
||||
size = number
|
||||
format = object({
|
||||
label = string
|
||||
fstype = string
|
||||
})
|
||||
mount = object({
|
||||
path = string
|
||||
options = string
|
||||
})
|
||||
}))
|
||||
}))
|
||||
description = "The LVM configuration for the virtual disk."
|
||||
default = []
|
||||
}
|
||||
307
builds/linux/opensuse/leap-15-6/variables.pkr.hcl
Normal file
307
builds/linux/opensuse/leap-15-6/variables.pkr.hcl
Normal file
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
openSUSE Leap 15.6 variables using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: variable
|
||||
// Defines the input variables.
|
||||
|
||||
// Proxmox Credentials
|
||||
|
||||
variable "proxmox_hostname" {
|
||||
type = string
|
||||
description = "The FQDN or IP address of a Proxmox node. Only one node should be specified in a cluster."
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_id" {
|
||||
type = string
|
||||
description = "The token to login to the Proxmox node/cluster. The format is USER@REALM!TOKENID. (e.g. packer@pam!packer_pve_token)"
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_secret" {
|
||||
type = string
|
||||
description = "The secret for the API token used to login to the Proxmox API."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "proxmox_insecure_connection" {
|
||||
description = "true/false to skip Proxmox TLS certificate checks."
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
// Proxmox Settings
|
||||
|
||||
variable "proxmox_node" {
|
||||
type = string
|
||||
description = "The name of the Proxmox node that Packer will build templates on."
|
||||
}
|
||||
|
||||
// Virtual Machine Settings
|
||||
|
||||
variable "vm_os_language" {
|
||||
type = string
|
||||
description = "The guest operating system language."
|
||||
default = "en_US"
|
||||
}
|
||||
|
||||
variable "vm_os_keyboard" {
|
||||
type = string
|
||||
description = "The guest operating system keyboard layout."
|
||||
default = "us"
|
||||
}
|
||||
|
||||
variable "vm_os_timezone" {
|
||||
type = string
|
||||
description = "The guest operating system timezone."
|
||||
default = "UTC"
|
||||
}
|
||||
|
||||
variable "vm_os_family" {
|
||||
type = string
|
||||
description = "The guest operating system family. Used for naming. (e.g. 'linux')"
|
||||
}
|
||||
|
||||
variable "vm_os_name" {
|
||||
type = string
|
||||
description = "The guest operating system name. Used for naming. (e.g. 'ubuntu')"
|
||||
}
|
||||
|
||||
variable "vm_os_version" {
|
||||
type = string
|
||||
description = "The guest operating system version. Used for naming. (e.g. '22-04-lts')"
|
||||
}
|
||||
|
||||
variable "vm_os_type" {
|
||||
type = string
|
||||
description = "The guest operating system type. (e.g. 'l26')"
|
||||
}
|
||||
|
||||
variable "vm_bios" {
|
||||
type = string
|
||||
description = "The firmware type. Allowed values 'ovmf' or 'seabios'"
|
||||
default = "ovmf"
|
||||
|
||||
validation {
|
||||
condition = contains(["ovmf", "seabios"], var.vm_bios)
|
||||
error_message = "The vm_bios value must be 'ovmf' or 'seabios'."
|
||||
}
|
||||
}
|
||||
|
||||
variable "vm_firmware_path" {
|
||||
type = string
|
||||
description = "The firmware file to be used. Needed for EFI"
|
||||
default = "/usr/share/ovmf/OVMF.fd"
|
||||
}
|
||||
|
||||
variable "vm_efi_storage_pool" {
|
||||
type = string
|
||||
description = "Set the UEFI disk storage location. (e.g. 'local-lvm')"
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "vm_efi_type" {
|
||||
type = string
|
||||
description = "Specifies the version of the OVMF firmware to be used. (e.g. '4m')"
|
||||
default = "4m"
|
||||
}
|
||||
|
||||
variable "vm_efi_pre_enrolled_keys" {
|
||||
type = bool
|
||||
description = "Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "vm_cpu_count" {
|
||||
type = number
|
||||
description = "The number of virtual CPUs. (e.g. '2')"
|
||||
}
|
||||
|
||||
variable "vm_cpu_sockets" {
|
||||
type = number
|
||||
description = "The number of virtual CPU sockets. (e.g. '1')"
|
||||
}
|
||||
|
||||
variable "vm_cpu_type" {
|
||||
type = string
|
||||
description = "The CPU type to emulate. See the Proxmox API documentation for the complete list of accepted values. For best performance, set this to host. Defaults to kvm64."
|
||||
}
|
||||
|
||||
variable "vm_mem_size" {
|
||||
type = number
|
||||
description = "The size for the virtual memory in MB. (e.g. '2048')"
|
||||
}
|
||||
|
||||
variable "vm_disk_controller_type" {
|
||||
type = string
|
||||
description = "The SCSI controller model to emulate. (e.g. 'virtio-scsi-pci')"
|
||||
}
|
||||
|
||||
variable "vm_disk_type" {
|
||||
type = string
|
||||
description = "The type of disk to emulate. (e.g. 'virtio')"
|
||||
}
|
||||
|
||||
variable "vm_storage_pool" {
|
||||
type = string
|
||||
description = "The name of the Proxmox storage pool to store the VM template. (e.g. 'local-lvm')"
|
||||
}
|
||||
|
||||
variable "vm_disk_size" {
|
||||
type = string
|
||||
description = "The size for the virtual disk in GB. (e.g. '32G')"
|
||||
}
|
||||
|
||||
variable "vm_disk_format" {
|
||||
type = string
|
||||
description = "The format of the file backing the disk. (e.g. 'qcow2')"
|
||||
}
|
||||
|
||||
variable "vm_network_card_model" {
|
||||
type = string
|
||||
description = "The model of the virtual network adapter to emulate. (e.g. 'virtio')"
|
||||
}
|
||||
|
||||
variable "vm_bridge_interface" {
|
||||
type = string
|
||||
description = "The name of the Proxmox bridge to attach the adapter to."
|
||||
}
|
||||
|
||||
variable "vm_vlan_tag" {
|
||||
type = string
|
||||
description = "If the adapter should tag packets, give the VLAN ID. (e.g. '102')"
|
||||
}
|
||||
|
||||
// Cloud-Init Settings
|
||||
|
||||
variable "vm_cloudinit" {
|
||||
type = bool
|
||||
description = "Enable or disable cloud-init drive in Proxmox. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
// Removable Media Settings
|
||||
|
||||
variable "common_iso_storage" {
|
||||
type = string
|
||||
description = "The name of the source Proxmox storage location for ISO images. (e.g. 'local-lvm')"
|
||||
}
|
||||
|
||||
variable "iso_path" {
|
||||
type = string
|
||||
description = "The path on the source Proxmox storage location for ISO images. (e.g. 'iso')"
|
||||
}
|
||||
|
||||
variable "iso_file" {
|
||||
type = string
|
||||
description = "The file name of the ISO image used by the vendor. (e.g. 'ubuntu-<version>-live-server-amd64.iso')"
|
||||
}
|
||||
|
||||
variable "iso_checksum" {
|
||||
type = string
|
||||
description = "The checksum value of the ISO image provided by the vendor."
|
||||
}
|
||||
|
||||
// Boot Settings
|
||||
|
||||
variable "common_data_source" {
|
||||
type = string
|
||||
description = "The provisioning data source. (e.g. 'http' or 'disk')"
|
||||
}
|
||||
|
||||
variable "common_http_bind_address" {
|
||||
type = string
|
||||
description = "Define an IP address on the host to use for the HTTP server."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "common_http_port_min" {
|
||||
type = number
|
||||
description = "The start of the HTTP port range."
|
||||
}
|
||||
|
||||
variable "common_http_port_max" {
|
||||
type = number
|
||||
description = "The end of the HTTP port range."
|
||||
}
|
||||
|
||||
variable "vm_boot" {
|
||||
type = string
|
||||
description = "The boot order for virtual machine devices. (e.g. 'order=virtio0;ide2;net0')"
|
||||
}
|
||||
|
||||
variable "vm_boot_wait" {
|
||||
type = string
|
||||
description = "The time to wait after booting the initial VM before typing the boot_command (e.g '10s')"
|
||||
}
|
||||
|
||||
variable "common_ip_wait_timeout" {
|
||||
type = string
|
||||
description = "Time to wait for guest operating system IP address response."
|
||||
}
|
||||
|
||||
variable "common_shutdown_timeout" {
|
||||
type = string
|
||||
description = "Time to wait for guest operating system shutdown."
|
||||
}
|
||||
|
||||
// Communicator Settings and Credentials
|
||||
|
||||
variable "build_username" {
|
||||
type = string
|
||||
description = "The username to login to the guest operating system. (e.g. 'ubuntu')"
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_password" {
|
||||
type = string
|
||||
description = "The password to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_password_encrypted" {
|
||||
type = string
|
||||
description = "The encrypted password to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_key" {
|
||||
type = string
|
||||
description = "The SSH public key to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "timeout" {
|
||||
description = "not sure why I need so high a timeout but here we are"
|
||||
default = "90m"
|
||||
}
|
||||
|
||||
// Ansible Credentials
|
||||
|
||||
variable "ansible_username" {
|
||||
type = string
|
||||
description = "The username for Ansible to login to the guest operating system. (e.g. 'ansible')"
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "ansible_key" {
|
||||
type = string
|
||||
description = "The public key for Ansible to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
// HCP Packer Settings
|
||||
|
||||
variable "common_hcp_packer_registry_enabled" {
|
||||
type = bool
|
||||
description = "Enable the HCP Packer registry."
|
||||
default = false
|
||||
}
|
||||
|
||||
// Additional Settings
|
||||
|
||||
variable "additional_packages" {
|
||||
type = list(string)
|
||||
description = "Additional packages to install."
|
||||
default = []
|
||||
}
|
||||
85
builds/linux/oracle/8/data/ks.pkrtpl.hcl
Normal file
85
builds/linux/oracle/8/data/ks.pkrtpl.hcl
Normal file
@@ -0,0 +1,85 @@
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Oracle Linux 8
|
||||
|
||||
### Installs from the first attached CD-ROM/DVD on the system.
|
||||
cdrom
|
||||
|
||||
### Performs the kickstart installation in text mode.
|
||||
### By default, kickstart installations are performed in graphical mode.
|
||||
text
|
||||
|
||||
### Accepts the End User License Agreement.
|
||||
eula --agreed
|
||||
|
||||
### Sets the language to use during installation and the default language to use on the installed system.
|
||||
lang ${vm_os_language}
|
||||
|
||||
### Sets the default keyboard type for the system.
|
||||
keyboard ${vm_os_keyboard}
|
||||
|
||||
### Configure network information for target system and activate network devices in the installer environment (optional)
|
||||
### --onboot enable device at a boot time
|
||||
### --device device to be activated and / or configured with the network command
|
||||
### --bootproto method to obtain networking configuration for device (default dhcp)
|
||||
### --noipv6 disable IPv6 on this device
|
||||
${network}
|
||||
|
||||
### Lock the root account.
|
||||
rootpw --lock
|
||||
|
||||
### The selected profile will restrict root login.
|
||||
### Add a user that can login and escalate privileges.
|
||||
user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel
|
||||
|
||||
### Configure firewall settings for the system.
|
||||
### --enabled reject incoming connections that are not in response to outbound requests
|
||||
### --ssh allow sshd service through the firewall
|
||||
firewall --enabled --ssh
|
||||
|
||||
### Sets up the authentication options for the system.
|
||||
### The SSSD profile sets sha512 to hash passwords. Passwords are shadowed by default
|
||||
### See the manual page for authselect-profile for a complete list of possible options.
|
||||
authselect select sssd
|
||||
|
||||
### Sets the state of SELinux on the installed system.
|
||||
### Defaults to enforcing.
|
||||
selinux --enforcing
|
||||
|
||||
### Sets the system time zone.
|
||||
timezone ${vm_os_timezone}
|
||||
|
||||
### Partitioning
|
||||
${storage}
|
||||
|
||||
### Modifies the default set of services that will run under the default runlevel.
|
||||
services --enabled=NetworkManager,sshd
|
||||
|
||||
### Do not configure X on the installed system.
|
||||
skipx
|
||||
|
||||
### Packages selection.
|
||||
%packages --ignoremissing --excludedocs
|
||||
@core
|
||||
-iwl*firmware
|
||||
%end
|
||||
|
||||
### Post-installation commands.
|
||||
%post
|
||||
dnf makecache
|
||||
dnf install epel-release -y
|
||||
dnf makecache
|
||||
dnf install -y sudo qemu-guest-tools
|
||||
%{ if additional_packages != "" ~}
|
||||
dnf install -y ${additional_packages}
|
||||
%{ endif ~}
|
||||
echo "${build_username} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/${build_username}
|
||||
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
|
||||
%end
|
||||
|
||||
### Reboot after the installation is complete.
|
||||
### --eject attempt to eject the media before rebooting.
|
||||
reboot --eject
|
||||
5
builds/linux/oracle/8/data/network.pkrtpl.hcl
Normal file
5
builds/linux/oracle/8/data/network.pkrtpl.hcl
Normal file
@@ -0,0 +1,5 @@
|
||||
%{ if ip != null ~}
|
||||
network --device=${device} --bootproto=static --ip=${ip} --netmask=${cidrnetmask("${ip}/${netmask}")} --gateway=${gateway} --nameserver=${join(",", dns)}
|
||||
%{ else ~}
|
||||
network --device=${device} --bootproto=dhcp
|
||||
%{ endif ~}
|
||||
76
builds/linux/oracle/8/data/storage.pkrtpl.hcl
Normal file
76
builds/linux/oracle/8/data/storage.pkrtpl.hcl
Normal file
@@ -0,0 +1,76 @@
|
||||
### Sets how the boot loader should be installed.
|
||||
bootloader --location=mbr
|
||||
|
||||
### Initialize any invalid partition tables found on disks.
|
||||
zerombr
|
||||
|
||||
### Removes partitions from the system, prior to creation of new partitions.
|
||||
### By default, no partitions are removed.
|
||||
### --all Erases all partitions from the system
|
||||
### --initlabel Initializes a disk (or disks) by creating a default disk label for all disks in their respective architecture.
|
||||
clearpart --all --initlabel
|
||||
|
||||
### Modify partition sizes for the virtual machine hardware.
|
||||
### Create primary system partitions.
|
||||
%{ for partition in partitions ~}
|
||||
part
|
||||
%{~ if partition.volume_group != "" ~}
|
||||
pv.${partition.volume_group}
|
||||
%{~ else ~}
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.format.fstype != "" ~}
|
||||
--label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
|
||||
%{ endfor ~}
|
||||
%{ if vm_bios == "seabios" ~}
|
||||
part biosboot --fstype="biosboot" --ondisk=${device} --size=1
|
||||
%{ endif ~}
|
||||
### Create a logical volume management (LVM) group.
|
||||
%{ for index, volume_group in lvm ~}
|
||||
volgroup sysvg pv.${volume_group.name}
|
||||
|
||||
### Modify logical volume sizes for the virtual machine hardware.
|
||||
### Create logical volumes.
|
||||
%{ for partition in volume_group.partitions ~}
|
||||
logvol
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
--name=${partition.name} --vgname=${volume_group.name} --label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
|
||||
%{ endfor ~}
|
||||
%{ endfor ~}
|
||||
40
builds/linux/oracle/8/linux-oracle.auto.pkrvars.hcl
Normal file
40
builds/linux/oracle/8/linux-oracle.auto.pkrvars.hcl
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Oracle Linux 8 variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// Guest Operating System Metadata
|
||||
vm_os_language = "en_US"
|
||||
vm_os_keyboard = "us"
|
||||
vm_os_timezone = "UTC"
|
||||
vm_os_family = "linux"
|
||||
vm_os_name = "oracle"
|
||||
vm_os_version = "8.10"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
vm_cloudinit = true
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "ovmf"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "kvm64"
|
||||
vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
iso_file = "OracleLinux-R8-U10-x86_64-dvd.iso"
|
||||
iso_checksum = "file:https://linux.oracle.com/security/gpg/checksum/OracleLinux-R8-U10-Server-x86_64.checksum"
|
||||
|
||||
// Boot Settings
|
||||
vm_boot = "order=virtio0;ide2;net0"
|
||||
vm_boot_wait = "10s"
|
||||
|
||||
// EFI Settings
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
227
builds/linux/oracle/8/linux-oracle.pkr.hcl
Normal file
227
builds/linux/oracle/8/linux-oracle.pkr.hcl
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Oracle Linux 8 template using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: packer
|
||||
// The Packer configuration.
|
||||
|
||||
packer {
|
||||
required_version = ">= 1.11.0"
|
||||
required_plugins {
|
||||
ansible = {
|
||||
source = "github.com/hashicorp/ansible"
|
||||
version = "~> 1"
|
||||
}
|
||||
git = {
|
||||
version = ">= 0.6.2"
|
||||
source = "github.com/ethanmdavidson/git"
|
||||
}
|
||||
proxmox = {
|
||||
version = ">= 1.1.8"
|
||||
source = "github.com/hashicorp/proxmox"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BLOCK: data
|
||||
// Defines the data sources.
|
||||
|
||||
data "git-repository" "cwd" {}
|
||||
|
||||
// BLOCK: locals
|
||||
// Defines the local variables.
|
||||
|
||||
locals {
|
||||
bios_boot_command = [
|
||||
// This sends the "up arrow" key, typically used to navigate through boot menu options.
|
||||
"<up>",
|
||||
// This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options.
|
||||
"<tab>",
|
||||
"inst.text biosdevname=0 net.ifnames=0 inst.gpt",
|
||||
" ${local.data_source_command}",
|
||||
"<enter><wait>"
|
||||
]
|
||||
uefi_boot_command = [
|
||||
// This sends the "up arrow" key, typically used to navigate through boot menu options.
|
||||
"<up>",
|
||||
// This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option.
|
||||
"e",
|
||||
// This sends two "down arrow" keys, followed by the "end" key, and then waits. This is used to navigate to a specific line in the boot menu option's configuration.
|
||||
"<down><down><end><wait>",
|
||||
// This types the string "text" followed by the value of the 'data_source_command' local variable.
|
||||
// This is used to modify the boot menu option's configuration to boot in text mode and specify the kickstart data source configured in the common variables.
|
||||
"text ${local.data_source_command}",
|
||||
// This sends the "enter" key, waits, turns on the left control key, sends the "x" key, and then turns off the left control key. This is used to save the changes and exit the boot menu option's configuration, and then continue the boot process.
|
||||
"<enter><wait><leftCtrlOn>x<leftCtrlOff>"
|
||||
]
|
||||
build_by = "Built by: HashiCorp Packer ${packer.version}"
|
||||
build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" )
|
||||
build_version = data.git-repository.cwd.head
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}"
|
||||
vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda"
|
||||
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
|
||||
manifest_path = "${path.cwd}/manifests/"
|
||||
manifest_output = "${local.manifest_path}${local.manifest_date}.json"
|
||||
data_source_content = {
|
||||
"/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", {
|
||||
build_username = var.build_username
|
||||
build_password = var.build_password
|
||||
build_password_encrypted = var.build_password_encrypted
|
||||
vm_disk_type = local.vm_disk_type
|
||||
vm_os_language = var.vm_os_language
|
||||
vm_os_keyboard = var.vm_os_keyboard
|
||||
vm_os_timezone = var.vm_os_timezone
|
||||
|
||||
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
|
||||
device = var.vm_bridge_interface
|
||||
ip = var.vm_ip_address
|
||||
netmask = var.vm_ip_netmask
|
||||
gateway = var.vm_ip_gateway
|
||||
dns = var.vm_dns_list
|
||||
})
|
||||
common_data_source = var.common_data_source
|
||||
# lvm needs to be here so late commands can access vg names
|
||||
#lvm = var.vm_disk_lvm
|
||||
storage = templatefile("${abspath(path.root)}/data/storage.pkrtpl.hcl", {
|
||||
device = var.vm_disk_device
|
||||
swap = var.vm_disk_use_swap
|
||||
partitions = var.vm_disk_partitions
|
||||
lvm = var.vm_disk_lvm
|
||||
vm_bios = var.vm_bios
|
||||
})
|
||||
additional_packages = join(" ", var.additional_packages)
|
||||
})
|
||||
}
|
||||
data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks.cfg" : "inst.ks=/cdrom/ks.cfg"
|
||||
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||
boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command
|
||||
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||
}
|
||||
|
||||
// BLOCK: source
|
||||
// Defines the builder configuration blocks.
|
||||
|
||||
source "proxmox-iso" "linux-oracle" {
|
||||
|
||||
// Proxmox Connection Settings and Credentials
|
||||
proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json"
|
||||
username = "${var.proxmox_api_token_id}"
|
||||
token = "${var.proxmox_api_token_secret}"
|
||||
insecure_skip_tls_verify = "${var.proxmox_insecure_connection}"
|
||||
|
||||
// Proxmox Settings
|
||||
node = "${var.proxmox_node}"
|
||||
|
||||
// Virtual Machine Settings
|
||||
vm_name = "${local.vm_name}"
|
||||
bios = "${var.vm_bios}"
|
||||
sockets = "${var.vm_cpu_sockets}"
|
||||
cores = "${var.vm_cpu_count}"
|
||||
cpu_type = "${var.vm_cpu_type}"
|
||||
memory = "${var.vm_mem_size}"
|
||||
os = "${var.vm_os_type}"
|
||||
scsi_controller = "${var.vm_disk_controller_type}"
|
||||
disks {
|
||||
disk_size = "${var.vm_disk_size}"
|
||||
type = "${var.vm_disk_type}"
|
||||
storage_pool = "${var.vm_storage_pool}"
|
||||
format = "${var.vm_disk_format}"
|
||||
}
|
||||
dynamic "efi_config" {
|
||||
for_each = var.vm_bios == "ovmf" ? [1] : []
|
||||
content {
|
||||
efi_storage_pool = var.vm_bios == "ovmf" ? var.vm_efi_storage_pool : null
|
||||
efi_type = var.vm_bios == "ovmf" ? var.vm_efi_type : null
|
||||
pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null
|
||||
}
|
||||
}
|
||||
unmount_iso = true
|
||||
ssh_username = "${var.build_username}"
|
||||
ssh_password = "${var.build_password}"
|
||||
ssh_timeout = "${var.timeout}"
|
||||
ssh_port = "22"
|
||||
iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}"
|
||||
iso_checksum = "${var.iso_checksum}"
|
||||
qemu_agent = true
|
||||
|
||||
network_adapters {
|
||||
bridge = "${var.vm_bridge_interface}"
|
||||
model = "${var.vm_network_card_model}"
|
||||
vlan_tag = "${var.vm_vlan_tag}"
|
||||
}
|
||||
|
||||
// Removable Media Settings
|
||||
http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null
|
||||
|
||||
// Boot and Provisioning Settings
|
||||
http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null
|
||||
http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null
|
||||
http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null
|
||||
boot = var.vm_boot
|
||||
boot_wait = var.vm_boot_wait
|
||||
boot_command = local.boot_command
|
||||
|
||||
dynamic "additional_iso_files" {
|
||||
for_each = var.common_data_source == "disk" ? [1] : []
|
||||
content {
|
||||
cd_files = var.common_data_source == "disk" ? local.data_source_content : null
|
||||
cd_label = var.common_data_source == "disk" ? "cidata" : null
|
||||
iso_storage_pool = var.common_data_source == "disk" ? "local" : null
|
||||
}
|
||||
}
|
||||
|
||||
template_name = "${local.vm_name}"
|
||||
template_description = "${local.build_description}"
|
||||
|
||||
# VM Cloud Init Settings
|
||||
cloud_init = var.vm_cloudinit
|
||||
cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null
|
||||
|
||||
}
|
||||
|
||||
# Build Definition to create the VM Template
|
||||
build {
|
||||
sources = ["source.proxmox-iso.linux-oracle"]
|
||||
|
||||
provisioner "ansible" {
|
||||
user = "${var.build_username}"
|
||||
galaxy_file = "${path.cwd}/ansible/linux-requirements.yml"
|
||||
galaxy_force_with_deps = true
|
||||
playbook_file = "${path.cwd}/ansible/linux-playbook.yml"
|
||||
roles_path = "${path.cwd}/ansible/roles"
|
||||
ansible_env_vars = [
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
|
||||
"ANSIBLE_PYTHON_INTERPRETER=/usr/libexec/platform-python"
|
||||
]
|
||||
extra_arguments = [
|
||||
"--extra-vars", "display_skipped_hosts=false",
|
||||
"--extra-vars", "build_username=${var.build_username}",
|
||||
"--extra-vars", "build_key='${var.build_key}'",
|
||||
"--extra-vars", "ansible_username=${var.ansible_username}",
|
||||
"--extra-vars", "ansible_key='${var.ansible_key}'",
|
||||
"--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'",
|
||||
]
|
||||
}
|
||||
|
||||
post-processor "manifest" {
|
||||
output = local.manifest_output
|
||||
strip_path = true
|
||||
strip_time = true
|
||||
custom_data = {
|
||||
ansible_username = "${var.ansible_username}"
|
||||
build_username = "${var.build_username}"
|
||||
build_date = "${local.build_date}"
|
||||
build_version = "${local.build_version}"
|
||||
common_data_source = "${var.common_data_source}"
|
||||
vm_cpu_sockets = "${var.vm_cpu_sockets}"
|
||||
vm_cpu_count = "${var.vm_cpu_count}"
|
||||
vm_disk_size = "${var.vm_disk_size}"
|
||||
vm_bios = "${var.vm_bios}"
|
||||
vm_os_type = "${var.vm_os_type}"
|
||||
vm_mem_size = "${var.vm_mem_size}"
|
||||
vm_network_card_model = "${var.vm_network_card_model}"
|
||||
vm_cloudinit = "${var.vm_cloudinit}"
|
||||
}
|
||||
}
|
||||
}
|
||||
36
builds/linux/oracle/8/variables-network.pkr.hcl
Normal file
36
builds/linux/oracle/8/variables-network.pkr.hcl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Oracle Linux 8 network variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// VM Network Settings
|
||||
|
||||
variable "vm_network_device" {
|
||||
type = string
|
||||
description = "The network device of the VM."
|
||||
default = "ens192"
|
||||
}
|
||||
|
||||
variable "vm_ip_address" {
|
||||
type = string
|
||||
description = "The IP address of the VM (e.g. 172.16.100.192)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_netmask" {
|
||||
type = number
|
||||
description = "The netmask of the VM (e.g. 24)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_gateway" {
|
||||
type = string
|
||||
description = "The gateway of the VM (e.g. 172.16.100.1)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_dns_list" {
|
||||
type = list(string)
|
||||
description = "The nameservers of the VM."
|
||||
default = []
|
||||
}
|
||||
53
builds/linux/oracle/8/variables-storage.pkr.hcl
Normal file
53
builds/linux/oracle/8/variables-storage.pkr.hcl
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Oracle Linux 8 storage variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// VM Storage Settings
|
||||
|
||||
variable "vm_disk_device" {
|
||||
type = string
|
||||
description = "The device for the virtual disk. (e.g. 'sda')"
|
||||
}
|
||||
|
||||
variable "vm_disk_use_swap" {
|
||||
type = bool
|
||||
description = "Whether to use a swap partition."
|
||||
}
|
||||
|
||||
variable "vm_disk_partitions" {
|
||||
type = list(object({
|
||||
name = string
|
||||
size = number
|
||||
format = object({
|
||||
label = string
|
||||
fstype = string
|
||||
})
|
||||
mount = object({
|
||||
path = string
|
||||
options = string
|
||||
})
|
||||
volume_group = string
|
||||
}))
|
||||
description = "The disk partitions for the virtual disk."
|
||||
}
|
||||
|
||||
variable "vm_disk_lvm" {
|
||||
type = list(object({
|
||||
name = string
|
||||
partitions = list(object({
|
||||
name = string
|
||||
size = number
|
||||
format = object({
|
||||
label = string
|
||||
fstype = string
|
||||
})
|
||||
mount = object({
|
||||
path = string
|
||||
options = string
|
||||
})
|
||||
}))
|
||||
}))
|
||||
description = "The LVM configuration for the virtual disk."
|
||||
default = []
|
||||
}
|
||||
307
builds/linux/oracle/8/variables.pkr.hcl
Normal file
307
builds/linux/oracle/8/variables.pkr.hcl
Normal file
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Oracle Linux 8 variables using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: variable
|
||||
// Defines the input variables.
|
||||
|
||||
// Proxmox Credentials
|
||||
|
||||
variable "proxmox_hostname" {
|
||||
type = string
|
||||
description = "The FQDN or IP address of a Proxmox node. Only one node should be specified in a cluster."
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_id" {
|
||||
type = string
|
||||
description = "The token to login to the Proxmox node/cluster. The format is USER@REALM!TOKENID. (e.g. packer@pam!packer_pve_token)"
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_secret" {
|
||||
type = string
|
||||
description = "The secret for the API token used to login to the Proxmox API."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "proxmox_insecure_connection" {
|
||||
description = "true/false to skip Proxmox TLS certificate checks."
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
// Proxmox Settings
|
||||
|
||||
variable "proxmox_node" {
|
||||
type = string
|
||||
description = "The name of the Proxmox node that Packer will build templates on."
|
||||
}
|
||||
|
||||
// Virtual Machine Settings
|
||||
|
||||
variable "vm_os_language" {
|
||||
type = string
|
||||
description = "The guest operating system language."
|
||||
default = "en_US"
|
||||
}
|
||||
|
||||
variable "vm_os_keyboard" {
|
||||
type = string
|
||||
description = "The guest operating system keyboard layout."
|
||||
default = "us"
|
||||
}
|
||||
|
||||
variable "vm_os_timezone" {
|
||||
type = string
|
||||
description = "The guest operating system timezone."
|
||||
default = "UTC"
|
||||
}
|
||||
|
||||
variable "vm_os_family" {
|
||||
type = string
|
||||
description = "The guest operating system family. Used for naming. (e.g. 'linux')"
|
||||
}
|
||||
|
||||
variable "vm_os_name" {
|
||||
type = string
|
||||
description = "The guest operating system name. Used for naming. (e.g. 'ubuntu')"
|
||||
}
|
||||
|
||||
variable "vm_os_version" {
|
||||
type = string
|
||||
description = "The guest operating system version. Used for naming. (e.g. '22-04-lts')"
|
||||
}
|
||||
|
||||
variable "vm_os_type" {
|
||||
type = string
|
||||
description = "The guest operating system type. (e.g. 'l26')"
|
||||
}
|
||||
|
||||
variable "vm_bios" {
|
||||
type = string
|
||||
description = "The firmware type. Allowed values 'ovmf' or 'seabios'"
|
||||
default = "ovmf"
|
||||
|
||||
validation {
|
||||
condition = contains(["ovmf", "seabios"], var.vm_bios)
|
||||
error_message = "The vm_bios value must be 'ovmf' or 'seabios'."
|
||||
}
|
||||
}
|
||||
|
||||
variable "vm_firmware_path" {
|
||||
type = string
|
||||
description = "The firmware file to be used. Needed for EFI"
|
||||
default = "/usr/share/ovmf/OVMF.fd"
|
||||
}
|
||||
|
||||
variable "vm_efi_storage_pool" {
|
||||
type = string
|
||||
description = "Set the UEFI disk storage location. (e.g. 'local-lvm')"
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "vm_efi_type" {
|
||||
type = string
|
||||
description = "Specifies the version of the OVMF firmware to be used. (e.g. '4m')"
|
||||
default = "4m"
|
||||
}
|
||||
|
||||
variable "vm_efi_pre_enrolled_keys" {
|
||||
type = bool
|
||||
description = "Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "vm_cpu_count" {
|
||||
type = number
|
||||
description = "The number of virtual CPUs. (e.g. '2')"
|
||||
}
|
||||
|
||||
variable "vm_cpu_sockets" {
|
||||
type = number
|
||||
description = "The number of virtual CPU sockets. (e.g. '1')"
|
||||
}
|
||||
|
||||
variable "vm_cpu_type" {
|
||||
type = string
|
||||
description = "The CPU type to emulate. See the Proxmox API documentation for the complete list of accepted values. For best performance, set this to host. Defaults to kvm64."
|
||||
}
|
||||
|
||||
variable "vm_mem_size" {
|
||||
type = number
|
||||
description = "The size for the virtual memory in MB. (e.g. '2048')"
|
||||
}
|
||||
|
||||
variable "vm_disk_controller_type" {
|
||||
type = string
|
||||
description = "The SCSI controller model to emulate. (e.g. 'virtio-scsi-pci')"
|
||||
}
|
||||
|
||||
variable "vm_disk_type" {
|
||||
type = string
|
||||
description = "The type of disk to emulate. (e.g. 'virtio')"
|
||||
}
|
||||
|
||||
variable "vm_storage_pool" {
|
||||
type = string
|
||||
description = "The name of the Proxmox storage pool to store the VM template. (e.g. 'local-lvm')"
|
||||
}
|
||||
|
||||
variable "vm_disk_size" {
|
||||
type = string
|
||||
description = "The size for the virtual disk in GB. (e.g. '32G')"
|
||||
}
|
||||
|
||||
variable "vm_disk_format" {
|
||||
type = string
|
||||
description = "The format of the file backing the disk. (e.g. 'qcow2')"
|
||||
}
|
||||
|
||||
variable "vm_network_card_model" {
|
||||
type = string
|
||||
description = "The model of the virtual network adapter to emulate. (e.g. 'virtio')"
|
||||
}
|
||||
|
||||
variable "vm_bridge_interface" {
|
||||
type = string
|
||||
description = "The name of the Proxmox bridge to attach the adapter to."
|
||||
}
|
||||
|
||||
variable "vm_vlan_tag" {
|
||||
type = string
|
||||
description = "If the adapter should tag packets, give the VLAN ID. (e.g. '102')"
|
||||
}
|
||||
|
||||
// Cloud-Init Settings
|
||||
|
||||
variable "vm_cloudinit" {
|
||||
type = bool
|
||||
description = "Enable or disable cloud-init drive in Proxmox. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
// Removable Media Settings
|
||||
|
||||
variable "common_iso_storage" {
|
||||
type = string
|
||||
description = "The name of the source Proxmox storage location for ISO images. (e.g. 'local-lvm')"
|
||||
}
|
||||
|
||||
variable "iso_path" {
|
||||
type = string
|
||||
description = "The path on the source Proxmox storage location for ISO images. (e.g. 'iso')"
|
||||
}
|
||||
|
||||
variable "iso_file" {
|
||||
type = string
|
||||
description = "The file name of the ISO image used by the vendor. (e.g. 'ubuntu-<version>-live-server-amd64.iso')"
|
||||
}
|
||||
|
||||
variable "iso_checksum" {
|
||||
type = string
|
||||
description = "The checksum value of the ISO image provided by the vendor."
|
||||
}
|
||||
|
||||
// Boot Settings
|
||||
|
||||
variable "common_data_source" {
|
||||
type = string
|
||||
description = "The provisioning data source. (e.g. 'http' or 'disk')"
|
||||
}
|
||||
|
||||
variable "common_http_bind_address" {
|
||||
type = string
|
||||
description = "Define an IP address on the host to use for the HTTP server."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "common_http_port_min" {
|
||||
type = number
|
||||
description = "The start of the HTTP port range."
|
||||
}
|
||||
|
||||
variable "common_http_port_max" {
|
||||
type = number
|
||||
description = "The end of the HTTP port range."
|
||||
}
|
||||
|
||||
variable "vm_boot" {
|
||||
type = string
|
||||
description = "The boot order for virtual machine devices. (e.g. 'order=virtio0;ide2;net0')"
|
||||
}
|
||||
|
||||
variable "vm_boot_wait" {
|
||||
type = string
|
||||
description = "The time to wait after booting the initial VM before typing the boot_command (e.g '10s')"
|
||||
}
|
||||
|
||||
variable "common_ip_wait_timeout" {
|
||||
type = string
|
||||
description = "Time to wait for guest operating system IP address response."
|
||||
}
|
||||
|
||||
variable "common_shutdown_timeout" {
|
||||
type = string
|
||||
description = "Time to wait for guest operating system shutdown."
|
||||
}
|
||||
|
||||
// Communicator Settings and Credentials
|
||||
|
||||
variable "build_username" {
|
||||
type = string
|
||||
description = "The username to login to the guest operating system. (e.g. 'ubuntu')"
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_password" {
|
||||
type = string
|
||||
description = "The password to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_password_encrypted" {
|
||||
type = string
|
||||
description = "The encrypted password to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_key" {
|
||||
type = string
|
||||
description = "The SSH public key to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "timeout" {
|
||||
description = "not sure why I need so high a timeout but here we are"
|
||||
default = "90m"
|
||||
}
|
||||
|
||||
// Ansible Credentials
|
||||
|
||||
variable "ansible_username" {
|
||||
type = string
|
||||
description = "The username for Ansible to login to the guest operating system. (e.g. 'ansible')"
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "ansible_key" {
|
||||
type = string
|
||||
description = "The public key for Ansible to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
// HCP Packer Settings
|
||||
|
||||
variable "common_hcp_packer_registry_enabled" {
|
||||
type = bool
|
||||
description = "Enable the HCP Packer registry."
|
||||
default = false
|
||||
}
|
||||
|
||||
// Additional Settings
|
||||
|
||||
variable "additional_packages" {
|
||||
type = list(string)
|
||||
description = "Additional packages to install."
|
||||
default = []
|
||||
}
|
||||
85
builds/linux/oracle/9/data/ks.pkrtpl.hcl
Normal file
85
builds/linux/oracle/9/data/ks.pkrtpl.hcl
Normal file
@@ -0,0 +1,85 @@
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Oracle Linux 9
|
||||
|
||||
### Installs from the first attached CD-ROM/DVD on the system.
|
||||
cdrom
|
||||
|
||||
### Performs the kickstart installation in text mode.
|
||||
### By default, kickstart installations are performed in graphical mode.
|
||||
text
|
||||
|
||||
### Accepts the End User License Agreement.
|
||||
eula --agreed
|
||||
|
||||
### Sets the language to use during installation and the default language to use on the installed system.
|
||||
lang ${vm_os_language}
|
||||
|
||||
### Sets the default keyboard type for the system.
|
||||
keyboard ${vm_os_keyboard}
|
||||
|
||||
### Configure network information for target system and activate network devices in the installer environment (optional)
|
||||
### --onboot enable device at a boot time
|
||||
### --device device to be activated and / or configured with the network command
|
||||
### --bootproto method to obtain networking configuration for device (default dhcp)
|
||||
### --noipv6 disable IPv6 on this device
|
||||
${network}
|
||||
|
||||
### Lock the root account.
|
||||
rootpw --lock
|
||||
|
||||
### The selected profile will restrict root login.
|
||||
### Add a user that can login and escalate privileges.
|
||||
user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel
|
||||
|
||||
### Configure firewall settings for the system.
|
||||
### --enabled reject incoming connections that are not in response to outbound requests
|
||||
### --ssh allow sshd service through the firewall
|
||||
firewall --enabled --ssh
|
||||
|
||||
### Sets up the authentication options for the system.
|
||||
### The SSSD profile sets sha512 to hash passwords. Passwords are shadowed by default
|
||||
### See the manual page for authselect-profile for a complete list of possible options.
|
||||
authselect select sssd
|
||||
|
||||
### Sets the state of SELinux on the installed system.
|
||||
### Defaults to enforcing.
|
||||
selinux --enforcing
|
||||
|
||||
### Sets the system time zone.
|
||||
timezone ${vm_os_timezone}
|
||||
|
||||
### Partitioning
|
||||
${storage}
|
||||
|
||||
### Modifies the default set of services that will run under the default runlevel.
|
||||
services --enabled=NetworkManager,sshd
|
||||
|
||||
### Do not configure X on the installed system.
|
||||
skipx
|
||||
|
||||
### Packages selection.
|
||||
%packages --ignoremissing --excludedocs
|
||||
@core
|
||||
-iwl*firmware
|
||||
%end
|
||||
|
||||
### Post-installation commands.
|
||||
%post
|
||||
dnf makecache
|
||||
dnf install epel-release -y
|
||||
dnf makecache
|
||||
dnf install -y sudo qemu-guest-tools
|
||||
%{ if additional_packages != "" ~}
|
||||
dnf install -y ${additional_packages}
|
||||
%{ endif ~}
|
||||
echo "${build_username} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/${build_username}
|
||||
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
|
||||
%end
|
||||
|
||||
### Reboot after the installation is complete.
|
||||
### --eject attempt to eject the media before rebooting.
|
||||
reboot --eject
|
||||
5
builds/linux/oracle/9/data/network.pkrtpl.hcl
Normal file
5
builds/linux/oracle/9/data/network.pkrtpl.hcl
Normal file
@@ -0,0 +1,5 @@
|
||||
%{ if ip != null ~}
|
||||
network --device=${device} --bootproto=static --ip=${ip} --netmask=${cidrnetmask("${ip}/${netmask}")} --gateway=${gateway} --nameserver=${join(",", dns)}
|
||||
%{ else ~}
|
||||
network --device=${device} --bootproto=dhcp
|
||||
%{ endif ~}
|
||||
76
builds/linux/oracle/9/data/storage.pkrtpl.hcl
Normal file
76
builds/linux/oracle/9/data/storage.pkrtpl.hcl
Normal file
@@ -0,0 +1,76 @@
|
||||
### Sets how the boot loader should be installed.
|
||||
bootloader --location=mbr
|
||||
|
||||
### Initialize any invalid partition tables found on disks.
|
||||
zerombr
|
||||
|
||||
### Removes partitions from the system, prior to creation of new partitions.
|
||||
### By default, no partitions are removed.
|
||||
### --all Erases all partitions from the system
|
||||
### --initlabel Initializes a disk (or disks) by creating a default disk label for all disks in their respective architecture.
|
||||
clearpart --all --initlabel
|
||||
|
||||
### Modify partition sizes for the virtual machine hardware.
|
||||
### Create primary system partitions.
|
||||
%{ for partition in partitions ~}
|
||||
part
|
||||
%{~ if partition.volume_group != "" ~}
|
||||
pv.${partition.volume_group}
|
||||
%{~ else ~}
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.format.fstype != "" ~}
|
||||
--label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
|
||||
%{ endfor ~}
|
||||
%{ if vm_bios == "seabios" ~}
|
||||
part biosboot --fstype="biosboot" --ondisk=${device} --size=1
|
||||
%{ endif ~}
|
||||
### Create a logical volume management (LVM) group.
|
||||
%{ for index, volume_group in lvm ~}
|
||||
volgroup sysvg pv.${volume_group.name}
|
||||
|
||||
### Modify logical volume sizes for the virtual machine hardware.
|
||||
### Create logical volumes.
|
||||
%{ for partition in volume_group.partitions ~}
|
||||
logvol
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
--name=${partition.name} --vgname=${volume_group.name} --label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
|
||||
%{ endfor ~}
|
||||
%{ endfor ~}
|
||||
40
builds/linux/oracle/9/linux-oracle.auto.pkrvars.hcl
Normal file
40
builds/linux/oracle/9/linux-oracle.auto.pkrvars.hcl
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Oracle Linux 9 variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// Guest Operating System Metadata
|
||||
vm_os_language = "en_US"
|
||||
vm_os_keyboard = "us"
|
||||
vm_os_timezone = "UTC"
|
||||
vm_os_family = "linux"
|
||||
vm_os_name = "oracle"
|
||||
vm_os_version = "9.4"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
vm_cloudinit = true
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "ovmf"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "x86-64-v2-AES"
|
||||
vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
iso_file = "OracleLinux-R9-U4-x86_64-dvd.iso"
|
||||
iso_checksum = "file:https://linux.oracle.com/security/gpg/checksum/OracleLinux-R9-U4-Server-x86_64.checksum"
|
||||
|
||||
// Boot Settings
|
||||
vm_boot = "order=virtio0;ide2;net0"
|
||||
vm_boot_wait = "10s"
|
||||
|
||||
// EFI Settings
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
227
builds/linux/oracle/9/linux-oracle.pkr.hcl
Normal file
227
builds/linux/oracle/9/linux-oracle.pkr.hcl
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Oracle Linux 9 template using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: packer
|
||||
// The Packer configuration.
|
||||
|
||||
packer {
|
||||
required_version = ">= 1.11.0"
|
||||
required_plugins {
|
||||
ansible = {
|
||||
source = "github.com/hashicorp/ansible"
|
||||
version = "~> 1"
|
||||
}
|
||||
git = {
|
||||
version = ">= 0.6.2"
|
||||
source = "github.com/ethanmdavidson/git"
|
||||
}
|
||||
proxmox = {
|
||||
version = ">= 1.1.8"
|
||||
source = "github.com/hashicorp/proxmox"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BLOCK: data
|
||||
// Defines the data sources.
|
||||
|
||||
data "git-repository" "cwd" {}
|
||||
|
||||
// BLOCK: locals
|
||||
// Defines the local variables.
|
||||
|
||||
locals {
|
||||
bios_boot_command = [
|
||||
// This sends the "up arrow" key, typically used to navigate through boot menu options.
|
||||
"<up>",
|
||||
// This sends the "tab" key. In the BIOS bootloader, this is how you customize the boot options.
|
||||
"<tab>",
|
||||
"inst.text biosdevname=0 net.ifnames=0 inst.gpt",
|
||||
" ${local.data_source_command}",
|
||||
"<enter><wait>"
|
||||
]
|
||||
uefi_boot_command = [
|
||||
// This sends the "up arrow" key, typically used to navigate through boot menu options.
|
||||
"<up>",
|
||||
// This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option.
|
||||
"e",
|
||||
// This sends two "down arrow" keys, followed by the "end" key, and then waits. This is used to navigate to a specific line in the boot menu option's configuration.
|
||||
"<down><down><end><wait>",
|
||||
// This types the string "text" followed by the value of the 'data_source_command' local variable.
|
||||
// This is used to modify the boot menu option's configuration to boot in text mode and specify the kickstart data source configured in the common variables.
|
||||
"text ${local.data_source_command}",
|
||||
// This sends the "enter" key, waits, turns on the left control key, sends the "x" key, and then turns off the left control key. This is used to save the changes and exit the boot menu option's configuration, and then continue the boot process.
|
||||
"<enter><wait><leftCtrlOn>x<leftCtrlOff>"
|
||||
]
|
||||
build_by = "Built by: HashiCorp Packer ${packer.version}"
|
||||
build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" )
|
||||
build_version = data.git-repository.cwd.head
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}"
|
||||
vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda"
|
||||
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
|
||||
manifest_path = "${path.cwd}/manifests/"
|
||||
manifest_output = "${local.manifest_path}${local.manifest_date}.json"
|
||||
data_source_content = {
|
||||
"/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", {
|
||||
build_username = var.build_username
|
||||
build_password = var.build_password
|
||||
build_password_encrypted = var.build_password_encrypted
|
||||
vm_disk_type = local.vm_disk_type
|
||||
vm_os_language = var.vm_os_language
|
||||
vm_os_keyboard = var.vm_os_keyboard
|
||||
vm_os_timezone = var.vm_os_timezone
|
||||
|
||||
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
|
||||
device = var.vm_bridge_interface
|
||||
ip = var.vm_ip_address
|
||||
netmask = var.vm_ip_netmask
|
||||
gateway = var.vm_ip_gateway
|
||||
dns = var.vm_dns_list
|
||||
})
|
||||
common_data_source = var.common_data_source
|
||||
# lvm needs to be here so late commands can access vg names
|
||||
#lvm = var.vm_disk_lvm
|
||||
storage = templatefile("${abspath(path.root)}/data/storage.pkrtpl.hcl", {
|
||||
device = var.vm_disk_device
|
||||
swap = var.vm_disk_use_swap
|
||||
partitions = var.vm_disk_partitions
|
||||
lvm = var.vm_disk_lvm
|
||||
vm_bios = var.vm_bios
|
||||
})
|
||||
additional_packages = join(" ", var.additional_packages)
|
||||
})
|
||||
}
|
||||
data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks.cfg" : "inst.ks=/cdrom/ks.cfg"
|
||||
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||
boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command
|
||||
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||
}
|
||||
|
||||
// BLOCK: source
|
||||
// Defines the builder configuration blocks.
|
||||
|
||||
source "proxmox-iso" "linux-oracle" {
|
||||
|
||||
// Proxmox Connection Settings and Credentials
|
||||
proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json"
|
||||
username = "${var.proxmox_api_token_id}"
|
||||
token = "${var.proxmox_api_token_secret}"
|
||||
insecure_skip_tls_verify = "${var.proxmox_insecure_connection}"
|
||||
|
||||
// Proxmox Settings
|
||||
node = "${var.proxmox_node}"
|
||||
|
||||
// Virtual Machine Settings
|
||||
vm_name = "${local.vm_name}"
|
||||
bios = "${var.vm_bios}"
|
||||
sockets = "${var.vm_cpu_sockets}"
|
||||
cores = "${var.vm_cpu_count}"
|
||||
cpu_type = "${var.vm_cpu_type}"
|
||||
memory = "${var.vm_mem_size}"
|
||||
os = "${var.vm_os_type}"
|
||||
scsi_controller = "${var.vm_disk_controller_type}"
|
||||
disks {
|
||||
disk_size = "${var.vm_disk_size}"
|
||||
type = "${var.vm_disk_type}"
|
||||
storage_pool = "${var.vm_storage_pool}"
|
||||
format = "${var.vm_disk_format}"
|
||||
}
|
||||
dynamic "efi_config" {
|
||||
for_each = var.vm_bios == "ovmf" ? [1] : []
|
||||
content {
|
||||
efi_storage_pool = var.vm_bios == "ovmf" ? var.vm_efi_storage_pool : null
|
||||
efi_type = var.vm_bios == "ovmf" ? var.vm_efi_type : null
|
||||
pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null
|
||||
}
|
||||
}
|
||||
unmount_iso = true
|
||||
ssh_username = "${var.build_username}"
|
||||
ssh_password = "${var.build_password}"
|
||||
ssh_timeout = "${var.timeout}"
|
||||
ssh_port = "22"
|
||||
iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}"
|
||||
iso_checksum = "${var.iso_checksum}"
|
||||
qemu_agent = true
|
||||
|
||||
network_adapters {
|
||||
bridge = "${var.vm_bridge_interface}"
|
||||
model = "${var.vm_network_card_model}"
|
||||
vlan_tag = "${var.vm_vlan_tag}"
|
||||
}
|
||||
|
||||
// Removable Media Settings
|
||||
http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null
|
||||
|
||||
// Boot and Provisioning Settings
|
||||
http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null
|
||||
http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null
|
||||
http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null
|
||||
boot = var.vm_boot
|
||||
boot_wait = var.vm_boot_wait
|
||||
boot_command = local.boot_command
|
||||
|
||||
dynamic "additional_iso_files" {
|
||||
for_each = var.common_data_source == "disk" ? [1] : []
|
||||
content {
|
||||
cd_files = var.common_data_source == "disk" ? local.data_source_content : null
|
||||
cd_label = var.common_data_source == "disk" ? "cidata" : null
|
||||
iso_storage_pool = var.common_data_source == "disk" ? "local" : null
|
||||
}
|
||||
}
|
||||
|
||||
template_name = "${local.vm_name}"
|
||||
template_description = "${local.build_description}"
|
||||
|
||||
# VM Cloud Init Settings
|
||||
cloud_init = var.vm_cloudinit
|
||||
cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null
|
||||
|
||||
}
|
||||
|
||||
# Build Definition to create the VM Template
|
||||
build {
|
||||
sources = ["source.proxmox-iso.linux-oracle"]
|
||||
|
||||
provisioner "ansible" {
|
||||
user = "${var.build_username}"
|
||||
galaxy_file = "${path.cwd}/ansible/linux-requirements.yml"
|
||||
galaxy_force_with_deps = true
|
||||
playbook_file = "${path.cwd}/ansible/linux-playbook.yml"
|
||||
roles_path = "${path.cwd}/ansible/roles"
|
||||
ansible_env_vars = [
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
|
||||
"ANSIBLE_PYTHON_INTERPRETER=/usr/libexec/platform-python"
|
||||
]
|
||||
extra_arguments = [
|
||||
"--extra-vars", "display_skipped_hosts=false",
|
||||
"--extra-vars", "build_username=${var.build_username}",
|
||||
"--extra-vars", "build_key='${var.build_key}'",
|
||||
"--extra-vars", "ansible_username=${var.ansible_username}",
|
||||
"--extra-vars", "ansible_key='${var.ansible_key}'",
|
||||
"--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'",
|
||||
]
|
||||
}
|
||||
|
||||
post-processor "manifest" {
|
||||
output = local.manifest_output
|
||||
strip_path = true
|
||||
strip_time = true
|
||||
custom_data = {
|
||||
ansible_username = "${var.ansible_username}"
|
||||
build_username = "${var.build_username}"
|
||||
build_date = "${local.build_date}"
|
||||
build_version = "${local.build_version}"
|
||||
common_data_source = "${var.common_data_source}"
|
||||
vm_cpu_sockets = "${var.vm_cpu_sockets}"
|
||||
vm_cpu_count = "${var.vm_cpu_count}"
|
||||
vm_disk_size = "${var.vm_disk_size}"
|
||||
vm_bios = "${var.vm_bios}"
|
||||
vm_os_type = "${var.vm_os_type}"
|
||||
vm_mem_size = "${var.vm_mem_size}"
|
||||
vm_network_card_model = "${var.vm_network_card_model}"
|
||||
vm_cloudinit = "${var.vm_cloudinit}"
|
||||
}
|
||||
}
|
||||
}
|
||||
36
builds/linux/oracle/9/variables-network.pkr.hcl
Normal file
36
builds/linux/oracle/9/variables-network.pkr.hcl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Oracle Linux 9 network variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// VM Network Settings
|
||||
|
||||
variable "vm_network_device" {
|
||||
type = string
|
||||
description = "The network device of the VM."
|
||||
default = "ens192"
|
||||
}
|
||||
|
||||
variable "vm_ip_address" {
|
||||
type = string
|
||||
description = "The IP address of the VM (e.g. 172.16.100.192)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_netmask" {
|
||||
type = number
|
||||
description = "The netmask of the VM (e.g. 24)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_ip_gateway" {
|
||||
type = string
|
||||
description = "The gateway of the VM (e.g. 172.16.100.1)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vm_dns_list" {
|
||||
type = list(string)
|
||||
description = "The nameservers of the VM."
|
||||
default = []
|
||||
}
|
||||
53
builds/linux/oracle/9/variables-storage.pkr.hcl
Normal file
53
builds/linux/oracle/9/variables-storage.pkr.hcl
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Oracle Linux 9 storage variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// VM Storage Settings
|
||||
|
||||
variable "vm_disk_device" {
|
||||
type = string
|
||||
description = "The device for the virtual disk. (e.g. 'sda')"
|
||||
}
|
||||
|
||||
variable "vm_disk_use_swap" {
|
||||
type = bool
|
||||
description = "Whether to use a swap partition."
|
||||
}
|
||||
|
||||
variable "vm_disk_partitions" {
|
||||
type = list(object({
|
||||
name = string
|
||||
size = number
|
||||
format = object({
|
||||
label = string
|
||||
fstype = string
|
||||
})
|
||||
mount = object({
|
||||
path = string
|
||||
options = string
|
||||
})
|
||||
volume_group = string
|
||||
}))
|
||||
description = "The disk partitions for the virtual disk."
|
||||
}
|
||||
|
||||
variable "vm_disk_lvm" {
|
||||
type = list(object({
|
||||
name = string
|
||||
partitions = list(object({
|
||||
name = string
|
||||
size = number
|
||||
format = object({
|
||||
label = string
|
||||
fstype = string
|
||||
})
|
||||
mount = object({
|
||||
path = string
|
||||
options = string
|
||||
})
|
||||
}))
|
||||
}))
|
||||
description = "The LVM configuration for the virtual disk."
|
||||
default = []
|
||||
}
|
||||
307
builds/linux/oracle/9/variables.pkr.hcl
Normal file
307
builds/linux/oracle/9/variables.pkr.hcl
Normal file
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Oracle Linux 9 variables using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: variable
|
||||
// Defines the input variables.
|
||||
|
||||
// Proxmox Credentials
|
||||
|
||||
variable "proxmox_hostname" {
|
||||
type = string
|
||||
description = "The FQDN or IP address of a Proxmox node. Only one node should be specified in a cluster."
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_id" {
|
||||
type = string
|
||||
description = "The token to login to the Proxmox node/cluster. The format is USER@REALM!TOKENID. (e.g. packer@pam!packer_pve_token)"
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_secret" {
|
||||
type = string
|
||||
description = "The secret for the API token used to login to the Proxmox API."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "proxmox_insecure_connection" {
|
||||
description = "true/false to skip Proxmox TLS certificate checks."
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
// Proxmox Settings
|
||||
|
||||
variable "proxmox_node" {
|
||||
type = string
|
||||
description = "The name of the Proxmox node that Packer will build templates on."
|
||||
}
|
||||
|
||||
// Virtual Machine Settings
|
||||
|
||||
variable "vm_os_language" {
|
||||
type = string
|
||||
description = "The guest operating system language."
|
||||
default = "en_US"
|
||||
}
|
||||
|
||||
variable "vm_os_keyboard" {
|
||||
type = string
|
||||
description = "The guest operating system keyboard layout."
|
||||
default = "us"
|
||||
}
|
||||
|
||||
variable "vm_os_timezone" {
|
||||
type = string
|
||||
description = "The guest operating system timezone."
|
||||
default = "UTC"
|
||||
}
|
||||
|
||||
variable "vm_os_family" {
|
||||
type = string
|
||||
description = "The guest operating system family. Used for naming. (e.g. 'linux')"
|
||||
}
|
||||
|
||||
variable "vm_os_name" {
|
||||
type = string
|
||||
description = "The guest operating system name. Used for naming. (e.g. 'ubuntu')"
|
||||
}
|
||||
|
||||
variable "vm_os_version" {
|
||||
type = string
|
||||
description = "The guest operating system version. Used for naming. (e.g. '22-04-lts')"
|
||||
}
|
||||
|
||||
variable "vm_os_type" {
|
||||
type = string
|
||||
description = "The guest operating system type. (e.g. 'l26')"
|
||||
}
|
||||
|
||||
variable "vm_bios" {
|
||||
type = string
|
||||
description = "The firmware type. Allowed values 'ovmf' or 'seabios'"
|
||||
default = "ovmf"
|
||||
|
||||
validation {
|
||||
condition = contains(["ovmf", "seabios"], var.vm_bios)
|
||||
error_message = "The vm_bios value must be 'ovmf' or 'seabios'."
|
||||
}
|
||||
}
|
||||
|
||||
variable "vm_firmware_path" {
|
||||
type = string
|
||||
description = "The firmware file to be used. Needed for EFI"
|
||||
default = "/usr/share/ovmf/OVMF.fd"
|
||||
}
|
||||
|
||||
variable "vm_efi_storage_pool" {
|
||||
type = string
|
||||
description = "Set the UEFI disk storage location. (e.g. 'local-lvm')"
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "vm_efi_type" {
|
||||
type = string
|
||||
description = "Specifies the version of the OVMF firmware to be used. (e.g. '4m')"
|
||||
default = "4m"
|
||||
}
|
||||
|
||||
variable "vm_efi_pre_enrolled_keys" {
|
||||
type = bool
|
||||
description = "Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "vm_cpu_count" {
|
||||
type = number
|
||||
description = "The number of virtual CPUs. (e.g. '2')"
|
||||
}
|
||||
|
||||
variable "vm_cpu_sockets" {
|
||||
type = number
|
||||
description = "The number of virtual CPU sockets. (e.g. '1')"
|
||||
}
|
||||
|
||||
variable "vm_cpu_type" {
|
||||
type = string
|
||||
description = "The CPU type to emulate. See the Proxmox API documentation for the complete list of accepted values. For best performance, set this to host. Defaults to kvm64."
|
||||
}
|
||||
|
||||
variable "vm_mem_size" {
|
||||
type = number
|
||||
description = "The size for the virtual memory in MB. (e.g. '2048')"
|
||||
}
|
||||
|
||||
variable "vm_disk_controller_type" {
|
||||
type = string
|
||||
description = "The SCSI controller model to emulate. (e.g. 'virtio-scsi-pci')"
|
||||
}
|
||||
|
||||
variable "vm_disk_type" {
|
||||
type = string
|
||||
description = "The type of disk to emulate. (e.g. 'virtio')"
|
||||
}
|
||||
|
||||
variable "vm_storage_pool" {
|
||||
type = string
|
||||
description = "The name of the Proxmox storage pool to store the VM template. (e.g. 'local-lvm')"
|
||||
}
|
||||
|
||||
variable "vm_disk_size" {
|
||||
type = string
|
||||
description = "The size for the virtual disk in GB. (e.g. '32G')"
|
||||
}
|
||||
|
||||
variable "vm_disk_format" {
|
||||
type = string
|
||||
description = "The format of the file backing the disk. (e.g. 'qcow2')"
|
||||
}
|
||||
|
||||
variable "vm_network_card_model" {
|
||||
type = string
|
||||
description = "The model of the virtual network adapter to emulate. (e.g. 'virtio')"
|
||||
}
|
||||
|
||||
variable "vm_bridge_interface" {
|
||||
type = string
|
||||
description = "The name of the Proxmox bridge to attach the adapter to."
|
||||
}
|
||||
|
||||
variable "vm_vlan_tag" {
|
||||
type = string
|
||||
description = "If the adapter should tag packets, give the VLAN ID. (e.g. '102')"
|
||||
}
|
||||
|
||||
// Cloud-Init Settings
|
||||
|
||||
variable "vm_cloudinit" {
|
||||
type = bool
|
||||
description = "Enable or disable cloud-init drive in Proxmox. (e.g. false)"
|
||||
default = false
|
||||
}
|
||||
|
||||
// Removable Media Settings
|
||||
|
||||
variable "common_iso_storage" {
|
||||
type = string
|
||||
description = "The name of the source Proxmox storage location for ISO images. (e.g. 'local-lvm')"
|
||||
}
|
||||
|
||||
variable "iso_path" {
|
||||
type = string
|
||||
description = "The path on the source Proxmox storage location for ISO images. (e.g. 'iso')"
|
||||
}
|
||||
|
||||
variable "iso_file" {
|
||||
type = string
|
||||
description = "The file name of the ISO image used by the vendor. (e.g. 'ubuntu-<version>-live-server-amd64.iso')"
|
||||
}
|
||||
|
||||
variable "iso_checksum" {
|
||||
type = string
|
||||
description = "The checksum value of the ISO image provided by the vendor."
|
||||
}
|
||||
|
||||
// Boot Settings
|
||||
|
||||
variable "common_data_source" {
|
||||
type = string
|
||||
description = "The provisioning data source. (e.g. 'http' or 'disk')"
|
||||
}
|
||||
|
||||
variable "common_http_bind_address" {
|
||||
type = string
|
||||
description = "Define an IP address on the host to use for the HTTP server."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "common_http_port_min" {
|
||||
type = number
|
||||
description = "The start of the HTTP port range."
|
||||
}
|
||||
|
||||
variable "common_http_port_max" {
|
||||
type = number
|
||||
description = "The end of the HTTP port range."
|
||||
}
|
||||
|
||||
variable "vm_boot" {
|
||||
type = string
|
||||
description = "The boot order for virtual machine devices. (e.g. 'order=virtio0;ide2;net0')"
|
||||
}
|
||||
|
||||
variable "vm_boot_wait" {
|
||||
type = string
|
||||
description = "The time to wait after booting the initial VM before typing the boot_command (e.g '10s')"
|
||||
}
|
||||
|
||||
variable "common_ip_wait_timeout" {
|
||||
type = string
|
||||
description = "Time to wait for guest operating system IP address response."
|
||||
}
|
||||
|
||||
variable "common_shutdown_timeout" {
|
||||
type = string
|
||||
description = "Time to wait for guest operating system shutdown."
|
||||
}
|
||||
|
||||
// Communicator Settings and Credentials
|
||||
|
||||
variable "build_username" {
|
||||
type = string
|
||||
description = "The username to login to the guest operating system. (e.g. 'ubuntu')"
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_password" {
|
||||
type = string
|
||||
description = "The password to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_password_encrypted" {
|
||||
type = string
|
||||
description = "The encrypted password to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "build_key" {
|
||||
type = string
|
||||
description = "The SSH public key to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "timeout" {
|
||||
description = "not sure why I need so high a timeout but here we are"
|
||||
default = "90m"
|
||||
}
|
||||
|
||||
// Ansible Credentials
|
||||
|
||||
variable "ansible_username" {
|
||||
type = string
|
||||
description = "The username for Ansible to login to the guest operating system. (e.g. 'ansible')"
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
variable "ansible_key" {
|
||||
type = string
|
||||
description = "The public key for Ansible to login to the guest operating system."
|
||||
# sensitive = true
|
||||
}
|
||||
|
||||
// HCP Packer Settings
|
||||
|
||||
variable "common_hcp_packer_registry_enabled" {
|
||||
type = bool
|
||||
description = "Enable the HCP Packer registry."
|
||||
default = false
|
||||
}
|
||||
|
||||
// Additional Settings
|
||||
|
||||
variable "additional_packages" {
|
||||
type = list(string)
|
||||
description = "Additional packages to install."
|
||||
default = []
|
||||
}
|
||||
85
builds/linux/rocky/8/data/ks.pkrtpl.hcl
Normal file
85
builds/linux/rocky/8/data/ks.pkrtpl.hcl
Normal file
@@ -0,0 +1,85 @@
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Rocky Linux 8
|
||||
|
||||
### Installs from the first attached CD-ROM/DVD on the system.
|
||||
cdrom
|
||||
|
||||
### Performs the kickstart installation in text mode.
|
||||
### By default, kickstart installations are performed in graphical mode.
|
||||
text
|
||||
|
||||
### Accepts the End User License Agreement.
|
||||
eula --agreed
|
||||
|
||||
### Sets the language to use during installation and the default language to use on the installed system.
|
||||
lang ${vm_os_language}
|
||||
|
||||
### Sets the default keyboard type for the system.
|
||||
keyboard ${vm_os_keyboard}
|
||||
|
||||
### Configure network information for target system and activate network devices in the installer environment (optional)
|
||||
### --onboot enable device at a boot time
|
||||
### --device device to be activated and / or configured with the network command
|
||||
### --bootproto method to obtain networking configuration for device (default dhcp)
|
||||
### --noipv6 disable IPv6 on this device
|
||||
${network}
|
||||
|
||||
### Lock the root account.
|
||||
rootpw --lock
|
||||
|
||||
### The selected profile will restrict root login.
|
||||
### Add a user that can login and escalate privileges.
|
||||
user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel
|
||||
|
||||
### Configure firewall settings for the system.
|
||||
### --enabled reject incoming connections that are not in response to outbound requests
|
||||
### --ssh allow sshd service through the firewall
|
||||
firewall --enabled --ssh
|
||||
|
||||
### Sets up the authentication options for the system.
|
||||
### The SSSD profile sets sha512 to hash passwords. Passwords are shadowed by default
|
||||
### See the manual page for authselect-profile for a complete list of possible options.
|
||||
authselect select sssd
|
||||
|
||||
### Sets the state of SELinux on the installed system.
|
||||
### Defaults to enforcing.
|
||||
selinux --enforcing
|
||||
|
||||
### Sets the system time zone.
|
||||
timezone ${vm_os_timezone}
|
||||
|
||||
### Partitioning
|
||||
${storage}
|
||||
|
||||
### Modifies the default set of services that will run under the default runlevel.
|
||||
services --enabled=NetworkManager,sshd
|
||||
|
||||
### Do not configure X on the installed system.
|
||||
skipx
|
||||
|
||||
### Packages selection.
|
||||
%packages --ignoremissing --excludedocs
|
||||
@core
|
||||
-iwl*firmware
|
||||
%end
|
||||
|
||||
### Post-installation commands.
|
||||
%post
|
||||
dnf makecache
|
||||
dnf install epel-release -y
|
||||
dnf makecache
|
||||
dnf install -y sudo qemu-guest-tools
|
||||
%{ if additional_packages != "" ~}
|
||||
dnf install -y ${additional_packages}
|
||||
%{ endif ~}
|
||||
echo "${build_username} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/${build_username}
|
||||
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
|
||||
%end
|
||||
|
||||
### Reboot after the installation is complete.
|
||||
### --eject attempt to eject the media before rebooting.
|
||||
reboot --eject
|
||||
5
builds/linux/rocky/8/data/network.pkrtpl.hcl
Normal file
5
builds/linux/rocky/8/data/network.pkrtpl.hcl
Normal file
@@ -0,0 +1,5 @@
|
||||
%{ if ip != null ~}
|
||||
network --device=${device} --bootproto=static --ip=${ip} --netmask=${cidrnetmask("${ip}/${netmask}")} --gateway=${gateway} --nameserver=${join(",", dns)}
|
||||
%{ else ~}
|
||||
network --device=${device} --bootproto=dhcp
|
||||
%{ endif ~}
|
||||
73
builds/linux/rocky/8/data/storage.pkrtpl.hcl
Normal file
73
builds/linux/rocky/8/data/storage.pkrtpl.hcl
Normal file
@@ -0,0 +1,73 @@
|
||||
### Sets how the boot loader should be installed.
|
||||
bootloader --location=mbr
|
||||
|
||||
### Initialize any invalid partition tables found on disks.
|
||||
zerombr
|
||||
|
||||
### Removes partitions from the system, prior to creation of new partitions.
|
||||
### By default, no partitions are removed.
|
||||
### --all Erases all partitions from the system
|
||||
### --initlabel Initializes a disk (or disks) by creating a default disk label for all disks in their respective architecture.
|
||||
clearpart --all --initlabel
|
||||
|
||||
### Modify partition sizes for the virtual machine hardware.
|
||||
### Create primary system partitions.
|
||||
%{ for partition in partitions ~}
|
||||
part
|
||||
%{~ if partition.volume_group != "" ~}
|
||||
pv.${partition.volume_group}
|
||||
%{~ else ~}
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.format.fstype != "" ~}
|
||||
--label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
|
||||
%{ endfor ~}
|
||||
### Create a logical volume management (LVM) group.
|
||||
%{ for index, volume_group in lvm ~}
|
||||
volgroup sysvg pv.${volume_group.name}
|
||||
|
||||
### Modify logical volume sizes for the virtual machine hardware.
|
||||
### Create logical volumes.
|
||||
%{ for partition in volume_group.partitions ~}
|
||||
logvol
|
||||
%{~ if partition.format.fstype == "swap" ~}
|
||||
swap
|
||||
%{~ else ~}
|
||||
${partition.mount.path}
|
||||
%{~ endif ~}
|
||||
--name=${partition.name} --vgname=${volume_group.name} --label=${partition.format.label}
|
||||
%{~ if partition.format.fstype == "fat32" ~}
|
||||
--fstype vfat
|
||||
%{~ else ~}
|
||||
--fstype ${partition.format.fstype}
|
||||
%{~ endif ~}
|
||||
%{~ if partition.mount.options != "" ~}
|
||||
--fsoptions="${partition.mount.options}"
|
||||
%{~ endif ~}
|
||||
%{~ if partition.size != -1 ~}
|
||||
--size=${partition.size}
|
||||
%{~ else ~}
|
||||
--size=100 --grow
|
||||
%{ endif ~}
|
||||
|
||||
%{ endfor ~}
|
||||
%{ endfor ~}
|
||||
40
builds/linux/rocky/8/linux-rocky.auto.pkrvars.hcl
Normal file
40
builds/linux/rocky/8/linux-rocky.auto.pkrvars.hcl
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Rocky Linux 8 variables used by the Packer Plugin for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// Guest Operating System Metadata
|
||||
vm_os_language = "en_US"
|
||||
vm_os_keyboard = "us"
|
||||
vm_os_timezone = "UTC"
|
||||
vm_os_family = "linux"
|
||||
vm_os_name = "rocky"
|
||||
vm_os_version = "8"
|
||||
|
||||
// Virtual Machine Guest Operating System Setting
|
||||
vm_os_type = "l26"
|
||||
vm_cloudinit = true
|
||||
|
||||
// Virtual Machine Hardware Settings
|
||||
vm_bios = "ovmf"
|
||||
vm_cpu_count = 1
|
||||
vm_cpu_sockets = 1
|
||||
vm_cpu_type = "kvm64"
|
||||
vm_mem_size = 2048
|
||||
vm_disk_type = "virtio"
|
||||
vm_disk_size = "32G"
|
||||
vm_disk_format = "raw"
|
||||
vm_disk_controller_type = "virtio-scsi-pci"
|
||||
vm_network_card_model = "virtio"
|
||||
|
||||
// Removable Media Settings
|
||||
iso_path = "iso"
|
||||
iso_file = "Rocky-8.10-x86_64-dvd1.iso"
|
||||
iso_checksum = "file:https://download.rockylinux.org/pub/rocky/8/isos/x86_64/CHECKSUM"
|
||||
|
||||
// Boot Settings
|
||||
vm_boot = "order=virtio0;ide2;net0"
|
||||
vm_boot_wait = "10s"
|
||||
|
||||
// EFI Settings
|
||||
vm_firmware_path = "./OVMF.fd"
|
||||
227
builds/linux/rocky/8/linux-rocky.pkr.hcl
Normal file
227
builds/linux/rocky/8/linux-rocky.pkr.hcl
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Rocky Linux 8 template using the Packer Builder for Proxmox (proxmox-iso).
|
||||
*/
|
||||
|
||||
// BLOCK: packer
|
||||
// The Packer configuration.
|
||||
|
||||
packer {
|
||||
required_version = ">= 1.9.1"
|
||||
required_plugins {
|
||||
ansible = {
|
||||
source = "github.com/hashicorp/ansible"
|
||||
version = "~> 1"
|
||||
}
|
||||
git = {
|
||||
version = ">= 0.4.2"
|
||||
source = "github.com/ethanmdavidson/git"
|
||||
}
|
||||
proxmox = {
|
||||
version = ">= 1.0.6"
|
||||
source = "github.com/hashicorp/proxmox"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BLOCK: data
|
||||
// Defines the data sources.
|
||||
|
||||
data "git-repository" "cwd" {}
|
||||
|
||||
// BLOCK: locals
|
||||
// Defines the local variables.
|
||||
|
||||
locals {
|
||||
|
||||
bios_boot_command = [
|
||||
"<up><wait>",
|
||||
"<tab><wait>",
|
||||
" text ${local.data_source_command}",
|
||||
"<enter><wait>"
|
||||
]
|
||||
|
||||
uefi_boot_command = [
|
||||
// This sends the "up arrow" key, typically used to navigate through boot menu options.
|
||||
"<up>",
|
||||
// This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option.
|
||||
"e",
|
||||
// This sends two "down arrow" keys, followed by the "end" key, and then waits. This is used to navigate to a specific line in the boot menu option's configuration.
|
||||
"<down><down><end><wait>",
|
||||
// This types the string "text" followed by the value of the 'data_source_command' local variable.
|
||||
// This is used to modify the boot menu option's configuration to boot in text mode and specify the kickstart data source configured in the common variables.
|
||||
"text ${local.data_source_command}",
|
||||
// This sends the "enter" key, waits, turns on the left control key, sends the "x" key, and then turns off the left control key. This is used to save the changes and exit the boot menu option's configuration, and then continue the boot process.
|
||||
"<enter><wait><leftCtrlOn>x<leftCtrlOff>"
|
||||
]
|
||||
|
||||
build_by = "Built by: HashiCorp Packer ${packer.version}"
|
||||
build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" )
|
||||
build_version = data.git-repository.cwd.head
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}"
|
||||
vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda"
|
||||
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
|
||||
manifest_path = "${path.cwd}/manifests/"
|
||||
manifest_output = "${local.manifest_path}${local.manifest_date}.json"
|
||||
data_source_content = {
|
||||
"/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", {
|
||||
build_username = var.build_username
|
||||
build_password = var.build_password
|
||||
build_password_encrypted = var.build_password_encrypted
|
||||
vm_disk_type = local.vm_disk_type
|
||||
vm_os_language = var.vm_os_language
|
||||
vm_os_keyboard = var.vm_os_keyboard
|
||||
vm_os_timezone = var.vm_os_timezone
|
||||
vm_cloudinit = var.vm_cloudinit
|
||||
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
|
||||
device = var.vm_bridge_interface
|
||||
ip = var.vm_ip_address
|
||||
netmask = var.vm_ip_netmask
|
||||
gateway = var.vm_ip_gateway
|
||||
dns = var.vm_dns_list
|
||||
})
|
||||
common_data_source = var.common_data_source
|
||||
# lvm needs to be here so late commands can access vg names
|
||||
lvm = var.vm_disk_lvm
|
||||
storage = templatefile("${abspath(path.root)}/data/storage.pkrtpl.hcl", {
|
||||
device = var.vm_disk_device
|
||||
swap = var.vm_disk_use_swap
|
||||
partitions = var.vm_disk_partitions
|
||||
lvm = var.vm_disk_lvm
|
||||
vm_bios = var.vm_bios
|
||||
})
|
||||
additional_packages = join(" ", var.additional_packages)
|
||||
})
|
||||
}
|
||||
data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks.cfg" : "inst.ks=/cdrom/ks.cfg"
|
||||
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||
boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command
|
||||
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||
}
|
||||
|
||||
// BLOCK: source
|
||||
// Defines the builder configuration blocks.
|
||||
|
||||
source "proxmox-iso" "linux-rocky" {
|
||||
|
||||
// Proxmox Connection Settings and Credentials
|
||||
proxmox_url = "https://${var.proxmox_hostname}:8006/api2/json"
|
||||
username = "${var.proxmox_api_token_id}"
|
||||
token = "${var.proxmox_api_token_secret}"
|
||||
insecure_skip_tls_verify = "${var.proxmox_insecure_connection}"
|
||||
|
||||
// Proxmox Settings
|
||||
node = "${var.proxmox_node}"
|
||||
|
||||
// Virtual Machine Settings
|
||||
vm_name = "${local.vm_name}"
|
||||
bios = "${var.vm_bios}"
|
||||
sockets = "${var.vm_cpu_sockets}"
|
||||
cores = "${var.vm_cpu_count}"
|
||||
cpu_type = "${var.vm_cpu_type}"
|
||||
memory = "${var.vm_mem_size}"
|
||||
os = "${var.vm_os_type}"
|
||||
scsi_controller = "${var.vm_disk_controller_type}"
|
||||
disks {
|
||||
disk_size = "${var.vm_disk_size}"
|
||||
type = "${var.vm_disk_type}"
|
||||
storage_pool = "${var.vm_storage_pool}"
|
||||
format = "${var.vm_disk_format}"
|
||||
}
|
||||
dynamic "efi_config" {
|
||||
for_each = var.vm_bios == "ovmf" ? [1] : []
|
||||
content {
|
||||
efi_storage_pool = var.vm_bios == "ovmf" ? var.vm_efi_storage_pool : null
|
||||
efi_type = var.vm_bios == "ovmf" ? var.vm_efi_type : null
|
||||
pre_enrolled_keys = var.vm_bios == "ovmf" ? var.vm_efi_pre_enrolled_keys : null
|
||||
}
|
||||
}
|
||||
unmount_iso = true
|
||||
ssh_username = "${var.build_username}"
|
||||
ssh_password = "${var.build_password}"
|
||||
ssh_timeout = "${var.timeout}"
|
||||
ssh_port = "22"
|
||||
iso_file = "${var.common_iso_storage}:${var.iso_path}/${var.iso_file}"
|
||||
iso_checksum = "${var.iso_checksum}"
|
||||
qemu_agent = true
|
||||
|
||||
network_adapters {
|
||||
bridge = "${var.vm_bridge_interface}"
|
||||
model = "${var.vm_network_card_model}"
|
||||
vlan_tag = "${var.vm_vlan_tag}"
|
||||
}
|
||||
|
||||
// Removable Media Settings
|
||||
http_content = "${var.common_data_source}" == "http" ? "${local.data_source_content}" : null
|
||||
|
||||
// Boot and Provisioning Settings
|
||||
http_bind_address = var.common_data_source == "http" ? var.common_http_bind_address : null
|
||||
http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null
|
||||
http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null
|
||||
boot = var.vm_boot
|
||||
boot_wait = var.vm_boot_wait
|
||||
boot_command = local.boot_command
|
||||
|
||||
dynamic "additional_iso_files" {
|
||||
for_each = var.common_data_source == "disk" ? [1] : []
|
||||
content {
|
||||
cd_files = var.common_data_source == "disk" ? local.data_source_content : null
|
||||
cd_label = var.common_data_source == "disk" ? "cidata" : null
|
||||
iso_storage_pool = var.common_data_source == "disk" ? "local" : null
|
||||
}
|
||||
}
|
||||
|
||||
template_name = "${local.vm_name}"
|
||||
template_description = "${local.build_description}"
|
||||
|
||||
# VM Cloud Init Settings
|
||||
cloud_init = var.vm_cloudinit
|
||||
cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null
|
||||
|
||||
}
|
||||
|
||||
# Build Definition to create the VM Template
|
||||
build {
|
||||
sources = ["source.proxmox-iso.linux-rocky"]
|
||||
|
||||
provisioner "ansible" {
|
||||
user = "${var.build_username}"
|
||||
galaxy_file = "${path.cwd}/ansible/linux-requirements.yml"
|
||||
galaxy_force_with_deps = true
|
||||
playbook_file = "${path.cwd}/ansible/linux-playbook.yml"
|
||||
roles_path = "${path.cwd}/ansible/roles"
|
||||
ansible_env_vars = [
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
|
||||
"ANSIBLE_PYTHON_INTERPRETER=/usr/libexec/platform-python"
|
||||
]
|
||||
extra_arguments = [
|
||||
"--extra-vars", "display_skipped_hosts=false",
|
||||
"--extra-vars", "build_username=${var.build_username}",
|
||||
"--extra-vars", "build_key='${var.build_key}'",
|
||||
"--extra-vars", "ansible_username=${var.ansible_username}",
|
||||
"--extra-vars", "ansible_key='${var.ansible_key}'",
|
||||
"--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'",
|
||||
]
|
||||
}
|
||||
|
||||
post-processor "manifest" {
|
||||
output = local.manifest_output
|
||||
strip_path = true
|
||||
strip_time = true
|
||||
custom_data = {
|
||||
ansible_username = "${var.ansible_username}"
|
||||
build_username = "${var.build_username}"
|
||||
build_date = "${local.build_date}"
|
||||
build_version = "${local.build_version}"
|
||||
common_data_source = "${var.common_data_source}"
|
||||
vm_cpu_sockets = "${var.vm_cpu_sockets}"
|
||||
vm_cpu_count = "${var.vm_cpu_count}"
|
||||
vm_disk_size = "${var.vm_disk_size}"
|
||||
vm_bios = "${var.vm_bios}"
|
||||
vm_os_type = "${var.vm_os_type}"
|
||||
vm_mem_size = "${var.vm_mem_size}"
|
||||
vm_network_card_model = "${var.vm_network_card_model}"
|
||||
vm_cloud_init_enable = "${var.vm_cloudinit}"
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user