chore: first commit

This commit is contained in:
Clément Désiles
2025-07-25 20:23:54 +02:00
parent 5c4016357f
commit c612cc7839
88 changed files with 3255 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
# net-persist
This role prevent the machine interface to change its name, thus to make unexpected changes to the network configuration. This rely on the mac address of the interface to map it to a static interface name.
If for some reason you might change your mac address (on a virtual machine for example), please update your inventory accordingly.
## Requirements
None
## Input variables
- `interface`:
```python
{
'mac_address': '02:a0:c9:8d:7e:b6',
'ip': '192.168.1.2',
'netmask': '255.255.255.0',
'gateway': '192.168.1.254',
'dns': ['1.1.1.1', '8.8.8.8'],
'name': 'lan0'
}
```
## License
MIT
## Author Information
Jokester <main@jokester.fr>
+19
View File
@@ -0,0 +1,19 @@
---
galaxy_info:
author: Jokester <main@jokester.fr>
description: Force the primary network interface to be 'lan0'
license: MIT
min_ansible_version: "2.10"
galaxy_tags:
- network
- persistent
- debian
- archlinux
- lan0
platforms:
- name: Debian
versions:
- all
- name: ArchLinux
versions:
- all
+34
View File
@@ -0,0 +1,34 @@
---
- name: Check if the interface is already named as expected
set_fact:
interface_original_name: "{{ ansible_facts.interfaces
| select('in', ansible_facts)
| map('extract', ansible_facts)
| selectattr('pciid', 'defined')
| selectattr('macaddress', 'equalto', interface.mac_address)
| map(attribute='device')
| first
}}"
- name: What patch is needed
debug:
msg: >-
{%- if interface_original_name != interface.name -%}
iface {{ interface_original_name }} ({{ interface.mac_address }}) will be patched to {{ interface.name }}.
{%- else -%}
iface {{ interface.name }} is already set, no action needed.
{%- endif -%}
- name: Create persistent-net link file
when: interface_original_name != interface.name
template:
src: persistent-net.link.j2
dest: /etc/systemd/network/10-persistent-net-{{ interface.name }}.link
owner: root
group: root
mode: "0644"
- name: Notify a reboot is required
set_fact:
reboot_required: true
when: interface_original_name != interface.name
@@ -0,0 +1,10 @@
# -----------------------------------------------------------------------------------
# Forcing {{ interface.name }} to be predictable
# see https://wiki.debian.org/NetworkInterfaceNames#CUSTOM_SCHEMES_USING_.LINK_FILES
# see https://wiki.archlinux.org/title/Network_configuration#Change_interface_name
# -----------------------------------------------------------------------------------
[Match]
MACAddress={{ interface.mac_address }}
[Link]
Name={{ interface.name }}