Merge branch 'wireguard'
This commit is contained in:
commit
aed08f9824
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1 +1,2 @@
|
||||
cargo_credentials.toml filter=git-crypt diff=git-crypt
|
||||
**/wireguard_configs/** filter=git-crypt diff=git-crypt
|
||||
|
@ -50,3 +50,6 @@ efi_dev: /dev/gpt/EFI
|
||||
sound_default_unit: 5
|
||||
sway_conf_files:
|
||||
- launch_gpg
|
||||
wireguard_directory: odo
|
||||
enabled_wireguard:
|
||||
- wgh
|
||||
|
@ -33,6 +33,7 @@
|
||||
- kubernetes
|
||||
- google_cloud_sdk
|
||||
- ansible
|
||||
- wireguard
|
||||
|
||||
- hosts: nat_dhcp:homeserver_nat_dhcp
|
||||
vars:
|
||||
|
BIN
ansible/roles/wireguard/files/wireguard_configs/odo/wgf.conf
Normal file
BIN
ansible/roles/wireguard/files/wireguard_configs/odo/wgf.conf
Normal file
Binary file not shown.
BIN
ansible/roles/wireguard/files/wireguard_configs/odo/wgh.conf
Normal file
BIN
ansible/roles/wireguard/files/wireguard_configs/odo/wgh.conf
Normal file
Binary file not shown.
15
ansible/roles/wireguard/tasks/common.yaml
Normal file
15
ansible/roles/wireguard/tasks/common.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
- import_tasks: tasks/freebsd.yaml
|
||||
when: 'os_flavor == "freebsd"'
|
||||
|
||||
- import_tasks: tasks/linux.yaml
|
||||
when: 'os_flavor == "linux"'
|
||||
|
||||
- include_tasks:
|
||||
file: tasks/peruser.yaml
|
||||
apply:
|
||||
become: yes
|
||||
become_user: "{{ initialize_user }}"
|
||||
when: users is defined
|
||||
loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}"
|
||||
loop_control:
|
||||
loop_var: initialize_user
|
45
ansible/roles/wireguard/tasks/freebsd.yaml
Normal file
45
ansible/roles/wireguard/tasks/freebsd.yaml
Normal file
@ -0,0 +1,45 @@
|
||||
- name: Install packages
|
||||
package:
|
||||
name:
|
||||
- wireguard
|
||||
state: present
|
||||
|
||||
- name: Configure wireguard
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: /usr/local/etc/wireguard/
|
||||
mode: 0440
|
||||
owner: root
|
||||
group: wheel
|
||||
with_fileglob: "files/wireguard_configs/{{ wireguard_directory }}/*.conf"
|
||||
|
||||
- name: Enable gateway
|
||||
when: wireguard_gateway is defined and wireguard_gateway == true
|
||||
community.general.sysrc:
|
||||
name: "{{ item }}"
|
||||
value: "YES"
|
||||
path: /etc/rc.conf.d/routing
|
||||
loop:
|
||||
- gateway_enable
|
||||
- ipv6_gateway_enable
|
||||
|
||||
- name: Enable wireguard service
|
||||
when: enabled_wireguard is defined
|
||||
community.general.sysrc:
|
||||
name: wireguard_enable
|
||||
value: "YES"
|
||||
path: /etc/rc.conf.d/wireguard
|
||||
|
||||
- name: Disable wireguard service
|
||||
when: enabled_wireguard is not defined
|
||||
community.general.sysrc:
|
||||
name: wireguard_enable
|
||||
value: "NO"
|
||||
path: /etc/rc.conf.d/wireguard
|
||||
|
||||
- name: Set enabled wireguard list
|
||||
when: enabled_wireguard is defined
|
||||
community.general.sysrc:
|
||||
name: wireguard_interfaces
|
||||
value: "{{ enabled_wireguard|join(' ') }}"
|
||||
path: /etc/rc.conf.d/wireguard
|
24
ansible/roles/wireguard/tasks/linux.yaml
Normal file
24
ansible/roles/wireguard/tasks/linux.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
- name: Install packages
|
||||
package:
|
||||
name:
|
||||
- wireguard-tools
|
||||
- qrencode # For generating qr codes to send to phone with `qrencode -t ansiutf8 -r <config_file>`
|
||||
- systemd-resolvconf # For wg-quick to regenerate resolv.conf
|
||||
state: present
|
||||
|
||||
- name: Configure wireguard
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: /etc/wireguard/
|
||||
mode: 0440
|
||||
owner: root
|
||||
group: root
|
||||
with_fileglob: "files/wireguard_configs/{{ wireguard_directory }}/*.conf"
|
||||
|
||||
- name: Enable Wireguard
|
||||
when: enabled_wireguard is defined
|
||||
systemd:
|
||||
enabled: yes
|
||||
name: "wg-quick@{{ item }}"
|
||||
daemon_reload: yes
|
||||
loop: "{{ enabled_wireguard }}"
|
2
ansible/roles/wireguard/tasks/main.yaml
Normal file
2
ansible/roles/wireguard/tasks/main.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
- import_tasks: tasks/common.yaml
|
||||
when: wireguard_directory is defined
|
29
ansible/roles/wireguard/tasks/peruser.yaml
Normal file
29
ansible/roles/wireguard/tasks/peruser.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
- include_role:
|
||||
name: per_user
|
||||
|
||||
# - name: Create directories
|
||||
# file:
|
||||
# name: "{{ account_homedir.stdout }}/{{ item }}"
|
||||
# state: directory
|
||||
# mode: 0700
|
||||
# owner: "{{ account_name.stdout }}"
|
||||
# group: "{{ group_name.stdout }}"
|
||||
# loop:
|
||||
# - ".config/foo"
|
||||
|
||||
# - name: Copy files
|
||||
# copy:
|
||||
# src: "files/{{ item.src }}"
|
||||
# dest: "{{ account_homedir.stdout }}/{{ item.dest }}"
|
||||
# mode: 0600
|
||||
# owner: "{{ account_name.stdout }}"
|
||||
# group: "{{ group_name.stdout }}"
|
||||
# loop:
|
||||
# - src: foo.conf
|
||||
# dest: .config/foo/foo.conf
|
||||
|
||||
- import_tasks: tasks/peruser_freebsd.yaml
|
||||
when: 'os_flavor == "freebsd"'
|
||||
|
||||
- import_tasks: tasks/peruser_linux.yaml
|
||||
when: 'os_flavor == "linux"'
|
0
ansible/roles/wireguard/tasks/peruser_freebsd.yaml
Normal file
0
ansible/roles/wireguard/tasks/peruser_freebsd.yaml
Normal file
0
ansible/roles/wireguard/tasks/peruser_linux.yaml
Normal file
0
ansible/roles/wireguard/tasks/peruser_linux.yaml
Normal file
Loading…
x
Reference in New Issue
Block a user