How to deterministic and reproducibly assign increasing port numbers in Ansible?
Disclaimer: I'm not using Ansible.

What I would do is use a random "predictable" number.
According to Ansible doc you can seed the random number generator:


  As of Ansible version 2.3, it’s also possible to initialize the random
  number generator from a seed. This way, you can create
  random-but-idempotent numbers:
  
  "{{ 59 |random(seed=inventory_hostname) }} * * * * root
  /script/from/cron"


So in your case for a port number (I assume unpriviledged) I would go for a variable with something like:

port="{{ 32767 |random(start=1024,seed=service_name) }}"


Max at 32767 to avoid clashing with any client initiated port (See Ephemeral port for the reason).