ansible-community / ansible-nomad

:watch: Ansible role for Nomad
https://galaxy.ansible.com/brianshumate/nomad
BSD 2-Clause "Simplified" License
298 stars 166 forks source link

Incorrect advertise addresses generated when using ipv6 #51

Closed snesbittsea closed 4 years ago

snesbittsea commented 5 years ago

This is version 1.8.0, commit: b8163a192467da3e665c736f6c67e314a7089804. If an ipv6 address is specified for the nomad_advertise_address, then nomad will error out with a bind: invalid argument error.

As can be seen in the basic.hcl the problem is that the ports are simply being appended to the nomad_advertise_address. IPv6 syntax requires that the IP portion be placed within brackets - e.g [fdd3:ecf5:726d:5fbf:2e99:93f6:ba25:8570]:4646 rather than fdd3:ecf5:726d:5fbf:2e99:93f6:ba25:8570:4646

Followup: I worked around this by changing the base.hcl.j2 by adding the ipwrap filter as described in the Ansible docs here.

bind_addr = "{{ nomad_bind_address }}"
advertise {
    http = "{{ nomad_advertise_address | ipwrap }}:{{ nomad_ports.http }}"
    rpc = "{{ nomad_advertise_address | ipwrap }}:{{ nomad_ports.rpc }}"
    serf = "{{ nomad_advertise_address | ipwrap }}:{{ nomad_ports.serf }}"

Note that the ipwrap filter requires that the netaddr package to be installed on the ansible server. It does not need to be installed on the remote client.

I tested it with both ipv6 and ipv4 addresses and it seems to work. Your mileage may vary :-)

lanefu commented 4 years ago

based on update going to assume this is working or workable