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

ansible_default_ipv4 variable not defined #419

Open
fred-gb opened this issue Nov 6, 2020 · 8 comments
Open

ansible_default_ipv4 variable not defined #419

fred-gb opened this issue Nov 6, 2020 · 8 comments

Comments

@fred-gb
Copy link

fred-gb commented Nov 6, 2020

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

@fatgit
Copy link

fatgit commented Nov 24, 2020

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

@fred-gb
Copy link
Author

fred-gb commented Nov 26, 2020

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"}

:'(

@fred-gb
Copy link
Author

fred-gb commented Dec 7, 2020

Does someone already try to install it on rapsberry already?

@fred-gb
Copy link
Author

fred-gb commented Apr 1, 2021

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!

@sandipb
Copy link
Contributor

sandipb commented Aug 3, 2021

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.

@bbarman4u
Copy link

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 ?

@fred-gb
Copy link
Author

fred-gb commented Dec 13, 2021

Hi @bbarman4u

If you try this in your playbook?

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

@bbarman4u
Copy link

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 !

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

4 participants