Re: [PATCH 1/4] ansible: fix bare conditionals for ansible-core 2.20+ strict booleans

Daniel Gomez <[email protected]> Wed, 20 May 2026 10:41:24 +0200
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
On 19/05/2026 12.54, Jeff Layton wrote:
> Starting with ansible-core 2.20, when: conditionals that evaluate to
> a string instead of a boolean cause a fatal error rather than a
> deprecation warning. This affected two categories of variables across
> 16 role files.
> 
> Kconfig boolean variables exported through extra_vars.yaml arrive as
> strings like "True" rather than native booleans and need the |bool

Is not a Kconfig's yaml issue but rather the old legacy Makefile extra 
vars propagation. Example:

scripts/gen-hosts.Makefile:GENHOSTS_EXTRA_ARGS += kdevops_workflows_dedicated_workflow='True'

FYI, at some point we need to promote these variables to Kconfig and 
cleaned them up from Makefiles. Considering the reports from Chuck and
you with configs being gated behind if-conditionals, I changed kconfig
to always generate the symbols:

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 88bb13e6..0c8806b2 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -888,8 +888,13 @@ int conf_write_defconfig(const char *filename)
                        continue;

                sym_calc_value(sym);
-               if (!(sym->flags & SYMBOL_WRITE))
+               if (!(sym->flags & SYMBOL_WRITE)) {
+                       /* See conf_write() for the yaml-override rationale. */
+                       if (yaml_out && (sym->flags & SYMBOL_YAML))
+                               __print_yaml_symbol(yaml_out, sym,
+                                                   OUTPUT_N, true);
                        continue;
+               }
                sym->flags &= ~SYMBOL_WRITE;
                /* Skip unchangeable symbols */
                if (!sym_is_changeable(sym))
@@ -990,8 +995,22 @@ int conf_write(const char *name)
                } else if (!sym_is_choice(sym) &&
                           !(sym->flags & SYMBOL_WRITTEN)) {
                        sym_calc_value(sym);
-                       if (!(sym->flags & SYMBOL_WRITE))
+                       if (!(sym->flags & SYMBOL_WRITE)) {
+                               /*
+                                * .config omits hidden bools that evaluate to
+                                * n and symbols inside a disabled `if`, per
+                                * Linux convention. An explicit `output yaml`
+                                * declaration overrides that for YAML so a
+                                * consumer never sees an undefined key for a
+                                * symbol the producer declared.
+                                */
+                               if (yaml_config && (sym->flags & SYMBOL_YAML)) {
+                                       sym->flags |= SYMBOL_WRITTEN;
+                                       __print_yaml_symbol(yaml_out, sym,
+                                                           OUTPUT_N, true);
+                               }
                                goto next;
+                       }
                        if (need_newline) {
                                fprintf(out, "\n");
                                need_newline = false;

But it's tedious work and needs testing. I already have some downstream 
changes that I intend to send soon that should help with this patch.
Can you share which kind of workloads you run so I double check before sending? 

> diff --git a/playbooks/roles/bootlinux/tasks/build/9p.yml b/playbooks/roles/bootlinux/tasks/build/9p.yml
> index f390f028db1e..79a9c2249517 100644
> --- a/playbooks/roles/bootlinux/tasks/build/9p.yml
> +++ b/playbooks/roles/bootlinux/tasks/build/9p.yml
> @@ -13,7 +13,7 @@
>        - b4
>    when:
>      - target_linux_install_b4 is defined
> -    - target_linux_install_b4
> +    - target_linux_install_b4 | default('', true) | length > 0

Changes are inconsistent. See the other target_linux_install_b4 hunk below.

> @@ -56,8 +56,8 @@
>      name:
>        - b4
>    when:
> -    - target_linux_install_b4 is defined
> -    - target_linux_install_b4
> +    - target_linux_install_b4 | default('', true) | length > 0 is defined
> +    - target_linux_install_b4 | default('', true) | length > 0
>      - ansible_facts['os_family']|lower != 'debian'
>      - not workflow_linux_packaged|bool

We probably don't need the 'is defined' condition as we are ensuring the 
variable always gets a default value even when it's not propagated through.