Simplify VPN connect and disconnect #7

Merged
rluetzner merged 1 commit from simplify-vpn into vpn 2022-08-13 20:28:01 +02:00
rluetzner commented 2022-08-13 17:13:17 +02:00 (Migrated from codeberg.org)

Ansible allows importing whole playbooks with 'import_playbook' or we
can just import tasks with the 'include_tasks' module. The latter in
combination with 'local_action' makes the playbooks quite a bit shorter.

Ansible allows importing whole playbooks with 'import_playbook' or we can just import tasks with the 'include_tasks' module. The latter in combination with 'local_action' makes the playbooks quite a bit shorter.
Tealk commented 2022-08-13 18:25:19 +02:00 (Migrated from codeberg.org)

so it executes the local command but as many times as hosts are selected?

so it executes the local command but as many times as hosts are selected?
rluetzner commented 2022-08-13 18:45:49 +02:00 (Migrated from codeberg.org)

Ah, good point. My test inventory only had one host in it.
I'll have a look at it later. That's an easy to solve problem with 'run_once: true' which can be added to any task as far as I know. I'll try it out and update the pull request accordingly.

Ah, good point. My test inventory only had one host in it. I'll have a look at it later. That's an easy to solve problem with 'run_once: true' which can be added to any task as far as I know. I'll try it out and update the pull request accordingly.
rluetzner commented 2022-08-13 19:19:27 +02:00 (Migrated from codeberg.org)

Done. 🙂

Done. 🙂
Tealk commented 2022-08-13 19:59:45 +02:00 (Migrated from codeberg.org)

Looks like the vpn taks is executed too late.

PLAY [Upgrade Servers] *****************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************************
fatal: [proxymanager]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.11 port 22: Network is unreachable", "unreachable": true}
fatal: [mastodon]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.12 port 22: Network is unreachable", "unreachable": true}
fatal: [mobilizon]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.13 port 22: Network is unreachable", "unreachable": true}
fatal: [writefreely]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.14 port 22: Network is unreachable", "unreachable": true}
fatal: [lemmy]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.15 port 22: Network is unreachable", "unreachable": true}
fatal: [pterodactyl]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.16 port 22: Network is unreachable", "unreachable": true}
fatal: [nextcloud]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.17 port 22: Network is unreachable", "unreachable": true}
fatal: [framadate]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.18 port 22: Network is unreachable", "unreachable": true}
fatal: [bookstack]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.19 port 22: Network is unreachable", "unreachable": true}
fatal: [yourls]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.20 port 22: Network is unreachable", "unreachable": true}
fatal: [freshrss]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.21 port 22: Network is unreachable", "unreachable": true}
fatal: [wallabag]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.22 port 22: Network is unreachable", "unreachable": true}
ok: [mailcow]
ok: [pve]
ok: [pbs]
fatal: [privatebin]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.23 port 22: Connection timed out", "unreachable": true}
fatal: [jitsi]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.24 port 22: Connection timed out", "unreachable": true}
fatal: [collaboraoffice]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.25 port 22: Connection timed out", "unreachable": true}
fatal: [foundryvtt]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.28 port 22: Network is unreachable", "unreachable": true}
fatal: [toot]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.26 port 22: Connection timed out", "unreachable": true}

TASK [include_tasks] *******************************************************************************************************************************************
included: /home/tealk/ansible/playbook/tasks/connect-vpn.yml for pve, pbs, mailcow

TASK [Connect VPN] *********************************************************************************************************************************************
changed: [pve -> localhost]
Looks like the vpn taks is executed too late. ``` PLAY [Upgrade Servers] ***************************************************************************************************************************************** TASK [Gathering Facts] ***************************************************************************************************************************************** fatal: [proxymanager]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.11 port 22: Network is unreachable", "unreachable": true} fatal: [mastodon]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.12 port 22: Network is unreachable", "unreachable": true} fatal: [mobilizon]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.13 port 22: Network is unreachable", "unreachable": true} fatal: [writefreely]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.14 port 22: Network is unreachable", "unreachable": true} fatal: [lemmy]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.15 port 22: Network is unreachable", "unreachable": true} fatal: [pterodactyl]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.16 port 22: Network is unreachable", "unreachable": true} fatal: [nextcloud]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.17 port 22: Network is unreachable", "unreachable": true} fatal: [framadate]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.18 port 22: Network is unreachable", "unreachable": true} fatal: [bookstack]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.19 port 22: Network is unreachable", "unreachable": true} fatal: [yourls]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.20 port 22: Network is unreachable", "unreachable": true} fatal: [freshrss]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.21 port 22: Network is unreachable", "unreachable": true} fatal: [wallabag]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.22 port 22: Network is unreachable", "unreachable": true} ok: [mailcow] ok: [pve] ok: [pbs] fatal: [privatebin]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.23 port 22: Connection timed out", "unreachable": true} fatal: [jitsi]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.24 port 22: Connection timed out", "unreachable": true} fatal: [collaboraoffice]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.25 port 22: Connection timed out", "unreachable": true} fatal: [foundryvtt]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.28 port 22: Network is unreachable", "unreachable": true} fatal: [toot]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.100.26 port 22: Connection timed out", "unreachable": true} TASK [include_tasks] ******************************************************************************************************************************************* included: /home/tealk/ansible/playbook/tasks/connect-vpn.yml for pve, pbs, mailcow TASK [Connect VPN] ********************************************************************************************************************************************* changed: [pve -> localhost] ```
rluetzner commented 2022-08-13 22:07:06 +02:00 (Migrated from codeberg.org)

You are right. I'm sorry. Ansible is failing to "gather facts" about your targets. I didn't run into this issue, because I don't have an actual VPN connection I can test with. So your initial idea with using separate playbooks is correct, because then the tasks will be run only for 'localhost'.
We can still clean this up a bit.

You are right. I'm sorry. Ansible is failing to "gather facts" about your targets. I didn't run into this issue, because I don't have an actual VPN connection I can test with. So your initial idea with using separate playbooks is correct, because then the tasks will be run only for 'localhost'. We can still clean this up a bit.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
RollenspielMonster/ansible_collection!7
No description provided.