1
0
Fork 0

make Ansible linter happy / changelog to separate file / new versioning scheme

This commit is contained in:
githubixx 2019-01-07 22:49:06 +01:00
parent 0b08c95a2a
commit 7605a76a03
3 changed files with 42 additions and 42 deletions

View file

@ -2,11 +2,11 @@
- name: Gather instance facts - name: Gather instance facts
setup: setup:
- include_tasks: "setup-{{ansible_os_family|lower}}.yml" - include_tasks: "setup-{{ ansible_os_family|lower }}.yml"
- name: Install WireGuard - name: Install WireGuard
package: package:
name: "{{item}}" name: "{{ item }}"
state: present state: present
with_items: with_items:
- wireguard-dkms - wireguard-dkms
@ -28,10 +28,10 @@
- name: Create WireGuard certificates directory - name: Create WireGuard certificates directory
file: file:
dest: "{{wireguard_cert_directory}}" dest: "{{ wireguard_cert_directory }}"
state: directory state: directory
owner: "{{wireguard_cert_owner}}" owner: "{{ wireguard_cert_owner }}"
group: "{{wireguard_cert_group}}" group: "{{ wireguard_cert_group }}"
mode: 0700 mode: 0700
run_once: true run_once: true
delegate_to: localhost delegate_to: localhost
@ -40,25 +40,25 @@
- name: Set WireGuard IP (without mask) - name: Set WireGuard IP (without mask)
set_fact: set_fact:
wireguard_ip: "{{wireguard_address.split('/')[0]}}" wireguard_ip: "{{ wireguard_address.split('/')[0] }}"
- 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-generate-keys 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-generate-keys wg-generate-keys
- name: Register if private key already exists - name: Register if private key already exists
local_action: stat:
module: stat path: "{{ private_key_file_path }}"
path: "{{private_key_file_path}}"
register: private_key_file_stat register: private_key_file_stat
delegate_to: localhost
tags: tags:
- wg-generate-keys - wg-generate-keys
@ -67,21 +67,21 @@
register: wg_private_key_result register: wg_private_key_result
with_inventory_hostnames: with_inventory_hostnames:
- vpn - vpn
when: private_key_file_stat.stat.exists == False when: not private_key_file_stat.stat.exists
tags: tags:
- wg-generate-keys - wg-generate-keys
- name: Set private key fact - name: Set private key fact
set_fact: set_fact:
wg_private_key: "{{wg_private_key_result.results[0].stdout}}" wg_private_key: "{{ wg_private_key_result.results[0].stdout }}"
when: private_key_file_stat.stat.exists == False when: not private_key_file_stat.stat.exists
tags: tags:
- wg-generate-keys - wg-generate-keys
- name: Generate WireGuard public key - name: Generate WireGuard public key
shell: "echo '{{wg_private_key}}' | wg pubkey" shell: "echo '{{ wg_private_key }}' | wg pubkey"
register: wg_public_key_result register: wg_public_key_result
when: private_key_file_stat.stat.exists == False when: not private_key_file_stat.stat.exists
with_inventory_hostnames: with_inventory_hostnames:
- vpn - vpn
tags: tags:
@ -89,50 +89,50 @@
- name: Set public key fact - name: Set public key fact
set_fact: set_fact:
wg_public_key: "{{wg_public_key_result.results[0].stdout}}" wg_public_key: "{{ wg_public_key_result.results[0].stdout }}"
when: private_key_file_stat.stat.exists == False when: not private_key_file_stat.stat.exists
tags: tags:
- wg-generate-keys - wg-generate-keys
- name: Store hosts private key locally - name: Store hosts private key locally
local_action: template:
module: template
src: "wg-privatekey.j2" src: "wg-privatekey.j2"
dest: "{{private_key_file_path}}" dest: "{{ private_key_file_path }}"
owner: "{{wireguard_cert_owner}}" owner: "{{ wireguard_cert_owner }}"
group: "{{wireguard_cert_group}}" group: "{{ wireguard_cert_group }}"
mode: 0644 mode: 0644
when: private_key_file_stat.stat.exists == False when: not private_key_file_stat.stat.exists
delegate_to: localhost
tags: tags:
- wg-generate-keys - wg-generate-keys
- name: Store hosts public key locally - name: Store hosts public key locally
local_action: template:
module: template
src: "wg-publickey.j2" src: "wg-publickey.j2"
dest: "{{public_key_file_path}}" dest: "{{ public_key_file_path }}"
owner: "{{wireguard_cert_owner}}" owner: "{{ wireguard_cert_owner }}"
group: "{{wireguard_cert_group}}" group: "{{ wireguard_cert_group }}"
mode: 0644 mode: 0644
when: private_key_file_stat.stat.exists == False when: not private_key_file_stat.stat.exists
delegate_to: localhost
tags: tags:
- wg-generate-keys - wg-generate-keys
- name: Read private key - name: Read private key
set_fact: set_fact:
private_key: "{{lookup('file', private_key_file_path)}}" private_key: "{{ lookup('file', private_key_file_path) }}"
tags: tags:
wg-config wg-config
- name: Read public key - name: Read public key
set_fact: set_fact:
public_key: "{{lookup('file', public_key_file_path)}}" public_key: "{{ lookup('file', public_key_file_path) }}"
tags: tags:
wg-config wg-config
- name: Create WireGuard configuration directory - name: Create WireGuard configuration directory
file: file:
dest: "{{wireguard_remote_directory}}" dest: "{{ wireguard_remote_directory }}"
state: directory state: directory
mode: 0700 mode: 0700
tags: tags:
@ -141,7 +141,7 @@
- name: Generate WireGuard configuration file - name: Generate WireGuard configuration file
template: template:
src: wg.conf.j2 src: wg.conf.j2
dest: "{{wireguard_remote_directory}}/{{wireguard_interface}}.conf" dest: "{{ wireguard_remote_directory }}/{{ wireguard_interface }}.conf"
owner: root owner: root
group: root group: root
mode: 0600 mode: 0600
@ -152,6 +152,6 @@
- name: Start and enable WireGuard service - name: Start and enable WireGuard service
service: service:
name: "wg-quick@{{wireguard_interface}}" name: "wg-quick@{{ wireguard_interface }}"
state: started state: started
enabled: yes enabled: yes

View file

@ -1,7 +1,7 @@
--- ---
- name: Install required packages - name: Install required packages
pacman: pacman:
name: "{{item}}" name: "{{ item }}"
state: present state: present
become: yes become: yes
with_items: with_items:

View file

@ -4,23 +4,23 @@
update_cache: true update_cache: true
cache_valid_time: 3600 cache_valid_time: 3600
when: ansible_distribution == "Ubuntu" when: ansible_distribution == "Ubuntu"
tags: tags:
- wg-install - wg-install
- name: Install required packages - name: Install required packages
package: package:
name: "{{item}}" name: "{{ item }}"
state: present state: present
with_items: with_items:
- software-properties-common - software-properties-common
- linux-headers-{{ansible_kernel}} - linux-headers-{{ ansible_kernel }}
tags: tags:
- wg-install - wg-install
- name : Add WireGuard repository - name: Add WireGuard repository
apt_repository: apt_repository:
repo: "ppa:wireguard/wireguard" repo: "ppa:wireguard/wireguard"
state: present state: present
update_cache: yes update_cache: yes
tags: tags:
- wg-install - wg-install