diff --git a/test/v2/playbook/test_task.py b/test/v2/playbook/test_task.py index a012dff4bf8..eef422aee88 100644 --- a/test/v2/playbook/test_task.py +++ b/test/v2/playbook/test_task.py @@ -32,7 +32,7 @@ class TestTask(unittest.TestCase): t = Task.load(basic_shell_task) assert t is not None assert t.name == basic_shell_task['name'] - assert t.module == 'shell' + assert t.action == 'shell' assert t.args == 'echo hi' def test_can_load_action_kv_form(self): diff --git a/v2/ansible/modules/__init__.py b/v2/ansible/modules/__init__.py new file mode 100644 index 00000000000..ec86ee61015 --- /dev/null +++ b/v2/ansible/modules/__init__.py @@ -0,0 +1,2 @@ +# TODO: header + diff --git a/v2/ansible/playbook/attribute.py b/v2/ansible/playbook/attribute.py index e3e2dd13d9f..1a22f3dbdbc 100644 --- a/v2/ansible/playbook/attribute.py +++ b/v2/ansible/playbook/attribute.py @@ -18,8 +18,9 @@ #from ansible.common.errors import AnsibleError class Attribute(object): - def __init__(self, isa=None): + def __init__(self, isa=None, private=False): self.isa = isa + self.private = private self.value = None def __call__(self): diff --git a/v2/ansible/playbook/base.py b/v2/ansible/playbook/base.py index 68dc2d6ffe3..825e9171ff8 100644 --- a/v2/ansible/playbook/base.py +++ b/v2/ansible/playbook/base.py @@ -37,6 +37,10 @@ class Base(object): ''' walk the input datastructure and assign any values ''' assert ds is not None + + # we currently don't do anything with private attributes but may + # later decide to filter them out of 'ds' here. + ds = self.munge(ds) # walk all attributes in the class @@ -54,7 +58,7 @@ class Base(object): else: if aname in ds: self._attributes[aname] = ds[aname] - + # return the constructed object self.validate() return self @@ -64,7 +68,7 @@ class Base(object): ''' validation that is done at parse time, not load time ''' # walk all fields in the object - for (name, attribute) in self.__dict__: + for (name, attribute) in self.__dict__.iteritems(): # find any field attributes if isinstance(attribute, FieldAttribute): @@ -95,5 +99,4 @@ class Base(object): if needle in self._attributes: return self._attributes[needle] - raise AttributeError - + raise AttributeError("attribute not found: %s" % needle) diff --git a/v2/ansible/playbook/task.py b/v2/ansible/playbook/task.py index ad708f167cb..6ab9231ba10 100644 --- a/v2/ansible/playbook/task.py +++ b/v2/ansible/playbook/task.py @@ -45,6 +45,8 @@ class Task(Base): # will be used if defined # might be possible to define others + + _args = FieldAttribute(isa='dict') _action = FieldAttribute(isa='string') _always_run = FieldAttribute(isa='bool') @@ -60,11 +62,11 @@ class Task(Base): # FIXME: this should not be a Task # include = FieldAttribute(isa='string') - _loop = Attribute() + _loop = FieldAttribute(isa='string', private=True) + _loop_args = FieldAttribute(isa='list', private=True) _local_action = FieldAttribute(isa='string') # FIXME: this should not be a Task - _module_args = Attribute(isa='dict') _meta = FieldAttribute(isa='string') _name = FieldAttribute(isa='string') @@ -127,25 +129,31 @@ class Task(Base): # convert it to "module + args" if k in module_finder: - if _module.value is not None or 'action' in ds or 'local_action' in ds: + + + if self._action.value is not None or 'action' in ds or 'local_action' in ds: raise AnsibleError("duplicate action in task: %s" % k) - _module.value = k - _module_args.value = v + + print "SCANNED: %s" % k + new_ds['action'] = k + new_ds['args'] = v # handle any loops, there can be only one kind of loop elif "with_%s" % k in lookup_finder: - if _loop.value is not None: + if self._loop.value is not None: raise AnsibleError("duplicate loop in task: %s" % k) - _loop.value = k - _loop_args.value = v + new_ds['loop'] = k + new_ds['loop_args'] = v # otherwise send it through straight else: # nothing we need to filter + print "PASSING: %s => %s" % (k,v) new_ds[k] = v + print "NEW_DS=%s" % new_ds return new_ds diff --git a/v2/ansible/plugins/__init__.py b/v2/ansible/plugins/__init__.py index 4bb6c393120..faa284ce165 100644 --- a/v2/ansible/plugins/__init__.py +++ b/v2/ansible/plugins/__init__.py @@ -216,28 +216,28 @@ class PluginLoader(object): action_loader = PluginLoader( 'ActionModule', - 'ansible.runner.action_plugins', + 'ansible.plugins.action', C.DEFAULT_ACTION_PLUGIN_PATH, 'action_plugins' ) cache_loader = PluginLoader( 'CacheModule', - 'ansible.cache', + 'ansible.plugins.cache', C.DEFAULT_CACHE_PLUGIN_PATH, 'cache_plugins' ) callback_loader = PluginLoader( 'CallbackModule', - 'ansible.callback_plugins', + 'ansible.plugins.callback', C.DEFAULT_CALLBACK_PLUGIN_PATH, 'callback_plugins' ) connection_loader = PluginLoader( 'Connection', - 'ansible.runner.connection_plugins', + 'ansible.plugins.connection', C.DEFAULT_CONNECTION_PLUGIN_PATH, 'connection_plugins', aliases={'paramiko': 'paramiko_ssh'} @@ -245,7 +245,7 @@ connection_loader = PluginLoader( shell_loader = PluginLoader( 'ShellModule', - 'ansible.runner.shell_plugins', + 'ansible.plugins.shell', 'shell_plugins', 'shell_plugins', ) @@ -259,21 +259,21 @@ module_finder = PluginLoader( lookup_finder = PluginLoader( 'LookupModule', - 'ansible.runner.lookup_plugins', + 'ansible.plugins.lookup', C.DEFAULT_LOOKUP_PLUGIN_PATH, 'lookup_plugins' ) vars_finder = PluginLoader( 'VarsModule', - 'ansible.inventory.vars_plugins', + 'ansible.plugins.vars', C.DEFAULT_VARS_PLUGIN_PATH, 'vars_plugins' ) filter_finder = PluginLoader( 'FilterModule', - 'ansible.runner.filter_plugins', + 'ansible.plugins.filter', C.DEFAULT_FILTER_PLUGIN_PATH, 'filter_plugins' )