dokku / ansible-dokku

Ansible modules for installing and configuring Dokku
MIT License
176 stars 44 forks source link

dokku_ports should `set` ports (rather than `add`) (?) #90

Closed ltalirz closed 3 years ago

ltalirz commented 3 years ago

Description of problem

When using the following task

- name: Configure ports for seekpath app
  dokku_ports:
    app: seekpath
    mappings:
      - http:80:80
      - https:443:80

I end up with the port mapping

ubuntu@dev-dokku:~$ dokku proxy:ports seekpath
-----> Port mappings for seekpath
    -----> scheme  host port  container port
    http           80         5000
    http           80         80
    https          443        5000
    https          443        80

This port mapping does not work as intended because dokku will take the first port for both http and https

Expected Results

In the case above, I clearly expect that the port mapping after running this task will be

ubuntu@dev-dokku:~$ dokku proxy:ports seekpath
-----> Port mappings for seekpath
    -----> scheme  host port  container port
    http           80         80
    https          443        80

One more open question arises if, prior to running the task, port mappings for other schemes were specified (say, myscheme 1234 123). One could decide to (a) leave those untouched or (b) remove them in order to make the list of port mappings exactly equal to the one specified in the ansible task.

Since proxy:ports-set implements (b), I'm going with (b) for the moment.

ltalirz commented 3 years ago

P.S. @josegonzalez What is the use case for the proxy:ports-add command? I'm having trouble imagining a case where I wouldn't want to use proxy:ports-set instead.

I just realized that proxy:ports-set indeed overwrites the entire port mapping, i.e. the use case for proxy:ports-add is now clear.