From 871756ec1b9d04aa4135e43f009a09aeba68f919 Mon Sep 17 00:00:00 2001
From: Evangelos Foutras <evangelos@foutrelis.com>
Date: Thu, 11 Aug 2022 05:24:28 +0300
Subject: [PATCH] install_arch: skip ucode update for hcloud/packer

Microcode updates are not applicable to cloud servers.
---
 roles/install_arch/tasks/main.yml | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/roles/install_arch/tasks/main.yml b/roles/install_arch/tasks/main.yml
index adeae6307..c6b54ff78 100644
--- a/roles/install_arch/tasks/main.yml
+++ b/roles/install_arch/tasks/main.yml
@@ -81,16 +81,21 @@
   register: chroot_pacman_key_populate
   changed_when: "chroot_pacman_key_populate.rc == 0"
 
-- name: install ucode update for Intel
-  set_fact: ucode="intel-ucode"
-  when: "'GenuineIntel' in ansible_facts['processor']"
-
-- name: install ucode update for AMD
-  set_fact: ucode="amd-ucode"
-  when: "'AuthenticAMD' in ansible_facts['processor']"
+- name: install ucode update
+  block:
+    - name: install ucode update for Intel
+      set_fact: ucode="intel-ucode"
+      when: "'GenuineIntel' in ansible_facts['processor']"
+
+    - name: install ucode update for AMD
+      set_fact: ucode="amd-ucode"
+      when: "'AuthenticAMD' in ansible_facts['processor']"
+  when:
+    - "'hcloud' not in group_names"
+    - inventory_hostname != 'packer-base-image'
 
 - name: install arch base from bootstrap chroot
-  command: chroot /tmp/root.x86_64 pacstrap /mnt base linux btrfs-progs grub openssh python-requests python-yaml inetutils {{ ucode }}
+  command: chroot /tmp/root.x86_64 pacstrap /mnt base linux btrfs-progs grub openssh python-requests python-yaml inetutils {{ ucode | default('') }}
   args:
     creates: /tmp/root.x86_64/mnt/bin
 
-- 
GitLab