Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
e66a0096
Commit
e66a0096
authored
Oct 06, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work in progress on task loading.
parent
1556b038
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
22 deletions
+36
-22
test/v2/playbook/test_task.py
+1
-1
v2/ansible/modules/__init__.py
+2
-0
v2/ansible/playbook/attribute.py
+2
-1
v2/ansible/playbook/base.py
+7
-4
v2/ansible/playbook/task.py
+16
-8
v2/ansible/plugins/__init__.py
+8
-8
No files found.
test/v2/playbook/test_task.py
View file @
e66a0096
...
...
@@ -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
):
...
...
v2/ansible/modules/__init__.py
0 → 100644
View file @
e66a0096
# TODO: header
v2/ansible/playbook/attribute.py
View file @
e66a0096
...
...
@@ -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
):
...
...
v2/ansible/playbook/base.py
View file @
e66a0096
...
...
@@ -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
)
v2/ansible/playbook/task.py
View file @
e66a0096
...
...
@@ -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
...
...
v2/ansible/plugins/__init__.py
View file @
e66a0096
...
...
@@ -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_plugin
s'
,
'ansible.
plugins.var
s'
,
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'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment