2020-09-25 08:01:17 +02:00
|
|
|
####################################################################
|
|
|
|
# WARNING: These are designed specifically for Ansible tests #
|
|
|
|
# and should not be used as examples of how to write Ansible roles #
|
|
|
|
####################################################################
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
# 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:
|
2021-07-25 13:53:38 +02:00
|
|
|
# link parameter present / absent ('with_link' variable)
|
2020-03-09 10:11:07 +01:00
|
|
|
# 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
|
|
|
|
|
|
|
|
# Test that path is checked: alternatives must fail when path is nonexistent
|
|
|
|
- import_tasks: path_is_checked.yml
|
|
|
|
|
2022-04-26 08:41:04 +02:00
|
|
|
# Test operation of the 'state' parameter
|
|
|
|
- block:
|
|
|
|
- include_tasks: remove_links.yml
|
|
|
|
- include_tasks: tests_state.yml
|
|
|
|
|
|
|
|
# Cleanup
|
2020-03-09 10:11:07 +01:00
|
|
|
always:
|
|
|
|
- include_tasks: remove_links.yml
|
|
|
|
|
|
|
|
- file:
|
|
|
|
path: '{{ item }}'
|
|
|
|
state: absent
|
|
|
|
with_items:
|
2021-07-25 13:53:38 +02:00
|
|
|
- '{{ alternatives_dir }}/dummy'
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
- file:
|
|
|
|
path: '/usr/bin/dummy{{ item }}'
|
|
|
|
state: absent
|
|
|
|
with_sequence: start=1 end=4
|
2022-04-26 08:41:04 +02:00
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
# *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.
|
2022-02-22 10:08:35 +01:00
|
|
|
#
|
|
|
|
# *Disable tests on Arch Linux*
|
|
|
|
# TODO: figure out whether there is an alternatives tool for Arch Linux
|
|
|
|
#
|
|
|
|
# *Disable tests on Alpine*
|
|
|
|
# TODO: figure out whether there is an alternatives tool for Alpine
|
|
|
|
when:
|
|
|
|
- ansible_distribution != 'Fedora' or ansible_distribution_major_version|int > 24
|
|
|
|
- ansible_distribution != 'Archlinux'
|
|
|
|
- ansible_distribution != 'Alpine'
|