diff --git a/changelogs/fragments/6456-fix-portage-withbdeps-false.yml b/changelogs/fragments/6456-fix-portage-withbdeps-false.yml new file mode 100644 index 0000000000..5227d3ff19 --- /dev/null +++ b/changelogs/fragments/6456-fix-portage-withbdeps-false.yml @@ -0,0 +1,2 @@ +bugfixes: + - "portage - update the logic for generating the emerge command arguments to ensure that ``withbdeps: false`` results in a passing an ``n`` argument with the ``--with-bdeps`` emerge flag (https://github.com/ansible-collections/community.general/issues/6451, https://github.com/ansible-collections/community.general/pull/6456)." diff --git a/plugins/modules/portage.py b/plugins/modules/portage.py index d33f44d578..c732e7f56f 100644 --- a/plugins/modules/portage.py +++ b/plugins/modules/portage.py @@ -383,14 +383,12 @@ def emerge_packages(module, packages): """Fallback to default: don't use this argument at all.""" continue - if not flag_val: + """Add the --flag=value pair.""" + if isinstance(flag_val, bool): + args.extend((arg, to_native('y' if flag_val else 'n'))) + elif not flag_val: """If the value is 0 or 0.0: add the flag, but not the value.""" args.append(arg) - continue - - """Add the --flag=value pair.""" - if isinstance(p[flag], bool): - args.extend((arg, to_native('y' if flag_val else 'n'))) else: args.extend((arg, to_native(flag_val)))