Skip to content

default_searchdomains is undefined when remove_default_searchdomains is true #12329

Open
@mr-luckiest

Description

@mr-luckiest

What happened?

Fatal error upgrade k8s cluster with kubespray 2.27:
task kubernetes_sigs.kubespray.kubernetes/preinstall : Configure dhclient to supersede search/domain/nameservers:
The task includes an option with an undefined variable. 'default_searchdomains' is undefined

What did you expect to happen?

roles/kubernetes/preinstall/vars/main.yml #92
domain-search: "{{ default_searchdomains | default([]) + searchdomains }}"

OR

set default fact:
default_searchdomains: []

How can we reproduce it (as minimally and precisely as possible)?

if i set remove_default_searchdomains is true, i have fatal error in task

OS

RHEL 8

Version of Ansible

9.13.0

Version of Python

3.11

Version of Kubespray (commit)

2.27.0

Network plugin used

calico

Full inventory with variables

all:
children:
kube_control_plane:
hosts:
master1
master2
master3
kube_node:
hosts:
app1
app2
app3
etcd:
hosts:
master1
master2
master3
k8s_cluster:
children:
kube_control_plane:
kube_node:
calico_rr:
hosts: {}

Command used to invoke ansible

ansible-playbook -i inventory/integration/hosts.yaml kubernetes.upgrade_cluster -b --diff -v --limit "kube_control_plane:etcd"

Output of ansible run

TASK [kubernetes_sigs.kubespray.kubernetes/preinstall : Configure dhclient to supersede search/domain/nameservers] **********************************************************************************************
fatal: [master1]: FAILED! =>
msg: |-
The task includes an option with an undefined variable. The error was: {'domain-name-servers': '{{ ([nameservers, cloud_resolver] | flatten | unique) if dns_early else nameserverentries }}', 'domain-name': '{{ [dns_domain] }}', 'domain-search': '{{ default_searchdomains + searchdomains }}'}: 'default_searchdomains' is undefined. 'default_searchdomains' is undefined. {'domain-name-servers': '{{ ([nameservers, cloud_resolver] | flatten | unique) if dns_early else nameserverentries }}', 'domain-name': '{{ [dns_domain] }}', 'domain-search': '{{ default_searchdomains + searchdomains }}'}: 'default_searchdomains' is undefined. 'default_searchdomains' is undefined

The error appears to be in '/home/.ansible/collections/ansible_collections/kubernetes_sigs/kubespray/roles/kubernetes/preinstall/tasks/0100-dhclient-hooks.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- name: Configure dhclient to supersede search/domain/nameservers
  ^ here

Anything else we need to know

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    RHEL 8kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions