Add Wireguard playbook and first commit
This commit is contained in:
73
roles/homelab/wireguard/tasks/main.yml
Normal file
73
roles/homelab/wireguard/tasks/main.yml
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
|
||||
- name: "Change repos"
|
||||
ansible.builtin.template:
|
||||
src: mirror-yandex.ru.j2
|
||||
dest: /etc/apt/sources.list
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0744'
|
||||
|
||||
- name: "Update cache"
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: "Install packages"
|
||||
ansible.builtin.include_tasks: install_package.yml
|
||||
|
||||
- name: "Configure system"
|
||||
ansible.builtin.include_tasks: configure_system.yml
|
||||
|
||||
- name: "Configure wireguard server"
|
||||
ansible.builtin.include_tasks: configure_wireguard_server.yml
|
||||
|
||||
- name: "Create client dirrectory"
|
||||
ansible.builtin.file:
|
||||
path: "{{ wireguard_client_config_dir }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0700"
|
||||
|
||||
- name: "Include peer management tasks"
|
||||
tags: peers
|
||||
ansible.builtin.include_tasks: peers.yml
|
||||
|
||||
- name: "Deploy wireguard server configuration"
|
||||
ansible.builtin.template:
|
||||
src: wg0.conf.j2
|
||||
dest: "{{ wireguard_config_dir }}/{{ wireguard_interface }}.conf"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0600'
|
||||
notify: "restart wireguard"
|
||||
#notify: restart wireguard_client_config_dir
|
||||
|
||||
- name: "Confiugre bind9"
|
||||
tags: bind9
|
||||
ansible.builtin.include_tasks: configure_bind9.yml
|
||||
|
||||
- name: "Enable and start nftables"
|
||||
ansible.builtin.systemd:
|
||||
name: "nftables"
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: "Enable and start wireguard"
|
||||
ansible.builtin.systemd:
|
||||
name: "wg-quick@{{ wireguard_interface }}"
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: "Enable and start bind9"
|
||||
ansible.builtin.systemd:
|
||||
name: "bind9"
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: "Enable and start named"
|
||||
ansible.builtin.systemd:
|
||||
name: "named"
|
||||
state: started
|
||||
enabled: yes
|
||||
Reference in New Issue
Block a user