From af82baf1d8a49e2afb65d4ea21f0bc1a2467a068 Mon Sep 17 00:00:00 2001 From: Sandwich Date: Thu, 31 Oct 2024 00:13:23 +0100 Subject: [PATCH] Include MAC-Address into the NetworkManager keyfile --- roles/bootstrap/vars/packages.yml | 2 ++ roles/configuration/tasks/main.yml | 5 +++++ roles/configuration/templates/network.j2 | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/roles/bootstrap/vars/packages.yml b/roles/bootstrap/vars/packages.yml index ee22606..64e5b26 100644 --- a/roles/bootstrap/vars/packages.yml +++ b/roles/bootstrap/vars/packages.yml @@ -179,6 +179,7 @@ rhel8: - open-vm-tools - shim - telnet + - vim - zstd rhel9: @@ -193,6 +194,7 @@ rhel9: - open-vm-tools - shim - telnet + - vim - zstd rocky: diff --git a/roles/configuration/tasks/main.yml b/roles/configuration/tasks/main.yml index 146d19d..ebbcc82 100644 --- a/roles/configuration/tasks/main.yml +++ b/roles/configuration/tasks/main.yml @@ -204,6 +204,11 @@ changed_when: net_inf.rc == 0 register: net_inf + - name: Register MAC Address of the Network Interface + ansible.builtin.shell: ip link show "{{ net_inf.stdout }}" | awk '/link\/ether/ {print $2}' | tr '[:lower:]' '[:upper:]' + register: net_mac + changed_when: net_mac.rc == 0 + - name: Copy NetworkManager keyfile ansible.builtin.template: src: network.j2 diff --git a/roles/configuration/templates/network.j2 b/roles/configuration/templates/network.j2 index f87ae10..5914e54 100644 --- a/roles/configuration/templates/network.j2 +++ b/roles/configuration/templates/network.j2 @@ -5,6 +5,7 @@ type=ethernet interface-name={{ net_inf.stdout }} [ethernet] +mac-address={{ net_mac.stdout }} [ipv4] address={{ vm_ip }},{{ vm_gw }} @@ -12,7 +13,7 @@ dns={{ vm_dns }} method=manual [ipv6] -addr-gen-mode=default +addr-gen-mode=stable-privacy method=disabled -[proxy] \ No newline at end of file +[proxy]