Skip to content

Commit

Permalink
roles/openvpn-install-connector: fix nftables not starting correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
naisanzaa committed May 16, 2024
1 parent af207d9 commit f24cb4e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# make sure nftables runs at startup

set -x

echo starting

while true; do

if /usr/sbin/ifconfig wlan0; then
/usr/bin/systemctl enable nftables
/usr/bin/systemctl restart nftables
/usr/bin/systemctl status nftables

echo done
exit 0
fi

sleep 1

done

echo failed

exit 1
20 changes: 18 additions & 2 deletions playbooks/roles/openvpn-install-connector/tasks/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: delete sessions
shell: |
shell: |
set -x
for path in $(sudo openvpn3 sessions-list | grep -o '\S*/net/openvpn/\S*'); do sudo openvpn3 session-manage --path ${path} --disconnect; done
become: yes
Expand All @@ -13,7 +13,8 @@
for path in $(sudo openvpn3 configs-list | grep -o '\S*/net/openvpn/\S*'); do sudo openvpn3 config-remove --path ${path} --force; done
become: yes
register: shell
changed_when: shell.stdout
changed_when:
- "'Configuration removed' not in shell.stdout"

#- name: install connector online
# shell: |
Expand Down Expand Up @@ -75,3 +76,18 @@
become: yes
register: shell
changed_when: shell.stderr

- name: copy openvpn-start-nftables.sh
copy:
src: openvpn-start-nftables.sh
dest: /root/openvpn-start-nftables.sh
become: yes
changed_when: false

- name: "@reboot /bin/bash /root/openvpn-start-nftables.sh > reboot_startup.log 2>&1"
cron:
name: make sure nftables runs at startup
special_time: reboot
job: '/bin/bash /root/openvpn-start-nftables.sh > reboot_startup.log 2>&1'
become: yes
changed_when: false

0 comments on commit f24cb4e

Please sign in to comment.