From 4cb418e2b63d7035a5550a3efbc2b661a855eac1 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 17 Oct 2022 14:51:52 +0200 Subject: [PATCH 1/5] Add role netmaker (netclient) --- netmaker/meta/main.yml | 3 +++ netmaker/tasks/install.yml | 25 +++++++++++++++++++++++++ netmaker/tasks/join-network.yml | 4 ++++ netmaker/tasks/main.yml | 5 +++++ netmaker/tasks/prerequisites.yml | 0 5 files changed, 37 insertions(+) create mode 100644 netmaker/meta/main.yml create mode 100644 netmaker/tasks/install.yml create mode 100644 netmaker/tasks/join-network.yml create mode 100644 netmaker/tasks/main.yml create mode 100644 netmaker/tasks/prerequisites.yml diff --git a/netmaker/meta/main.yml b/netmaker/meta/main.yml new file mode 100644 index 0000000..3b2d8d8 --- /dev/null +++ b/netmaker/meta/main.yml @@ -0,0 +1,3 @@ +--- + dependencies: + - role: docker diff --git a/netmaker/tasks/install.yml b/netmaker/tasks/install.yml new file mode 100644 index 0000000..239dfec --- /dev/null +++ b/netmaker/tasks/install.yml @@ -0,0 +1,25 @@ +- name: Install Packages +# when: docker_file.stat.exists == False + package: + name: + - gpg + - gpg-agent + +- name: Add netmaker-key + apt_key: + url: https://apt.netmaker.org/gpg.key + state: present + +- name: Add netmaker-repository + apt_repository: + repo: "deb https:apt.netmaker.org stable main" + state: present + filename: netmaker + update_cache: yes + +- name: Install wireguard & netclient + package: + name: + - wireguard + - netclient + state: latest diff --git a/netmaker/tasks/join-network.yml b/netmaker/tasks/join-network.yml new file mode 100644 index 0000000..b57ad1a --- /dev/null +++ b/netmaker/tasks/join-network.yml @@ -0,0 +1,4 @@ +- name: Join netmaker-network + when: "netclient.join_network_token is defined" + command: "netclient join -t {{ netclient.join_network_token }}" + failed_when: command.rc != 0 diff --git a/netmaker/tasks/main.yml b/netmaker/tasks/main.yml new file mode 100644 index 0000000..78b8f81 --- /dev/null +++ b/netmaker/tasks/main.yml @@ -0,0 +1,5 @@ +- import_tasks: ./prerequisites.yml + +- import_tasks: ./install.yml + +- import_tasks: ./join-network.yml diff --git a/netmaker/tasks/prerequisites.yml b/netmaker/tasks/prerequisites.yml new file mode 100644 index 0000000..e69de29 From 811fc22eeff96328db630b7d6f1446cca2bae45a Mon Sep 17 00:00:00 2001 From: Ruakij Date: Fri, 21 Oct 2022 15:31:37 +0200 Subject: [PATCH 2/5] Delete unnecessary task-file --- netmaker/tasks/prerequisites.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 netmaker/tasks/prerequisites.yml diff --git a/netmaker/tasks/prerequisites.yml b/netmaker/tasks/prerequisites.yml deleted file mode 100644 index e69de29..0000000 From f9cc97a8f2766cabfc9050d1e7b0864710a9d152 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Fri, 21 Oct 2022 15:32:08 +0200 Subject: [PATCH 3/5] Add CA to trust-store --- netmaker/tasks/certs.yml | 4 ++++ netmaker/tasks/main.yml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 netmaker/tasks/certs.yml diff --git a/netmaker/tasks/certs.yml b/netmaker/tasks/certs.yml new file mode 100644 index 0000000..a13e98e --- /dev/null +++ b/netmaker/tasks/certs.yml @@ -0,0 +1,4 @@ +- name: Deploy CA Certificate + ansible.builtin.copy: + src: secret_files/netmaker_server/ca/ca.crt + dest: /etc/ssl/certs/netmaker-ca.pem diff --git a/netmaker/tasks/main.yml b/netmaker/tasks/main.yml index 78b8f81..9b522e8 100644 --- a/netmaker/tasks/main.yml +++ b/netmaker/tasks/main.yml @@ -1,4 +1,4 @@ -- import_tasks: ./prerequisites.yml +- import_tasks: ./certs.yml - import_tasks: ./install.yml From de0e220004c0c46ebbdb704153a18ba8e680c4a2 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Fri, 21 Oct 2022 15:32:20 +0200 Subject: [PATCH 4/5] Add defaults-var-file --- netmaker/defauls/netmaker.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 netmaker/defauls/netmaker.yml diff --git a/netmaker/defauls/netmaker.yml b/netmaker/defauls/netmaker.yml new file mode 100644 index 0000000..2be09fa --- /dev/null +++ b/netmaker/defauls/netmaker.yml @@ -0,0 +1,4 @@ +netclient: + # Token to join default-network + # leave empty to ignore + join_network_token: From fcc4f1ed18d0c689ff50ae96cb8a243990a024c1 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Fri, 21 Oct 2022 15:40:00 +0200 Subject: [PATCH 5/5] Fix task --- netmaker/tasks/join-network.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/netmaker/tasks/join-network.yml b/netmaker/tasks/join-network.yml index b57ad1a..0cc5cb0 100644 --- a/netmaker/tasks/join-network.yml +++ b/netmaker/tasks/join-network.yml @@ -2,3 +2,4 @@ when: "netclient.join_network_token is defined" command: "netclient join -t {{ netclient.join_network_token }}" failed_when: command.rc != 0 + register: command