yum action plugin: 'use' as an alias of 'use_backend' (#70792)
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: rukmangathan <rukmangathan.annadurai@gigamon.com>
This commit is contained in:
parent
5640093f1c
commit
e0558ac193
3 changed files with 113 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- yum - yum action plugin changes to support 'use' as an alias of 'use_backend' (https://github.com/ansible/ansible/issues/70774).
|
|
@ -17,6 +17,7 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.errors import AnsibleActionFail
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.display import Display
|
||||
|
||||
|
@ -47,7 +48,10 @@ class ActionModule(ActionBase):
|
|||
del tmp # tmp no longer has any effect
|
||||
|
||||
# Carry-over concept from the package action plugin
|
||||
module = self._task.args.get('use_backend', "auto")
|
||||
if 'use' in self._task.args and 'use_backend' in self._task.args:
|
||||
raise AnsibleActionFail("parameters are mutually exclusive: ('use', 'use_backend')")
|
||||
|
||||
module = self._task.args.get('use', self._task.args.get('use_backend', 'auto'))
|
||||
|
||||
if module == 'auto':
|
||||
try:
|
||||
|
@ -90,6 +94,8 @@ class ActionModule(ActionBase):
|
|||
new_module_args = self._task.args.copy()
|
||||
if 'use_backend' in new_module_args:
|
||||
del new_module_args['use_backend']
|
||||
if 'use' in new_module_args:
|
||||
del new_module_args['use']
|
||||
|
||||
display.vvvv("Running %s as the backend for the yum action plugin" % module)
|
||||
result.update(self._execute_module(
|
||||
|
|
|
@ -143,4 +143,108 @@
|
|||
- name: verify at command is installed
|
||||
shell: which at
|
||||
|
||||
- name: remove at package
|
||||
package:
|
||||
name: at
|
||||
state: absent
|
||||
register: at_install0
|
||||
|
||||
- name: validate package removal
|
||||
assert:
|
||||
that:
|
||||
- "at_install0 is changed"
|
||||
|
||||
when: ansible_distribution in package_distros
|
||||
|
||||
##
|
||||
## yum
|
||||
##
|
||||
#Validation for new parameter 'use' in yum action plugin which aliases to 'use_backend'
|
||||
#Issue: https://github.com/ansible/ansible/issues/70774
|
||||
- block:
|
||||
- name: verify if using both the parameters 'use' and 'use_backend' throw error
|
||||
yum:
|
||||
name: at
|
||||
state: present
|
||||
use_backend: yum
|
||||
use: yum
|
||||
ignore_errors: yes
|
||||
register: result
|
||||
|
||||
- name: verify error
|
||||
assert:
|
||||
that:
|
||||
- "'parameters are mutually exclusive' in result.msg"
|
||||
- "not result is changed"
|
||||
|
||||
- name: verify if package installation is successful using 'use' parameter
|
||||
yum:
|
||||
name: at
|
||||
state: present
|
||||
use: dnf
|
||||
register: result
|
||||
|
||||
- name: verify the result
|
||||
assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: remove at package
|
||||
yum:
|
||||
name: at
|
||||
state: absent
|
||||
use: dnf
|
||||
register: result
|
||||
|
||||
- name: verify package removal
|
||||
assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: verify if package installation is successful using 'use_backend' parameter
|
||||
yum:
|
||||
name: at
|
||||
state: present
|
||||
use_backend: dnf
|
||||
register: result
|
||||
|
||||
- name: verify the result
|
||||
assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: remove at package
|
||||
yum:
|
||||
name: at
|
||||
state: absent
|
||||
use_backend: dnf
|
||||
register: result
|
||||
|
||||
- name: verify package removal
|
||||
assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: verify if package installation is successful without using 'use_backend' and 'use' parameters
|
||||
yum:
|
||||
name: at
|
||||
state: present
|
||||
register: result
|
||||
|
||||
- name: verify the result
|
||||
assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: remove at package
|
||||
yum:
|
||||
name: at
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- name: verify package removal
|
||||
assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
when: ansible_distribution == "Fedora"
|
Loading…
Reference in a new issue