Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/alternatives/tasks/main.yml

raw
1 ####################################################################
2 # WARNING: These are designed specifically for Ansible tests #
3 # and should not be used as examples of how to write Ansible roles #
4 ####################################################################
5
6 # Copyright (c) 2017 Pierre-Louis Bonicoli <[email protected]>
7 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
8 # SPDX-License-Identifier: GPL-3.0-or-later
9
10 - name: 'setup: create a dummy alternative'
11 block:
12 - import_tasks: setup.yml
13
14 ##############
15 # Test parameters:
16 # link parameter present / absent ('with_link' variable)
17 # with / without alternatives defined in alternatives file ('with_alternatives' variable)
18 # auto / manual ('mode' variable)
19
20 - include_tasks: tests.yml
21 with_nested:
22 - [true, false] # with_link
23 - [true, false] # with_alternatives
24 - ['auto', 'manual'] # mode
25 loop_control:
26 loop_var: test_conf
27
28 ##########
29 # Priority
30 - block:
31 - include_tasks: remove_links.yml
32 - include_tasks: setup_test.yml
33 # at least two iterations again
34 - include_tasks: tests_set_priority.yml
35 with_sequence: start=3 end=4
36 vars:
37 with_alternatives: true
38 mode: auto
39
40 - block:
41 - include_tasks: remove_links.yml
42 - include_tasks: setup_test.yml
43 # at least two iterations again
44 - include_tasks: tests_set_priority.yml
45 with_sequence: start=3 end=4
46 vars:
47 with_alternatives: false
48 mode: auto
49
50 # Test that path is checked: alternatives must fail when path is nonexistent
51 - import_tasks: path_is_checked.yml
52
53 # Test that subcommands commands work
54 - import_tasks: subcommands.yml
55
56 # Test operation of the 'state' parameter
57 - block:
58 - include_tasks: remove_links.yml
59 - include_tasks: tests_state.yml
60
61 # Test for the family parameter
62 - block:
63 - include_tasks: remove_links.yml
64 - include_tasks: tests_family.yml
65 when: ansible_facts.os_family == 'RedHat'
66
67 # Cleanup
68 always:
69 - include_tasks: remove_links.yml
70
71 - file:
72 path: '{{ item }}'
73 state: absent
74 with_items:
75 - '{{ alternatives_dir }}/dummy'
76 - '{{ alternatives_dir }}/dummymain'
77 - '{{ alternatives_dir }}/dummysubcmd'
78
79 - file:
80 path: '/usr/bin/dummy{{ item }}'
81 state: absent
82 with_sequence: start=1 end=4
83
84 # *Disable tests on Fedora 24*
85 # Shippable Fedora 24 image provides chkconfig-1.7-2.fc24.x86_64 but not the
86 # latest available version (chkconfig-1.8-1.fc24.x86_64). update-alternatives
87 # in chkconfig-1.7-2 fails when /etc/alternatives/dummy link is missing,
88 # error is: 'failed to read link /usr/bin/dummy: No such file or directory'.
89 # Moreover Fedora 24 is no longer maintained.
90 #
91 # *Disable tests on Arch Linux*
92 # TODO: figure out whether there is an alternatives tool for Arch Linux
93 #
94 # *Disable tests on Alpine*
95 # TODO: figure out whether there is an alternatives tool for Alpine
96 when:
97 - ansible_facts.distribution != 'Fedora' or ansible_facts.distribution_major_version|int > 24
98 - ansible_facts.distribution != 'Archlinux'
99 - ansible_facts.distribution != 'Alpine'