From d9e0ea938e3cdb9b2cfd3067761ba739f2bcf8b8 Mon Sep 17 00:00:00 2001 From: tolerryan Date: Tue, 1 Sep 2026 22:25:10 +0000 Subject: [PATCH] add netbird setup --- roles/security/defaults/main.yml | 12 ++++++- roles/security/tasks/main.yml | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/roles/security/defaults/main.yml b/roles/security/defaults/main.yml index 5e3371b..87a59cd 100644 --- a/roles/security/defaults/main.yml +++ b/roles/security/defaults/main.yml @@ -4,4 +4,14 @@ security_ufw_allowed_tcp_ports_extra: [] #sshd config ssh_permit_root_login: "no" ssh_password_authentication: "no" -ssh_port: 25456 \ No newline at end of file +ssh_port: 25456 + +# Netbird Setup key +netbird_setup_key: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 39613534636437396661383737356635343832613362653161663030633239643030663138383435 + 6666626537653764373838396135366333393262313638370a396362623035663231613361666362 + 36326437646265353438323330626464326366313531613062343731613463323033623764663433 + 3462356238363433370a316631656433633834316364643431356431363766613366326634633766 + 62373662626330336430666238346462343437396139306431383265353937633135353433643334 + 6431396538663865363734313739353733633438366232653865 \ No newline at end of file diff --git a/roles/security/tasks/main.yml b/roles/security/tasks/main.yml index 9557ef0..4fb5106 100644 --- a/roles/security/tasks/main.yml +++ b/roles/security/tasks/main.yml @@ -56,3 +56,59 @@ name: fail2ban state: started enabled: true + +- name: Install required packages for netbird + apt: + name: + - curl + - gnupg + - ca-certificates + state: present + update_cache: no + +- name: Configure network buffer sizes (increased speed) + ansible.posix.sysctl: + name: "{{ item.key }}" + value: "{{ item.value }}" + state: present + reload: yes + ignoreerrors: yes + loop: + - { key: 'net.core.rmem_max', value: '7500000' } + - { key: 'net.core.wmem_max', value: '7500000' } + +- name: Add repository with key + ansible.builtin.deb822_repository: + name: netbird + types: [deb] + uris: "https://pkgs.netbird.io/debian" + components: [main] + suites: ["stable"] + signed_by: https://pkgs.netbird.io/debian/public.key + state: present + enabled: true + +- name: Install netbird + apt: + name: + - netbird + state: present + update_cache: yes + +- name: Enable netbird service + systemd: + name: netbird + state: started + enabled: yes + +- name: Check NetBird status + ansible.builtin.command: netbird status + register: netbird_status + ignore_errors: yes + changed_when: False + +- name: Start NetBird if needed + ansible.builtin.command: netbird up --management-url https://api.netbird.io --setup-key "{{ netbird_setup_key }}" + when: netbird_status.stdout is search("NeedsLogin") + vars: + ansible_command_timeout: 3600 \ No newline at end of file