From debd25dfb5c2ac57f3e8ffd276300ccd2b1041a7 Mon Sep 17 00:00:00 2001 From: Alessandro Chitolina Date: Mon, 29 Jul 2024 13:06:48 +0200 Subject: [PATCH 1/2] feat: add proxmox ubuntu 24.04 --- docs/book/src/capi/providers/proxmox.md | 1 + images/capi/Makefile | 3 +- .../ansible/roles/providers/tasks/main.yml | 3 + .../ansible/roles/providers/tasks/proxmox.yml | 57 ++++++++++++++ .../proxmox/linux/ubuntu/http/24.04/meta-data | 0 .../proxmox/linux/ubuntu/http/24.04/user-data | 75 +++++++++++++++++++ images/capi/packer/proxmox/packer.json | 1 + images/capi/packer/proxmox/ubuntu-2404.json | 13 ++++ 8 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 images/capi/ansible/roles/providers/tasks/proxmox.yml create mode 100644 images/capi/packer/proxmox/linux/ubuntu/http/24.04/meta-data create mode 100644 images/capi/packer/proxmox/linux/ubuntu/http/24.04/user-data create mode 100644 images/capi/packer/proxmox/ubuntu-2404.json diff --git a/docs/book/src/capi/providers/proxmox.md b/docs/book/src/capi/providers/proxmox.md index 3a7cb6d20a..92cb0fbfb5 100644 --- a/docs/book/src/capi/providers/proxmox.md +++ b/docs/book/src/capi/providers/proxmox.md @@ -37,6 +37,7 @@ the different operating systems. | File | Description | |--------------------|-----------------------------------------| | `ubuntu-2204.json` | The settings for the Ubuntu 22.04 image | +| `ubuntu-2404.json` | The settings for the Ubuntu 24.04 image | The full list of available environment vars can be found in the `variables` section of `images/capi/packer/proxmox/packer.json`. diff --git a/images/capi/Makefile b/images/capi/Makefile index 7526a126e7..0b6e80782b 100644 --- a/images/capi/Makefile +++ b/images/capi/Makefile @@ -382,7 +382,7 @@ NUTANIX_BUILD_NAMES ?= nutanix-ubuntu-2004 nutanix-ubuntu-2204 nutanix-ubuntu-24 HCLOUD_BUILD_NAMES ?= hcloud-ubuntu-2004 hcloud-ubuntu-2204 hcloud-ubuntu-2404 hcloud-centos-7 hcloud-rockylinux-8 hcloud-rockylinux-9 hcloud-flatcar -PROXMOX_BUILD_NAMES ?= proxmox-ubuntu-2204 +PROXMOX_BUILD_NAMES ?= proxmox-ubuntu-2204 proxmox-ubuntu-2404 VULTR_BUILD_NAMES ?= vultr-ubuntu-2204 @@ -849,6 +849,7 @@ build-hcloud-flatcar: ## Builds the Hetzner Cloud Flatcar image build-hcloud-all: $(HCLOUD_BUILD_TARGETS) ## Builds all Hetzner Cloud image build-proxmox-ubuntu-2204: ## Builds the Proxmox ubuntu-2204 image +build-proxmox-ubuntu-2404: ## Builds the Proxmox ubuntu-2404 image build-vultr-ubuntu-2204: ## Builds Ubuntu 22.04 Vultr Snapshot diff --git a/images/capi/ansible/roles/providers/tasks/main.yml b/images/capi/ansible/roles/providers/tasks/main.yml index 33f8ae6eb4..e1ea07a37c 100644 --- a/images/capi/ansible/roles/providers/tasks/main.yml +++ b/images/capi/ansible/roles/providers/tasks/main.yml @@ -33,6 +33,9 @@ - ansible.builtin.include_tasks: oci.yml when: packer_builder_type.startswith('oracle-oci') +- ansible.builtin.include_tasks: proxmox.yml + when: packer_builder_type.startswith('proxmox') + - ansible.builtin.include_tasks: qemu.yml when: packer_builder_type is search('qemu') and build_target is not search('raw') diff --git a/images/capi/ansible/roles/providers/tasks/proxmox.yml b/images/capi/ansible/roles/providers/tasks/proxmox.yml new file mode 100644 index 0000000000..54c8404158 --- /dev/null +++ b/images/capi/ansible/roles/providers/tasks/proxmox.yml @@ -0,0 +1,57 @@ +# Copyright 2020 The Kubernetes Authors. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +--- +- name: Install cloud-init packages + ansible.builtin.apt: + name: "{{ packages }}" + state: present + force_apt_get: true + vars: + packages: + - cloud-init + - cloud-guest-utils + - cloud-initramfs-copymods + - cloud-initramfs-dyn-netconf + when: ansible_os_family == "Debian" + +- name: Install cloud-init packages + ansible.builtin.yum: + name: "{{ packages }}" + state: present + vars: + packages: + - cloud-init + - cloud-utils-growpart + when: ansible_os_family == "RedHat" + +- name: Disable Hyper-V KVP protocol daemon on Ubuntu + ansible.builtin.systemd: + name: hv-kvp-daemon + state: stopped + enabled: false + when: ansible_os_family == "Debian" + +- name: Copy networkd-dispatcher scripts to add DHCP provided NTP servers + ansible.builtin.template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: a+x + vars: + server_dir: /var/lib/dhcp + chrony_helper_dir: /usr/libexec/chrony + loop: + - { src: files/etc/networkd-dispatcher/routable.d/20-chrony.j2, dest: /etc/networkd-dispatcher/routable.d/20-chrony } + - { src: files/etc/networkd-dispatcher/off.d/20-chrony.j2, dest: /etc/networkd-dispatcher/off.d/20-chrony } + - { src: files/etc/networkd-dispatcher/no-carrier.d/20-chrony.j2, dest: /etc/networkd-dispatcher/no-carrier.d/20-chrony } + when: ansible_os_family == "Debian" diff --git a/images/capi/packer/proxmox/linux/ubuntu/http/24.04/meta-data b/images/capi/packer/proxmox/linux/ubuntu/http/24.04/meta-data new file mode 100644 index 0000000000..e69de29bb2 diff --git a/images/capi/packer/proxmox/linux/ubuntu/http/24.04/user-data b/images/capi/packer/proxmox/linux/ubuntu/http/24.04/user-data new file mode 100644 index 0000000000..8af863154b --- /dev/null +++ b/images/capi/packer/proxmox/linux/ubuntu/http/24.04/user-data @@ -0,0 +1,75 @@ +#cloud-config +autoinstall: + version: 1 + # Disable ssh server during installation, otherwise packer tries to connect and exceed max attempts + early-commands: + - systemctl stop ssh + # Configure the locale + locale: en_US.UTF-8 + keyboard: + layout: us + ssh: + install-server: true + allow-pw: true + packages: + - qemu-guest-agent + apt: + mirror-selection: + primary: + - uri: http://archive.ubuntu.com/ubuntu + # Create a single-partition with no swap space. Kubernetes + # really dislikes the idea of anyone else managing memory. + # For more information on how partitioning is configured, + # please refer to https://curtin.readthedocs.io/en/latest/topics/storage.html. + storage: + grub: + replace_linux_default: false + config: + - type: disk + id: disk-0 + size: largest + grub_device: true + preserve: false + ptable: msdos + wipe: superblock + - type: partition + id: partition-0 + device: disk-0 + size: -1 + number: 1 + preserve: false + flag: boot + - type: format + id: format-0 + volume: partition-0 + fstype: ext4 + preserve: false + - type: mount + id: mount-0 + device: format-0 + path: / + updates: 'all' + # Create the default user. + # Ensures the "builder" user doesn't require a password to use sudo. + user-data: + users: + - name: builder + # openssl passwd -6 -stdin <<< builder + passwd: $6$xyz$UtXVazU08Q5b8AW.TJ3MPYZglyXa3Ttf2RCel8MCUPlEYO1evWxeWBhZ2QqivU/Ij4tqYAxMCqc2ujEM4dMSe1 + groups: [adm, cdrom, dip, plugdev, lxd, sudo] + lock-passwd: false + sudo: ALL=(ALL) NOPASSWD:ALL + shell: /bin/bash + + # This command runs after all other steps; it: + # 1. Disables swapfiles + # 2. Removes the existing swapfile + # 3. Removes the swapfile entry from /etc/fstab + # 4. Cleans up any packages that are no longer required + # 5. Removes the cached list of packages + late-commands: + - swapoff -a + - rm -f /swapfile + - sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab + - apt-get purge --auto-remove -y + - rm -rf /var/lib/apt/lists/* diff --git a/images/capi/packer/proxmox/packer.json b/images/capi/packer/proxmox/packer.json index b882be43e3..ea41b515e1 100644 --- a/images/capi/packer/proxmox/packer.json +++ b/images/capi/packer/proxmox/packer.json @@ -109,6 +109,7 @@ "--scp-extra-args", "{{user `ansible_scp_extra_args`}}" ], + "pause_before": "10s", "playbook_file": "./ansible/node.yml", "type": "ansible", "user": "builder" diff --git a/images/capi/packer/proxmox/ubuntu-2404.json b/images/capi/packer/proxmox/ubuntu-2404.json new file mode 100644 index 0000000000..db7813b1fa --- /dev/null +++ b/images/capi/packer/proxmox/ubuntu-2404.json @@ -0,0 +1,13 @@ +{ + "boot_command_prefix": "clinux /casper/vmlinuz --- autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/24.04/'initrd /casper/initrdboot", + "build_name": "ubuntu-2404", + "distribution_version": "2404", + "distro_name": "ubuntu", + "iso_checksum": "8762f7e74e4d64d72fceb5f70682e6b069932deedb4949c6975d0f0fe0a91be3", + "iso_checksum_type": "sha256", + "iso_url": "https://releases.ubuntu.com/releases/24.04/ubuntu-24.04-live-server-amd64.iso", + "os_display_name": "Ubuntu 24.04", + "source_image": "ubuntu-20-04-x64", + "unmount_iso": "true", + "version": "24.04" +} From 02cc0a85cf897c3b348256511c9e9b965457d87b Mon Sep 17 00:00:00 2001 From: Alessandro Chitolina Date: Tue, 30 Jul 2024 15:45:12 +0200 Subject: [PATCH 2/2] fix: copyright notice year --- images/capi/ansible/roles/providers/tasks/proxmox.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/capi/ansible/roles/providers/tasks/proxmox.yml b/images/capi/ansible/roles/providers/tasks/proxmox.yml index 54c8404158..fe58d96935 100644 --- a/images/capi/ansible/roles/providers/tasks/proxmox.yml +++ b/images/capi/ansible/roles/providers/tasks/proxmox.yml @@ -1,4 +1,4 @@ -# Copyright 2020 The Kubernetes Authors. +# Copyright 2024 The Kubernetes Authors. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.