ansible-collections / ansible-consul

:satellite: Ansible role for Hashicorp Consul clusters

Home Page:https://galaxy.ansible.com/ansible-community/consul/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ansible_default_ipv4 variable not defined

fred-gb opened this issue · comments

commented

Hello,

TASK [community.hashicorp.ansible-consul : Create configuration] ********************************************************************************************************************
task path: /---/ansible_collections/community/hashicorp/roles/ansible-consul/tasks/config.yml:4
fatal: [qpi.lan]: FAILED! => {
    "msg": "An unhandled exception occurred while running the lookup plugin 'template'. Error was a <class 'ansible.errors.AnsibleFilterError'>, original message: Mandatory variable 'ansible_default_ipv4'  not defined."
}

I have an Rapsberry Pi with Ubuntu 20.04.1

I tried to changed in template to ansible_all_ipv4_addresses

But same error.

Thanks

I was able to setup client only with
consul_datacenter: "dc"
if I leave empty or dc1 I get the same error

commented

Thanks,
I add it, but... New variable, new error...

TASK [community.hashicorp.ansible-consul : Create configuration] ***********************************************************************************************************
fatal: [qpi.lan]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'consul_bind_address'\n\nThe error appears to be in '/[...]/ansible_collections/community/hashicorp/roles/ansible-consul/tasks/config.yml': line 4, 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: Create configuration\n  ^ here\n"}

:'(

commented

Does someone already try to install it on rapsberry already?

commented

Hello,
My friend @wiseflat find the solution for me.

In inventory.ini, add this and ajust to your case:

[consul_instances]
vps02 consul_node_role=server consul_bootstrap_expect=true

[nomad_instances]
vps02

[server:children]
consul_instances
nomad_instances

Only one instance of consul in my case.
Or if you need many instances, all must be reachable and on same project

And it works!

This role doesn't allow you to run the playbook with the --limit option. If you do use this, it will fail with this error message because it needs to be able to collect facts for all the consul hosts.

Hi all, I am getting same error as mentioned by @fred-gb in above post running on RHEL 8.1 on Azure. I already have the inventory ini file structured. It was working about a month ago with similar set up but now while running against a set of new hosts it is throwing up this error. Any ideas what the actual resolution was on it ?

commented

Hi @bbarman4u

If you try this in your playbook?

  tasks:
    - name: Add host to consul group
      add_host:
        hostname: "{{ instance }}"
        group: consul_instances

Hi @bbarman4u

If you try this in your playbook?

  tasks:
    - name: Add host to consul group
      add_host:
        hostname: "{{ instance }}"
        group: consul_instances

@fred-gb Could you please explain how this solves the problem ? As I understand, it will help if some one has a dynamic inventory of the target hosts other than what is being worked upon from the static list in an inventory file. In my case my inventory file is static (pretty much mirrors the way the example in the README.md is).

Appreciate your help and response !