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

Upgrade fails when ansible_host is not set for control plane nodes #9344

Closed
dgerhardt opened this issue Sep 28, 2022 · 1 comment · Fixed by #9355
Closed

Upgrade fails when ansible_host is not set for control plane nodes #9344

dgerhardt opened this issue Sep 28, 2022 · 1 comment · Fixed by #9355
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@dgerhardt
Copy link

dgerhardt commented Sep 28, 2022

With the lastest kubespray release, the cluster upgrade (initial installation not tested but likely effected in the same way) fails when ansible_host is not set for nodes in the inventory. This issue did not occur with previous releases using the same inventory config.

This issue was introduced with acb6f24 (#9194). After reverting this commit, the upgrade succeeded.

Environment:

  • Cloud provider or hardware configuration:
    Bare metal/KVM (5 nodes)

  • OS (printf "$(uname -srm)\n$(cat /etc/os-release)\n"):
    Linux 5.10.0-17-amd64 x86_64
    Debian GNU/Linux 11 (bullseye)

  • Version of Ansible (ansible --version):
    ansible [core 2.12.5]

  • Version of Python (python --version):
    Python 3.8.10

Kubespray version (commit) (git rev-parse --short HEAD):
v2.20.0 (18efdc2)

Network plugin used:
Calico

Full inventory with variables (ansible -i inventory/sample/inventory.ini all -m debug -a "var=hostvars[inventory_hostname]"):

"hostvars[inventory_hostname].groups":
    {
        "all": [
            "h4.example.com",
            "h4n1.example.com",
            "h4n2.example.com",
            "h4n3.example.com",
            "h4n4.example.com",
            "h4n5.example.com",
            "h4n6.example.com"
        ],
        "clusters": [
            "h4.example.com",
            "h4n1.example.com",
            "h4n2.example.com",
            "h4n3.example.com",
            "h4n4.example.com",
            "h4n5.example.com",
            "h4n6.example.com"
        ],
        "etcd": [
            "h4n3.example.com"
        ],
        "h4_nodes": [
            "h4n1.example.com",
            "h4n2.example.com",
            "h4n3.example.com",
            "h4n4.example.com",
            "h4n5.example.com",
            "h4n6.example.com"
        ],
        "myisp": [
            "h4.example.com",
            "h4n1.example.com",
            "h4n2.example.com",
            "h4n3.example.com",
            "h4n4.example.com",
            "h4n5.example.com",
            "h4n6.example.com"
        ],
        "k8s_cluster": [
            "h4n2.example.com",
            "h4n3.example.com",
            "h4n4.example.com",
            "h4n5.example.com",
            "h4n6.example.com"
        ],
        "kube_control_plane": [
            "h4n2.example.com"
        ],
        "kube_node": [
            "h4n4.example.com",
            "h4n5.example.com",
            "h4n6.example.com"
        ],
        "kvm_hosts": [
            "h4.example.com"
        ],
        "mail": [
            "h4n1.example.com"
        ],
        "ungrouped": []
    }
ansible -i my.inventory.yml -m debug -a var=hostvars[inventory_hostname].ansible_host -l k8s_cluster
h4n2.example.com | SUCCESS => {
    "hostvars[inventory_hostname].ansible_host": "VARIABLE IS NOT DEFINED!"
}
h4n3.example.com | SUCCESS => {
    "hostvars[inventory_hostname].ansible_host": "VARIABLE IS NOT DEFINED!"
}
h4n4.example.com | SUCCESS => {
    "hostvars[inventory_hostname].ansible_host": "VARIABLE IS NOT DEFINED!"
}
h4n5.example.com | SUCCESS => {
    "hostvars[inventory_hostname].ansible_host": "VARIABLE IS NOT DEFINED!"
}
h4n6.example.com | SUCCESS => {
    "hostvars[inventory_hostname].ansible_host": "VARIABLE IS NOT DEFINED!"
}

Command used to invoke ansible:
ansible-playbook -u myuser --become -i my.inventory.yml upgrade-cluster.yml

Output of ansible run:

[...]

TASK [kubernetes/node : Write kubelet systemd init file] ***************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: {{ groups['kube_control_plane'] | map('extract', hostvars, ['ansible_host']) | join(' ') }}: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_host'
fatal: [h4n2.example.com]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: {{ groups['kube_control_plane'] | map('extract', hostvars, ['ansible_host']) | join(' ') }}: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_host'"}

Anything else do we need to know:
kubelet_systemd_hardening: false
Template line which causes the error: acb6f24#diff-184b5937f6be4d63c1e833fd13903f1560034737d2e7ca93c631ea605ed2092eR29

@dgerhardt dgerhardt added the kind/bug Categorizes issue or PR as related to a bug. label Sep 28, 2022
@dgerhardt dgerhardt changed the title Upgrade fails when ansible_host is not set for nodes Upgrade fails when ansible_host is not set for control plane nodes Sep 28, 2022
@rickerc
Copy link
Contributor

rickerc commented Oct 2, 2022

Confirmation that this also impacts new installs (as expected)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants