Skip to content

Ansible 12 (core 2.19) type check failures #240

@filippog

Description

@filippog

Summary

I'm running ansible-role-k3s on Ansible 12 (core 2.19) on Debian Trixie and running into failures regarding type checks.

Issue Type

  • Bug Report

Controller Environment and Configuration

Debian Trixie + Ansible 12 (core 2.19)

Steps to Reproduce

Run with Ansible 12

Expected Result

No errors

Actual Result

TASK [ansible-role-k3s : Ensure directories exist] *****************************
[ERROR]: The filter plugin 'ansible.builtin.dirname' failed: expected str, bytes or os.PathLike object, not _OmitType
Origin: roles/ansible-role-k3s/vars/main.yml:151:11

149     path: "{{ k3s_runtime_config['default-local-storage-path'] | default(omit) }}"
150   - name: Private registry config file
151     path: "{{ (k3s_runtime_config['private-registry'] | default(omit)) | dirname }}"
              ^ column 11

fatal: [server-0]: FAILED! => {"msg": "The filter plugin 'ansible.builtin.dirname' failed: expected str, bytes or os.PathLike object, not _OmitType"}
fatal: [server-1]: FAILED! => {"msg": "The filter plugin 'ansible.builtin.dirname' failed: expected str, bytes or os.PathLike object, not _OmitType"}
fatal: [server-2]: FAILED! => {"msg": "The filter plugin 'ansible.builtin.dirname' failed: expected str, bytes or os.PathLike object, not _OmitType"}

I came up with the following changes, I'm happy to submit a PR as a followup!

diff --git i/tasks/ensure_downloads.yml w/tasks/ensure_downloads.yml
index 4d12fec..b8c8ee0 100644
--- i/tasks/ensure_downloads.yml
+++ w/tasks/ensure_downloads.yml
@@ -17,7 +17,7 @@
     k3s_binary_url: "https://storage.googleapis.com/k3s-ci-builds/k3s{{ k3s_arch_suffix }}-{{ k3s_release_version }}"
     k3s_hash_url: "https://storage.googleapis.com/k3s-ci-builds/k3s{{ k3s_arch_suffix }}-{{ k3s_release_version }}.sha256sum"
   when:
-    - k3s_release_version | regex_search("^[a-z0-9]{40}$")
+    - k3s_release_version | regex_search("^[a-z0-9]{40}$") | bool
   check_mode: false
 
 - name: Ensure the k3s hashsum is downloaded
diff --git i/vars/main.yml w/vars/main.yml
index f58c254..e5f8a1c 100644
--- i/vars/main.yml
+++ w/vars/main.yml
@@ -148,7 +148,7 @@ k3s_ensure_directories_exist:
   - name: Default local storage path
     path: "{{ k3s_runtime_config['default-local-storage-path'] | default(omit) }}"
   - name: Private registry config file
-    path: "{{ (k3s_runtime_config['private-registry'] | default(omit)) | dirname }}"
+    path: "{{ (k3s_runtime_config['private-registry'] | default('')) | dirname or omit }}"
 
 # Config items that should not appear in k3s_server or k3s_agent
 k3s_config_exclude:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions