1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

gem_module: Use --norc to avoid surprises

Run install and uninstall actions with `--norc`. This way ansible has
more control over the way gems are installed.
This commit is contained in:
Stanislav German-Evtushenko 2021-06-19 23:02:46 +09:00
parent e18de3f396
commit 66f40bcfe6
2 changed files with 14 additions and 12 deletions

View file

@ -200,6 +200,7 @@ def uninstall(module):
cmd = get_rubygems_path(module)
environ = get_rubygems_environ(module)
cmd.append('uninstall')
cmd.append('--norc')
if module.params['install_dir']:
cmd.extend(['--install-dir', module.params['install_dir']])
@ -228,6 +229,7 @@ def install(module):
cmd = get_rubygems_path(module)
cmd.append('install')
cmd.append('--norc')
if module.params['version']:
cmd.extend(['--version', module.params['version']])
if module.params['repository']:

View file

@ -185,35 +185,35 @@
name: gist
state: present
bindir: "{{ output_dir }}/custom_bindir"
user_install: no # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL
register: install_gem_result
- name: Get stats of gem executable
stat:
path: "{{ output_dir }}/custom_bindir/gist"
register: gem_bindir_stat
- name: Find gem executable
find:
paths: "{{ output_dir }}/custom_bindir"
patterns: "gist*"
register: gem_bindir_search
- name: Ensure gem executable was installed in custom directory
assert:
that:
- install_gem_result is changed
- gem_bindir_stat.stat.exists and gem_bindir_stat.stat.isreg
- gem_bindir_search.files | length == 1
- name: Remove gem with custom bindir
gem:
name: gist
state: absent
bindir: "{{ output_dir }}/custom_bindir"
user_install: no # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL
register: install_gem_result
- name: Get stats of gem executable
stat:
path: "{{ output_dir }}/custom_bindir/gist"
register: gem_bindir_stat
- name: Find gem executable
find:
paths: "{{ output_dir }}/custom_bindir"
patterns: "gist*"
register: gem_bindir_search
- name: Ensure gem executable was removed from custom directory
assert:
that:
- install_gem_result is changed
- not gem_bindir_stat.stat.exists
- gem_bindir_search.files | length == 0