mirror of https://github.com/ansible/ansible.git
alternatives: handle absent link, add integration tests (#27967)
* alternatives: add integration tests * alternatives: handle absent link (fix AttributeError) Error occurred at least on Debian Stretch and OpenSuse 42.2: Traceback (most recent call last): File "/tmp/ansible_RY6X41/ansible_module_alternatives.py", line 161, in <module> main() File "/tmp/ansible_RY6X41/ansible_module_alternatives.py", line 113, in main current_path = current_path_regex.search(display_output).group(1) AttributeError: 'NoneType' object has no attribute 'group' update-alternatives stdout sample: dummy - manual mode link best version is /usr/bin/dummy1 link currently absent link dummy is /usr/bin/dummy * alternatives: PEP 8 fixes * alternatives: fix copyright in integration tests * alternatives: nested loops handle more than 2 items Thanks to Michael Scherer (@mscherer) for pointing that. * alternatives: enable integration testspull/28283/head
parent
6886153b54
commit
016cd0691c
@ -0,0 +1,5 @@
|
|||||||
|
posix/ci/group3
|
||||||
|
destructive
|
||||||
|
needs/root
|
||||||
|
skip/freebsd
|
||||||
|
skip/osx
|
@ -0,0 +1,7 @@
|
|||||||
|
- name: remove links
|
||||||
|
file:
|
||||||
|
path: '{{ item }}'
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- /etc/alternatives/dummy
|
||||||
|
- /usr/bin/dummy
|
@ -0,0 +1,14 @@
|
|||||||
|
- include_vars: '{{ item }}'
|
||||||
|
with_first_found:
|
||||||
|
- files:
|
||||||
|
- '{{ 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,15 @@
|
|||||||
|
- 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,12 @@
|
|||||||
|
{{ mode }}
|
||||||
|
/usr/bin/dummy
|
||||||
|
|
||||||
|
{% if with_alternatives %}
|
||||||
|
/usr/bin/dummy1
|
||||||
|
40
|
||||||
|
/usr/bin/dummy2
|
||||||
|
30
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{% endif %}
|
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
echo dummy{{ item }}
|
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
alternatives_dir: /var/lib/dpkg/alternatives/
|
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
alternatives_dir: /var/lib/rpm/alternatives/
|
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
alternatives_dir: /var/lib/alternatives/
|
Loading…
Reference in New Issue