Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues on ipv6-only hosts #447

Open
iojcde opened this issue Nov 7, 2021 · 2 comments
Open

Issues on ipv6-only hosts #447

iojcde opened this issue Nov 7, 2021 · 2 comments

Comments

@iojcde
Copy link

iojcde commented Nov 7, 2021

I'm having issues setting up consul on ipv6-only hosts.

TASK [ansible-consul : Expose advertise_address(_wan) datacenter and node_role as facts] **********************************************************************************
fatal: [dfw-master-2]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: {{ consul_bind_address }}: {% if ansible_system == 'FreeBSD' %}{{ lookup('env','CONSUL_BIND_ADDRESS') | default(hostvars[inventory_hostname]['ansible_'+ consul_iface ]['ipv4'][0]['address'], true) }}{% elif ansible_os_family == 'Windows'  %}{{ lookup('env','CONSUL_BIND_ADDRESS') | default(hostvars[inventory_hostname]['ansible_ip_addresses'][0], true) }}{% else %}{{ lookup('env','CONSUL_BIND_ADDRESS') | default(hostvars[inventory_hostname]['ansible_'+ consul_iface | replace('-', '_')]['ipv4']['address'], true) }}{% endif %}: 'dict object' has no attribute 'ipv4'\n\nThe error appears to be in '/home/jcde/teardrop/provisioning/ansible/roles/ansible-consul/tasks/nix.yml': line 14, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Expose advertise_address(_wan) datacenter and node_role as facts\n  ^ here\n"}
fatal: [dfw-master-0]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: {{ consul_bind_address }}: {% if ansible_system == 'FreeBSD' %}{{ lookup('env','CONSUL_BIND_ADDRESS') | default(hostvars[inventory_hostname]['ansible_'+ consul_iface ]['ipv4'][0]['address'], true) }}{% elif ansible_os_family == 'Windows'  %}{{ lookup('env','CONSUL_BIND_ADDRESS') | default(hostvars[inventory_hostname]['ansible_ip_addresses'][0], true) }}{% else %}{{ lookup('env','CONSUL_BIND_ADDRESS') | default(hostvars[inventory_hostname]['ansible_'+ consul_iface | replace('-', '_')]['ipv4']['address'], true) }}{% endif %}: 'dict object' has no attribute 'ipv4'\n\nThe error appears to be in '/home/jcde/teardrop/provisioning/ansible/roles/ansible-consul/tasks/nix.yml': line 14, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Expose advertise_address(_wan) datacenter and node_role as facts\n  ^ here\n"}
fatal: [dfw-master-1]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: {{ consul_bind_address }}: {% if ansible_system == 'FreeBSD' %}{{ lookup('env','CONSUL_BIND_ADDRESS') | default(hostvars[inventory_hostname]['ansible_'+ consul_iface ]['ipv4'][0]['address'], true) }}{% elif ansible_os_family == 'Windows'  %}{{ lookup('env','CONSUL_BIND_ADDRESS') | default(hostvars[inventory_hostname]['ansible_ip_addresses'][0], true) }}{% else %}{{ lookup('env','CONSUL_BIND_ADDRESS') | default(hostvars[inventory_hostname]['ansible_'+ consul_iface | replace('-', '_')]['ipv4']['address'], true) }}{% endif %}: 'dict object' has no attribute 'ipv4'\n\nThe error appears to be in '/home/jcde/teardrop/provisioning/ansible/roles/ansible-consul/tasks/nix.yml': line 14, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Expose advertise_address(_wan) datacenter and node_role as facts\n  ^ here\n"}```

I've specified consul_iface in the playbook, but it doesn't seem to work for some reason.

---
# File: site.yml - Example nomad site playbook
- name: Assemble Consul cluster
  hosts: masters
  any_errors_fatal: true
  become: true
  become_user: root
  roles:
    - ansible-consul
  vars:
    consul_group_name: masters
    consul_iface: eth0
    consul_node_role: server 
    consul_bootstrap_expect: true

I'm very new to ansible, so it might be something I did wrong.

@iojcde
Copy link
Author

iojcde commented Nov 7, 2021

If I'm understanding correctly, shouldn't consul_bind_address be configured to the address of the interface in consul_iface by default?

Edit: seems like #40 is kinda related

@bpbp-boop
Copy link

Just ran across this, the project hard-codes 'ipv4' in its default for consul_bind_address. You can define your own address instead
eg

    consul_bind_address: "{{ ansible_facts['ens18']['ipv6'][0]['address'] }}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants