netbird_client: manage the wt0 MTU in default.json
This commit is contained in:
@@ -9,3 +9,5 @@ netbird_client:
|
|||||||
iface_blacklist_extra: []
|
iface_blacklist_extra: []
|
||||||
# Overrides the --log-level of the netbird service when set
|
# Overrides the --log-level of the netbird service when set
|
||||||
log_level:
|
log_level:
|
||||||
|
# MTU of wt0, written to /var/lib/netbird/default.json (netbird restarts on change); leave empty to keep the config as is
|
||||||
|
mtu:
|
||||||
|
|||||||
@@ -36,6 +36,43 @@
|
|||||||
cfg: "{{ netbird_config_stopped.content | b64decode | from_json }}"
|
cfg: "{{ netbird_config_stopped.content | b64decode | from_json }}"
|
||||||
when: netbird_stopped is changed
|
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
|
- name: Set netbird log level
|
||||||
copy:
|
copy:
|
||||||
dest: /etc/systemd/system/netbird.service.d/20-log-level.conf
|
dest: /etc/systemd/system/netbird.service.d/20-log-level.conf
|
||||||
|
|||||||
Reference in New Issue
Block a user