diff --git a/changelogs/fragments/5822-gem-uninstall-force.yml b/changelogs/fragments/5822-gem-uninstall-force.yml new file mode 100644 index 0000000000..7b8a0efbda --- /dev/null +++ b/changelogs/fragments/5822-gem-uninstall-force.yml @@ -0,0 +1,2 @@ +bugfixes: + - gem - fix force parameter not being passed to gem command when uninstalling (https://github.com/ansible-collections/community.general/pull/5822). diff --git a/plugins/modules/gem.py b/plugins/modules/gem.py index 21e9efea58..a44683c786 100644 --- a/plugins/modules/gem.py +++ b/plugins/modules/gem.py @@ -105,7 +105,7 @@ options: required: false force: description: - - Force gem to install, bypassing dependency checks. + - Force gem to (un-)install, bypassing dependency checks. required: false default: false type: bool @@ -235,6 +235,8 @@ def uninstall(module): else: cmd.append('--all') cmd.append('--executable') + if module.params['force']: + cmd.append('--force') cmd.append(module.params['name']) module.run_command(cmd, environ_update=environ, check_rc=True)