1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/alternatives/tasks/test.yml

52 lines
1.5 KiB
YAML
Raw Normal View History

2020-03-09 10:11:07 +01:00
- debug:
msg: ' with_alternatives: {{ with_alternatives }}, mode: {{ mode }}'
- block:
- name: set alternative (using link parameter)
alternatives:
name: dummy
path: '/usr/bin/dummy{{ item }}'
2020-03-09 10:11:07 +01:00
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 }}'
2020-03-09 10:11:07 +01:00
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$"'
2020-03-09 10:11:07 +01:00
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$"'
2020-03-09 10:11:07 +01:00
when: ansible_os_family == 'RedHat' and not with_alternatives and item == 1
- name: check that alternative has been updated
Add subcommands parameter for module alternatives. (#4654) (#4788) * Add slaves parameter for module alternatives. * alternatives: Improve documentation abous slaves parameter * alternatives: Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * alternatives: Add schangelog for slaves parameter * alernatives: Add integration tests * alternatives: Improv tests * alternatives: Update tests/integration/targets/alternatives/tasks/slaves.yml Co-authored-by: Felix Fontein <felix@fontein.de> * alternatives: Rework logic to support updating priority and subcommands * alternatives: Use more inclusive naming * alternatives: Fix linter warnings * alternatives: Dont fail if link is absent * alternatives: Update changelog fragment * alternatives: Add tests for prio change and removing * alternatives: Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * alternatives: Add `state=auto`to reset mode to auto * alternatives: Fix linter warnings * alternatives: Fix documentation. * alternatives: Combine multiple messages. * alternatives: Set command env for all commands. * alternatives: Do not update subcommands if parameter is omited * alternatives: Fix a bug with python 2.7 var scoping * alternatives: Improce diff before generation * alternatives: Fix linter warnings * alternatives: Fix test names * alternatives: Simplify subcommands handling and improve diffs * aliases: Only test for subcommand changes if subcommands parameter is set. * Update plugins/modules/system/alternatives.py Co-authored-by: Felix Fontein <felix@fontein.de> * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit 373da56b5b3adaaa82645a2370371b2a5d4aa410) Co-authored-by: Marius Rieder <marius.rieder@durchmesser.ch>
2022-06-06 10:57:41 +02:00
command: "grep -Pzq '/bin/dummy{{ item }}\\n50' '{{ alternatives_dir }}/dummy'"