V1
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
azp/posix/3
|
||||
destructive
|
||||
needs/root
|
||||
skip/aix
|
||||
skip/freebsd
|
||||
skip/osx
|
||||
skip/macos
|
||||
@@ -0,0 +1,93 @@
|
||||
####################################################################
|
||||
# WARNING: These are designed specifically for Ansible tests #
|
||||
# and should not be used as examples of how to write Ansible roles #
|
||||
####################################################################
|
||||
|
||||
# Copyright (c) 2017 Pierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- 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
|
||||
|
||||
# Test that path is checked: alternatives must fail when path is nonexistent
|
||||
- import_tasks: path_is_checked.yml
|
||||
|
||||
# Test that subcommands commands work
|
||||
- import_tasks: subcommands.yml
|
||||
|
||||
# Test operation of the 'state' parameter
|
||||
- block:
|
||||
- include_tasks: remove_links.yml
|
||||
- include_tasks: tests_state.yml
|
||||
|
||||
# Cleanup
|
||||
always:
|
||||
- include_tasks: remove_links.yml
|
||||
|
||||
- file:
|
||||
path: '{{ item }}'
|
||||
state: absent
|
||||
with_items:
|
||||
- '{{ alternatives_dir }}/dummy'
|
||||
- '{{ alternatives_dir }}/dummymain'
|
||||
- '{{ alternatives_dir }}/dummysubcmd'
|
||||
|
||||
- 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.
|
||||
#
|
||||
# *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'
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: Try with nonexistent path
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: '/non/existent/path/there'
|
||||
link: '/usr/bin/dummy'
|
||||
ignore_errors: True
|
||||
register: alternative
|
||||
|
||||
- name: Check previous task failed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is failed'
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: remove links
|
||||
file:
|
||||
path: '{{ item }}'
|
||||
state: absent
|
||||
with_items:
|
||||
- "{{ alternatives_dir }}/dummy"
|
||||
- /etc/alternatives/dummy
|
||||
- /usr/bin/dummy
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- include_vars: '{{ item }}'
|
||||
with_first_found:
|
||||
- files:
|
||||
- '{{ ansible_os_family }}-{{ ansible_distribution_version }}.yml'
|
||||
- '{{ ansible_os_family }}.yml'
|
||||
- default.yml
|
||||
paths: ../vars
|
||||
- template:
|
||||
src: dummy_command
|
||||
dest: /usr/bin/dummy{{ item }}
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
with_sequence: start=1 end=4
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- template:
|
||||
src: dummy_alternative
|
||||
dest: '{{ alternatives_dir }}/dummy'
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
when: with_alternatives or ansible_os_family != 'RedHat'
|
||||
- file:
|
||||
path: '{{ alternatives_dir }}/dummy'
|
||||
state: absent
|
||||
when: not with_alternatives and ansible_os_family == 'RedHat'
|
||||
@@ -0,0 +1,222 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: Try with subcommands
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy1'
|
||||
link: '/usr/bin/dummymain'
|
||||
subcommands:
|
||||
- name: dummysubcmd
|
||||
path: '/usr/bin/dummy2'
|
||||
link: '/usr/bin/dummysubcmd'
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is changed'
|
||||
|
||||
- name: Execute the current dummymain command
|
||||
command: dummymain
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy1"
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy2"
|
||||
|
||||
- name: Get dummymain alternatives output
|
||||
command:
|
||||
cmd: '{{ alternatives_command }} --display dummymain'
|
||||
register: result
|
||||
|
||||
- name: Print result
|
||||
debug:
|
||||
var: result.stdout_lines
|
||||
|
||||
- name: Subcommands are not removed if not specified
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy1'
|
||||
link: '/usr/bin/dummymain'
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is not changed'
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy2"
|
||||
|
||||
- name: Subcommands are removed if set to an empty list
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy1'
|
||||
link: '/usr/bin/dummymain'
|
||||
subcommands: []
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is changed'
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
ignore_errors: True
|
||||
|
||||
- name: Ensure that the subcommand is gone
|
||||
assert:
|
||||
that:
|
||||
- cmd.rc == 2
|
||||
- '"No such file" in cmd.msg'
|
||||
|
||||
- name: Get dummymain alternatives output
|
||||
command:
|
||||
cmd: '{{ alternatives_command }} --display dummymain'
|
||||
register: result
|
||||
|
||||
- name: Print result
|
||||
debug:
|
||||
var: result.stdout_lines
|
||||
|
||||
- name: Install other alternative with subcommands
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy3'
|
||||
link: '/usr/bin/dummymain'
|
||||
subcommands:
|
||||
- name: dummysubcmd
|
||||
path: '/usr/bin/dummy4'
|
||||
link: '/usr/bin/dummysubcmd'
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is changed'
|
||||
|
||||
- name: Execute the current dummymain command
|
||||
command: dummymain
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy3"
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy4"
|
||||
|
||||
- name: Get dummymain alternatives output
|
||||
command:
|
||||
cmd: '{{ alternatives_command }} --display dummymain'
|
||||
register: result
|
||||
|
||||
- name: Print result
|
||||
debug:
|
||||
var: result.stdout_lines
|
||||
|
||||
- name: Switch to first alternative
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy1'
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is changed'
|
||||
|
||||
- name: Execute the current dummymain command
|
||||
command: dummymain
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy1"
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
ignore_errors: True
|
||||
|
||||
- name: Ensure that the subcommand is gone
|
||||
assert:
|
||||
that:
|
||||
- cmd.rc == 2
|
||||
- '"No such file" in cmd.msg'
|
||||
|
||||
- name: Get dummymain alternatives output
|
||||
command:
|
||||
cmd: '{{ alternatives_command }} --display dummymain'
|
||||
register: result
|
||||
|
||||
- name: Print result
|
||||
debug:
|
||||
var: result.stdout_lines
|
||||
|
||||
- name: Switch to second alternative
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy3'
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is changed'
|
||||
|
||||
- name: Execute the current dummymain command
|
||||
command: dummymain
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy3"
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy4"
|
||||
|
||||
- name: Get dummymain alternatives output
|
||||
command:
|
||||
cmd: '{{ alternatives_command }} --display dummymain'
|
||||
register: result
|
||||
|
||||
- name: Print result
|
||||
debug:
|
||||
var: result.stdout_lines
|
||||
@@ -0,0 +1,56 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- debug:
|
||||
msg: ' with_alternatives: {{ with_alternatives }}, mode: {{ mode }}'
|
||||
|
||||
- block:
|
||||
- name: set alternative (using link parameter)
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: '/usr/bin/dummy{{ item }}'
|
||||
link: '/usr/bin/dummy'
|
||||
register: alternative
|
||||
|
||||
- name: check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is successful'
|
||||
- 'alternative is changed'
|
||||
when: with_link
|
||||
|
||||
- block:
|
||||
- name: set alternative (without link parameter)
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: '/usr/bin/dummy{{ item }}'
|
||||
register: alternative
|
||||
|
||||
- name: check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is successful'
|
||||
- 'alternative is changed'
|
||||
when: not with_link
|
||||
|
||||
- name: execute dummy command
|
||||
shell: dummy
|
||||
register: cmd
|
||||
|
||||
- name: check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'cmd.stdout == "dummy" ~ item'
|
||||
|
||||
- name: 'check mode (manual: alternatives file existed, it has been updated)'
|
||||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^manual$"'
|
||||
when: ansible_os_family != 'RedHat' or with_alternatives or item != 1
|
||||
|
||||
- name: 'check mode (auto: alternatives file didn''t exist, it has been created)'
|
||||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^auto$"'
|
||||
when: ansible_os_family == 'RedHat' and not with_alternatives and item == 1
|
||||
|
||||
- name: check that alternative has been updated
|
||||
command: "grep -Pzq '/bin/dummy{{ item }}\\n' '{{ alternatives_dir }}/dummy'"
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- block:
|
||||
- include_tasks: remove_links.yml
|
||||
- include_tasks: setup_test.yml
|
||||
# at least two iterations:
|
||||
# - first will use 'link currently absent',
|
||||
# - second will receive 'link currently points to'
|
||||
- include_tasks: test.yml
|
||||
with_sequence: start=1 end=2
|
||||
vars:
|
||||
with_link: '{{ test_conf[0] }}'
|
||||
with_alternatives: '{{ test_conf[1] }}'
|
||||
mode: '{{ test_conf[2] }}'
|
||||
# update-alternatives included in Fedora 26 (1.10) & Red Hat 7.4 (1.8) doesn't provide
|
||||
# '--query' switch, 'link' is mandatory for these distributions.
|
||||
when: ansible_os_family != 'RedHat' or test_conf[0]
|
||||
@@ -0,0 +1,54 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- 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 is 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'"
|
||||
|
||||
- name: update dummy priority
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: '/usr/bin/dummy{{ item }}'
|
||||
link: /usr/bin/dummy
|
||||
priority: '{{ 70 + item|int }}'
|
||||
register: alternative
|
||||
|
||||
- name: check that alternative priority has been updated
|
||||
command: "grep -Pzq '/bin/dummy{{ item }}\\n{{ 70 + item|int }}' '{{ alternatives_dir }}/dummy'"
|
||||
|
||||
- name: no change without priority
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: '/usr/bin/dummy{{ item }}'
|
||||
link: /usr/bin/dummy
|
||||
register: alternative
|
||||
|
||||
- name: check no change was triggered without priority
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is not changed'
|
||||
|
||||
- name: check that alternative priority has not been changed
|
||||
command: "grep -Pzq '/bin/dummy{{ item }}\\n{{ 70 + item|int }}' '{{ alternatives_dir }}/dummy'"
|
||||
@@ -0,0 +1,120 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# Add a few dummy alternatives with state = present and make sure that the
|
||||
# group is in 'auto' mode and the highest priority alternative is selected.
|
||||
- name: Add some dummy alternatives with state = present
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: "/usr/bin/dummy{{ item.n }}"
|
||||
link: /usr/bin/dummy
|
||||
priority: "{{ item.priority }}"
|
||||
state: present
|
||||
loop:
|
||||
- { n: 1, priority: 50 }
|
||||
- { n: 2, priority: 70 }
|
||||
- { n: 3, priority: 25 }
|
||||
|
||||
- name: Ensure that the link group is in auto mode
|
||||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^auto$"'
|
||||
|
||||
# Execute current selected 'dummy' and ensure it's the alternative we expect
|
||||
- name: Execute the current dummy command
|
||||
shell: dummy
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy2"
|
||||
|
||||
# Add another alternative with state = 'selected' and make sure that
|
||||
# this change results in the group being set to manual mode, and the
|
||||
# new alternative being the selected one.
|
||||
- name: Add another dummy alternative with state = selected
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: /usr/bin/dummy4
|
||||
link: /usr/bin/dummy
|
||||
priority: 10
|
||||
state: selected
|
||||
|
||||
- name: Ensure that the link group is in manual mode
|
||||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^manual$"'
|
||||
|
||||
- name: Execute the current dummy command
|
||||
shell: dummy
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy4"
|
||||
|
||||
# Set the currently selected alternative to state = 'present' (was previously
|
||||
# selected), and ensure that this results in the group not being set to 'auto'
|
||||
# mode, and the alternative is still selected.
|
||||
- name: Set current selected dummy to state = present
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: /usr/bin/dummy4
|
||||
link: /usr/bin/dummy
|
||||
state: present
|
||||
|
||||
- name: Ensure that the link group is in auto mode
|
||||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^manual$"'
|
||||
|
||||
- name: Execute the current dummy command
|
||||
shell: dummy
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy4"
|
||||
|
||||
# Set the currently selected alternative to state = 'auto' (was previously
|
||||
# selected), and ensure that this results in the group being set to 'auto'
|
||||
# mode, and the highest priority alternative is selected.
|
||||
- name: Set current selected dummy to state = present
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: /usr/bin/dummy4
|
||||
link: /usr/bin/dummy
|
||||
state: auto
|
||||
|
||||
- name: Ensure that the link group is in auto mode
|
||||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^auto$"'
|
||||
|
||||
- name: Execute the current dummy command
|
||||
shell: dummy
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy2"
|
||||
|
||||
# Remove an alternative with state = 'absent' and make sure that
|
||||
# this change results in the alternative being removed.
|
||||
- name: Remove best dummy alternative with state = absent
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: /usr/bin/dummy2
|
||||
state: absent
|
||||
|
||||
- name: Ensure that the link group is in auto mode
|
||||
shell: 'grep "/usr/bin/dummy2" {{ alternatives_dir }}/dummy'
|
||||
register: cmd
|
||||
failed_when: cmd.rc == 0
|
||||
|
||||
- name: Execute the current dummy command
|
||||
shell: dummy
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy1"
|
||||
@@ -0,0 +1,17 @@
|
||||
{#
|
||||
Copyright (c) Ansible Project
|
||||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#}
|
||||
{{ mode }}
|
||||
/usr/bin/dummy
|
||||
|
||||
{% if with_alternatives %}
|
||||
/usr/bin/dummy1
|
||||
40
|
||||
/usr/bin/dummy2
|
||||
30
|
||||
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
echo dummy{{ item }}
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
alternatives_dir: /var/lib/dpkg/alternatives/
|
||||
alternatives_command: update-alternatives
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
alternatives_dir: /var/lib/rpm/alternatives/
|
||||
alternatives_command: update-alternatives
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
alternatives_dir: /var/lib/alternatives/
|
||||
alternatives_command: update-alternatives
|
||||
Reference in New Issue
Block a user