Debian Codegraph @

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

raw symbols SCIP
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Add an alternative with a family
7 alternatives:
8 name: dummy
9 path: /usr/bin/dummy1
10 link: /usr/bin/dummy
11 family: family1
12 priority: 100
13 state: selected
14
15 - name: Ensure that the alternative has family assigned
16 shell: 'grep family1 {{ alternatives_dir }}/dummy'
17
18 - name: Add two alternatives with different families
19 alternatives:
20 name: dummy
21 path: '/usr/bin/dummy{{ item.n }}'
22 link: /usr/bin/dummy
23 family: family2
24 priority: "{{ item.priority }}"
25 state: present
26 loop:
27 - { n: 2, priority: 20 }
28 - { n: 3, priority: 10 }
29 - { n: 4, priority: 5 }
30
31 # Here we select the whole family of alternatives
32 - name: Set family as an alternatives
33 alternatives:
34 name: dummy
35 family: family2
36 state: selected
37
38 - name: Ensure manual mode
39 shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^manual"'
40
41 - name: Execute the current dummy command
42 shell: dummy
43 register: cmd
44
45 # Despite the fact that there is alternative with higher priority (/usr/bin/dummy1),
46 # it is not chosen as it doesn't belong to the selected family
47 - name: Ensure that the alternative from the selected family is used
48 assert:
49 that:
50 - cmd.stdout == "dummy2"
51
52 - name: Remove the alternative with the highest priority that belongs to the family
53 alternatives:
54 name: dummy
55 path: '/usr/bin/dummy2'
56 state: absent
57
58 - name: Execute the current dummy command
59 shell: dummy
60 register: cmd
61
62 - name: Ensure that the next alternative is selected as having the highest priority from the family
63 assert:
64 that:
65 - cmd.stdout == "dummy3"