mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-01 14:51:27 -07:00
Add force parameter to gem module (#51366)
This commit is contained in:
parent
9babd16942
commit
063cd5ea44
2 changed files with 29 additions and 0 deletions
|
@ -95,6 +95,13 @@ options:
|
||||||
- Allow adding build flags for gem compilation
|
- Allow adding build flags for gem compilation
|
||||||
required: false
|
required: false
|
||||||
version_added: "2.0"
|
version_added: "2.0"
|
||||||
|
force:
|
||||||
|
description:
|
||||||
|
- Force gem to install, bypassing dependency checks.
|
||||||
|
required: false
|
||||||
|
default: "no"
|
||||||
|
type: bool
|
||||||
|
version_added: "2.8"
|
||||||
author:
|
author:
|
||||||
- "Ansible Core Team"
|
- "Ansible Core Team"
|
||||||
- "Johan Wiren (@johanwiren)"
|
- "Johan Wiren (@johanwiren)"
|
||||||
|
@ -247,6 +254,8 @@ def install(module):
|
||||||
cmd.append(module.params['gem_source'])
|
cmd.append(module.params['gem_source'])
|
||||||
if module.params['build_flags']:
|
if module.params['build_flags']:
|
||||||
cmd.extend(['--', module.params['build_flags']])
|
cmd.extend(['--', module.params['build_flags']])
|
||||||
|
if module.params['force']:
|
||||||
|
cmd.append('--force')
|
||||||
module.run_command(cmd, check_rc=True)
|
module.run_command(cmd, check_rc=True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -267,6 +276,7 @@ def main():
|
||||||
env_shebang=dict(required=False, default=False, type='bool'),
|
env_shebang=dict(required=False, default=False, type='bool'),
|
||||||
version=dict(required=False, type='str'),
|
version=dict(required=False, type='str'),
|
||||||
build_flags=dict(required=False, type='str'),
|
build_flags=dict(required=False, type='str'),
|
||||||
|
force=dict(required=False, default=False, type='bool'),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
mutually_exclusive=[['gem_source', 'repository'], ['gem_source', 'version']],
|
mutually_exclusive=[['gem_source', 'repository'], ['gem_source', 'version']],
|
||||||
|
|
|
@ -119,3 +119,22 @@ class TestGem(ModuleTestCase):
|
||||||
|
|
||||||
update_environ = run_command.call_args[1].get('environ_update', {})
|
update_environ = run_command.call_args[1].get('environ_update', {})
|
||||||
assert update_environ.get('GEM_HOME') == '/opt/dummy'
|
assert update_environ.get('GEM_HOME') == '/opt/dummy'
|
||||||
|
|
||||||
|
def test_passes_add_force_option(self):
|
||||||
|
set_module_args({
|
||||||
|
'name': 'dummy',
|
||||||
|
'force': True,
|
||||||
|
})
|
||||||
|
|
||||||
|
self.patch_rubygems_version()
|
||||||
|
self.patch_installed_versions([])
|
||||||
|
run_command = self.patch_run_command()
|
||||||
|
|
||||||
|
with pytest.raises(AnsibleExitJson) as exc:
|
||||||
|
gem.main()
|
||||||
|
|
||||||
|
result = exc.value.args[0]
|
||||||
|
assert result['changed']
|
||||||
|
assert run_command.called
|
||||||
|
|
||||||
|
assert '--force' in get_command(run_command)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue