diff --git a/infra-config/04-vm-templates/README.md b/infra-config/04-vm-templates/README.md new file mode 100644 index 0000000..37296a7 --- /dev/null +++ b/infra-config/04-vm-templates/README.md @@ -0,0 +1,29 @@ +# Steps for creating VM templates with Hashicorp Packer + +As this is one of the early steps, the assumption is made that these commands will be run on a jumpbox/laptop. + +Templates will always live on within the cluster. + +Steps to install Packer: + +```bash +brew tap hashicorp/tap +brew install hashicorp/tap/packer +``` + +packer plugins install github.com/hashicorp/proxmox +packer plugins install github.com/hashicorp/ansible + +my-packer-project/ +├── main.pkr.hcl # Main build definition(s) +├── variables.pkr.hcl # Variable declarations and default values +├── .pkrvars.hcl # (Optional) Specific variable values for a particular image +├── scripts/ # Directory for shell/PowerShell scripts used by provisioners +│ ├── setup-apache.sh +│ ├── install-deps.ps1 +│ └── common-config.sh +├── httpd-template/ # (Optional) Subdirectory for a specific image's configuration +│ ├── source.pkr.hcl # Source block for Apache image +│ ├── build.pkr.hcl # Build block for Apache image +│ └── vars.pkrvars.hcl # Variables specific to Apache image +└── README.md diff --git a/infra-config/04-vm-templates/fedora-41/LICENSE b/infra-config/04-vm-templates/fedora-41/LICENSE new file mode 100644 index 0000000..c3c2cb7 --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 eaksel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. diff --git a/infra-config/04-vm-templates/fedora-41/README.md b/infra-config/04-vm-templates/fedora-41/README.md new file mode 100644 index 0000000..9a11e3f --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/README.md @@ -0,0 +1,63 @@ +# packer-CentOS8 + +## What is packer-CentOS8 ? + +packer-CentOS8 is a set of configuration files used to build an automated CentOS 8 virtual machine images using [Packer](https://www.packer.io/). +This Packer configuration file allows you to build images for VMware Workstation and Oracle VM VirtualBox. + +## Prerequisites + +- [Packer](https://www.packer.io/downloads.html) + - +- A Hypervisor + - [VMware Workstation](https://www.vmware.com/products/workstation-pro.html) + - [Oracle VM VirtualBox](https://www.virtualbox.org/) + +## How to use Packer + +Commands to create an automated VM image: + +To create a CentOS 8 VM image using VMware Workstation use the following commands: + +```cmd +cd c:\packer-CentOS8 +packer build -only=vmware-iso centos8.json +``` + +To create a CentOS 8 VM image using Oracle VM VirtualBox use the following commands: + +```cmd +cd c:\packer-CentOS8 +packer build -only=virtualbox-iso centos8.json +``` + +*If you omit the keyword "-only=" both the Workstation and Virtualbox VMs will be created.* + +By default the .iso of CentOS 8 is pulled from + +You can change the URL to one closer to your build server. To do so change the **"iso_url"** parameter in the **"variables"** section of the centos8.json file. + +```json +{ + "variables": { + "iso_url": "http://miroir.univ-paris13.fr/centos/8/isos/x86_64/CentOS-8.1.1911-x86_64-boot.iso" +} +``` + +## Keyboard configuration + +By default the keyboard is set to be US qwerty. +To switch it to something else edit the following file: + +- ./http/ks.cfg + +Set the `keyboard` parameter as desired, for example: `keyboard --vckeymap=fr --xlayouts='fr'` + +## Default credentials + +The default credentials for this VM image are: + +|Username|Password| +|--------|--------| +|packer|packer| +|root|packer| diff --git a/infra-config/04-vm-templates/fedora-41/fedora-41-small.pkrvars.hcl b/infra-config/04-vm-templates/fedora-41/fedora-41-small.pkrvars.hcl new file mode 100755 index 0000000..bf2a32c --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/fedora-41-small.pkrvars.hcl @@ -0,0 +1,29 @@ +################################################################################## +# VARIABLES +################################################################################## + +# Virtual Machine Settings + +vm_boot_wait = "5s" +vm_name = "fedora-41-small" +vm_id = "9101" +vm_cpu_sockets = "1" +vm_cpu_cores = "2" +vm_mem_size = "2048" +vm_disk_size = "8" + +proxmox_bridge = "vmbr1" +proxmox_vlan = "71" + +ssh_username = "wed" + +# ISO Objects + +iso_file = "Fedora-Server-netinst-x86_64-41-1.4.iso" +iso_checksum = "ca03867ab88fbe565b91ae518e6f7f83debe6415234f29ff2cc5634052840ce8" +iso_checksum_type = "sha256" +# iso_url = "https://mirror.rackspace.com/centos-stream/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-dvd1.iso" + +# Scripts + +shell_scripts = ["scripts/cleanup.sh"] diff --git a/infra-config/04-vm-templates/fedora-41/fedora-41.pkr.hcl b/infra-config/04-vm-templates/fedora-41/fedora-41.pkr.hcl new file mode 100755 index 0000000..b36d3f4 --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/fedora-41.pkr.hcl @@ -0,0 +1,119 @@ +################################################################################## +# LOCALS +################################################################################## + +locals { + buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) +} + +################################################################################## +# SOURCE +################################################################################## + +source "proxmox-iso" "fedora-kickstart" { + #insecure_skip_tls_verify = "${var.proxmox_insecure_verify}" + + boot_iso { + type = "scsi" + iso_file = "${var.proxmox_iso_storage_pool}:iso/${var.iso_file}" + unmount = true + #iso_checksum = "sha512:33c08e56c83d13007e4a5511b9bf2c4926c4aa12fd5dd56d493c0653aecbab380988c5bf1671dbaea75c582827797d98c4a611f7fb2b131fbde2c677d5258ec9" + # iso_checksum = "${iso_checksum_type}:${var.iso_checksum}" + } + + os = "l26" + bios = "ovmf" + vm_id = "${var.vm_id}" + + efi_config { + efi_storage_pool = "${var.proxmox_vm_storage_pool}" + efi_type = "4m" + pre_enrolled_keys = true #false + } + + http_directory = "http" + + boot_command = [ + "", + "e", + "", + # leave a space from last arg + " inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks1.cfg " + ] + + boot_wait = "${var.vm_boot_wait}" + + sockets = "${var.vm_cpu_sockets}" + cores = "${var.vm_cpu_cores}" + cpu_type = "host" + memory = "${var.vm_mem_size}" + scsi_controller = "virtio-scsi-single" + + disks { + storage_pool = "${var.proxmox_vm_storage_pool}" + disk_size = "${var.vm_disk_size}G" + } + + network_adapters { + model = "virtio" + bridge = "${var.proxmox_bridge}" + vlan_tag = "${var.proxmox_vlan}" + firewall = "true" + } + + node = "${var.proxmox_node}" + username = "${var.proxmox_username}" + password = "${var.proxmox_password}" + proxmox_url = "https://${var.proxmox_node}.${var.proxmox_domain}:8006/api2/json" + ssh_timeout = "15m" + ssh_username = "${var.ssh_username}" + ssh_password = "${var.ssh_password}" + template_description = "Fedora 41-1.4, generated on ${timestamp()}" + template_name = "${var.vm_name}" +} + +################################################################################## +# BUILD +################################################################################## +# inline = ["dnf -y update", "dnf -y install python-pip", "python3 -m pip install --upgrade pip", "alternatives --set python /usr/bin/python3", "pip3 install ansible"] + +build { + sources = ["source.proxmox-iso.fedora-kickstart"] + #name = "${var.vm_mame}" + provisioner "shell" { + execute_command = "echo 'packer'|{{ .Vars }} sudo -S -E bash '{{ .Path }}'" + inline = [ + "dnf -y update", + "dnf -y install python-pip", + "pip install ansible" + ] + } + + provisioner "file" { + source = "files/ansible.pub" + destination = "/tmp/ansible.pub" + } + + provisioner "shell" { + execute_command = "echo 'packer'|{{ .Vars }} sudo -S -E bash '{{ .Path }}'" + inline = [ + "mkdir /home/wed/.ssh", + "chown wed:wed /home/wed/.ssh", + "cat /tmp/ansible.pub > /home/wed/.ssh/authorized_keys", + "chmod 600 /home/wed/.ssh/authorized_keys", + "chown wed:wed /home/wed/.ssh/authorized_keys", + "rm /tmp/ansible.pub" + ] + } + + provisioner "ansible-local" { + playbook_file = "scripts/setup.yml" + } + + provisioner "shell" { + execute_command = "echo 'packer'|{{ .Vars }} sudo -S -E bash '{{ .Path }}'" + scripts = [ + "scripts/cleanup.sh" + ] + } + } diff --git a/infra-config/04-vm-templates/fedora-41/files/ansible.pub b/infra-config/04-vm-templates/fedora-41/files/ansible.pub new file mode 100644 index 0000000..1586a14 --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/files/ansible.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINnSM/9fO8rz/amqkyoGUzUKNNzzmtSXPwOCr1O9zKNO ansible diff --git a/infra-config/04-vm-templates/fedora-41/http/ks.cfg b/infra-config/04-vm-templates/fedora-41/http/ks.cfg new file mode 100644 index 0000000..9529288 --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/http/ks.cfg @@ -0,0 +1,54 @@ +# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/performing_an_advanced_rhel_installation/kickstart-commands-and-options-reference_installing-rhel-as-an-experienced-user +#cdrom +# License agreement +eula --agreed +# Use network installation +#url --url="https://mirror.rackspace.com/centos-stream/9-stream/BaseOS/x86_64/os/" +#repo --name="AppStream" --baseurl=http://mirror.rackspace.com/centos-stream/9-stream/BaseOS/x86_64/os/../../../AppStream/x86_64/os/ +# Use text mode install +text +# Disable Initial Setup on first boot +firstboot --disable +# Keyboard layout +keyboard --vckeymap=us --xlayouts='us' +# System language +lang en_US.UTF-8 +# Network information +network --bootproto=dhcp --device=link --activate +network --hostname=fedora.localdomain +# Root password +rootpw $5$CXpezfLKTajPP7yI$VM8STd3QaHBTKMe2DLTmK5p.lEGbUYYZV8jGG3nxX2/ --iscrypted +# SELinux configuration +selinux --enforcing +# Do not configure the X Window System +skipx +# System timezone +timezone US/Chicago --utc +# Add a user named packer +user --groups=wheel --name=wed --password=$5$UOpZHG55fWCHlNSp$nFnpaVLb9enbQTebHo4SKBqolGr39SMYo2ZshHCe2d3 --iscrypted --gecos="wed" +# System bootloader configuration +bootloader --location=mbr --append="crashkernel=auto" +# Clear the Master Boot Record +zerombr +# Remove partitions +clearpart --all --initlabel +# Automatically create partitions using LVM +autopart --type=lvm +# Reboot after successful installation +reboot + +%packages --ignoremissing +# dnf group info minimal-environment +@^minimal-environment +# Exclude unnecessary firmwares +-iwl*firmware +%end + +%post --nochroot --logfile=/mnt/sysimage/root/ks-post.log +# Disable quiet boot and splash screen +sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/etc/default/grub +sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/boot/grub2/grubenv + +# Passwordless sudo for the user 'wed' +echo "wed ALL=(ALL) NOPASSWD: ALL" >> /mnt/sysimage/etc/sudoers.d/wed +%end diff --git a/infra-config/04-vm-templates/fedora-41/http/ks1.cfg b/infra-config/04-vm-templates/fedora-41/http/ks1.cfg new file mode 100644 index 0000000..126c085 --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/http/ks1.cfg @@ -0,0 +1,64 @@ +# Kickstart file for Fedora 41 Server (Text-based Installation) +# +# For use with the Fedora Server netinstall ISO. +# Boot the installer with: +# linux /isolinux/vmlinuz inst.ks=http:////ks.cfg +# +# For a local file on a USB drive, you can use: +# linux /isolinux/vmlinuz inst.ks=hd:LABEL=:/ks.cfg + +# System language, keyboard layout, and timezone +lang en_US.UTF-8 +keyboard us +timezone America/Chicago --isUtc + +# Installation source +url --mirrorlist=https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-41&arch=x86_64 + +# Use text mode installer +text + +# Network configuration +# Using DHCP for automatic network configuration. +# For a static configuration, uncomment and modify the following lines: +# network --bootproto=static --device=eth0 --ip=192.168.1.10 --netmask=255.255.255.0 --gateway=192.168.1.1 --nameserver=8.8.8.8,8.8.4.4 --hostname=fedora-server +network --bootproto=dhcp --device=eth0 --onboot=on --ipv6=auto --hostname=fedora41-server + +# Root password (encrypted) +# To generate an encrypted password, use: +# python -c 'import crypt; print(crypt.crypt("YourPassword", crypt.mksalt(crypt.METHOD_SHA512)))' +rootpw --iscrypted $6$your_encrypted_root_password_hash + +# Disk partitioning +# This will erase the specified disk. +# --ondisk=sda can be changed to a more specific device like vda for virtual machines. +# --all will erase all partitions on the disk. +# LVM partitioning scheme is used for flexibility. +zerombr +clearpart --all --initlabel --drives=sda +autopart --type=lvm + +# System services +# Disables services not typically required on a minimal server. +services --disabled="kdump,mdmonitor,mdmonitor-takeover" --enabled="sshd,chronyd" + +# Package selection +# @^server-product-environment provides a minimal server installation. +# You can add additional packages as needed. +%packages +@^server-product-environment +-@standard +# Add essential command-line tools +vim-enhanced +tmux +git +%end + +# Post-installation script +%post --log=/root/ks-post.log +echo "Fedora 41 Server installation complete." > /etc/motd +# Add any additional post-installation tasks here. +%end + +# Reboot after installation +reboot diff --git a/infra-config/04-vm-templates/fedora-41/proxmox.pkvars.hcl b/infra-config/04-vm-templates/fedora-41/proxmox.pkvars.hcl new file mode 100644 index 0000000..9947f70 --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/proxmox.pkvars.hcl @@ -0,0 +1,20 @@ +################################################################################## +# VARIABLES +################################################################################## + +# Credentials + +proxmox_username = "root@pam" +proxmox_password = "" +ssh_username = "wed" +ssh_password = "" + +# Proxmox Objects +proxmox_node = "pve03" +proxmox_domain = "int.mk-labs.cloud" +#proxmox_url = "https://${var.proxmox_node}.${proxmox_domain}:8006/api2/json" +proxmox_vm_storage_pool = "pve-templates" +#proxmox_insecure_connection = false #Default: true +proxmox_iso_storage_pool = "local" + +template_name = "" diff --git a/infra-config/04-vm-templates/fedora-41/scripts/cleanup.sh b/infra-config/04-vm-templates/fedora-41/scripts/cleanup.sh new file mode 100644 index 0000000..050e71b --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/scripts/cleanup.sh @@ -0,0 +1,12 @@ +#!/bin/bash -eux + +pip uninstall -y ansible + +dnf clean all + +# Zero out the rest of the free space using dd, then delete the written file. +#dd if=/dev/zero of=/EMPTY bs=1M +#rm -f /EMPTY + +# Add `sync` so Packer doesn't quit too early, before the large file is deleted. +sync diff --git a/infra-config/04-vm-templates/fedora-41/scripts/setup.yml b/infra-config/04-vm-templates/fedora-41/scripts/setup.yml new file mode 100644 index 0000000..1b746dd --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/scripts/setup.yml @@ -0,0 +1,81 @@ +--- +- name: "Setup.yml" + hosts: localhost + gather_facts: yes + become: yes + tasks: + - name: Colorize root shell prompt + lineinfile: + path: /root/.bashrc + line: 'export PS1="\[\033[38;5;11m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\h:\[$(tput sgr0)\]\[\033[38;5;6m\][\w]:\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"' + state: present + + - name: Alias vi to vim + lineinfile: + path: /root/.bashrc + line: "alias vi='vim'" + state: present + + - name: Create vim configuration file + file: + path: /root/.vimrc + state: touch + owner: root + group: root + mode: 0644 + + - name: Configure vim + blockinfile: + path: /root/.vimrc + block: | + set nocompatible + set number + set autoindent + syntax on + highlight Comment ctermfg=LightCyan + marker: "" + state: present + + - name: Disable GSSAPIAuthentication + lineinfile: + path: /etc/ssh/sshd_config + regexp: "^GSSAPIAuthentication" + line: "GSSAPIAuthentication no" + state: present + + - name: Update CA bundle (RedHat) + get_url: + url: https://curl.haxx.se/ca/cacert.pem + dest: /etc/pki/tls/certs/ca-bundle.crt + force: yes + when: ansible_os_family == "RedHat" + + - name: Install epel repo (RedHat) + dnf: + name: "epel-release" + state: latest + when: ansible_os_family == "RedHat" + + - name: Install packages (RedHat) + dnf: + name: "{{ packages }}" + state: latest + vars: + packages: + - bash-completion + - curl + - git + - rsync + - screen + - tcpdump + - vim + - wget + when: ansible_os_family == "RedHat" + + - name: Install open-vm-tools (RedHat) + dnf: + name: open-vm-tools + state: latest + when: + - ansible_os_family == "RedHat" + - ansible_virtualization_type == "VMware" diff --git a/infra-config/04-vm-templates/fedora-41/variables.pkr.hcl b/infra-config/04-vm-templates/fedora-41/variables.pkr.hcl new file mode 100644 index 0000000..93eb413 --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/variables.pkr.hcl @@ -0,0 +1,144 @@ +# Proxmox variable definitions + +variable "proxmox_username" { + type = string + description = "The username for authenticating to Proxmox." + default = "" + sensitive = true +} + +variable "proxmox_password" { + type = string + description = "The plaintext password for authenticating to Proxmox." + default = "" + sensitive = true +} + +variable "proxmox_node" { + type = string + description = "The Proxmox node to store the templates on." + default = "" +} + +variable "proxmox_domain" { + type = string + description = "The domain the Proxmox node resizes in." + default = "" +} + +variable "proxmox_insecure_verify" { + type = bool + description = "If true, does not validate the proxmox server's TLS certificate." + default = true +} + +variable "proxmox_vm_storage_pool" { + type = string + description = "The storage pool where the VM will live." + default = "" +} + +# Virtual Machine variables + +variable "vm_name" { + type = string + description = "The template vm name" + default = "" +} + +variable "vm_id" { + type = number + description = "The ID of virtual machine." +} + +variable "vm_cpu_sockets" { + type = number + description = "The number of virtual CPUs sockets." + default = "1" +} + +variable "vm_cpu_cores" { + type = number + description = "The number of virtual CPUs cores per socket." + default = "1" +} + +variable "vm_mem_size" { + type = number + description = "The size for the virtual memory in MB." +} + +variable "vm_disk_size" { + type = number + description = "The size of the primary virtual disk in GiB." +} + +variable "proxmox_bridge" { + type = string + description = "The Proxmox bridge the NIC connects to." +} + +variable "proxmox_vlan" { + type = number + description = "The VLAN the NIC is on." +} + +variable "vm_boot_wait" { + type = string + description = "The time to wait before boot (in seconds)." + default = "" +} + +variable "shell_scripts" { + type = list(string) + description = "A list of scripts." + default = [] +} + +# ISO Objects + +variable "proxmox_iso_storage_pool" { + type = string + description = "The storage pool where the ISO is located." + default = "" +} + +variable "iso_url" { + type = string + description = "The url to retrieve the iso image" + default = "" + } + +variable "iso_file" { + type = string + description = "The file name of the guest operating system ISO image installation media." + default = "" +} + +variable "iso_checksum" { + type = string + description = "The checksum of the ISO image." + default = "" +} + +variable "iso_checksum_type" { + type = string + description = "The checksum type of the ISO image. Ex: sha256" + default = "" +} + +# SSH info + +variable "ssh_username" { + type = string + description = "The username to use to authenticate over SSH." + default = "" + sensitive = true +} + +variable "ssh_password" { + type = string + description = "The plaintext password to use to authenticate over SSH." + default = "" + sensitive = true +} diff --git a/infra-config/04-vm-templates/fedora-41/variables.pkrvars-large.hcl b/infra-config/04-vm-templates/fedora-41/variables.pkrvars-large.hcl new file mode 100755 index 0000000..87da981 --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/variables.pkrvars-large.hcl @@ -0,0 +1,35 @@ +################################################################################## +# VARIABLES +################################################################################## + +# HTTP Settings + +http_directory = "http" + +# Virtual Machine Settings + +vm_name = "centos9-large" +vm_guest_os_type = "centos8_64Guest" +vm_version = 19 +vm_firmware = "efi" +vm_cdrom_type = "sata" +vm_cpu_sockets = 1 +vm_cpu_cores = 1 +vm_mem_size = 2048 +vm_disk_size = 51200 +thin_provision = true +disk_eagerly_scrub = false +vm_disk_controller_type = ["pvscsi"] +vm_network_card = "vmxnet3" +vm_boot_wait = "5s" +ssh_username = "wed" +ssh_password = "1mag!ne3R" + +# ISO Objects + +iso_checksum = "ca03867ab88fbe565b91ae518e6f7f83debe6415234f29ff2cc5634052840ce8" +iso_checksum_type = "sha256" +iso_url = "https://mirror.rackspace.com/centos-stream/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-dvd1.iso" +# Scripts + +shell_scripts = ["scripts/cleanup.sh"] diff --git a/infra-config/04-vm-templates/fedora-41/variables.pkrvars-medium.hcl b/infra-config/04-vm-templates/fedora-41/variables.pkrvars-medium.hcl new file mode 100755 index 0000000..7356e0b --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/variables.pkrvars-medium.hcl @@ -0,0 +1,35 @@ +################################################################################## +# VARIABLES +################################################################################## + +# HTTP Settings + +http_directory = "http" + +# Virtual Machine Settings + +vm_name = "centos9-medium" +vm_guest_os_type = "centos8_64Guest" +vm_version = 19 +vm_firmware = "efi" +vm_cdrom_type = "sata" +vm_cpu_sockets = 1 +vm_cpu_cores = 1 +vm_mem_size = 2048 +vm_disk_size = 25600 +thin_provision = true +disk_eagerly_scrub = false +vm_disk_controller_type = ["pvscsi"] +vm_network_card = "vmxnet3" +vm_boot_wait = "5s" +ssh_username = "wed" +ssh_password = "1mag!ne3R" + +# ISO Objects + +iso_checksum = "ca03867ab88fbe565b91ae518e6f7f83debe6415234f29ff2cc5634052840ce8" +iso_checksum_type = "sha256" +iso_url = "https://mirror.rackspace.com/centos-stream/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-dvd1.iso" +# Scripts + +shell_scripts = ["scripts/cleanup.sh"] diff --git a/infra-config/04-vm-templates/fedora-41/variables.pkrvars-xlarge.hcl b/infra-config/04-vm-templates/fedora-41/variables.pkrvars-xlarge.hcl new file mode 100755 index 0000000..43b34ad --- /dev/null +++ b/infra-config/04-vm-templates/fedora-41/variables.pkrvars-xlarge.hcl @@ -0,0 +1,35 @@ +################################################################################## +# VARIABLES +################################################################################## + +# HTTP Settings + +http_directory = "http" + +# Virtual Machine Settings + +vm_name = "centos9-large" +vm_guest_os_type = "centos8_64Guest" +vm_version = 19 +vm_firmware = "efi" +vm_cdrom_type = "sata" +vm_cpu_sockets = 1 +vm_cpu_cores = 1 +vm_mem_size = 2048 +vm_disk_size = 102400 +thin_provision = true +disk_eagerly_scrub = false +vm_disk_controller_type = ["pvscsi"] +vm_network_card = "vmxnet3" +vm_boot_wait = "5s" +ssh_username = "wed" +ssh_password = "1mag!ne3R" + +# ISO Objects + +iso_checksum = "ca03867ab88fbe565b91ae518e6f7f83debe6415234f29ff2cc5634052840ce8" +iso_checksum_type = "sha256" +iso_url = "https://mirror.rackspace.com/centos-stream/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-dvd1.iso" +# Scripts + +shell_scripts = ["scripts/cleanup.sh"] diff --git a/infra-config/README.md b/infra-config/README.md index 920217c..f1f58bc 100644 --- a/infra-config/README.md +++ b/infra-config/README.md @@ -1,3 +1,18 @@ # infra-config +## Create a virtual environment for ansible-core, activate it upgrade pip +### Linux + +```bash +python3 -m venv ~/venv-ansible +source ~/venv-ansible/bin/activate +pip3 install --upgrade pip +``` + +## Install ansible-core, proxmoxer and requests (needed by community.general.proxmox_*) + +```bash +pip3 install ansible-core proxmoxer requests +ansible-galaxy collection install community.proxmox +``` diff --git a/infra-config/create_vms.yml b/infra-config/create_vms.yml new file mode 100644 index 0000000..fcb97b0 --- /dev/null +++ b/infra-config/create_vms.yml @@ -0,0 +1,37 @@ +--- +- name: Create VM ID from IP address for Proxmox hosts + hosts: all + gather_facts: false + + tasks: + - name: Create Proxmox VMs + delegate_to: "localhost" + when: platform is defined and platform == "proxmox" + block: + - name: Create VM ID from IP address + ansible.builtin.set_fact: + vm_id: "{{ ip_address.split('.')[-2] }}{{ '%03d' % (ip_address.split('.')[-1] | int) }}" + + - name: Create new VM with minimal options and given vmid + community.proxmox.proxmox_kvm: + api_user: "{{ proxmox_user }}" + api_password: "{{ proxmox_password }}" + api_host: "{{ proxmox_host }}" + name: "{{ inventory_hostname }}" + node: "{{ proxmox_target_node }}" + vmid: "{{ vm_id }}" + cores: "{{ vm_cpus }}" + memory: "{{ vm_memory }}" + bios: ovmf + efidisk0: + storage: "{{ vm_storage }}" + format: raw + efitype: 4m + pre_enrolled_keys: false + scsihw: virtio-scsi-single + scsi: + scsi0: "{{ vm_storage }}:{{ vm_disk_size }},format=raw,aio=native" #VMs_LVM:10,format=raw + net: + net0: "virtio,bridge={{ vm_net_bridge}}{{vm_net_vlan}}" + onboot: "true" + #update: "true" diff --git a/infra-config/group_vars/all/vars b/infra-config/group_vars/all/vars index 4de479d..20d81a7 100644 --- a/infra-config/group_vars/all/vars +++ b/infra-config/group_vars/all/vars @@ -1,6 +1,11 @@ --- # file: group_vars/all +# Proxmox variables +proxmox_user: "root@pam" +proxmox_password: "{{ vault_proxmox_root_password }}" +proxmox_host: "pve01" + # DNS variables dns_server: "infra01.int.mk-labs.cloud" dns_admin: "admin" diff --git a/infra-config/group_vars/all/vault b/infra-config/group_vars/all/vault index e1f59b4..248d42f 100644 --- a/infra-config/group_vars/all/vault +++ b/infra-config/group_vars/all/vault @@ -1,153 +1,155 @@ $ANSIBLE_VAULT;1.1;AES256 -64343766343632623130366435613934363465653264663165616466303364306632633930326333 -6336663534313662373938666530363636313561343738340a366131323836633061316338313766 -32303032626135373264396638643031326264383637343162343432373731303530333565653761 -3735303536396366630a666136373437353038333664306665333938666262646566396430623664 -32343163643863326566303635653032346266656538653034383266663566343064313261396561 -66313062333630656564653339353065666462626330653738353333623038623836653462633538 -61323235303339363836306434643033346234626238626136366534636463303163633130663533 -64646562346566386365336466346434656138306665623833313933383939323438393935623937 -33636131386430383861663363386532396664383239643133663738363635353736303262326462 -65613038353731363337633935623662666361646364653534643561306561623535663232366134 -33353466666561376262623062613563363662363461306434656361666233303763313732353466 -66616532613262313531363361343963343062396463396130356436666331323036383135663638 -36303364323436653730386365656332346164656139383436653836613066353334383335633661 -30393761363738626438393761623435326139343034306632653039666336633566653863653264 -35653734646466316564343036646237346534333139643735306636626664646361633035623362 -63376439656664323564363765386630613662393735633162316135653735636231633730346132 -61653930343238393262623439326635636630626234326338333163353139303833336339333361 -39376165343064383032313533636165613261623735646432313131363035626539653038616436 -39643737363238353536386236316434363066626164633837333264386163393831646439343631 -31363365333736353965393132363535613363663138643432386633653764383738346431626133 -63633864613533366536633130316662333761366330313535333363653038623763316561353264 -65663033636134343833656336633762353364306537303837343939373066616430376565393137 -62383030323563363236343765383235626139393137626663353537613037663539316565663662 -37373165636630633664303362386331633662303136653132356234383435376665636430303937 -38396639653363643839376166653436636435326464613939353439316463613462343631663565 -66346466376332366135323932656265353234393735346132333932306537353862356436346133 -65663637396662623665653334313464353339303362396139366639383866353061383062303337 -63633863366432383435363866613939323433613164323132376436323236353335353337646663 -64303338323830386337636463663738376566616630633663383165313332643438323137326565 -34333035616533393961653531323466303032383765303065323464373130663839343661633063 -39353761396430313035376365653031396232316464343662323734386538326431653065646331 -63336465386261326338646632363565623132663264623832303565346261663531393463396239 -36326236383231363530383566393937616636666335626364623239396463346566643066343736 -62396632383839346463613735613730373762383435343065306562356462383630383962653139 -63323739306437313065663139303037363365656365343038633466346339353437393439393166 -37333033623531313333666363353230323339666232393936663331666433386238383532343634 -61613531646438363466626565373033356365343931636265303633666539306639303237373130 -38656239343065643830623739343236343062356162663165656537636238653265643039643834 -63353039656362373365646466626135353438663865643861313238633539336666323535343637 -61666533356533626563346664333338373832396162363534393130613561663335323134653030 -62333038616235383637313736353264346233303437303632393933376463343133396638613366 -34366165336339313932633866623663353736373965303666653334383239326362633836636437 -30313564353835343564356334353862373761643861336536326338623334656539663934323865 -61303430316265663464316330643032313732353763393165636133616232386635363333346164 -65393864623939343430343435386638333735363838646530633036396530666233303231653366 -31316333343530323962383430616336323638623735616431323366303132613533373937376135 -63326431653832356137656535393763646134666239376164346330633637613631303236333632 -35616266616431383333656530663838346238616331363635326532396566386461353362353035 -63633138666561653063333566373637623433643666346534313938666361376431396234666265 -33323563323139326333396633383537623564333636626461633333623264626363303161346139 -32616432663737303764353366323766333665326561343463373339346331366338326432613230 -33653165343835393564373334306631363334646462656665643631303539303065346638653031 -64343862373665363231353464373639356139373338373639656161646135393665373738303866 -65353262623536366636316137336633383434306463656336643233363837376238386166663438 -38393762353962353365366333623336336631353133636238313238616234333564313530383036 -66343964353564303434316137653261613635313430656335316534633339373964383765623865 -34333930343033373234326561333432336165306533313237343866363330393334616130366336 -34316330336165393034336135633465313566346265616238656362363762356664643564313132 -39326434303163656166373965373338383439616132303065333762326465376136653562663339 -32373063313837643339323062323361643766376366386563386431353563363736323933356333 -33633737336239316164653533626231393037343664616536393039356332363338303765653833 -65363134646238356534653037383631303866633234313331383066666233336262303062383064 -30366362663736353632393032363030653537666162356230343261623463353439623538613863 -35623564353465313335373763373538333537333938363536646231396132646364383135343534 -34323635346663383361616664306530353038653436376638656464386334626238356239363231 -32393365376462323035366432326165366138646163343734646136623033376134643737666635 -35663962653662353039623737353466306662323664643430373835313832666363346133366261 -32386435633366613337333933326564623230663631373964663832633662616239373262366264 -62663164636263646538653037646136353433383937393434313362656262356532613331383232 -36646361326332666634383435373632613231316165326637333439633638323265373437336461 -64313163326364306236613162653036646163383164646237623938333934343366643930666530 -36633763663730386432653461613833376462336162343334346435323537633537633161363464 -62313136346362323433623137323935366235393334336139363731336332303362643664373038 -66366437353332313464656131396434663132656531363762663432373632306332653163633765 -36663165656562383063333538393261323062336662346539623335643463336437636334396661 -62656163356530333534313539356436323733393663313265656431613130613137306530643538 -32393362623237393764313930646661636565363331643431303533323838323030366562376231 -62636536363733623536346339356634303236656531393737333834396231386637353638666638 -62323964666530313361333666326238626439323834393434633831316466623938653431396434 -37326136396134326162383331656563346339623032646565336262636632636433313439383264 -34336432393761613938623839396138376533326663656161393331383461353234626637343633 -65633765363064663636363031653636313034636563326565353931656633626236333037633261 -30666633306133386536343133383538636336353261376531626566383134613966343766386232 -30386464343731626634626234386633343462366434303763383733386263396361353132343339 -62636130346262336637643934643838333762623931323230333137366363333062343763393762 -35616630333138383034386232626532636532623962636534353130323732613937323231313637 -39323837396133366363366261326232656464356338336362336163333362313661303433356562 -64353431333761376237343062333266343664386439663964333538653134663237396538333031 -61323031376235363137623364393735383337383661333762343561373433376137373234613938 -64633531656230333465303666643034346236373532306139323466383134636361613262636162 -31336135636237393565313334666230646630376462393937393565333531643735616432306665 -66313361313835363333373562333764353236653331666431363838653565613562343437353432 -34653933363131323932363333336466346631303036613134323063376364363763313730646465 -37663637613866623432316165616463613739336632646332386532313438363766656566373430 -64383930373333396135663662646230656565613161616238306338376332653362353430646637 -61666636363332343733613263343030613164393237616238363562373938383865643031343032 -37613238353935366638363564643461326330383339343431396434643430643434383365383162 -66643535353565333838636265386365666261656637633133633164616566323061363837323364 -65653037386133393039353062313630353065653436666333613637376534653665633261623239 -66616134613766353264353864323464396364653838363363393036343132633630393132343631 -35656434643631323630343230323537653334663135393439356263666237333662373631323538 -31653839336436636130653035373061323038623339623336313935373530646331346131663838 -32313835376566366464656634633261353562323566383330386336396335653731636636343062 -66623533663539326461393739663063343666636239633839643330356537346231653034353934 -63396662363133386635666232333535373038333632656336633736393733643566393462663631 -64353137653032653263366266623531323633346661343561306161643334633237633532353434 -36373532383532373936383532633936616436623135653263613338393232623739363132666166 -37343337333561346331313336396331346666653138666262356434646536313731613938616634 -34626466333630653765343665653465643933306533626634333635336565646236613633366532 -36313539373736383834373833373836316137313639336231386662663836303861353465306639 -32303035303832666564653032636339663830333930313630316536333966366536653133656338 -32666432663064376436653865366138353337393665616562356434663031626138386334633661 -62393565303164343965313166646361356262353063623134333936313963316139636432383738 -34663736306663373666623538633732663630646136333135663433356336666635306132343032 -64333565396635346337303663383865323262636365356537376465656631613462326264643835 -37333933363339323836346338623562323737356535323762356235363964383265333836343761 -65666465306539666437386436666262663163393639663662393363306237356630616630363863 -39363338366365366430333730323133396633366136353039306437383162313131656563623664 -39343639663037323535363437623936336235353237356164316161343364383736373630626335 -37333539633064323232373330366239636631306264353661343861333530366439366131643936 -32643132616537643339653730303835623235636561316261396238353463643133313263383463 -63323332393939303564656436326238386266366464373038376263633135303164383261376235 -61323830386537323762393134666163663064613330636235383837623436353339336561633732 -38363130633338666334383864383935326131376566313133313166333639653338653037393139 -31626138643339643137613864633662303162343166643039623062663338346561633430643065 -62316535373631353665323938646464623863323632346463336430663031393435333463303930 -36363434306135313332623839313138353132323266636163333661383634306434306164363735 -32333632343265313831323235363764343061363537323963646430333031363534353065303063 -63303265383234303335383638343438323636323235663230313762313566663833333866383134 -62663061383464616565626635313732343335356536633932323639306661663430336230353064 -36393066633330633438353431373761653761373439353463346163646232653865366533396462 -39306462383862646436353339313734333463336530326433326634336264313034343431353037 -65393461616361666462366234666563393234633862616532323966346662643533393832626133 -34313435626264376334313066333638376562666633356231613037303536343431623666643937 -63326330303830356436393131376331393732636161306633643630663836306266343766306332 -63656331353438643636623763323866376435616161633734613532636663653939333434356333 -66613162616664373561666232313036323733353535343238393665636433326234653163663834 -31616336653664316337393762626463353065643837303737313336656264613230663430636466 -31326537306662373062303761623261363766643665393835613733646161623361356132353265 -30366336616463386334643966633633643261333833636130353362643233666339303235356366 -34626564633062363336383431376631343836366561653634396638326262323062303237336566 -64643365636232633338643035353030326130643164303231363537646465353562363938626265 -64393464333330333635313338666565366138643866663966643362633237366634643465353366 -31646262623865366664646662613931343963343364323234613935373362316539633430353535 -30386531343932373537376137373335313965313763623333303935643965633338373530626661 -34353439626664383639623665336135623234336435653261316635646364366233383034346533 -66633736613636396336323665666431346135346336656538623361336236653262653063386562 -64373634643065663765313331353438313139386333313263643639633861663431313833653263 -61363930386632663937663863333561363533363434346132396366626234306136646161653935 -61336362313439336439356663666264343935313137653264336539386262666536333930356235 -39323263623461373336336364666466336631643738333731366230616232323737353164356361 -61346530373561383864 +33636666323832646139323162666263383232643233633539303464363730636163343162663930 +6132323032626433306635626239643764653966316262650a316366343264303835633063613961 +38386666623865633236616364303864663133396562313664313030393435613065636265383333 +6366643932666265610a373331363731343531363763626337313664633933383163363635336136 +35376131363764616139333734623930373233653961383535623861373361643433313761623663 +32633836333063313630633936346366306637323638326337376630646435306163366262373037 +66613765633463333934373264633332333532376461313137333133356333313964663233313632 +35396630396135643761336237636463313233623064316233666237343562343936346530393230 +66616638316665353232353738616532393638396364313433646134373336313631396633313731 +32363361366563643039383735643132643465326331613564306261376332656136656438313738 +33316432633231313837376238396538666562323662393634393661643966393262323238363639 +66366564356431653664633663366564303561313134653866396134386561396635343230643331 +38346661333436356237323136306238636337396266363265393865363535636164633036613730 +30386637363834633934343839323238366639383964646531393862363363626538303035343938 +38323166653835343961653664666432616162386532353563346663373536613233623035643431 +35323136643236366463646365343266383937643062363232336435616134666338646361383864 +37393633313531643064643336646161323930363032356630313438396134646361373466396533 +33653335316162373832336665353334613031316436393664343963316330333062633737636264 +63343766666639626235623535316432373431363931623432643566366130303166353866376464 +38313332613333656236333832363136323563633966386666323666396536336637373562383962 +31643966383465356464306530623437663139633761316161313532656662616139323461636133 +39336534366632363935386236353336656239363131313333653966633561396230613665613261 +35383735323237323838366637313765623132346230393633653063613034373263353866613734 +39316431306430316536346334623563653762333030656632336537363562666265316633373836 +33383766363361616663376630356561323565316531623138356135353139616465663138373634 +31326539626331383839343332653230653337393031353934663634386133616437633834383437 +61663561353837353831363931663434363137326264613465366438323763303465366238643233 +37646337323363333166643366363434366336383736623561616665613232643438356432626363 +35616162663730636163383233633263626435626331343635663130303633643538373136653936 +65323731316464326364343061353561623535653530623636396165343134393865666133356466 +37643137306235663635643166363364323135613736363261393739376531363863653136313133 +30306566346533343963386432396431393738396531373862316461633765353766646533326461 +36316430326430353333306261353633343035383139303866656431626364646636656131363332 +31396635663362373731313265643336626266306333336130323761383262333032626662346666 +62356635393032393837356166306335326462393365346639623237346438353637323038613834 +64633439633237666131646664326531343836393538376237363338626634336431663561353663 +35343837366263353635396538626262653930653961393166646261393763643135386630653666 +34373464663065656365336536666631663831363832333136653065626436356266633735663834 +32343133623835353062353733663530323138666232633961393365393563326462653164633266 +32353839393635616661646133356538373938613232303837326439623839333637313138666535 +38316161633365376438616261663463386334633436353530663965376432313834396638306237 +36613665383965636533353532396566343661633763363638343064393031653230393037666166 +30613039376365666236366263623361643266633236336633386438663938663938656565316136 +36656237376366616163623334316130383363393834643033363338343362313863313638383433 +63313264336632316663306665653630376266656233353439646637356365353063613961376231 +61643137623365393132353462386134333430663466666165613937333964373230396535393134 +30396134616463656464343637656562646165396635353066646633373832356261626634366138 +62326138343435666662396630363136393634306335653063396134383731383165663432373131 +34326363643037326465326435616164393033363565366135313133393866396136356137663139 +66316138663732393430633338346136353738626534633164623830663734343337636562316538 +61323566326434643036363866363263616435356466303464653131633937353233376539616465 +36303738343262373761326538616632393761383662656231336434383334333735613264393662 +37653336336666333765663434393765313664316332643030333464376566306666323833663036 +62653964643532306436626261363161633937323835663036343133353065313866373639313633 +31663635376266653639626365383430346666363262666638323564353661386137313865653337 +62306530383332343931653137353139363236393137613437663333633664653230306264316432 +61353132656564383437386237323765393034393237376531343331623966343636626534616232 +61613538396636633737643331663333336666313966633739633936333535376264346231363939 +39353133396562623466646237303639313665613863633531396235306166333936373733396532 +32663737363765663638633739336438613663363430386338373361306636313366356135363362 +62316666356331623965333930336566393032386364336266636338323337353661653638663663 +38623463353061663134313265323530346266636665373833653461353237366135623832643732 +65613231646431373537636663386237613435373734633763306434393133653133333830626365 +62376166316639366161616635616234316234383230376539616337656637663332306136333662 +35396166303166373163383836303963343434343735383665376533613532363331613437656164 +38386336653361633866623136666131356537303038343061313034623761656234396266306233 +33616338393662303737643932653738303438393335623162363732363339363231396432343361 +30646539306332333639343737326366653433386363373033363562353535623431316363363736 +64663863653664366136643234626261653039393031363161333337643166366634303631633261 +30323866643266333132326564376263333434343565343738613632393838346331616165663766 +32343735316334653136393838363763333939646261646333633030383932373461373266346134 +36306336346339646639326333353531393563323265303936663036653334333065313033613936 +63643036336562346261316434646539333163323233393638636165383935633535366637623431 +34373731306436613964646138353539393231633336373937613165636535613731353830616535 +63326632303662323433656133626266613566663730386532393431333862656239646633663663 +66353363663135613761616136326134633538373661396666643832376137346132666232623939 +66323139623332393834633532396230666463656637336634356365363731633061646631326434 +39353134303932313134313836653163383566653832643435653166396533353062373537616234 +31316432623439303261353333643130653562366666306239633139313939303330346130663637 +30656238626131343131363530306431336366303735653532666231656531343230306232393130 +30343537343064626531343530373435373561623231336539373331316231366461616464383461 +37326139633636656632663362613530636436323832613633336339346634616239386363363964 +61383538636433316133323263326265313661646439393162393735313036363361653638353665 +62326565343431343962316339653237613735643934363661326534643663383666343165653937 +66633863666537663366653565386335663663353863666632316334306562656666666532326666 +36376435373530303530666535356435663735353233633561306564326231653563663862303137 +61616432366566333733333765356561613538383836363338386435373561626133303938353735 +39333236346135343930393930353433393136613537383736356661383133623334636263383130 +32626431333532326238373466663732346331393463643936343635303837623531356334383031 +36326364333266633938386330623833356662373634363865306162666639613537376130363534 +33393566356137353539633932643065313733633838336531306433633063306635616163363064 +35646436646633373834343561383237633131643233326133663835383838616162333831363766 +38376265333835373836343964633366623561386565623734373661333238646630326439643539 +65306366333863636634623763356534323132346566393733633564643966663962653236363933 +61336233383133616138303661623764303865313230366162653066623737383261363633623339 +30666230343830323634363465313132623132336436346138386266383364363131613433646435 +38333332326363326262353234376434656231336136366430303434303032623238633362343330 +37333935626264353637666666316564653966376365373464616563353861343166316165303563 +39653763393131356661386634653237633130663533356234656465356533343963653330356137 +35353763373363313061653637333166323834333033653332316432623938393966303632383065 +63656237616231636564386438333564613935313835326536383064656464363261643164623863 +64356435626539623230323132333364386362323533303961396337336438353264643265626464 +66666266613036613835313130646638613532373062663132326162396636623931363734613262 +39396232646235666130386334633665643833326138663534376562393936616264623161626164 +62663361336466636436383663663132356161393462373263373132633835663730346231396166 +33363738343531653636313236666231393538653934613639383366386136386133623937626337 +61373333366630396162656138343537363338326239373938376465376538666236313932373364 +34333165393331313331393736623362366637383231666664383133323135646163306639396162 +62353366343839666333376530326334303936666139383936363462393566653732353431656530 +33336237666535646565383731333966626632383661653666316339623631373532383937643932 +65373535626537393632333366613530393265323763316533386335343737313462343562333338 +30663130623633376465333665333738653566656237323563653230653130653938373966626635 +34356432303938613231316663326662333733363036333265393233343862356233383961323464 +30346162383137373735646336343463376534383235626233306538373463366264393130663066 +32333236313531613238396136343538343439343062353266643838363136343433623837313631 +64313865383762396231643265613839643539306137363834373165313832633631373234626439 +61333533383236333432613564643431613039366661663262626330376133616331363037343838 +34336365663730356433613734393639333139323436316635656539626261326336343039666262 +61653766363430383037326532323834373663346563393766313335383531323537626537643335 +32373034636461353635643731346239333634353361326237303134666632383266303166363932 +39653734636137393635343131383766356136383965336536343039613266373738393737643564 +66353766666633626261653863363331386534663965333130353764396263323536316162643730 +36386162613537626164386335363737613361653831376265623939633362343065626633363363 +35323166663634373563396234663263363064363930656434323864616463613233666632363635 +37623565646131633433386633376230643332626564333565373362363561656366393931366231 +38356131343837663031366133666263633330656339633237376362323765373064323236653264 +36333163393565393138306435353839343062356530633966633235656531616363313432636163 +33323934323731323338383230393465646664396535353535336130363864306631353164373238 +35383637653161356233306165363564636130613538663363653134643439393931393266323564 +37336534353836656462393339623333363132663539313665626462303866316463626330373733 +31363636363038636661373062383762323335326163353634643237393563303139643034636532 +30643836306262393335376461333762346439646433643037393438353339653730393830383935 +61326333643862333365636535396433313235666433333563656330663763353833326630356164 +65346636393061653039643436353763343839326131383534663137313637313265666431666461 +38656634633731303036376537313465393234616436353566396338393534613935656561666133 +33613936336530303763616664323433656362643334343061333563656634313864633032616366 +62363133336138613366313135643633643135613963303466633330303633626435373632303938 +62613332353033396636333365346439373539343037313065333733613962343737336531636537 +36646233623463343530346162346230343037323366363730376532326633323334663765323762 +66616138313434623032623437343438343530363132613564353532363235643962306162643035 +33633234613336386234653036333462336539356530393032303662323032616536323264363862 +37626437353232393335373765333732616532383333373438623439393932613330373264393731 +62633936303436656661303130336363633637666531343263373633663334386434393762633732 +36333430653037643339363330376163396132343830396161643864376436393964646264636239 +33623733303163316137616533646462633866343932656539383363333631316338653239343734 +32666130633238313763313437643038616430363566313337363465353335353630333362373265 +38363338383261663636366233346262333431393766613236383830393662363033326535376137 +64666338343630373066663363393939383436623535663362656637323833363061313936343831 +36353166666239303032666466333662613935393634663534646534313766316533666539626636 +64353063373539363136303731313130343439643562623433636630616238343339346362383036 +30353031353366343332613461623837353736316665316234643235366661626464386534353332 +30313662313665343138656430353562343366626130383639663964396633343865613333363233 +65303831343537393834663930303164653164376466336562333633623039613734663132333665 +6636323466636239373237353264623363383330623932373133 diff --git a/infra-config/host_vars/docker01/vars b/infra-config/host_vars/docker01/vars new file mode 100644 index 0000000..2ba0fe7 --- /dev/null +++ b/infra-config/host_vars/docker01/vars @@ -0,0 +1,11 @@ +--- +# file: host_vars/matchbox/vars + +# Networking +# primary_interface: "enp1s0f0" +mac_address: "BC:24:11:03:A9:7B" +ip_address: 10.1.71.211 +hostname: "docker01.{{ base_domain }}" + +# Software +#terraform_version: "1.11.3" diff --git a/infra-config/host_vars/n8n/vars b/infra-config/host_vars/n8n/vars new file mode 100644 index 0000000..6512339 --- /dev/null +++ b/infra-config/host_vars/n8n/vars @@ -0,0 +1,11 @@ +--- +# file: host_vars/matchbox/vars + +# Networking +# primary_interface: "enp1s0f0" +mac_address: "BC:24:11:1B:BB:92" +ip_address: 10.1.71.81 +hostname: "n8n.{{ base_domain }}" + +# Software +#terraform_version: "1.11.3" diff --git a/infra-config/host_vars/sql01/vars b/infra-config/host_vars/sql01/vars new file mode 100644 index 0000000..305b4c1 --- /dev/null +++ b/infra-config/host_vars/sql01/vars @@ -0,0 +1,11 @@ +--- +# file: host_vars/matchbox/vars + +# Networking +# primary_interface: "enp1s0f0" +mac_address: "BC:24:11:1C:95:1B" +ip_address: 10.1.71.91 +hostname: "sql01.{{ base_domain }}" + +# Software +#terraform_version: "1.11.3" diff --git a/infra-config/host_vars/unbound02/vars b/infra-config/host_vars/unbound02/vars new file mode 100644 index 0000000..0dc2c44 --- /dev/null +++ b/infra-config/host_vars/unbound02/vars @@ -0,0 +1,25 @@ +--- +# file: host_vars/unbound02/vars + +# Host Definition +platform: "proxmox" +hostname: "{{ inventory_hostname }}.{{ base_domain }}" #change variable to fqdn + +# Networking +ip_address: 10.1.71.252 +# primary_interface: "enp1s0f0" +# mac_address: "BC:24:11:03:A9:7B" # convert this to a proxmox read for VMs + +# VM Definition +proxmox_target_node: "pve02" +vm_cpus: 1 +vm_memory: 2048 +vm_storage: "pve-general" +vm_disk_size: "16" # GB +vm_net_bridge: "vmbr1" +vm_net_vlan: ",tag=71" +# vm_disk_size: 20 +# vm_disk_type: "virtio" + +# Software +#terraform_version: "1.11.3" diff --git a/infra-config/inventory.yml b/infra-config/inventory.yml index d2d4e55..9eb34ce 100644 --- a/infra-config/inventory.yml +++ b/infra-config/inventory.yml @@ -3,7 +3,11 @@ proxmox: hosts: pve0[1:3]: -backup: +unbound_servers: + hosts: + unbound02: + +backup_servers: hosts: backup: @@ -19,3 +23,15 @@ matchbox: hub_cluster: hosts: ocp-hub: + +sql_servers: + hosts: + sql01: + +n8n_servers: + hosts: + n8n: + +docker_servers: + hosts: + docker01: \ No newline at end of file diff --git a/infra-config/test1.yml b/infra-config/test1.yml new file mode 100644 index 0000000..f342f48 --- /dev/null +++ b/infra-config/test1.yml @@ -0,0 +1,102 @@ +--- +- name: Test IP address parsing - extract last two octets + hosts: localhost + gather_facts: false + + vars: + test_ip: "192.168.1.100" + + tasks: + - name: Method 1 - Using split and join + ansible.builtin.set_fact: + last_two_octets_1: "{{ test_ip.split('.')[-2:] | join('.') }}" + + + - name: Display results + ansible.builtin.debug: + msg: | + Original IP: {{ test_ip }} + Method 1 (split + join): {{ last_two_octets_1 }} + + + - name: Test with different IP addresses + ansible.builtin.set_fact: + test_ips: + - "10.0.0.1" + - "172.16.254.1" + - "192.168.100.200" + - "8.8.8.8" + + - name: Process multiple IPs + ansible.builtin.set_fact: + results: "{{ results | default([]) + [{'ip': item, 'last_two': item.split('.')[-2:] | join('.')}] }}" + loop: "{{ test_ips }}" + + - name: Display all results + ansible.builtin.debug: + msg: "{{ results }}" + + # New tasks for 3-digit formatting + - name: Method 1 - Format last octet to 3 digits using zfill + ansible.builtin.set_fact: + last_two_octets_3digits_1: "{{ test_ip.split('.')[-2] }}.{{ (test_ip.split('.')[-1] | int) | string | zfill(3) }}" + + - name: Method 2 - Format last octet to 3 digits using format + ansible.builtin.set_fact: + last_two_octets_3digits_2: "{{ test_ip.split('.')[-2] }}.{{ '%03d' % (test_ip.split('.')[-1] | int) }}" + + - name: Method 3 - Format last octet to 3 digits using sprintf + ansible.builtin.set_fact: + last_two_octets_3digits_3: "{{ test_ip.split('.')[-2] }}.{{ (test_ip.split('.')[-1] | int) | string | sprintf('%03d') }}" + + - name: Display 3-digit formatting results + ansible.builtin.debug: + msg: | + Original IP: {{ test_ip }} + Method 1 (zfill): {{ last_two_octets_3digits_1 }} + Method 2 (format): {{ last_two_octets_3digits_2 }} + Method 3 (sprintf): {{ last_two_octets_3digits_3 }} + + - name: Test 3-digit formatting with different IPs + ansible.builtin.set_fact: + test_ips_3digits: + - "10.0.0.1" + - "172.16.254.1" + - "192.168.100.200" + - "8.8.8.8" + - "192.168.1.10" + - "10.0.0.255" + + - name: Process multiple IPs with 3-digit formatting + ansible.builtin.set_fact: + results_3digits: "{{ results_3digits | default([]) + [{'ip': item, 'last_two_3digits': item.split('.')[-2] + '.' + ('%03d' % (item.split('.')[-1] | int))}] }}" + loop: "{{ test_ips_3digits }}" + + - name: Display all 3-digit results + ansible.builtin.debug: + msg: "{{ results_3digits }}" + + # VM ID creation without dot separator + - name: Create vm_id using format (no dot separator) + ansible.builtin.set_fact: + vm_id: "{{ test_ip.split('.')[-2] }}{{ '%03d' % (test_ip.split('.')[-1] | int) }}" + + - name: Create vm_id using sprintf (no dot separator) + ansible.builtin.set_fact: + vm_id_sprintf: "{{ test_ip.split('.')[-2] }}{{ (test_ip.split('.')[-1] | int) | string | sprintf('%03d') }}" + + - name: Display vm_id results + ansible.builtin.debug: + msg: | + Original IP: {{ test_ip }} + VM ID (format): {{ vm_id }} + VM ID (sprintf): {{ vm_id_sprintf }} + + - name: Test vm_id with different IPs + ansible.builtin.set_fact: + vm_id_results: "{{ vm_id_results | default([]) + [{'ip': item, 'vm_id': item.split('.')[-2] + ('%03d' % (item.split('.')[-1] | int))}] }}" + loop: "{{ test_ips_3digits }}" + + - name: Display all vm_id results + ansible.builtin.debug: + msg: "{{ vm_id_results }}" diff --git a/step-by-step.md b/step-by-step.md index d16d739..d521346 100644 --- a/step-by-step.md +++ b/step-by-step.md @@ -87,6 +87,13 @@ Other needed software: ### [FreeIPA](04-free-ipa/README.md) *Manual* +### Update DNS + +```bash +cd /infra-config +ansible-playbook -i inventory.yml site.yml --tags update-dns -v +``` + ### [Templates](05-templates/README.md) *Manual* ### [Matchbox](06-matchbox/README.md) *Manual*