initial commit
This commit is contained in:
commit
13eace9ce9
219 files changed
+6918
No files matched your search
@@ -0,0 +1,6 @@
|
||||
.retry
|
||||
.cache/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
[defaults]
|
||||
inventory = ../inventory/
|
||||
roles_path = roles/
|
||||
host_key_checking = False
|
||||
forks = 8
|
||||
vault_password_file = ../inventory/.vault_pass
|
||||
deprecation_warnings=False
|
||||
|
||||
[inventory]
|
||||
enable_plugins = community.proxmox.proxmox, host_list, yaml, ini
|
||||
cache = True
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: asf
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- asf
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: bootstrap ssh keys via pct on all proxmox LXC containers
|
||||
hosts: proxmox_all_lxc
|
||||
gather_facts: false
|
||||
roles:
|
||||
- authorized-key
|
||||
|
||||
- name: router-specific pct-only network bootstrap (before ssh is reachable)
|
||||
hosts: router
|
||||
gather_facts: false
|
||||
roles:
|
||||
- ifupdown2
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: byparr
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- byparr
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: coturn
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- coturn
|
||||
- certbot
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: dev
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: >-
|
||||
-o UserKnownHostsFile=/dev/null
|
||||
-o StrictHostKeyChecking=no
|
||||
-o PreferredAuthentications=publickey,password
|
||||
-o PubkeyAuthentication=yes
|
||||
roles:
|
||||
- authorized-key
|
||||
- sshd
|
||||
- sysctl
|
||||
- hostname
|
||||
- resolv
|
||||
- nftables
|
||||
- nginx
|
||||
- certbot
|
||||
- placeholder
|
||||
- xray-core
|
||||
- logrotate
|
||||
- telemt
|
||||
- netutils
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: dev_shin
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: >-
|
||||
-o UserKnownHostsFile=/dev/null
|
||||
-o StrictHostKeyChecking=no
|
||||
-o PreferredAuthentications=publickey,password
|
||||
-o PubkeyAuthentication=yes
|
||||
roles:
|
||||
- authorized-key
|
||||
- sshd
|
||||
- sysctl
|
||||
- hostname
|
||||
- resolv
|
||||
- nftables
|
||||
- nginx
|
||||
- certbot
|
||||
- placeholder
|
||||
- xray-core
|
||||
- logrotate
|
||||
- telemt
|
||||
- netutils
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: firebat
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- zfs
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: gitea
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- gitea
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: lampa
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- lampa
|
||||
@@ -0,0 +1,26 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: liqueur
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: >-
|
||||
-o UserKnownHostsFile=/dev/null
|
||||
-o StrictHostKeyChecking=no
|
||||
-o PreferredAuthentications=publickey,password
|
||||
-o PubkeyAuthentication=yes
|
||||
roles:
|
||||
- authorized-key
|
||||
- sshd
|
||||
- sysctl
|
||||
- hostname
|
||||
- resolv
|
||||
- nftables
|
||||
- nginx
|
||||
- certbot
|
||||
- stunnel4
|
||||
- openvpn
|
||||
- haproxy
|
||||
- netutils
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: nfs
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- nfs
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: nginx
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- nginx
|
||||
- certbot
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: ntfy
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- ntfy
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: pgsql
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- pgsql
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: prosody
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- prosody
|
||||
- certbot
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: prowlarr
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- prowlarr
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: ps3netsrv
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- ps3netsrv
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: radicale
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- radicale
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: router
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: >-
|
||||
-o UserKnownHostsFile=/dev/null
|
||||
-o StrictHostKeyChecking=no
|
||||
-o PreferredAuthentications=publickey,password
|
||||
-o PubkeyAuthentication=yes
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- sysctl
|
||||
- stunnel4
|
||||
- openvpn
|
||||
- xray-core
|
||||
- logrotate
|
||||
- dnsmasq
|
||||
- xray-lists
|
||||
- unbound
|
||||
- resolv
|
||||
- nftables
|
||||
- netutils
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: rtorrent
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- rtorrent
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
- name: deploy rasy-rsa
|
||||
hosts: localhost
|
||||
connection: local
|
||||
become: true
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- easy-rsa
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: slskd
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- slskd
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: smb-legacy
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- samba
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: torrserver
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- torrserver
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: valheim
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- valheim
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: vaultwarden
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- vaultwarden
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: vector
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: >-
|
||||
-o UserKnownHostsFile=/dev/null
|
||||
-o StrictHostKeyChecking=no
|
||||
-o PreferredAuthentications=publickey,password
|
||||
-o PubkeyAuthentication=yes
|
||||
roles:
|
||||
- authorized-key
|
||||
- sshd
|
||||
- sysctl
|
||||
- hostname
|
||||
- resolv
|
||||
- nftables
|
||||
- nginx
|
||||
- certbot
|
||||
- placeholder
|
||||
- xray-core
|
||||
- logrotate
|
||||
- telemt
|
||||
- netutils
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: configure over ssh
|
||||
hosts: zabbix
|
||||
vars:
|
||||
ansible_connection: ssh
|
||||
ansible_host: "{{ ip }}"
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
roles:
|
||||
- sshd
|
||||
- timezone
|
||||
- locales
|
||||
- zabbix-server
|
||||
@@ -0,0 +1,2 @@
|
||||
collections:
|
||||
- name: community.proxmox
|
||||
@@ -0,0 +1,50 @@
|
||||
[Unit]
|
||||
Description=ArchiSteamFarm Service
|
||||
Documentation=https://github.com/JustArchiNET/ArchiSteamFarm/wiki
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Environment="DOTNET_CLI_TELEMETRY_OPTOUT=true"
|
||||
Environment="DOTNET_EnableDiagnostics=0"
|
||||
Environment="DOTNET_NOLOGO=true"
|
||||
EnvironmentFile=-/etc/asf/asf
|
||||
WorkingDirectory=/var/lib/asf
|
||||
ExecStart=/opt/asf/ArchiSteamFarm --path /var/lib/asf --no-restart --service --system-required
|
||||
Restart=on-success
|
||||
RestartSec=1s
|
||||
RuntimeDirectory=asf
|
||||
SyslogIdentifier=asf
|
||||
User=asf
|
||||
Group=asf
|
||||
CapabilityBoundingSet=
|
||||
DevicePolicy=closed
|
||||
LockPersonality=yes
|
||||
NoNewPrivileges=yes
|
||||
PrivateDevices=yes
|
||||
PrivateIPC=yes
|
||||
PrivateMounts=yes
|
||||
PrivateUsers=yes
|
||||
ProcSubset=pid
|
||||
ProtectClock=yes
|
||||
ProtectControlGroups=yes
|
||||
ProtectHome=read-only
|
||||
ProtectHostname=yes
|
||||
ProtectKernelLogs=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectKernelTunables=yes
|
||||
ProtectProc=invisible
|
||||
ProtectSystem=strict
|
||||
ReadWritePaths=/var/lib/asf /tmp
|
||||
RemoveIPC=yes
|
||||
RestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK AF_UNIX
|
||||
RestrictNamespaces=yes
|
||||
RestrictRealtime=yes
|
||||
RestrictSUIDSGID=yes
|
||||
SecureBits=noroot-locked
|
||||
SystemCallArchitectures=native
|
||||
SystemCallFilter=@system-service mincore
|
||||
SystemCallFilter=~@privileged
|
||||
UMask=0077
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Headless": true
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"HTTP4": {
|
||||
"Url": "http://*:1242"
|
||||
}
|
||||
},
|
||||
"KnownNetworks": [
|
||||
"10.0.0.0/8",
|
||||
"192.168.0.0/16"
|
||||
],
|
||||
"PathBase": "/"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: restart asf
|
||||
ansible.builtin.systemd_service:
|
||||
name: asf
|
||||
state: restarted
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
@@ -0,0 +1,147 @@
|
||||
---
|
||||
- name: create asf group
|
||||
ansible.builtin.group:
|
||||
name: asf
|
||||
system: true
|
||||
state: present
|
||||
|
||||
- name: create asf user
|
||||
ansible.builtin.user:
|
||||
name: asf
|
||||
group: asf
|
||||
system: true
|
||||
shell: /usr/sbin/nologin
|
||||
home: /var/lib/asf
|
||||
create_home: true
|
||||
state: present
|
||||
|
||||
- name: install depenedencies
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- unzip
|
||||
- jq
|
||||
- curl
|
||||
state: latest
|
||||
update_cache: true
|
||||
|
||||
- name: get latest asf release info
|
||||
ansible.builtin.uri:
|
||||
url: https://api.github.com/repos/JustArchiNET/ArchiSteamFarm/releases/latest
|
||||
return_content: yes
|
||||
register: asf_release
|
||||
run_once: true
|
||||
check_mode: false
|
||||
|
||||
- name: set current asf version
|
||||
ansible.builtin.set_fact:
|
||||
asf_version: "{{ asf_release.json.tag_name | regex_replace('^v', '') }}"
|
||||
asf_asset_url: "{{ asf_release.json.assets | selectattr('name', 'equalto', 'ASF-linux-x64.zip') | map(attribute='browser_download_url') | first }}"
|
||||
|
||||
- name: check asf installed version
|
||||
ansible.builtin.command: su - asf -s /bin/bash -c "curl -s http://127.0.0.1:1242/Api/ASF | jq -r '.Result.Version'"
|
||||
register: asf_current_version
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: display asf version info
|
||||
ansible.builtin.debug:
|
||||
msg: "latest version: {{ asf_version }}, installed version: {{ asf_current_version.stdout | default('not installed', true) }}"
|
||||
|
||||
- name: ensure asf directory exists
|
||||
ansible.builtin.file:
|
||||
path: /opt/asf
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
|
||||
- name: update asf
|
||||
ansible.builtin.unarchive:
|
||||
src: "{{ asf_asset_url }}"
|
||||
dest: /opt/asf
|
||||
remote_src: yes
|
||||
owner: root
|
||||
group: root
|
||||
when: asf_version != (asf_current_version.stdout | default(''))
|
||||
notify: restart asf
|
||||
|
||||
- name: make asf binary executable
|
||||
ansible.builtin.file:
|
||||
path: /opt/asf/ArchiSteamFarm
|
||||
mode: "0755"
|
||||
|
||||
- name: deploy asf systemd service unit
|
||||
ansible.builtin.copy:
|
||||
src: asf.service
|
||||
dest: /etc/systemd/system/asf.service
|
||||
mode: "0644"
|
||||
notify: restart asf
|
||||
|
||||
- name: ensure asf config directory exists
|
||||
ansible.builtin.file:
|
||||
path: /etc/asf
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
|
||||
- name: deploy asf configs
|
||||
ansible.builtin.copy:
|
||||
src: "{{ inventory_hostname }}/{{ item }}"
|
||||
dest: "/etc/asf/{{ item }}"
|
||||
owner: asf
|
||||
group: asf
|
||||
mode: "0640"
|
||||
loop:
|
||||
- ASF.json
|
||||
- IPC.config
|
||||
notify: restart asf
|
||||
|
||||
- name: ensure asf config directory exists
|
||||
ansible.builtin.file:
|
||||
path: /var/lib/asf/config
|
||||
state: directory
|
||||
owner: asf
|
||||
group: asf
|
||||
mode: "0755"
|
||||
|
||||
- name: symlink asf configs
|
||||
ansible.builtin.file:
|
||||
src: "/etc/asf/{{ item }}"
|
||||
dest: "/var/lib/asf/config/{{ item }}"
|
||||
state: link
|
||||
force: true
|
||||
loop:
|
||||
- ASF.json
|
||||
- IPC.config
|
||||
notify: restart asf
|
||||
|
||||
- name: check if asf data directory is a mountpoint
|
||||
ansible.builtin.command: mountpoint -q /var/lib/asf/config/
|
||||
register: vw_mountpoint
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: ensure asf data source directory exists
|
||||
ansible.builtin.file:
|
||||
path: /mnt/asf/data
|
||||
state: directory
|
||||
owner: asf
|
||||
group: asf
|
||||
mode: "0755"
|
||||
|
||||
- name: bind mount asf data directory
|
||||
ansible.posix.mount:
|
||||
path: /var/lib/asf/config/
|
||||
src: /mnt/asf/data
|
||||
fstype: none
|
||||
opts: bind
|
||||
state: mounted
|
||||
notify: restart asf
|
||||
|
||||
- name: set ownership on asf data directory
|
||||
ansible.builtin.file:
|
||||
path: /mnt/asf/data
|
||||
owner: asf
|
||||
group: asf
|
||||
recurse: true
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: ensure .ssh exists
|
||||
ansible.builtin.file:
|
||||
path: /root/.ssh
|
||||
state: directory
|
||||
mode: "0700"
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: set authorized key
|
||||
ansible.posix.authorized_key:
|
||||
user: root
|
||||
state: present
|
||||
key: "{{ item }}"
|
||||
loop: "{{ ssh_keys }}"
|
||||
@@ -0,0 +1,30 @@
|
||||
[Unit]
|
||||
Description=Byparr (FlareSolverr-compatible solver)
|
||||
Documentation=https://github.com/ThePhaseless/Byparr
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=byparr
|
||||
Group=byparr
|
||||
WorkingDirectory=/opt/byparr
|
||||
Environment=HOME=/var/lib/byparr
|
||||
Environment=PYTHONDONTWRITEBYTECODE=1
|
||||
EnvironmentFile=-/etc/byparr/byparr.env
|
||||
ExecStart=/opt/byparr/.venv/bin/python main.py
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
NoNewPrivileges=yes
|
||||
PrivateTmp=yes
|
||||
ProtectSystem=strict
|
||||
ReadWritePaths=/var/lib/byparr
|
||||
ProtectKernelTunables=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectControlGroups=yes
|
||||
RestrictSUIDSGID=yes
|
||||
LockPersonality=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: restart byparr
|
||||
ansible.builtin.systemd:
|
||||
name: byparr
|
||||
state: restarted
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
@@ -0,0 +1,93 @@
|
||||
---
|
||||
- name: create byparr group
|
||||
ansible.builtin.group:
|
||||
name: byparr
|
||||
system: true
|
||||
state: present
|
||||
|
||||
- name: create byparr user
|
||||
ansible.builtin.user:
|
||||
name: byparr
|
||||
group: byparr
|
||||
system: true
|
||||
shell: /usr/sbin/nologin
|
||||
home: /var/lib/byparr
|
||||
create_home: true
|
||||
state: present
|
||||
|
||||
- name: install dependencies
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- git
|
||||
- curl
|
||||
- ca-certificates
|
||||
- xvfb
|
||||
- libgtk-3-0
|
||||
- libasound2
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: install uv
|
||||
ansible.builtin.shell: >
|
||||
curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR=/usr/local/bin UV_NO_MODIFY_PATH=1 sh
|
||||
args:
|
||||
executable: /bin/bash
|
||||
creates: /usr/local/bin/uv
|
||||
|
||||
- name: ensure byparr directory exists
|
||||
ansible.builtin.file:
|
||||
path: "/opt/byparr"
|
||||
state: directory
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: "0755"
|
||||
|
||||
- name: clone byparr
|
||||
ansible.builtin.git:
|
||||
repo: https://github.com/ThePhaseless/Byparr
|
||||
dest: /opt/byparr
|
||||
version: "{{ byparr_version | default('main') }}"
|
||||
force: true
|
||||
register: byparr_repo
|
||||
notify: restart byparr
|
||||
|
||||
- name: check if byparr venv exists
|
||||
ansible.builtin.stat:
|
||||
path: /opt/byparr/.venv/bin/python
|
||||
register: byparr_venv
|
||||
|
||||
- name: sync byparr dependencies
|
||||
ansible.builtin.command: /usr/local/bin/uv sync --frozen --no-dev
|
||||
args:
|
||||
chdir: /opt/byparr
|
||||
environment:
|
||||
UV_PROJECT_ENVIRONMENT: /opt/byparr/.venv
|
||||
UV_PYTHON_INSTALL_DIR: /opt/byparr/python
|
||||
when: byparr_repo.changed or not byparr_venv.stat.exists
|
||||
notify: restart byparr
|
||||
|
||||
- name: ensure byparr config directory exists
|
||||
ansible.builtin.file:
|
||||
path: "/etc/byparr"
|
||||
state: directory
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: "0755"
|
||||
|
||||
- name: deploy byparr environment
|
||||
ansible.builtin.template:
|
||||
src: byparr.env.j2
|
||||
dest: /etc/byparr/byparr.env
|
||||
owner: root
|
||||
group: byparr
|
||||
mode: "0640"
|
||||
notify: restart byparr
|
||||
|
||||
- name: deploy byparr systemd unit
|
||||
ansible.builtin.copy:
|
||||
src: byparr.service
|
||||
dest: /etc/systemd/system/byparr.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: restart byparr
|
||||
@@ -0,0 +1,3 @@
|
||||
{% for key, value in (byparr_env | default({})).items() %}
|
||||
{{ key }}={{ value }}
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
- name: install certbot and dnsutils
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- certbot
|
||||
- dnsutils
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: install certbot cloudflare plugin
|
||||
ansible.builtin.apt:
|
||||
name: python3-certbot-dns-cloudflare
|
||||
state: present
|
||||
when: >-
|
||||
dnsmasq | selectattr('cert_method', 'defined')
|
||||
| selectattr('cert_method', 'equalto', 'cloudflare_dns')
|
||||
| list | length > 0
|
||||
|
||||
- name: resolve certificate domain
|
||||
ansible.builtin.command:
|
||||
cmd: "dig +short A {{ item.name }}"
|
||||
loop: "{{ dnsmasq }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
register: dns_check
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when: item.cert | default(false)
|
||||
|
||||
- name: fail if a domain does not point at this server
|
||||
ansible.builtin.fail:
|
||||
msg: "{{ item.item.name }} does not resolve to {{ ip }}"
|
||||
loop: "{{ dns_check.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item.name }}"
|
||||
when:
|
||||
- item.item.cert | default(false)
|
||||
- item.item.cert_method | default('standalone') != 'cloudflare_dns'
|
||||
- (ip | default(ansible_host)) not in item.stdout_lines
|
||||
|
||||
- name: create cloudflare secret
|
||||
ansible.builtin.copy:
|
||||
content: "dns_cloudflare_api_token = {{ item.cloudflare_token }}\n"
|
||||
dest: "/etc/letsencrypt/cloudflare-{{ item.name }}.ini"
|
||||
mode: '0600'
|
||||
loop: "{{ dnsmasq }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
when:
|
||||
- item.cert | default(false)
|
||||
- item.cert_method | default('standalone') == 'cloudflare_dns'
|
||||
no_log: true
|
||||
|
||||
- name: issue certificate if missing
|
||||
ansible.builtin.command:
|
||||
cmd: >-
|
||||
certbot certonly --non-interactive --agree-tos --register-unsafely-without-email
|
||||
{% if item.cert_method | default('standalone') == 'cloudflare_dns' %}
|
||||
--dns-cloudflare
|
||||
--dns-cloudflare-credentials /etc/letsencrypt/cloudflare-{{ item.name }}.ini
|
||||
--dns-cloudflare-propagation-seconds 60
|
||||
{% else %}
|
||||
--standalone
|
||||
{% if item.pre_hook is defined %}--pre-hook "{{ item.pre_hook }}"{% endif %}
|
||||
{% if item.post_hook is defined %}--post-hook "{{ item.post_hook }}"{% endif %}
|
||||
{% endif %}
|
||||
{% if item.deploy_hook is defined %}--deploy-hook "{{ item.deploy_hook }}"{% endif %}
|
||||
-d {{ item.name }}
|
||||
{% if item.cert_wildcard | default(false) %}-d '*.{{ item.name }}'{% endif %}
|
||||
creates: "/etc/letsencrypt/live/{{ item.name }}/fullchain.pem"
|
||||
loop: "{{ dnsmasq }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
when: item.cert | default(false)
|
||||
@@ -0,0 +1 @@
|
||||
TURNSERVER_ENABLED=1
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: restart coturn
|
||||
ansible.builtin.systemd_service:
|
||||
name: coturn
|
||||
state: restarted
|
||||
enabled: true
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
- name: install coturn
|
||||
ansible.builtin.apt:
|
||||
name: coturn
|
||||
state: latest
|
||||
update_cache: true
|
||||
notify: restart coturn
|
||||
|
||||
- name: ensure /var/lib/coturn/certs exists
|
||||
ansible.builtin.file:
|
||||
path: /var/lib/turn/certs
|
||||
owner: "turnserver"
|
||||
group: "turnserver"
|
||||
state: directory
|
||||
|
||||
- name: enable coturn daemon
|
||||
ansible.builtin.copy:
|
||||
src: coturn
|
||||
dest: /etc/default/coturn
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: restart coturn
|
||||
|
||||
- name: deploy coturn config
|
||||
ansible.builtin.template:
|
||||
src: "{{ inventory_hostname }}/turnserver.conf.j2"
|
||||
dest: /etc/turnserver.conf
|
||||
owner: root
|
||||
group: turnserver
|
||||
mode: "0640"
|
||||
notify: restart coturn
|
||||
@@ -0,0 +1,29 @@
|
||||
listening-ip={{ ip }}
|
||||
external-ip={{ hostvars['liqueur'].ip }}/{{ ip }}
|
||||
listening-port=3478
|
||||
tls-listening-port=5349
|
||||
verbose
|
||||
min-port=49152
|
||||
max-port=65535
|
||||
fingerprint
|
||||
use-auth-secret
|
||||
static-auth-secret={{ turn_external_secret }}
|
||||
realm=oyacoi.ru
|
||||
cert=/var/lib/turn/certs/fullchain.pem
|
||||
pkey=/var/lib/turn/certs/privkey.pem
|
||||
prod
|
||||
no-multicast-peers
|
||||
no-cli
|
||||
no-tlsv1
|
||||
no-tlsv1_1
|
||||
no-rfc5780
|
||||
no-stun-backward-compatibility
|
||||
response-origin-only-with-rfc5780
|
||||
relay-ip={{ ip }}
|
||||
denied-peer-ip=10.0.0.0-10.255.255.255
|
||||
denied-peer-ip=172.16.0.0-172.31.255.255
|
||||
denied-peer-ip=192.168.0.0-192.168.255.255
|
||||
denied-peer-ip=0.0.0.0-0.255.255.255
|
||||
denied-peer-ip=100.64.0.0-100.127.255.255
|
||||
denied-peer-ip=169.254.0.0-169.254.255.255
|
||||
allowed-peer-ip={{ hostvars['prosody'].ip }}
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: restart dnsmasq
|
||||
ansible.builtin.service:
|
||||
name: dnsmasq
|
||||
state: restarted
|
||||
enables: true
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
- name: install dnsmasq
|
||||
ansible.builtin.apt:
|
||||
name: dnsmasq
|
||||
state: latest
|
||||
update_cache: true
|
||||
notify: restart dnsmasq
|
||||
|
||||
- name: ensure dnsmasq.d directory exists
|
||||
ansible.builtin.file:
|
||||
path: /etc/dnsmasq.d
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: deploy dnsmasq hook
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate
|
||||
content: |
|
||||
make_resolv_conf() {
|
||||
:
|
||||
}
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
notify: restart dnsmasq
|
||||
|
||||
- name: deploy dnsmasq rule
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}"
|
||||
dest: "/etc/dnsmasq.d/{{ item | basename | regex_replace('\\.j2$', '') }}"
|
||||
mode: "0644"
|
||||
loop: "{{ query('ansible.builtin.fileglob', role_path + '/templates/' + inventory_hostname + '/*.conf.j2') }}"
|
||||
notify: restart dnsmasq
|
||||
@@ -0,0 +1,14 @@
|
||||
interface=lo
|
||||
interface=br-eth0
|
||||
interface=eth0.2
|
||||
interface=eth0.3
|
||||
interface=eth0.4
|
||||
interface=eth0.10
|
||||
interface=eth0.11
|
||||
interface=eth0.12
|
||||
bind-dynamic
|
||||
no-resolv
|
||||
server=127.0.0.1#5353
|
||||
#server=1.1.1.1
|
||||
domain=lan
|
||||
local=/lan/
|
||||
@@ -0,0 +1,10 @@
|
||||
server=/dev.oyacoi.ru/9.9.9.9
|
||||
server=/vector.oyacoi.ru/9.9.9.9
|
||||
server=/.themoviedb.org/9.9.9.9
|
||||
server=/.tmdb.org/9.9.9.9
|
||||
server=/tmdb-image-prod.b-cdn.net/9.9.9.9
|
||||
server=/infolada.ru/217.113.115.150
|
||||
server=/infolada.ru/217.113.114.100
|
||||
server=/start.infolada.ru/217.113.115.150
|
||||
server=/start.infolada.ru/217.113.114.100
|
||||
conf-file=/var/lib/xray-lists/generated/nftsets.conf
|
||||
@@ -0,0 +1,3 @@
|
||||
dhcp-range=interface:eth0.3,10.3.0.200,10.3.0.254,255.255.255.0,2h
|
||||
dhcp-option=interface:eth0.3,option:router,10.3.0.1
|
||||
dhcp-option=interface:eth0.3,option:dns-server,10.3.0.1
|
||||
@@ -0,0 +1,4 @@
|
||||
filterwin2k
|
||||
domain-needed
|
||||
bogus-priv
|
||||
cache-size=0
|
||||
@@ -0,0 +1,13 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
{% for item in dnsmasq_managed_group | sort %}
|
||||
{% set client = hostvars[item] %}
|
||||
{% set ip = client.ip | default(client.ansible_host | default(none)) %}
|
||||
{% if client['dhcp-host'] is defined and client['dhcp-host'] and ip %}
|
||||
{% set entries = client['dhcp-host'] if (client['dhcp-host'] is iterable and client['dhcp-host'] is not string) else [client['dhcp-host']] %}
|
||||
{% for entry in entries %}
|
||||
{% if entry.mac %}
|
||||
dhcp-host={{ entry.mac }},{{ ip }},{{ item }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,9 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
{% for item in dnsmasq_managed_group | sort %}
|
||||
{% for entry in hostvars[item].dnsmasq | default([]) %}
|
||||
{% set ip = entry.ip | default(hostvars[entry.ip_from].ip if entry.ip_from is defined else none) %}
|
||||
{% if ip %}
|
||||
host-record={{ entry.name }},{{ ip }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,8 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
{% for item in dnsmasq_managed_group | sort %}
|
||||
{% set client = hostvars[item] %}
|
||||
{% set ip = client.ip | default(client.ansible_host | default(none)) %}
|
||||
{% if ip %}
|
||||
host-record={{ item }},{{ item }}.lan,{{ ip }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,140 @@
|
||||
---
|
||||
- name: get latest easy-rsa release info
|
||||
ansible.builtin.uri:
|
||||
url: https://api.github.com/repos/OpenVPN/easy-rsa/releases/latest
|
||||
return_content: true
|
||||
register: easyrsa_release
|
||||
run_once: true
|
||||
check_mode: false
|
||||
|
||||
- name: set current easy-rsa version
|
||||
ansible.builtin.set_fact:
|
||||
easyrsa_version: "{{ easyrsa_release.json.tag_name | replace('v', '') }}"
|
||||
easyrsa_asset_url: "{{ easyrsa_release.json.assets | selectattr('name', 'search', 'EasyRSA.*\\.tgz') | map(attribute='browser_download_url') | first }}"
|
||||
|
||||
- name: check easy-rsa installed version
|
||||
ansible.builtin.shell: >
|
||||
/opt/easy-rsa/easyrsa version 2>&1 | grep -oP 'Version\s*:\s*\K[\d.]+'
|
||||
register: easyrsa_current_version
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: display easy-rsa version info
|
||||
ansible.builtin.debug:
|
||||
msg: "latest version: {{ easyrsa_version }}, installed version: {{ easyrsa_current_version.stdout | default('not installed', true) }}"
|
||||
|
||||
- name: ensure easy-rsa directory exists
|
||||
ansible.builtin.file:
|
||||
path: /opt/easy-rsa
|
||||
state: directory
|
||||
mode: "0755"
|
||||
check_mode: false
|
||||
|
||||
- name: update easy-rsa
|
||||
ansible.builtin.unarchive:
|
||||
src: "{{ easyrsa_asset_url }}"
|
||||
dest: /opt/easy-rsa
|
||||
remote_src: true
|
||||
extra_opts:
|
||||
- --strip-components=1
|
||||
when: easyrsa_version not in (easyrsa_current_version.stdout | default(''))
|
||||
|
||||
- name: prepare list of client certificates
|
||||
ansible.builtin.set_fact:
|
||||
cert_list: "{{ cert_list | default([]) + [ {'instance': item.0.name, 'pki_dir': item.0.pki_dir, 'client': item.1} ] }}"
|
||||
loop: "{{ openvpn_instances | subelements('clients') }}"
|
||||
|
||||
- name: ensure local pki directories exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.pki_dir }}"
|
||||
state: directory
|
||||
mode: '0700'
|
||||
loop: "{{ openvpn_instances }}"
|
||||
|
||||
- name: init pki if missing
|
||||
ansible.builtin.command:
|
||||
cmd: /opt/easy-rsa/easyrsa --batch init-pki
|
||||
creates: "{{ item.pki_dir }}/private"
|
||||
environment:
|
||||
EASYRSA_PKI: "{{ item.pki_dir }}"
|
||||
loop: "{{ openvpn_instances }}"
|
||||
|
||||
- name: build ca if missing
|
||||
ansible.builtin.command:
|
||||
cmd: /opt/easy-rsa/easyrsa --batch build-ca nopass
|
||||
creates: "{{ item.pki_dir }}/ca.crt"
|
||||
environment:
|
||||
EASYRSA_PKI: "{{ item.pki_dir }}"
|
||||
EASYRSA_REQ_CN: "CA-{{ item.name }}"
|
||||
loop: "{{ openvpn_instances }}"
|
||||
|
||||
- name: build server cert if missing
|
||||
ansible.builtin.command:
|
||||
cmd: /opt/easy-rsa/easyrsa --batch build-server-full server nopass
|
||||
creates: "{{ item.pki_dir }}/issued/server.crt"
|
||||
environment:
|
||||
EASYRSA_PKI: "{{ item.pki_dir }}"
|
||||
loop: "{{ openvpn_instances }}"
|
||||
|
||||
- name: generate dh params if missing
|
||||
ansible.builtin.command:
|
||||
cmd: /opt/easy-rsa/easyrsa gen-dh
|
||||
creates: "{{ item.pki_dir }}/dh.pem"
|
||||
environment:
|
||||
EASYRSA_PKI: "{{ item.pki_dir }}"
|
||||
loop: "{{ openvpn_instances }}"
|
||||
|
||||
- name: check client certificates validity
|
||||
ansible.builtin.command:
|
||||
cmd: "openssl x509 -checkend 2592000 -in {{ item.pki_dir }}/issued/{{ item.client.name }}.crt"
|
||||
register: cert_check
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
loop: "{{ cert_list }}"
|
||||
|
||||
- name: remove old cert file before reissue
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.item.pki_dir }}/issued/{{ item.item.client.name }}.crt"
|
||||
state: absent
|
||||
loop: "{{ cert_check.results }}"
|
||||
when: item.rc != 0
|
||||
|
||||
- name: remove old req file before reissue
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.item.pki_dir }}/reqs/{{ item.item.client.name }}.req"
|
||||
state: absent
|
||||
loop: "{{ cert_check.results }}"
|
||||
when: item.rc != 0
|
||||
|
||||
- name: remove old key file before reissue
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.item.pki_dir }}/private/{{ item.item.client.name }}.key"
|
||||
state: absent
|
||||
loop: "{{ cert_check.results }}"
|
||||
when: item.rc != 0
|
||||
|
||||
- name: issue or renew client certificates
|
||||
ansible.builtin.command:
|
||||
cmd: /opt/easy-rsa/easyrsa --batch build-client-full "{{ item.item.client.name }}" nopass
|
||||
environment:
|
||||
EASYRSA_PKI: "{{ item.item.pki_dir }}"
|
||||
when: item.rc != 0
|
||||
loop: "{{ cert_check.results }}"
|
||||
|
||||
- name: ensure local output directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ openvpn_client_bundle_dir }}/{{ item.0.name }}"
|
||||
state: directory
|
||||
mode: '0700'
|
||||
loop: "{{ openvpn_instances | subelements('clients') }}"
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
|
||||
- name: render standalone client bundles
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/client-certs/{{ item.0.name }}.conf.j2"
|
||||
dest: "{{ openvpn_client_bundle_dir }}/{{ item.0.name }}/{{ item.1.name }}.ovpn"
|
||||
mode: '0600'
|
||||
loop: "{{ openvpn_instances | subelements('clients') }}"
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
@@ -0,0 +1,26 @@
|
||||
client
|
||||
dev tap0
|
||||
proto tcp
|
||||
remote 127.0.0.1 1195
|
||||
resolv-retry infinite
|
||||
nobind
|
||||
persist-key
|
||||
persist-tun
|
||||
remote-cert-tls server
|
||||
auth SHA256
|
||||
cipher AES-256-GCM
|
||||
verb 3
|
||||
{% if item.1.ip is defined %}
|
||||
route-metric {{ item.1.route_metric | default(50) }}
|
||||
script-security 2
|
||||
up "C:\\Windows\\System32\\netsh.exe interface ip set address name="OpenVPN TAP-Windows6" static {{ item.1.ip }} 255.255.255.0"
|
||||
{% endif %}
|
||||
<ca>
|
||||
{{ lookup('file', item.0.pki_dir + '/ca.crt') }}
|
||||
</ca>
|
||||
<cert>
|
||||
{{ lookup('file', item.0.pki_dir + '/issued/' + item.1.name + '.crt') }}
|
||||
</cert>
|
||||
<key>
|
||||
{{ lookup('file', item.0.pki_dir + '/private/' + item.1.name + '.key') }}
|
||||
</key>
|
||||
@@ -0,0 +1,21 @@
|
||||
client
|
||||
dev tun0
|
||||
proto tcp
|
||||
remote 127.0.0.1 1194
|
||||
resolv-retry infinite
|
||||
nobind
|
||||
persist-key
|
||||
persist-tun
|
||||
remote-cert-tls server
|
||||
auth SHA256
|
||||
cipher AES-256-GCM
|
||||
verb 3
|
||||
<ca>
|
||||
{{ lookup('file', item.0.pki_dir + '/ca.crt') }}
|
||||
</ca>
|
||||
<cert>
|
||||
{{ lookup('file', item.0.pki_dir + '/issued/' + item.1.name + '.crt') }}
|
||||
</cert>
|
||||
<key>
|
||||
{{ lookup('file', item.0.pki_dir + '/private/' + item.1.name + '.key') }}
|
||||
</key>
|
||||
@@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=Gitea (Git with a cup of tea)
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
LimitNOFILE=524288:524288
|
||||
RestartSec=2s
|
||||
Type=simple
|
||||
User=git
|
||||
Group=git
|
||||
WorkingDirectory=/var/lib/gitea/
|
||||
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
|
||||
Restart=always
|
||||
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: restart gitea
|
||||
ansible.builtin.systemd:
|
||||
name: gitea
|
||||
state: restarted
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
@@ -0,0 +1,123 @@
|
||||
---
|
||||
- name: create git group
|
||||
ansible.builtin.group:
|
||||
name: git
|
||||
system: true
|
||||
state: present
|
||||
|
||||
- name: create git user
|
||||
ansible.builtin.user:
|
||||
name: git
|
||||
group: git
|
||||
system: true
|
||||
shell: /bin/bash
|
||||
home: /home/git
|
||||
create_home: true
|
||||
comment: "Git Version Control"
|
||||
state: present
|
||||
|
||||
- name: install git
|
||||
ansible.builtin.apt:
|
||||
name: git
|
||||
state: latest
|
||||
update_cache: true
|
||||
|
||||
- name: get latest gitea release info
|
||||
ansible.builtin.uri:
|
||||
url: https://api.github.com/repos/go-gitea/gitea/releases/latest
|
||||
return_content: true
|
||||
headers:
|
||||
Accept: "application/vnd.github+json"
|
||||
register: gitea_latest_release
|
||||
run_once: true
|
||||
delegate_to: localhost
|
||||
vars:
|
||||
ansible_connection: local
|
||||
failed_when: false
|
||||
|
||||
- name: set gitea version fact
|
||||
ansible.builtin.set_fact:
|
||||
gitea_version: "{{ gitea_latest_release.json.tag_name | regex_replace('^v', '') }}"
|
||||
when:
|
||||
- gitea_latest_release is succeeded
|
||||
- gitea_latest_release.json is defined
|
||||
- gitea_latest_release.json.tag_name is defined
|
||||
|
||||
- name: ensure gitea directory exists
|
||||
ansible.builtin.file:
|
||||
path: /etc/gitea
|
||||
state: directory
|
||||
owner: git
|
||||
group: root
|
||||
mode: 0750
|
||||
|
||||
- name: download gitea sha256 checksum
|
||||
ansible.builtin.uri:
|
||||
url: "https://dl.gitea.com/gitea/{{ gitea_version }}/gitea-{{ gitea_version }}-linux-amd64.sha256"
|
||||
return_content: true
|
||||
register: gitea_checksum
|
||||
failed_when: false
|
||||
|
||||
- name: download gitea binary
|
||||
ansible.builtin.get_url:
|
||||
url: "https://dl.gitea.com/gitea/{{ gitea_version }}/gitea-{{ gitea_version }}-linux-amd64"
|
||||
dest: /usr/local/bin/gitea
|
||||
mode: '0755'
|
||||
owner: root
|
||||
group: root
|
||||
checksum: "{{ ('sha256:' ~ gitea_checksum.content.split()[0]) if gitea_checksum is succeeded and gitea_checksum.content is defined else omit }}"
|
||||
notify: restart gitea
|
||||
|
||||
- name: deploy gitea config
|
||||
ansible.builtin.template:
|
||||
src: "{{ inventory_hostname }}/app.ini.j2"
|
||||
dest: "/etc/gitea/app.ini"
|
||||
owner: root
|
||||
group: git
|
||||
mode: '0640'
|
||||
notify: restart gitea
|
||||
|
||||
- name: deploy gitea systemd unit
|
||||
ansible.builtin.copy:
|
||||
src: gitea.service
|
||||
dest: /etc/systemd/system/gitea.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
notify: restart gitea
|
||||
|
||||
- name: check if gitea data directory is a mountpoint
|
||||
ansible.builtin.command: mountpoint -q /var/lib/gitea
|
||||
register: vw_mountpoint
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: remove default gitea data directory
|
||||
ansible.builtin.file:
|
||||
path: /var/lib/gitea
|
||||
state: absent
|
||||
when: vw_mountpoint.rc != 0
|
||||
|
||||
- name: ensure gitea data directory exists
|
||||
ansible.builtin.file:
|
||||
path: /mnt/gitea/data
|
||||
state: directory
|
||||
owner: git
|
||||
group: git
|
||||
mode: "0755"
|
||||
|
||||
- name: bind mount gitea data directory
|
||||
ansible.posix.mount:
|
||||
path: /var/lib/gitea
|
||||
src: /mnt/gitea/data
|
||||
fstype: none
|
||||
opts: bind
|
||||
state: mounted
|
||||
notify: restart gitea
|
||||
|
||||
- name: set ownership on gitea data directory
|
||||
ansible.builtin.file:
|
||||
path: /mnt/gitea/data
|
||||
owner: git
|
||||
group: git
|
||||
recurse: true
|
||||
@@ -0,0 +1,76 @@
|
||||
APP_NAME = Gitea: Git with a cup of tea
|
||||
RUN_USER = git
|
||||
WORK_PATH = /var/lib/gitea
|
||||
RUN_MODE = prod
|
||||
|
||||
[database]
|
||||
DB_TYPE = postgres
|
||||
HOST = {{ hostvars['pgsql'].ip }}:5432
|
||||
NAME = gitea
|
||||
USER = gitea_user
|
||||
PASSWD = `{{ database_password }}`
|
||||
SCHEMA = public
|
||||
SSL_MODE = disable
|
||||
PATH = /var/lib/gitea/data/gitea.db
|
||||
LOG_SQL = false
|
||||
|
||||
[repository]
|
||||
ROOT = /var/lib/gitea/data/gitea-repositories
|
||||
|
||||
[server]
|
||||
SSH_DOMAIN = gitea.lan
|
||||
DOMAIN = gitea.oyacoi.ru
|
||||
HTTP_PORT = 3000
|
||||
ROOT_URL = http://gitea.oyacoi.ru/
|
||||
APP_DATA_PATH = /var/lib/gitea/data
|
||||
DISABLE_SSH = false
|
||||
SSH_PORT = 22
|
||||
LFS_START_SERVER = true
|
||||
LFS_JWT_SECRET = {{ lfs_jwt_secret }}
|
||||
|
||||
[lfs]
|
||||
PATH = /var/lib/gitea/data/lfs
|
||||
|
||||
[mailer]
|
||||
ENABLED = false
|
||||
|
||||
[service]
|
||||
REGISTER_EMAIL_CONFIRM = false
|
||||
ENABLE_NOTIFY_MAIL = false
|
||||
DISABLE_REGISTRATION = true
|
||||
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
|
||||
ENABLE_CAPTCHA = false
|
||||
REQUIRE_SIGNIN_VIEW = false
|
||||
DEFAULT_KEEP_EMAIL_PRIVATE = false
|
||||
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
|
||||
DEFAULT_ENABLE_TIMETRACKING = true
|
||||
NO_REPLY_ADDRESS = noreply.localhost
|
||||
|
||||
[openid]
|
||||
ENABLE_OPENID_SIGNIN = false
|
||||
ENABLE_OPENID_SIGNUP = false
|
||||
|
||||
[cron.update_checker]
|
||||
ENABLED = false
|
||||
|
||||
[session]
|
||||
PROVIDER = file
|
||||
|
||||
[log]
|
||||
MODE = console
|
||||
LEVEL = info
|
||||
ROOT_PATH = /var/lib/gitea/log
|
||||
|
||||
[repository.pull-request]
|
||||
DEFAULT_MERGE_STYLE = merge
|
||||
|
||||
[repository.signing]
|
||||
DEFAULT_TRUST_MODEL = committer
|
||||
|
||||
[security]
|
||||
INSTALL_LOCK = true
|
||||
INTERNAL_TOKEN = {{ internal_token }}
|
||||
PASSWORD_HASH_ALGO = pbkdf2
|
||||
|
||||
[oauth2]
|
||||
JWT_SECRET = {{ jwt_secret }}
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: validate haproxy config
|
||||
ansible.builtin.command: haproxy -c -f /etc/haproxy/haproxy.cfg
|
||||
changed_when: false
|
||||
listen: restart haproxy
|
||||
|
||||
- name: restart haproxy systemd service unit
|
||||
ansible.builtin.systemd_service:
|
||||
name: haproxy
|
||||
state: restarted
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
listen: restart haproxy
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: install haproxy
|
||||
ansible.builtin.apt:
|
||||
name: haproxy
|
||||
state: latest
|
||||
update_cache: true
|
||||
notify: restart haproxy
|
||||
|
||||
- name: deploy haproxy config
|
||||
ansible.builtin.template:
|
||||
src: "{{ inventory_hostname }}/haproxy.cfg.j2"
|
||||
dest: "/etc/haproxy/haproxy.cfg"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
loop: "{{ query('fileglob', role_path + '/templates/' + inventory_hostname + '/*.cfg.j2') }}"
|
||||
notify: restart haproxy
|
||||
@@ -0,0 +1,85 @@
|
||||
global
|
||||
log /dev/log local2
|
||||
chroot /var/lib/haproxy
|
||||
maxconn 4000
|
||||
user haproxy
|
||||
group haproxy
|
||||
daemon
|
||||
stats socket /var/lib/haproxy/stats mode 660 level admin
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode tcp
|
||||
option tcplog
|
||||
option dontlognull
|
||||
retries 3
|
||||
timeout connect 5s
|
||||
timeout client 1h
|
||||
timeout server 1h
|
||||
timeout check 10s
|
||||
|
||||
frontend http_frontend
|
||||
bind 127.0.0.1:10080 accept-proxy
|
||||
mode http
|
||||
option httplog
|
||||
acl host_dttx hdr_end(host) -m end dttx.ru
|
||||
use_backend dttx_http_srv if host_dttx
|
||||
default_backend oyacoi_http_srv
|
||||
|
||||
backend oyacoi_http_srv
|
||||
mode http
|
||||
server oyacoi_srv {{ hostvars['nginx']['ip'] }}:81 send-proxy-v2
|
||||
|
||||
backend dttx_http_srv
|
||||
mode http
|
||||
server dttx_srv {{ hostvars['rbpi4']['ip'] }}:81 send-proxy-v2
|
||||
|
||||
frontend https_frontend
|
||||
bind 127.0.0.1:10443 accept-proxy
|
||||
mode tcp
|
||||
option tcplog
|
||||
tcp-request inspect-delay 5s
|
||||
tcp-request content accept if { req_ssl_hello_type 1 }
|
||||
acl host_dttx req_ssl_sni -m end dttx.ru
|
||||
acl host_telemt req_ssl_sni -m end regionculture.ru
|
||||
use_backend dttx_https_srv if host_dttx
|
||||
use_backend telemt_https_srv if host_telemt
|
||||
default_backend oyacoi_https_srv
|
||||
|
||||
backend oyacoi_https_srv
|
||||
mode tcp
|
||||
server nginx_srv {{ hostvars['nginx']['ip'] }}:444 send-proxy-v2
|
||||
|
||||
backend dttx_https_srv
|
||||
mode tcp
|
||||
server dttx_srv {{ hostvars['rbpi4']['ip'] }}:444 send-proxy-v2
|
||||
|
||||
backend telemt_https_srv
|
||||
mode tcp
|
||||
option tcp-check
|
||||
server telemt_srv {{ hostvars['vector']['ip'] }}:443 check
|
||||
server telemt_srv_backup {{ hostvars['dev']['ip'] }}:443 check backup
|
||||
|
||||
listen xmpp_c2s
|
||||
bind {{ hostvars['liqueur']['ip'] }}:5222
|
||||
server prosody_srv {{ hostvars['prosody']['ip'] }}:5222
|
||||
|
||||
listen xmpp_legacy_ssl
|
||||
bind {{ hostvars['liqueur']['ip'] }}:5223
|
||||
server prosody_srv {{ hostvars['prosody']['ip'] }}:5223
|
||||
|
||||
listen xmpp_s2s
|
||||
bind {{ hostvars['liqueur']['ip'] }}:5269
|
||||
server prosody_srv {{ hostvars['prosody']['ip'] }}:5269
|
||||
|
||||
listen prosody_proxy65
|
||||
bind {{ hostvars['liqueur']['ip'] }}:5000
|
||||
server prosody_srv {{ hostvars['prosody']['ip'] }}:5000
|
||||
|
||||
listen prosody_components
|
||||
bind {{ hostvars['liqueur']['ip'] }}:5270
|
||||
server prosody_srv {{ hostvars['prosody']['ip'] }}:5270
|
||||
|
||||
listen prosody_bosh_http
|
||||
bind {{ hostvars['liqueur']['ip'] }}:5280
|
||||
server prosody_srv {{ hostvars['prosody']['ip'] }}:5280
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
- name: set hostname
|
||||
ansible.builtin.hostname:
|
||||
name: "{{ hostname }}"
|
||||
@@ -0,0 +1,50 @@
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
post-up ip rule add fwmark 0x1 lookup 100 2>/dev/null || true
|
||||
post-up ip route add local 0.0.0.0/0 dev lo table 100 2>/dev/null || true
|
||||
pre-down ip route del local 0.0.0.0/0 dev lo table 100 2>/dev/null || true
|
||||
pre-down ip rule del fwmark 0x1 lookup 100 2>/dev/null || true
|
||||
|
||||
auto br-eth0
|
||||
iface br-eth0 inet static
|
||||
address 10.1.0.1/24
|
||||
bridge_ports eth0 tap0
|
||||
bridge_stp off
|
||||
pre-up ip tuntap add dev tap0 mode tap || true
|
||||
post-down ip tuntap del dev tap0 mode tap || true
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet manual
|
||||
|
||||
auto eth0.2
|
||||
iface eth0.2 inet static
|
||||
address 10.2.0.1/24
|
||||
vlan-raw-device eth0
|
||||
|
||||
auto eth0.3
|
||||
iface eth0.3 inet static
|
||||
address 10.3.0.1/24
|
||||
vlan-raw-device eth0
|
||||
|
||||
auto eth0.4
|
||||
iface eth0.4 inet static
|
||||
address 10.4.0.1/24
|
||||
vlan-raw-device eth0
|
||||
|
||||
auto eth0.10
|
||||
iface eth0.10 inet static
|
||||
address 10.10.0.1/24
|
||||
vlan-raw-device eth0
|
||||
|
||||
auto eth0.11
|
||||
iface eth0.11 inet static
|
||||
address 10.11.0.1/24
|
||||
vlan-raw-device eth0
|
||||
|
||||
auto eth0.12
|
||||
iface eth0.12 inet static
|
||||
address 10.12.0.1/24
|
||||
vlan-raw-device eth0
|
||||
|
||||
auto eth1
|
||||
iface eth1 inet dhcp
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
- name: ensure rt_tables.d directory exists
|
||||
ansible.builtin.file:
|
||||
path: /etc/iproute2/rt_tables.d
|
||||
state: directory
|
||||
mode: "0755"
|
||||
register: rt_tables_dir
|
||||
|
||||
- name: deploy ifupdown interfaces
|
||||
ansible.builtin.copy:
|
||||
src: "{{ inventory_hostname }}/interfaces"
|
||||
dest: /etc/network/interfaces
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
register: interfaces_conf
|
||||
|
||||
- name: reload ifupdown2
|
||||
command: ifreload -a
|
||||
when: interfaces_conf.changed
|
||||
|
||||
- name: install bridge-utils
|
||||
ansible.builtin.package:
|
||||
name: bridge-utils
|
||||
state: present
|
||||
register: bridge_utils_install
|
||||
when: (ifupdown2_need_bridge_utils | default(false)) == true
|
||||
|
||||
- name: reload ifupdown2
|
||||
ansible.builtin.command: ifreload -a
|
||||
when:
|
||||
- bridge_utils_install.changed or rt_tables_dir.changed
|
||||
- ifupdown2_need_bridge_utils | default(false)
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: restart lampa
|
||||
ansible.builtin.systemd:
|
||||
name: lampac
|
||||
state: restarted
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
@@ -0,0 +1,108 @@
|
||||
---
|
||||
- name: install dependencies
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- curl
|
||||
- sudo
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: get latest lampac release info
|
||||
ansible.builtin.uri:
|
||||
url: https://api.github.com/repos/lampac-nextgen/lampac/releases/latest
|
||||
return_content: true
|
||||
register: lampa_release
|
||||
check_mode: false
|
||||
|
||||
- name: set latest lampac version
|
||||
ansible.builtin.set_fact:
|
||||
lampa_version: "{{ lampa_release.json.tag_name | regex_replace('^v', '') }}"
|
||||
|
||||
- name: download lampac installer
|
||||
ansible.builtin.get_url:
|
||||
url: https://raw.githubusercontent.com/lampac-nextgen/lampac/main/install.sh
|
||||
dest: /usr/local/sbin/lampac-install.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
force: true
|
||||
|
||||
- name: check lampac installed version
|
||||
ansible.builtin.shell: >
|
||||
/usr/local/sbin/lampac-install.sh --version | grep -oP 'Installed Version:\s*\K[\d.]+'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: lampa_current_version
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: set lampac installed version
|
||||
ansible.builtin.set_fact:
|
||||
lampa_installed_version: "{{ lampa_current_version.stdout | trim }}"
|
||||
|
||||
- name: display lampac version info
|
||||
ansible.builtin.debug:
|
||||
msg: "latest: {{ lampa_version }}, installed: {{ lampa_installed_version | default('not installed', true) }}"
|
||||
|
||||
- name: install lampac
|
||||
ansible.builtin.command: /usr/local/sbin/lampac-install.sh --tag v{{ lampa_version }}
|
||||
when: lampa_installed_version == ''
|
||||
|
||||
- name: update lampac
|
||||
ansible.builtin.command: /usr/local/sbin/lampac-install.sh --update --force --tag v{{ lampa_version }}
|
||||
when:
|
||||
- lampa_installed_version != ''
|
||||
- lampa_installed_version is version(lampa_version, '<')
|
||||
notify: restart lampa
|
||||
|
||||
- name: ensure lampa database directory is a mountpoint
|
||||
ansible.builtin.command: mountpoint -q /opt/lampac/database
|
||||
register: vw_mountpoint
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: stop lampa before relocating database
|
||||
ansible.builtin.systemd:
|
||||
name: lampac
|
||||
state: stopped
|
||||
when: vw_mountpoint.rc != 0
|
||||
|
||||
- name: remove default lampa database directory
|
||||
ansible.builtin.file:
|
||||
path: /opt/lampac/database
|
||||
state: absent
|
||||
when: vw_mountpoint.rc != 0
|
||||
|
||||
- name: ensure lampa database source directory exists
|
||||
ansible.builtin.file:
|
||||
path: /mnt/lampa/database
|
||||
state: directory
|
||||
owner: lampac
|
||||
group: lampac
|
||||
mode: "0755"
|
||||
|
||||
- name: bind mount lampa database directory
|
||||
ansible.posix.mount:
|
||||
path: /opt/lampac/database
|
||||
src: /mnt/lampa/database/
|
||||
fstype: none
|
||||
opts: bind
|
||||
state: mounted
|
||||
notify: restart lampa
|
||||
|
||||
- name: set lampa database directory ownership
|
||||
ansible.builtin.file:
|
||||
path: /mnt/lampa/database
|
||||
owner: lampac
|
||||
group: lampac
|
||||
recurse: true
|
||||
|
||||
- name: deploy lampac config
|
||||
ansible.builtin.template:
|
||||
src: "{{ inventory_hostname }}/init.conf.j2"
|
||||
dest: /opt/lampac/init.conf
|
||||
owner: lampac
|
||||
group: lampac
|
||||
mode: "0640"
|
||||
notify: restart lampa
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"lowMemoryMode": true,
|
||||
"listen": { "ip": "any", "port": 9118, "version": true },
|
||||
"BaseModule": {
|
||||
"LoadModules": ["LampaWeb", "Sync", "TimeCode", "Storage", "SyncEvents"]
|
||||
},
|
||||
"chromium": { "enable": false },
|
||||
"firefox": { "enable": false },
|
||||
"rch": { "enable": false },
|
||||
"LampaWeb": {
|
||||
"initPlugins": {
|
||||
"online": false,
|
||||
"sisi": false,
|
||||
"torrserver": false,
|
||||
"jacred": false,
|
||||
"tmdbProxy": false,
|
||||
"cubProxy": false,
|
||||
"sync": true,
|
||||
"bookmark": false,
|
||||
"timecode": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: generate locales
|
||||
community.general.locale_gen:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop: "{{ locales_list }}"
|
||||
|
||||
- name: configure default locale
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/locale.conf
|
||||
content: LANG={{ locale_default }}
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
@@ -0,0 +1,9 @@
|
||||
/var/log/xray-core/*.log {
|
||||
daily
|
||||
rotate 4
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
copytruncate
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/var/log/xray-core/*.log {
|
||||
daily
|
||||
rotate 4
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
copytruncate
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/var/log/xray-core/*.log {
|
||||
daily
|
||||
rotate 4
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
copytruncate
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/var/log/xray-core/*.log {
|
||||
daily
|
||||
rotate 4
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
copytruncate
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: deploy logrotate config
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "/etc/logrotate.d/{{ item | basename }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
loop: "{{ query('ansible.builtin.fileglob', role_path + '/files/' + inventory_hostname + '/*') }}"
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: install network tools
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- tcpdump
|
||||
- iperf3
|
||||
- mtr-tiny
|
||||
- bind9-dnsutils
|
||||
- ethtool
|
||||
- conntrack
|
||||
- iftop
|
||||
- socat
|
||||
- nmap
|
||||
state: latest
|
||||
update_cache: true
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: restart nfs
|
||||
ansible.builtin.service:
|
||||
name: nfs-kernel-server
|
||||
state: restarted
|
||||
enabled: true
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
- name: install nfs-kernel-server
|
||||
ansible.builtin.apt:
|
||||
name: nfs-kernel-server
|
||||
state: latest
|
||||
update_cache: true
|
||||
notify: restart nfs
|
||||
|
||||
- name: deploy exports
|
||||
ansible.builtin.template:
|
||||
src: "{{ inventory_hostname }}/exports"
|
||||
dest: /etc/exports
|
||||
mode: "0755"
|
||||
notify: restart nfs
|
||||
|
||||
- name: disable nfs3
|
||||
community.general.ini_file:
|
||||
path: /etc/nfs.conf
|
||||
section: nfsd
|
||||
option: "{{ item.key }}"
|
||||
value: "{{ item.value }}"
|
||||
no_extra_spaces: true
|
||||
mode: 0755
|
||||
backup: true
|
||||
loop:
|
||||
- { key: vers3, value: "n" }
|
||||
- { key: vers4, value: "y" }
|
||||
- { key: "vers4.0", value: "y" }
|
||||
- { key: "vers4.1", value: "y" }
|
||||
- { key: "vers4.2", value: "y" }
|
||||
notify: restart nfs
|
||||
@@ -0,0 +1,2 @@
|
||||
/mnt/media1 10.1.0.0/24(rw,sync,no_subtree_check,all_squash,anonuid=100000,anongid=101000)
|
||||
/mnt/media2 10.1.0.0/24(rw,sync,no_subtree_check,all_squash,anonuid=100000,anongid=101000)
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- name: check nftables config
|
||||
ansible.builtin.command: nft -c -f /etc/nftables.conf
|
||||
changed_when: false
|
||||
listen: restart nftables
|
||||
|
||||
- name: enable and start nftables
|
||||
ansible.builtin.systemd:
|
||||
name: nftables
|
||||
state: started
|
||||
enabled: true
|
||||
listen: restart nftables
|
||||
|
||||
- name: reload nftables
|
||||
ansible.builtin.systemd:
|
||||
name: nftables
|
||||
state: reloaded
|
||||
listen: restart nftables
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
- name: install nftables
|
||||
ansible.builtin.apt:
|
||||
name: nftables
|
||||
state: latest
|
||||
update_cache: true
|
||||
|
||||
- name: ensure nftables.d directory exists
|
||||
ansible.builtin.file:
|
||||
path: /etc/nftables.d
|
||||
state: directory
|
||||
mode: "0755"
|
||||
when: nftables_bootstrap_files | default([]) | length > 0
|
||||
|
||||
- name: bootstrap empty config files
|
||||
ansible.builtin.copy:
|
||||
dest: "/etc/nftables.d/{{ item }}"
|
||||
content: ""
|
||||
force: false
|
||||
mode: "0644"
|
||||
loop: "{{ nftables_bootstrap_files | default([]) }}"
|
||||
|
||||
- name: deploy nftables rules
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}"
|
||||
dest: "/etc/nftables.d/{{ item | basename | regex_replace('\\.j2$', '') }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
loop: "{{ query('ansible.builtin.fileglob', role_path + '/templates/' + inventory_hostname + '/*.nft.j2') }}"
|
||||
notify: restart nftables
|
||||
|
||||
- name: deploy nftables config
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}"
|
||||
dest: "/etc/{{ item | basename | regex_replace('\\.j2$', '') }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
loop: "{{ query('ansible.builtin.fileglob', role_path + '/templates/' + inventory_hostname + '/*.conf.j2') }}"
|
||||
notify: restart nftables
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/sbin/nft -f
|
||||
flush ruleset
|
||||
table inet filter {
|
||||
chain input {
|
||||
type filter hook input priority filter;
|
||||
policy drop;
|
||||
iif "lo" accept
|
||||
ct state established,related accept
|
||||
ct state invalid drop
|
||||
tcp dport 22 counter accept comment "ssh"
|
||||
tcp dport 80 counter accept comment "http"
|
||||
tcp dport 443 counter accept comment "https"
|
||||
}
|
||||
chain forward {
|
||||
type filter hook forward priority filter;
|
||||
policy drop;
|
||||
}
|
||||
chain output {
|
||||
type filter hook output priority filter;
|
||||
policy accept;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/sbin/nft -f
|
||||
flush ruleset
|
||||
table inet filter {
|
||||
chain input {
|
||||
type filter hook input priority filter;
|
||||
policy drop;
|
||||
iif "lo" accept
|
||||
ct state established,related accept
|
||||
ct state invalid drop
|
||||
tcp dport 22 counter accept comment "ssh"
|
||||
tcp dport 80 counter accept comment "http"
|
||||
tcp dport 443 counter accept comment "https"
|
||||
}
|
||||
chain forward {
|
||||
type filter hook forward priority filter;
|
||||
policy drop;
|
||||
}
|
||||
chain output {
|
||||
type filter hook output priority filter;
|
||||
policy accept;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/usr/sbin/nft -f
|
||||
flush ruleset
|
||||
table inet filter {
|
||||
chain input {
|
||||
type filter hook input priority filter;
|
||||
policy drop;
|
||||
iif "lo" accept
|
||||
ct state established,related accept
|
||||
ct state invalid drop
|
||||
tcp dport 22 counter accept comment "ssh"
|
||||
tcp dport 80 counter accept comment "http"
|
||||
tcp dport 443 counter accept comment "https"
|
||||
tcp dport { 5222, 5223, 5269, 5000, 5270, 5280 } counter accept comment "xmpp"
|
||||
}
|
||||
chain forward {
|
||||
type filter hook forward priority filter;
|
||||
policy drop;
|
||||
ct state established,related accept
|
||||
ip daddr {{ hostvars['coturn']['ip'] }} udp dport { 3478, 5349, 49152-65535 } counter accept
|
||||
ip daddr {{ hostvars['coturn']['ip'] }} tcp dport { 3478, 5349 } counter accept
|
||||
ip daddr {{ hostvars['valheim']['ip'] }} udp dport 2456 counter accept
|
||||
ip daddr {{ hostvars['valheim']['ip'] }} udp dport 2457 counter accept
|
||||
ip daddr {{ hostvars['rbpi4']['ip'] }} udp dport 21116 counter accept
|
||||
ip daddr {{ hostvars['rbpi4']['ip'] }} tcp dport 21114-21119 counter accept
|
||||
iifname tun0 ip saddr {{ hostvars['workuter']['ip'] }} oifname tun0 ip daddr {{ hostvars['xiawrt']['ip'] }} tcp dport 22 counter accept
|
||||
iifname tun0 ip saddr {{ hostvars['workuter']['ip'] }} oifname tun0 ip daddr {{ hostvars['rbpi4']['ip'] }} tcp dport 22 counter accept
|
||||
iifname tun0 ip saddr {{ hostvars['oyacoi-odcm']['ip'] }} oifname tun0 ip daddr {{ hostvars['xiawrt']['ip'] }} tcp dport 22 counter accept
|
||||
iifname tun0 ip saddr {{ hostvars['oyacoi-odcm']['ip'] }} oifname tun0 ip daddr {{ hostvars['rbpi4']['ip'] }} tcp dport 22 counter accept
|
||||
}
|
||||
chain output {
|
||||
type filter hook output priority filter;
|
||||
policy accept;
|
||||
}
|
||||
}
|
||||
table ip nat {
|
||||
chain prerouting {
|
||||
type nat hook prerouting priority dstnat;
|
||||
policy accept;
|
||||
ip daddr {{ ip }} udp dport { 3478, 5349, 49152-65535 } counter dnat to {{ hostvars['coturn']['ip'] }}
|
||||
ip daddr {{ ip }} tcp dport { 3478, 5349 } counter dnat to {{ hostvars['coturn']['ip'] }}
|
||||
ip daddr {{ ip }} udp dport 2456 counter dnat to {{ hostvars['valheim']['ip'] }}
|
||||
ip daddr {{ ip }} udp dport 2457 counter dnat to {{ hostvars['valheim']['ip'] }}
|
||||
ip daddr {{ ip }} udp dport 21116 counter dnat to {{ hostvars['rbpi4']['ip'] }}
|
||||
ip daddr {{ ip }} tcp dport 21114-21119 counter dnat to {{ hostvars['rbpi4']['ip'] }}
|
||||
}
|
||||
chain postrouting {
|
||||
type nat hook postrouting priority srcnat;
|
||||
policy accept;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
set private_ip {
|
||||
type ipv4_addr
|
||||
flags interval
|
||||
auto-merge
|
||||
elements = { 10.0.0.0/8, 100.64.0.0/10, 127.0.0.0/8, 169.254.0.0/16, 172.16.0.0/12, 192.0.0.0/24, 192.0.2.0/24, 192.88.99.0/24, 192.168.0.0/16, 198.18.0.0/15, 198.51.100.0/24, 203.0.113.0/24, 224.0.0.0/4, 240.0.0.0/4 }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
{%- for id, item in xray_ip_sets.items() -%}
|
||||
set {{ id }}_ip {
|
||||
type ipv4_addr
|
||||
flags interval
|
||||
auto-merge
|
||||
include "{{ xray_lists_global.output_dir }}/{{ id }}_ip.elements.nft"
|
||||
}
|
||||
{% endfor -%}
|
||||
{%- for id, item in xray_domain_sets.items() -%}
|
||||
set {{ id }}_dom {
|
||||
type ipv4_addr
|
||||
flags interval
|
||||
}
|
||||
{% endfor -%}
|
||||
@@ -0,0 +1,8 @@
|
||||
chain postrouting {
|
||||
type nat hook postrouting priority srcnat; policy accept;
|
||||
oifname eth1 masquerade
|
||||
}
|
||||
chain prerouting {
|
||||
type nat hook prerouting priority dstnat; policy accept;
|
||||
include "/etc/nftables.d/90-dstnat.nft"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
chain prerouting {
|
||||
type filter hook prerouting priority -150; policy accept;
|
||||
iifname "tun0" ct mark set 0x2 comment "tun0 -> mart 0x2"
|
||||
iifname != { "tun0", "lo" } ct mark 0x2 meta mark set ct mark comment "mark 0x2 -> tun0"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
flowtable ft {
|
||||
hook ingress priority filter
|
||||
devices = { eth0, eth1 }
|
||||
}
|
||||
chain input {
|
||||
type filter hook input priority filter; policy drop;
|
||||
ct state established,related accept
|
||||
ct state invalid drop
|
||||
iif lo accept
|
||||
meta mark 0x00000001 accept
|
||||
iifname br-eth0 tcp dport 22 accept
|
||||
iifname eth0.11 tcp dport 22 accept
|
||||
iifname tun0 tcp dport 22 accept
|
||||
iifname { br-eth0, eth0.2, eth0.3, eth0.4, eth0.10, eth0.11, eth0.12 } tcp dport 61219 accept
|
||||
iifname { br-eth0, eth0.2, eth0.3, eth0.4, eth0.10, eth0.11, eth0.12 } udp dport 61219 accept
|
||||
iifname { br-eth0, eth0.2, eth0.3, eth0.4, eth0.10, eth0.11, eth0.12 } udp dport 53 accept
|
||||
iifname { br-eth0, eth0.2, eth0.3, eth0.4, eth0.10, eth0.11, eth0.12 } tcp dport 53 accept
|
||||
iifname eth0.3 udp dport 67 accept
|
||||
iifname eth1 udp dport 68 accept
|
||||
include "/etc/nftables.d/90-input.nft"
|
||||
}
|
||||
chain forward {
|
||||
type filter hook forward priority filter; policy drop;
|
||||
ct state established,related accept
|
||||
ct state invalid drop
|
||||
iifname { br-eth0, eth0.2, eth0.3, eth0.4, eth0.10, eth0.11, eth0.12 } oifname eth1 ct state new flow add @ft
|
||||
iifname { br-eth0, eth0.2, eth0.3, eth0.4, eth0.10, eth0.11, eth0.12 } oifname eth1 accept
|
||||
tcp flags syn tcp option maxseg size set rt mtu
|
||||
include "/etc/nftables.d/90-forward.nft"
|
||||
}
|
||||
chain output {
|
||||
type route hook output priority filter; policy accept;
|
||||
include "/etc/nftables.d/90-output.nft"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
chain proxy_prerouting {
|
||||
type filter hook prerouting priority filter - 50; policy accept;
|
||||
fib daddr type local accept
|
||||
meta mark 0x00000001 iif "lo" meta l4proto { tcp, udp } tproxy ip to :61219 counter accept
|
||||
include "/etc/nftables.d/90-proxy-prerouting.nft"
|
||||
}
|
||||
chain proxy_output {
|
||||
type route hook output priority mangle; policy accept;
|
||||
meta mark != 0 return
|
||||
include "/etc/nftables.d/90-proxy-output.nft"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
{% for item in nft_managed_group | sort %}
|
||||
{% set client = hostvars[item] %}
|
||||
{% if 'nft_dst' in client and client.nft_dst is not none %}
|
||||
{% set target_ip = client.ip %}
|
||||
{% for client in client.nft_dst %}
|
||||
{% set ports = client.port if (client.port is iterable and client.port is not string) else [client.port] %}
|
||||
{% set protos = client.proto if (client.proto is iterable and client.proto is not string) else [client.proto] %}
|
||||
{% set ifaces = client.iface if (client.iface is iterable and client.iface is not string) else [client.iface] %}
|
||||
{% for proto in protos %}
|
||||
{% for port in ports %}
|
||||
{% for iface in ifaces %}
|
||||
iifname "{{ iface }}" {{ proto }} dport {{ port }} counter dnat ip to {{ target_ip }}:{{ port }} comment "{{ iface }} -> {{ item }}"
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,47 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
{% for item in nft_managed_group | sort %}
|
||||
{% set client = hostvars[item] %}
|
||||
{% if 'nft_to' in client and client.nft_to is not none %}
|
||||
{% set rules = client.nft_to if (client.nft_to is iterable and client.nft_to is not string) else [client.nft_to] %}
|
||||
{% for rule in rules %}
|
||||
{% set rule = rule if rule is mapping else {'to': rule} %}
|
||||
{% set dests = rule.to if (rule.to is iterable and rule.to is not string) else [rule.to] %}
|
||||
{% set protos = rule.proto if (rule.proto is iterable and rule.proto is not string) else [rule.proto | default(none)] %}
|
||||
{% set ports = rule.port if (rule.port is iterable and rule.port is not string) else [rule.port | default(none)] %}
|
||||
{% for dest in dests %}
|
||||
{% if dest.startswith('zone:') %}
|
||||
{% set oif = dest.split(':')[1] %}
|
||||
{% set daddr = none %}
|
||||
{% set dest_name = oif %}
|
||||
{% else %}
|
||||
{% set oif = hostvars[dest].iface %}
|
||||
{% set daddr = hostvars[dest].ip %}
|
||||
{% set dest_name = dest %}
|
||||
{% endif %}
|
||||
{% for proto in protos %}
|
||||
{% for port in ports %}
|
||||
iifname "{{ client.iface }}" ip saddr {{ client.ip }} oifname "{{ oif }}" {% if daddr %}ip daddr {{ daddr }} {% endif %}{% if proto and port %}{{ proto }} dport {{ port }} {% endif %}counter accept comment "{{ item }} -> {{ dest_name }}"
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for item in nft_managed_group | sort %}
|
||||
{% set client = hostvars[item] %}
|
||||
{% if 'nft_from' in client and client.nft_from is not none %}
|
||||
{% set rules = client.nft_from if (client.nft_from is iterable and client.nft_from is not string) else [client.nft_from] %}
|
||||
{% for rule in rules %}
|
||||
{% set ifaces = rule.iface if (rule.iface is iterable and rule.iface is not string) else [rule.iface] %}
|
||||
{% set protos = rule.proto if (rule.proto is iterable and rule.proto is not string) else [rule.proto | default(none)] %}
|
||||
{% set ports = rule.port if (rule.port is iterable and rule.port is not string) else [rule.port | default(none)] %}
|
||||
{% for iface in ifaces %}
|
||||
{% for proto in protos %}
|
||||
{% for port in ports %}
|
||||
iifname "{{ iface }}" oifname "{{ client.iface }}" ip daddr {{ client.ip }} {% if proto and port %}{{ proto }} dport {{ port }} {% endif %}counter accept comment "{{ iface }} -> {{ item }}"
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,16 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
{% for item in nft_managed_group | sort %}
|
||||
{% set client = hostvars[item] %}
|
||||
{% if 'nft_input' in client and client.nft_input is not none %}
|
||||
{% set rules = client.nft_input if (client.nft_input is iterable and client.nft_input is not string) else [client.nft_input] %}
|
||||
{% for rule in rules %}
|
||||
{% set protos = rule.proto if (rule.proto is iterable and rule.proto is not string) else [rule.proto | default(none)] %}
|
||||
{% set ports = rule.port if (rule.port is iterable and rule.port is not string) else [rule.port | default(none)] %}
|
||||
{% for proto in protos %}
|
||||
{% for port in ports %}
|
||||
iifname "{{ client.iface }}" ip saddr {{ client.ip }} {% if proto and port %}{{ proto }} dport {{ port }} {% endif %}counter accept comment "{{ item }} -> router"
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,11 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
{% macro set_daddr(rule) %}
|
||||
{%- if rule in (xray_ip_sets | default([])) or rule in (xray_static_sets | default([])) -%}
|
||||
{{ rule }}_ip
|
||||
{%- elif rule in (xray_domain_sets | default([])) -%}
|
||||
{{ rule }}_dom
|
||||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
{% for rule in output_rules | default([]) | sort %}
|
||||
ip daddr @{{ set_daddr(rule) }} meta mark set {{ xray_fwmark }} counter accept comment "router -> tproxy"
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,28 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
{% macro set_daddr(name) -%}
|
||||
{%- if name == 'all' -%}
|
||||
0.0.0.0/0
|
||||
{%- elif name in (xray_ip_sets | default([])) or name in (xray_static_sets | default([])) -%}
|
||||
@{{ name }}_ip
|
||||
{%- elif name in (xray_domain_sets | default([])) -%}
|
||||
@{{ name }}_dom
|
||||
{%- else -%}
|
||||
invalid_xray_set_{{ name }}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
{% for item in xray_managed_group | default([]) | sort %}
|
||||
{% set client = hostvars[item] %}
|
||||
{% if client.xray_policy is defined %}
|
||||
{% set src_ip = client.ip %}
|
||||
{% for rule in client.xray_policy %}
|
||||
{% set target_set = rule.bypass | default(rule.proxy) %}
|
||||
{% if rule.bypass is defined %}
|
||||
meta l4proto tcp ip saddr {{ src_ip }} ip daddr {{ set_daddr(target_set) }} counter accept comment "{{ item }} -> accept"
|
||||
meta l4proto udp ip saddr {{ src_ip }} ip daddr {{ set_daddr(target_set) }} counter accept comment "{{ item }} -> accept"
|
||||
{% elif rule.proxy is defined %}
|
||||
meta l4proto tcp ip saddr {{ src_ip }} ip daddr {{ set_daddr(target_set) }} tproxy ip to :{{ xray_tproxy_port }} meta mark set {{ xray_fwmark }} counter accept comment "{{ item }} -> trpoxy"
|
||||
meta l4proto udp ip saddr {{ src_ip }} ip daddr {{ set_daddr(target_set) }} tproxy ip to :{{ xray_tproxy_port }} meta mark set {{ xray_fwmark }} counter accept comment "{{ item }} -> tproxy"
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/usr/sbin/nft -f
|
||||
flush ruleset
|
||||
table inet filter {
|
||||
include "/etc/nftables.d/10-sets.nft"
|
||||
include "/etc/nftables.d/20-sets.nft"
|
||||
include "/etc/nftables.d/40-filter.nft"
|
||||
include "/etc/nftables.d/50-proxy.nft"
|
||||
}
|
||||
table inet mangle {
|
||||
include "/etc/nftables.d/35-mangle.nft"
|
||||
}
|
||||
table ip nat {
|
||||
include "/etc/nftables.d/30-nat.nft"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/sbin/nft -f
|
||||
flush ruleset
|
||||
table inet filter {
|
||||
chain input {
|
||||
type filter hook input priority filter;
|
||||
policy drop;
|
||||
iif "lo" accept
|
||||
ct state established,related accept
|
||||
ct state invalid drop
|
||||
tcp dport 22 counter accept comment "ssh"
|
||||
tcp dport 80 counter accept comment "http"
|
||||
tcp dport 443 counter accept comment "https"
|
||||
}
|
||||
chain forward {
|
||||
type filter hook forward priority filter;
|
||||
policy drop;
|
||||
}
|
||||
chain output {
|
||||
type filter hook output priority filter;
|
||||
policy accept;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: check nginx config
|
||||
ansible.builtin.command: nginx -t
|
||||
changed_when: false
|
||||
listen: restart nginx
|
||||
|
||||
- name: restart nginx systemd service unit
|
||||
ansible.builtin.systemd_service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
enabled: true
|
||||
listen: restart nginx
|
||||
Loaded 100 of 219 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user