diff options
author | Aurélien Bondis <aurelien.bondis@gmail.com> | 2012-10-09 06:21:13 +0200 |
---|---|---|
committer | Aurélien Bondis <aurelien.bondis@gmail.com> | 2012-10-09 06:21:13 +0200 |
commit | e07bfd9ef826e90b7f5804cd6e930791e671c424 (patch) | |
tree | c8bc63d435067328483077859ee07baccf6a2b85 /lib | |
parent | Fix up changelog (diff) | |
download | ansible-e07bfd9ef826e90b7f5804cd6e930791e671c424.tar.xz ansible-e07bfd9ef826e90b7f5804cd6e930791e671c424.zip |
playbook/tasks: allow to use a module's name instead of action:
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ansible/playbook/task.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index 5003fbf433..3178b23aec 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -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 |