|
|
@ -32,24 +32,95 @@
|
|
|
|
loop_var: package_item
|
|
|
|
loop_var: package_item
|
|
|
|
when: ansible_distribution != "MacOSX"
|
|
|
|
when: ansible_distribution != "MacOSX"
|
|
|
|
|
|
|
|
|
|
|
|
- name: remove a gem
|
|
|
|
- name: Install a gem
|
|
|
|
gem: name=gist state=absent
|
|
|
|
gem:
|
|
|
|
|
|
|
|
name: gist
|
|
|
|
- name: verify gist is not installed
|
|
|
|
state: present
|
|
|
|
shell: gem list | egrep '^gist '
|
|
|
|
register: install_gem_result
|
|
|
|
register: uninstall
|
|
|
|
ignore_errors: yes
|
|
|
|
failed_when: "uninstall.rc != 1"
|
|
|
|
|
|
|
|
|
|
|
|
# when running as root on Fedora, '--install-dir' is set in the os defaults which is
|
|
|
|
- name: install a gem
|
|
|
|
# incompatible with '--user-install', we ignore this error for this case only
|
|
|
|
gem: name=gist state=present
|
|
|
|
- name: fail if failed to install gem
|
|
|
|
register: gem_result
|
|
|
|
fail:
|
|
|
|
|
|
|
|
msg: "failed to install gem: {{ install_gem_result.msg }}"
|
|
|
|
- name: verify module output properties
|
|
|
|
when:
|
|
|
|
assert:
|
|
|
|
- install_gem_result is failed
|
|
|
|
that:
|
|
|
|
- not (ansible_user_uid == 0 and "User --install-dir or --user-install but not both" not in install_gem_result.msg)
|
|
|
|
- "'name' in gem_result"
|
|
|
|
|
|
|
|
- "'changed' in gem_result"
|
|
|
|
- block:
|
|
|
|
- "'state' in gem_result"
|
|
|
|
- name: List gems
|
|
|
|
|
|
|
|
command: gem list
|
|
|
|
- name: verify gist is installed
|
|
|
|
register: current_gems
|
|
|
|
shell: gem list | egrep '^gist '
|
|
|
|
|
|
|
|
|
|
|
|
- name: Ensure gem was installed
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- install_gem_result is changed
|
|
|
|
|
|
|
|
- current_gems.stdout is search('gist\s+\([0-9.]+\)')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Remove a gem
|
|
|
|
|
|
|
|
gem:
|
|
|
|
|
|
|
|
name: gist
|
|
|
|
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
register: remove_gem_results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: List gems
|
|
|
|
|
|
|
|
command: gem list
|
|
|
|
|
|
|
|
register: current_gems
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Verify gem is not installed
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- remove_gem_results is changed
|
|
|
|
|
|
|
|
- current_gems.stdout is not search('gist\s+\([0-9.]+\)')
|
|
|
|
|
|
|
|
when: not install_gem_result is failed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# install gem in --no-user-install
|
|
|
|
|
|
|
|
- block:
|
|
|
|
|
|
|
|
- name: Install a gem with --no-user-install
|
|
|
|
|
|
|
|
gem:
|
|
|
|
|
|
|
|
name: gist
|
|
|
|
|
|
|
|
state: present
|
|
|
|
|
|
|
|
user_install: no
|
|
|
|
|
|
|
|
register: install_gem_result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: List gems
|
|
|
|
|
|
|
|
command: gem list
|
|
|
|
|
|
|
|
register: current_gems
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Ensure gem was installed
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- install_gem_result is changed
|
|
|
|
|
|
|
|
- current_gems.stdout is search('gist\s+\([0-9.]+\)')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Remove a gem
|
|
|
|
|
|
|
|
gem:
|
|
|
|
|
|
|
|
name: gist
|
|
|
|
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
register: remove_gem_results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: List gems
|
|
|
|
|
|
|
|
command: gem list
|
|
|
|
|
|
|
|
register: current_gems
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Verify gem is not installed
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- remove_gem_results is changed
|
|
|
|
|
|
|
|
- current_gems.stdout is not search('gist\s+\([0-9.]+\)')
|
|
|
|
|
|
|
|
when: ansible_user_uid == 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check cutom gem directory
|
|
|
|
|
|
|
|
- name: Install gem in a custom directory with incorrect options
|
|
|
|
|
|
|
|
gem:
|
|
|
|
|
|
|
|
name: gist
|
|
|
|
|
|
|
|
state: present
|
|
|
|
|
|
|
|
install_dir: "{{ output_dir }}/gems"
|
|
|
|
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
register: install_gem_fail_result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
|
|
|
|
var: install_gem_fail_result
|
|
|
|
|
|
|
|
tags: debug
|
|
|
|