diff --git a/tasks/main.yml b/tasks/main.yml index 39854c4..4a6f108 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,17 +1,5 @@ --- -- name: Install required packages - package: - name: "{{item}}" - state: present - with_items: - - software-properties-common - - linux-headers-{{ansible_kernel}} - -- name : Add WireGuard repository - apt_repository: - repo: "ppa:wireguard/wireguard" - state: present - update_cache: yes +- include_tasks: "setup-{{ansible_os_family|lower}}.yml" - name: Install WireGuard package: @@ -20,6 +8,8 @@ with_items: - wireguard-dkms - wireguard-tools + tags: + - wg-install - name: Enable WireGuard kernel module modprobe: @@ -30,6 +20,8 @@ retries: 10 delay: 10 failed_when: wireguard_module_enabled is failure + tags: + - wg-install - name: Create WireGuard certificates directory file: @@ -38,18 +30,20 @@ mode: 0700 run_once: true delegate_to: localhost + tags: + wg-generate-keys - name: Set path to private key file set_fact: private_key_file_path: "{{wireguard_cert_directory}}/{{inventory_hostname}}.private.key" tags: - wg-config + wg-generate-keys - name: Set path to public key file set_fact: public_key_file_path: "{{wireguard_cert_directory}}/{{inventory_hostname}}.public.key" tags: - wg-config + wg-generate-keys - name: Register if private key already exists local_action: diff --git a/tasks/setup-archlinux.yml b/tasks/setup-archlinux.yml new file mode 100644 index 0000000..ef164fe --- /dev/null +++ b/tasks/setup-archlinux.yml @@ -0,0 +1,10 @@ +--- +- name: Install required packages + pacman: + name: "{{item}}" + state: present + become: yes + with_items: + - linux-headers + tags: + - wg-install diff --git a/tasks/setup-debian.yml b/tasks/setup-debian.yml new file mode 100644 index 0000000..1b0ff7b --- /dev/null +++ b/tasks/setup-debian.yml @@ -0,0 +1,26 @@ +--- +- name: Update APT package cache + apt: + update_cache: true + cache_valid_time: 3600 + when: ansible_distribution == "Ubuntu" + tags: + - wg-install + +- name: Install required packages + package: + name: "{{item}}" + state: present + with_items: + - software-properties-common + - linux-headers-{{ansible_kernel}} + tags: + - wg-install + +- name : Add WireGuard repository + apt_repository: + repo: "ppa:wireguard/wireguard" + state: present + update_cache: yes + tags: + - wg-install