Open bcurran3 opened 4 years ago
Rather than trying to do this as a task in ansible, what about catching this in the build process?
It becomes slightly difficult for apps that require working in host
mode, but a build step would capture 98% of them.
We could use an port assigning scheme. That's what I've done. it would require some slight modifications for some of the current applications that rely on default ports, but I was able to use 32XXY for assigning ports to different applications.
32 (just an arbitrary port >20 to be out of most commonly used ranges)
XX (double digits to be assigned to the application 01 = heimdall, 02 = portainer, 03 = transmission
Y (takes care of applications that need more that 1 port, such as an http and https port. Note: hopefully I don't run any applications that need more than 10 ports :sweat_smile: )
If it makes things safer/"futureproof" we could do (3XXYY)
Example:
By default, applications can be found on the ports listed below.
Application | Port | Notes |
---|---|---|
----------------- | -------- | -------------- |
Airsonic | 32010 | |
Bazarr | 32020 | |
Bitwarden "hub" | 32030 | Web Not. |
Bitwarden | 32031 | HTTP |
Calibre-web | 32040 | HTTP |
Cloud Commander | 32050 | |
Couchpotato | 32060 | |
Duplicati | 32070 | |
Emby | 32080 | HTTP |
Emby | 32081 | HTTPS |
Firefly III | 32090 | |
get_iplayer | 32100 | |
Gitea | 32110 | Web |
Gitea | 32111 | SSH |
GitLab | 32120 | HTTP |
GitLab | 32121 | HTTPS |
GitLab | 32122 | SSH |
Glances | 32130 | SSH |
and by making the ports more variable it will also allow users to change their port scheme easier, say if they add custom docker containers
Edit: also just realized that this also doesn't help check conflicts with applications not installed by ansible-nas. It only helps minimize risk of overlap.
Hello
I faced an issue with port 9000:
MSG:
Error starting container 0672123cc9a206cb942270d4235978193a7ae8cb5b5164531dd0f22f62fea29c: 500 Server Error for http+docker://localhost/v1.43/containers/0672123cc9a206cb942270d4235978193a7ae8cb5b5164531dd0f22f62fea29c/start: Internal Server Error ("driver failed programming external connectivity on endpoint minio (b33131ee8166ec86607347810aa2082f75432c34a6f97c2a3f8b7733e2166c96): Bind for 0.0.0.0:9000 failed: port is already allocated")
$ grep \"9000\" -R ./ | grep -v traefik
./roles/minio/defaults/main.yml:minio_api_port: "9000"
./roles/portainer/defaults/main.yml:portainer_port: "9000"
Is your feature request related to a problem? Please describe.
No so much a problem as an enhancement. As more and more apps get added to AN, there are going to be more and more default app port conflicts. Though port conflicts for most apps can be avoided when a contributor adds an app, sometimes new apps have required static ports (e.g. my Logitech Media Server and Unifi Controller additions) that, since they can't be changed, require a port configuration change by the end user (If they choose to use the apps that conflict of course). It's my guess that some user's wont read or follow the instructions or choose ports that cause a further conflict and AN should take steps to avoid aborting during an install and just skip the conflict.
Describe the solution you'd like
Some REGEX wizardry that will check *_port and make sure it doesn't match a set of ports assigned to a another app. This would be implemented in nas.yml as a when not condition.
High level faux example entry in nas.yml:
Describe alternatives you've considered
Contributors configuring AN from skipping installing an app that has port conflicts with previously AN installed base apps. This is not hard to do (see below) but doesn't take into account non-default settings conflicts that users might self-inflict.
Additional context
No, it's not high priority. Yes, it would add some nice checks. No, I'm not good enough at REGEX or parsing arrays to take this on. Hell, I'm learning Ansible on the fly thanks to Ansible-NAS. :)