mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
playbook/tasks: allow to use a module's name instead of action:
This commit is contained in:
parent
4bd17ee518
commit
e07bfd9ef8
1 changed files with 11 additions and 2 deletions
|
@ -17,6 +17,9 @@
|
|||
|
||||
from ansible import errors
|
||||
from ansible import utils
|
||||
import ansible.constants as C
|
||||
import os
|
||||
from os import pathsep
|
||||
|
||||
|
||||
class Task(object):
|
||||
|
@ -38,9 +41,15 @@ class Task(object):
|
|||
|
||||
def __init__(self, play, ds, module_vars=None):
|
||||
''' constructor loads from a task or handler datastructure '''
|
||||
|
||||
modules_list = set()
|
||||
for path in C.DEFAULT_MODULE_PATH.split(pathsep):
|
||||
modules_list.update(os.listdir(path))
|
||||
modules_list = list(modules_list)
|
||||
for x in ds.keys():
|
||||
if not x in Task.VALID_KEYS:
|
||||
if x in modules_list:
|
||||
ds['action'] = x + " " + ds.get(x, None)
|
||||
ds.pop(x)
|
||||
elif not x in Task.VALID_KEYS:
|
||||
raise errors.AnsibleError("%s is not a legal parameter in an Ansible task or handler" % x)
|
||||
|
||||
self.module_vars = module_vars
|
||||
|
|
Loading…
Reference in a new issue