ahembree / ansible-hms-docker

Ansible playbook for automated home media server setup
GNU General Public License v3.0
391 stars 47 forks source link

Error when checking transmission proxy #56

Closed dustinleblanc closed 5 months ago

dustinleblanc commented 5 months ago

Just trying to get setup on a fresh install of Ubuntu server, ran into this:

TASK [hmsdocker : Get public IP from Transmission VPN container.] *******************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "cmd": ["docker", "exec", "transmission", "curl", "-s", "icanhazip.com"], "delta": "0:00:00.012565", "end": "2024-01-06 21:36:53.293296", "msg": "non-zero return code", "rc": 1, "start": "2024-01-06 21:36:53.280731", "stderr": "Error response from daemon: Container 1b60906b9ec460354a3e7e7ee629f0273c353cac1cd087621df02f5ba75aa946 is restarting, wait until the container is running", "stderr_lines": ["Error response from daemon: Container 1b60906b9ec460354a3e7e7ee629f0273c353cac1cd087621df02f5ba75aa946 is restarting, wait until the container is running"], "stdout": "", "stdout_lines": []}

if I inspect the logs, this is what I see:

Found configs for PROTONVPN in /config/vpn-configs-contrib/openvpn/protonvpn, will replace current content in /etc/openvpn/protonvpn
No VPN configuration provided. Using default.
Modifying /etc/openvpn/protonvpn/default.ovpn for best behaviour in this container
Modification: Point auth-user-pass option to the username/password file
sed: can't read /etc/openvpn/protonvpn/default.ovpn: No such file or directory
Modification: Change ca certificate path
sed: can't read /etc/openvpn/protonvpn/default.ovpn: No such file or directory
Modification: Change ping options
sed: can't read /etc/openvpn/protonvpn/default.ovpn: No such file or directory
sed: can't read /etc/openvpn/protonvpn/default.ovpn: No such file or directory
sed: can't read /etc/openvpn/protonvpn/default.ovpn: No such file or directory
sed: can't read /etc/openvpn/protonvpn/default.ovpn: No such file or directory
Modification: Update/set resolv-retry to 15 seconds
Modification: Change tls-crypt keyfile path
Modification: Set output verbosity to 3
Modification: Remap SIGUSR1 signal to SIGTERM, avoid OpenVPN restart loop
Modification: Updating status for config failure detection
Setting OpenVPN credentials...
adding route to local network 192.168.1.0/24 via 172.19.0.1 dev eth0
2024-01-06 16:38:33 Cipher negotiation is disabled since neither P2MP client nor server mode is enabled
Options error: You must define TUN/TAP device (--dev)
Use --help for more information.

I wanted to try to troubleshoot this myself but I don't know enough about OVPN and transmission in a container to know what I am doing. My setup is just an old tower setup with Ubuntu server (22.04) and for the VPN I am using the credentials from my proton VPN OVPN credentials. I've tried this both by modifying the config to run ansible remotely from my laptop, and by running ansible directly on server (which seems to be the project intention) I am running the script as root as the make file doesn't seem setup to run via become, etc. I have suspicion that there might be some ovpn config I can tweak here but I am not sure.

ahembree commented 5 months ago

Thanks for grabbing those container logs!

Unfortunately, this appears to be an issue with the VPN container itself since this repo does not directly modify any openvpn files, but you were definitely on the right track for troubleshooting.

ProtonVPN is considered an "External Provider" and I haven't dealt with one of these before, but I did some digging and found that how to configure this external ProtonVPN provider can be found here: https://github.com/haugene/vpn-configs-contrib/tree/main/openvpn/protonvpn

With that said though, the below may resolve your issue.

If you're using the "basic" configuration, can you edit your vars/custom/transmission.yml file to add the following to the bottom:

transmission_additional_env_vars:
  {
    "OPENVPN_CONFIG": "us.protonvpn.net.udp"
    "TRANSMISSION_DOWNLOAD_QUEUE_SIZE": "25",
    "TRANSMISSION_MAX_PEERS_GLOBAL": "3000",
    "TRANSMISSION_PEER_LIMIT_GLOBAL": "3000",
    "TRANSMISSION_PEER_LIMIT_PER_TORRENT": "300",
  }

If you're using the advanced configuration, could you try adding the below environment variable to the transmission_additional_env_vars list in the vars/custom/transmission.yml file?

"OPENVPN_CONFIG": "us.protonvpn.net.udp"

If you need to select a different country other than US, check out the configuration page at the link above for the available configs.

ahembree commented 5 months ago

I actually just realized that PR https://github.com/ahembree/ansible-hms-docker/pull/41 helps fix this, I'll dig deeper into merging those proposed changes.

dustinleblanc commented 5 months ago

Thanks so much for the quick response, giving it a try!

dustinleblanc commented 5 months ago

I'm having issues getting that syntax to parse in the yaml interpreter (using the basic config btw). I'll keep trying but just a heads up

ahembree commented 5 months ago

Oh whoops I forgot a comma at the end of a line, so it should be:

transmission_additional_env_vars:
  {
    "OPENVPN_CONFIG": "us.protonvpn.net.udp",
    "TRANSMISSION_DOWNLOAD_QUEUE_SIZE": "25",
    "TRANSMISSION_MAX_PEERS_GLOBAL": "3000",
    "TRANSMISSION_PEER_LIMIT_GLOBAL": "3000",
    "TRANSMISSION_PEER_LIMIT_PER_TORRENT": "300",
  }

sorry about that

dustinleblanc commented 5 months ago

No problem, thanks again for such a quick response

PLAY RECAP **************************************************************************************************************************************************
localhost                  : ok=29   changed=2    unreachable=0    failed=0    skipped=63   rescued=0    ignored=0

Looks like the whole playbook ran now, so time to go check it out and play :)

Thank you again, have a great weekend!

ahembree commented 5 months ago

Thanks for checking out and using my repo, hopefully it works well and fits your needs!

Any feature recommendations or enhancements to initial setup steps are always welcome.

If you encounter any further issues, don't hesitate to create another issue.