Skip to content

Ansible task [Get previous cluster configuration] fails due to missing --kubeconfig parameter #346

Closed
@stefanoghinelli

Description

Describe the bug
The task "Get previous cluster configuration" fails during the first execution because the ansible.builtin.command for retrieving the furyctl-config secret does not include the --kubeconfig parameter.

The issue does not occur on subsequent executions.

Here is the task affected:

    - name: Get previous cluster configuration
      delegate_to: localhost
      ansible.builtin.command: "{{ .paths.kubectl }} get secrets -n kube-system furyctl-config -o jsonpath='{.data.config}'"
      register: previous_state
      # We ignore the secret not found error because when we init the cluster the secret does not exist yet, so the command fails.
      # Notice that all conditions must be true.
      failed_when:
        - previous_state.rc != 0
        - '"Error from server (NotFound): secrets \"furyctl-config\" not found" not in previous_state.stderr'
      # This is common for all the nodes, just run it once.
      run_once: true

To Reproduce
Steps to reproduce the behavior:

  1. Ensure a clean environment with no existing kubeconfig.
  2. Run furyctl apply --debug
  3. Observe the failure with the error message indicating that the Kubernetes API is not reachable.

Expected behavior
The task should succeed by providing the --kubeconfig parameter to kubectl, pointing to the appropriate kubeconfig file.

Screenshots
N/A (output is command-line based).

Desktop (please complete the following information):
N/A

Kubernetes (please complete the following information):

  • KFD version: v1.31.0, v1.30.1, v1.29.6, v1.28.6

Additional context
Adding the --kubeconfig parameter resolves the issue. The updated task should look like this:

    - name: Get previous cluster configuration
      delegate_to: localhost
      ansible.builtin.command: "{{ .paths.kubectl }} {{" get secrets -n kube-system furyctl-config -o jsonpath='{.data.config}' --kubeconfig={{ kubernetes_kubeconfig_path }}admin.conf" }}"
      register: previous_state
      # We ignore the secret not found error because when we init the cluster the secret does not exist yet, so the command fails.
      # Notice that all conditions must be true.
      failed_when:
        - previous_state.rc != 0
        - '"Error from server (NotFound): secrets \"furyctl-config\" not found" not in previous_state.stderr'
      # This is common for all the nodes, just run it once.
      run_once: true

Metadata

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions