Kubeinit / kubeinit

Ansible automation to have a KUBErnetes cluster INITialized as soon as possible...

Home Page:https://www.kubeinit.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_host'"}

jeffabailey opened this issue · comments

Describe the bug
A clear and concise description of what the bug is.

Error when running final step of installation.

FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_host'"}

To Reproduce
Steps to reproduce the behavior:

  1. Install on a fresh Raspian or Rocky linux system using these instructions: https://github.com/Kubeinit/kubeinit#directly-executing-the-deployment-playbook
  2. See this error output: full-error-output.txt

Expected behavior

A complete installation.

Screenshots
If applicable, add screenshots to help explain your problem.

Infrastructure

  • Hypervisors OS: Raspian or Rocky Linux
  • Version: Raspbian GNU/Linux 11 (bullseye) & Rocky Linux release 8.5 (Green Obsidian)

Deployment command

Followed instructions.

Inventory file diff

Run the following command:

diff \
    <(curl https://raw.githubusercontent.com/Kubeinit/kubeinit/main/kubeinit/hosts/k8s/inventory) \
    <(curl https://raw.githubusercontent.com/Kubeinit/kubeinit/main/kubeinit/hosts/okd/inventory)

And paste the output:

$ diff \
    <(curl https://raw.githubusercontent.com/Kubeinit/kubeinit/main/kubeinit/hosts/k8s/inventory) \
    <(curl https://raw.githubusercontent.com/Kubeinit/kubeinit/main/kubeinit/hosts/okd/inventory)
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                     % Total    % Received % Xferd  Average Speed   Time    Time        T i         Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 e  Curr--:--:-- --:--:-- --:--:--     0ent
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- 100    14  100    14    0     0     59      0 --:--:-- --:--:-- --:--:--    60
100    14  100    14    0     0     56      0 --:--:-- --:--:-- --:--:--    56

Additional context
Add any other context about the problem here.

Hi, would you mind running the de[ployment like this?

ansible-playbook     -v --user root     -e kubeinit_spec=k8s-libvirt-1-1-1   -e hypervisor_hosts_spec='[[ansible_host=nyctea],[ansible_host=tyto]]'      ./kubeinit/playbook.yml

I bet you are using the default inventory file, there might be a nit there.

Or you can have:

hypervisor_hosts:
  hosts:
    hypervisor-01:
      ansible_host: nyctea
    hypervisor-02:
      ansible_host: tyto

In your inventory.yml file

@ccamacho I updated to the latest code and ran the command.

I encountered a new error.

fatal: [hypervisor-01]: UNREACHABLE! => {"changed": false, "msg": "Data could not be sent to remote host \"nyctea\". Make sure this host can be reached over ssh: Warning: Identity file /root/.ssh/kubeinit_id_rsa not accessible: Permission denied.\nCan't open user config file /root/.ssh/k8scluster_config: Permission denied\r\n", "unreachable": true}

I wonder if it makes sense for me to clone this repo and set up a test like this one for Rocky Linux & Raspian?

https://github.com/Kubeinit/kubeinit/actions/workflows/distro_test.yml

What do you think?

@Gl1TcH-1n-Th3-M4tR1x Thanks for the input, but the inventory.yml already contains that configuration.

commented

Thanks for the input, but the inventory.yml already contains that configuration.

NO. IT DOES NOT.

The inventory file contains commented out lines like this:

We calculate the inventory dynamically so we dont expect you to have anything there.

# -e hypervisor_hosts_spec='[{"host":"hypervisor-01","ansible_host":"192.168.222.202"}]'

ie ansible extravars format, not even yaml.

The proper inventory file stuff suggested by @Gl1TcH-1n-Th3-M4tR1x is NOT THERE.
So it sounds like it has been accidentally deleted for some reason, and it should either be re-instated, or the instructions amended, because this bug is now 6 months old, and I have hit this same issue.

I didnt see this again @jeffabailey I built all the packages for aarch64 but there are some changes needed in the guest vm images to have it running in ARM. (Rocky should work ootb I dont think this will ever work on a raspberry)

commented

Ok, if inventory is calculated dynamically, and you dont expect anyone to use it, then why do instructions say:

Adjust the inventory file to suit your needs.
By default the first hypervisor node is called nyctea (defined in the inventory). Replace it with the hostname you specified if you changed it. You can also use the names in the inventory as aliases for your own hostnames using 

It is no wonder people are struggling with this, when the instructions are misleading.

Further, the contents of the inventory file give this as an example of setting the ansible extravars:

# -e hypervisor_hosts_spec='[{"host":"hypervisor-01","ansible_host":"nyctea","ssh_hostname":"server1.example.com"}]'

But ccamacho on Jun 27 suggested Jeff use:

#-e hypervisor_hosts_spec='[[ansible_host=nyctea],[ansible_host=tyto]]'

That's a completely different format for the var. So what is going on with that?

It would be helpful to clarify the syntax for this extra var - both, in the inventory file, and, in the main instructions!