netbird_client: manage the wt0 MTU in default.json

This commit is contained in:
2026-11-02 22:35:03 +00:00
parent 0267db247e
commit c7c9f6d5d1
2 changed files with 39 additions and 0 deletions
+37
View File
@@ -36,6 +36,43 @@
cfg: "{{ netbird_config_stopped.content | b64decode | from_json }}"
when: netbird_stopped is changed
- name: Read netbird config for the MTU
slurp:
src: /var/lib/netbird/default.json
register: netbird_config_mtu_file
when: netbird_client.mtu | default('') | string | length > 0
tags: netbird_client_config
- name: Set the wt0 MTU in the netbird config
when: netbird_config_mtu_file.content is defined
vars:
netbird_config_mtu: "{{ netbird_config_mtu_file.content | b64decode | from_json }}"
tags: netbird_client_config
block:
# netbird writes its in-memory config back on exit, so edit only while it is stopped
- name: Stop netbird to edit its MTU
systemd:
name: netbird
state: stopped
when: (netbird_config_mtu.MTU | default(0)) != (netbird_client.mtu | int)
notify: restart_netbird
register: netbird_mtu_stopped
- name: Re-read netbird config after stop
slurp:
src: /var/lib/netbird/default.json
register: netbird_config_mtu_stopped
when: netbird_mtu_stopped is changed
- name: Write MTU
copy:
dest: /var/lib/netbird/default.json
content: "{{ cfg | combine({'MTU': netbird_client.mtu | int}) | to_nice_json(indent=4, sort_keys=False) }}\n"
mode: "0600"
vars:
cfg: "{{ netbird_config_mtu_stopped.content | b64decode | from_json }}"
when: netbird_mtu_stopped is changed
- name: Set netbird log level
copy:
dest: /etc/systemd/system/netbird.service.d/20-log-level.conf