016cd0691c
* alternatives: add integration tests * alternatives: handle absent link (fix AttributeError) Error occurred at least on Debian Stretch and OpenSuse 42.2: Traceback (most recent call last): File "/tmp/ansible_RY6X41/ansible_module_alternatives.py", line 161, in <module> main() File "/tmp/ansible_RY6X41/ansible_module_alternatives.py", line 113, in main current_path = current_path_regex.search(display_output).group(1) AttributeError: 'NoneType' object has no attribute 'group' update-alternatives stdout sample: dummy - manual mode link best version is /usr/bin/dummy1 link currently absent link dummy is /usr/bin/dummy * alternatives: PEP 8 fixes * alternatives: fix copyright in integration tests * alternatives: nested loops handle more than 2 items Thanks to Michael Scherer (@mscherer) for pointing that. * alternatives: enable integration tests
23 lines
651 B
YAML
23 lines
651 B
YAML
- name: update dummy alternative
|
||
alternatives:
|
||
name: dummy
|
||
path: '/usr/bin/dummy{{ item }}'
|
||
link: /usr/bin/dummy
|
||
priority: '{{ 60 + item|int }}'
|
||
register: alternative
|
||
|
||
- name: execute dummy command
|
||
shell: dummy
|
||
register: cmd
|
||
|
||
- name: check if link group is in manual mode
|
||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^manual$"'
|
||
|
||
- name: check expected command was executed
|
||
assert:
|
||
that:
|
||
- 'alternative|changed'
|
||
- 'cmd.stdout == "dummy{{ item }}"'
|
||
|
||
- name: check that alternative has been updated
|
||
command: "grep -Pzq '/bin/dummy{{ item }}\\n{{ 60 + item|int }}' '{{ alternatives_dir }}/dummy'"
|