1
0
Fork 0

separate includes for Debian based and Archlinux OS

This commit is contained in:
githubixx 2018-07-22 00:37:36 +02:00
parent 251d97d18a
commit af444f8b77
3 changed files with 45 additions and 15 deletions

View file

@ -1,17 +1,5 @@
--- ---
- name: Install required packages - include_tasks: "setup-{{ansible_os_family|lower}}.yml"
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
- name: Install WireGuard - name: Install WireGuard
package: package:
@ -20,6 +8,8 @@
with_items: with_items:
- wireguard-dkms - wireguard-dkms
- wireguard-tools - wireguard-tools
tags:
- wg-install
- name: Enable WireGuard kernel module - name: Enable WireGuard kernel module
modprobe: modprobe:
@ -30,6 +20,8 @@
retries: 10 retries: 10
delay: 10 delay: 10
failed_when: wireguard_module_enabled is failure failed_when: wireguard_module_enabled is failure
tags:
- wg-install
- name: Create WireGuard certificates directory - name: Create WireGuard certificates directory
file: file:
@ -38,18 +30,20 @@
mode: 0700 mode: 0700
run_once: true run_once: true
delegate_to: localhost delegate_to: localhost
tags:
wg-generate-keys
- name: Set path to private key file - name: Set path to private key file
set_fact: set_fact:
private_key_file_path: "{{wireguard_cert_directory}}/{{inventory_hostname}}.private.key" private_key_file_path: "{{wireguard_cert_directory}}/{{inventory_hostname}}.private.key"
tags: tags:
wg-config wg-generate-keys
- name: Set path to public key file - name: Set path to public key file
set_fact: set_fact:
public_key_file_path: "{{wireguard_cert_directory}}/{{inventory_hostname}}.public.key" public_key_file_path: "{{wireguard_cert_directory}}/{{inventory_hostname}}.public.key"
tags: tags:
wg-config wg-generate-keys
- name: Register if private key already exists - name: Register if private key already exists
local_action: local_action:

10
tasks/setup-archlinux.yml Normal file
View file

@ -0,0 +1,10 @@
---
- name: Install required packages
pacman:
name: "{{item}}"
state: present
become: yes
with_items:
- linux-headers
tags:
- wg-install

26
tasks/setup-debian.yml Normal file
View file

@ -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