From 911bc47acb4099bc3f7fe1665276d612495ad10b Mon Sep 17 00:00:00 2001 From: Ruakij Date: Fri, 17 Mar 2023 15:58:49 +0100 Subject: [PATCH] Initial role stuff --- netbird_client/defaults/netbird_client.yml | 6 +++++ netbird_client/tasks/install.yml | 26 ++++++++++++++++++++++ netbird_client/tasks/join-network.yml | 7 ++++++ netbird_client/tasks/main.yml | 6 +++++ 4 files changed, 45 insertions(+) create mode 100644 netbird_client/defaults/netbird_client.yml create mode 100644 netbird_client/tasks/install.yml create mode 100644 netbird_client/tasks/join-network.yml create mode 100644 netbird_client/tasks/main.yml diff --git a/netbird_client/defaults/netbird_client.yml b/netbird_client/defaults/netbird_client.yml new file mode 100644 index 0000000..9fc3622 --- /dev/null +++ b/netbird_client/defaults/netbird_client.yml @@ -0,0 +1,6 @@ +netbird_client: + # Key and url to join a network + # leave empty to ignore + join_network: + setup_key: + management_url: diff --git a/netbird_client/tasks/install.yml b/netbird_client/tasks/install.yml new file mode 100644 index 0000000..283e6bd --- /dev/null +++ b/netbird_client/tasks/install.yml @@ -0,0 +1,26 @@ +- name: Install Packages +# when: docker_file.stat.exists == False + package: + name: + - ca-certificates + - curl + - gnupg + +- name: Add netbird-key + apt_key: + url: https://pkgs.wiretrustee.com/debian/public.key + state: present + +- name: Add netbird-repository + apt_repository: + repo: "deb https://pkgs.wiretrustee.com/debian stable main" + state: present + filename: netbird + update_cache: yes + +- name: Install wireguard & netbird + package: + name: + - wireguard + - netbird + state: latest diff --git a/netbird_client/tasks/join-network.yml b/netbird_client/tasks/join-network.yml new file mode 100644 index 0000000..4aadc3d --- /dev/null +++ b/netbird_client/tasks/join-network.yml @@ -0,0 +1,7 @@ +- name: Join netbird-network + when: "netbird_client.join_network.setup_key is defined" + command: "netbird up --management-url {{ netbird_client.join_network.management_url }} {{ netbird_client.join_network.setup_key }}" + failed_when: command.rc != 0 + changed_when: "'Connected' in command.stdout" + register: command + throttle: 1 diff --git a/netbird_client/tasks/main.yml b/netbird_client/tasks/main.yml new file mode 100644 index 0000000..b698801 --- /dev/null +++ b/netbird_client/tasks/main.yml @@ -0,0 +1,6 @@ +- import_tasks: ./install.yml + +- import_tasks: ./join-network.yml + +- name: Gather facts to get changes + ansible.builtin.gather_facts: