resolvconf

This commit is contained in:
BENEDEK László 2024-12-23 15:53:44 +01:00
parent 7f4ac7485b
commit b8224b7a6a
9 changed files with 82 additions and 30 deletions

View File

@ -1,22 +1,24 @@
[nodes]
192.168.50.1
192.168.50.2
192.168.50.3
# 192.168.50.11
# 192.168.50.12
# 192.168.50.13
# masters
192.168.50.41
192.168.50.42
192.168.50.43
# workers
# 192.168.50.44
# 192.168.50.45
# 192.168.50.46
[master-primary]
192.168.50.1
192.168.50.41
# do one at a time
# the k3s service restarts
# on the primary when a node joins
[master-secondary]
192.168.50.2
192.168.50.3
192.168.50.42
192.168.50.43
[workers]
# 192.168.50.11
# 192.168.50.12
# 192.168.50.13
# 192.168.50.44
# 192.168.50.45
# 192.168.50.46

View File

@ -0,0 +1,35 @@
- name: Install packages
ansible.builtin.apt:
name: "{{ item }}"
state: present
install_recommends: false
loop: "nfs-kernel-server rpcbind"
- name: Check the disk for existing partitions
ansible.builtin.stat:
path: "{{ storage_disk }}1"
register: partition_exists
- name: Format disk
community.general.filesystem:
fstype: "{{ fs_type }}"
dev: "{{ storage_disk }}"
when: not partition_exists
- name: Create mount
ansible.builtin.template:
src: etc-systemd-system-mnt-storage.mount.j2
dest: "/etc/systemd/system/mnt-{{ mount_path }}.mount"
mode: "0644"
- name: Enable mount
ansible.builtin.systemd_service:
name: "mnt-{{ mount_path }}.mount"
state: started
enabled: true
- name: Setup nfs-server
ansible.builtin.template:
src: etc-exports.j2
dest: /etc/exports
mode: "0644"

View File

@ -0,0 +1 @@
/mnt/cluster rw,no_root_squash

View File

@ -0,0 +1,7 @@
[Unit]
Description=mount {{ storage_disk }} at {{ mount_path }}
[Mount]
Where={{ mount_path }}
What={{ storage_disk }}1
Type={{ fs_type }}

View File

@ -1,9 +1,6 @@
packages:
- nfs-common
- curl
- systemd-resolved # needs to be the last one
# breaks dns resolution until
# systemd-networkd is configured
# hostsnames:
# - ip: x.x.x.x
@ -13,6 +10,6 @@ hostnames: []
interface_name: lan0
gateway: "192.168.50.254"
dns_servers:
nameservers:
- "192.168.11.1"
- "1.1.1.1"

View File

@ -6,7 +6,7 @@
cmd: >
update-initramfs -k all -u
- name: Warn user to reboot
ansible.builtin.set_fact:
user_notify: Reboot the machine to use the new name for primary interface!
when: systemd_networkd_ifname is changed
- name: Reboot
listen:
- reboot
ansible.builtin.reboot:

View File

@ -1,25 +1,32 @@
- name: Check if default interface is configured
ansible.builtin.set_fact:
interface_configured: "{{ interface_name in ansible_interfaces }}"
- name: Configure default interface name
ansible.builtin.template:
src: etc-systemd-network-10-lan0.link.j2
dest: /etc/systemd/network/10-lan0.link
mode: "0644"
register: systemd_networkd_ifname
notify:
- update initramfs
- reboot
when: not interface_configured
- name: Configure network for default interface
ansible.builtin.template:
src: etc-systemd-network-20-lan0.network.j2
dest: /etc/systemd/network/20-lan0.network
mode: "0644"
notify: update initramfs
when: not interface_configured
- name: Configure nameservers
ansible.builtin.template:
src: etc-resolv.conf.j2
dest: /etc/resolv.conf
mode: "0644"
- name: Enable systemd-networkd
ansible.builtin.systemd_service:
name: systemd-networkd
enabled: true
state: restarted
- name: Enable systemd-resolved
ansible.builtin.systemd_service:
name: systemd-resolved
enabled: true
state: restarted

View File

@ -0,0 +1,3 @@
{% for nameserver in nameservers %}
nameserver {{ nameserver }}
{% endfor %}

View File

@ -4,6 +4,6 @@ Name={{ interface_name }}
[Network]
Address={{ ansible_default_ipv4.address|default(ansible_all_ipv4_addresses[0]) }}/24
Gateway={{ gateway }}
{% for dns in dns_servers %}
DNS={{ dns }}
{% for nameserver in nameservers %}
DNS={{ nameserver }}
{% endfor %}