Re: [PATCH 1/4] ansible: fix bare conditionals for ansible-core 2.20+ strict booleans
Jeff Layton <[email protected]> Wed, 20 May 2026 06:19:44 -0400
| Newsgroups | dev.linux.lists.kdevops |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 2026-05-20 at 10:41 +0200, Daniel Gomez wrote:
> 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.
> >=20
> > Kconfig boolean variables exported through extra_vars.yaml arrive as
> > strings like "True" rather than native booleans and need the |bool
>=20
> Is not a Kconfig's yaml issue but rather the old legacy Makefile extra=
=20
> vars propagation. Example:
>=20
> scripts/gen-hosts.Makefile:GENHOSTS_EXTRA_ARGS +=3D kdevops_workflows_ded=
icated_workflow=3D'True'
>=20
> FYI, at some point we need to promote these variables to Kconfig and=20
> 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:
>=20
> 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;
>=20
> sym_calc_value(sym);
> - if (!(sym->flags & SYMBOL_WRITE))
> + if (!(sym->flags & SYMBOL_WRITE)) {
> + /* See conf_write() for the yaml-override rationa=
le. */
> + if (yaml_out && (sym->flags & SYMBOL_YAML))
> + __print_yaml_symbol(yaml_out, sym,
> + OUTPUT_N, true);
> continue;
> + }
> sym->flags &=3D ~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 evalua=
te 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 f=
or a
> + * symbol the producer declared.
> + */
> + if (yaml_config && (sym->flags & SYMBOL_Y=
AML)) {
> + sym->flags |=3D SYMBOL_WRITTEN;
> + __print_yaml_symbol(yaml_out, sym=
,
> + OUTPUT_N, tru=
e);
> + }
> goto next;
> + }
> if (need_newline) {
> fprintf(out, "\n");
> need_newline =3D false;
>=20
> But it's tedious work and needs testing. I already have some downstream=
=20
> 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 se=
nding?=20
>=20
Mostly NFS workloads with fstests, pynfs, etc.
I'm not clear -- do you want me to wait on merging this patch until
your change goes in, or will you be doing that on top of this one?
> > diff --git a/playbooks/roles/bootlinux/tasks/build/9p.yml b/playbooks/r=
oles/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
>=20
> Changes are inconsistent. See the other target_linux_install_b4 hunk belo=
w.
>=20
> > @@ -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 defi=
ned
> > + - target_linux_install_b4 | default('', true) | length > 0
> > - ansible_facts['os_family']|lower !=3D 'debian'
> > - not workflow_linux_packaged|bool
>=20
> We probably don't need the 'is defined' condition as we are ensuring the=
=20
> variable always gets a default value even when it's not propagated throug=
h.
>=20
Good point. Will fix.
--=20
Jeff Layton <[email protected]>