mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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
62 lines
2 KiB
YAML
62 lines
2 KiB
YAML
# Copyright (c) 2017 Pierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>
|
||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||
|
||
- name: 'setup: create a dummy alternative'
|
||
block:
|
||
- import_tasks: setup.yml
|
||
|
||
##############
|
||
# Test parameters:
|
||
# link parameter present / absent ('with_link' variable)
|
||
# with / without alternatives defined in alternatives file ('with_alternatives' variable)
|
||
# auto / manual ('mode' variable)
|
||
|
||
- include_tasks: tests.yml
|
||
with_nested:
|
||
- [ True, False ] # with_link
|
||
- [ True, False ] # with_alternatives
|
||
- [ 'auto', 'manual' ] # mode
|
||
loop_control:
|
||
loop_var: test_conf
|
||
|
||
##########
|
||
# Priority
|
||
- block:
|
||
- include_tasks: remove_links.yml
|
||
- include_tasks: setup_test.yml
|
||
# at least two iterations again
|
||
- include_tasks: tests_set_priority.yml
|
||
with_sequence: start=3 end=4
|
||
vars:
|
||
with_alternatives: True
|
||
mode: auto
|
||
|
||
- block:
|
||
- include_tasks: remove_links.yml
|
||
- include_tasks: setup_test.yml
|
||
# at least two iterations again
|
||
- include_tasks: tests_set_priority.yml
|
||
with_sequence: start=3 end=4
|
||
vars:
|
||
with_alternatives: False
|
||
mode: auto
|
||
always:
|
||
- include_tasks: remove_links.yml
|
||
|
||
- file:
|
||
path: '{{ item }}'
|
||
state: absent
|
||
with_items:
|
||
- '{{ alternatives_dir }}/dummy'
|
||
|
||
- file:
|
||
path: '/usr/bin/dummy{{ item }}'
|
||
state: absent
|
||
with_sequence: start=1 end=4
|
||
# *Disable tests on Fedora 24*
|
||
# Shippable Fedora 24 image provides chkconfig-1.7-2.fc24.x86_64 but not the
|
||
# latest available version (chkconfig-1.8-1.fc24.x86_64). update-alternatives
|
||
# in chkconfig-1.7-2 fails when /etc/alternatives/dummy link is missing,
|
||
# error is: 'failed to read link /usr/bin/dummy: No such file or directory'.
|
||
# Moreover Fedora 24 is no longer maintained.
|
||
when: ansible_distribution != 'Fedora' or ansible_distribution_major_version|int > 24
|