Skip to content

bug: etcd restore failing on getting rke2_node_name #333

@michalg91

Description

@michalg91

Summary

When i try to restore newly deployed cluster from s3 backup task that gathers all rke2_node_name from inventories is failing. In debug mode i can see that vars are gathered also from localhost which is not using this variable since it is not in rke2_cluster_group_name which in my case is k8s_cluster. I am setting all rke2 setting in group_vars/k8s_cluster/rke2.yaml so group_vars/all/main.yaml files has no rke2 settings at all.

The related task is here: to

- name: Get all node names
ansible.builtin.set_fact:
node_names: "{{ hostvars | dict2items | map(attribute='value.rke2_node_name') }}"
run_once: true
register: node_names

Issue Type

Bug Report

Ansible Version

ansible [core 2.17.12]
  config file = /Users/michal/platform-infra/ansible/ansible.cfg
  configured module search path = ['/Users/michal/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/michal/.pyenv/versions/3.13.3/envs/platform/lib/python3.13/site-packages/ansible
  ansible collection location = /Users/michal/.ansible/collections:/usr/share/ansible/collections:/Users/michal/platform-infra/ansible/collections
  executable location = /Users/michal/.pyenv/versions/platform/bin/ansible
  python version = 3.13.3 (main, May  5 2025, 13:28:27) [Clang 17.0.0 (clang-1700.0.13.3)] (/Users/michal/.pyenv/versions/3.13.3/envs/platform/bin/python)
  jinja version = 3.1.6
  libyaml = True

Steps to Reproduce

backup etcd (to s3 or local), provision new nodes, configure restore parameters and use previous backup with playbook

Expected Results

Module gathers all current inventory node names from rke2_cluster_group_name group

Actual Results

15:44:12  TASK [lablabs.rke2 : Get all node names] ***************************************
15:44:16  fatal: [dev-02-node01]: FAILED! => 
15:44:16    msg: |-
15:44:16      The task includes an option with an undefined variable. The error was: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'rke2_node_name'. 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'rke2_node_name'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions