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
c1b290a3
Commit
c1b290a3
authored
Oct 21, 2014
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix logic that prevents multiple action, local_action, and modules to be specified.
parent
6c94d856
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
16 deletions
+26
-16
v2/ansible/parsing/mod_args.py
+19
-16
v2/test/parsing/test_mod_args.py
+7
-0
No files found.
v2/ansible/parsing/mod_args.py
View file @
c1b290a3
...
...
@@ -198,6 +198,12 @@ class ModuleArgsParser:
delegate_to
=
None
args
=
dict
()
#
# We can have one of action, local_action, or module specified
#
# action
if
'action'
in
ds
:
# an old school 'action' statement
...
...
@@ -205,7 +211,8 @@ class ModuleArgsParser:
delegate_to
=
None
action
,
args
=
self
.
_normalize_parameters
(
thing
)
elif
'local_action'
in
ds
:
# local_action
if
'local_action'
in
ds
:
# local_action is similar but also implies a delegate_to
if
action
is
not
None
:
...
...
@@ -214,21 +221,17 @@ class ModuleArgsParser:
delegate_to
=
'localhost'
action
,
args
=
self
.
_normalize_parameters
(
thing
)
else
:
# module: <stuff> is the more new-style invocation
if
action
is
not
None
:
raise
AnsibleParserError
(
"conflicting action statements"
,
obj
=
self
.
_task
)
# walk the input dictionary to see we recognize a module name
for
(
item
,
value
)
in
iteritems
(
ds
):
if
item
in
module_finder
:
# finding more than one module name is a problem
if
action
is
not
None
:
raise
AnsibleParserError
(
"conflicting action statements"
,
obj
=
self
.
_task
)
action
=
item
thing
=
value
action
,
args
=
self
.
_normalize_parameters
(
value
,
action
=
action
)
# module: <stuff> is the more new-style invocation
# walk the input dictionary to see we recognize a module name
for
(
item
,
value
)
in
iteritems
(
ds
):
if
item
in
module_finder
:
# finding more than one module name is a problem
if
action
is
not
None
:
raise
AnsibleParserError
(
"conflicting action statements"
,
obj
=
self
.
_task
)
action
=
item
thing
=
value
action
,
args
=
self
.
_normalize_parameters
(
value
,
action
=
action
)
# if we didn't see any module in the task at all, it's not a task really
if
action
is
None
:
...
...
v2/test/parsing/test_mod_args.py
View file @
c1b290a3
...
...
@@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__
=
type
from
ansible.parsing.mod_args
import
ModuleArgsParser
from
ansible.errors
import
AnsibleParserError
from
ansible.compat.tests
import
unittest
...
...
@@ -106,3 +107,9 @@ class TestModArgsDwim(unittest.TestCase):
self
.
assertEqual
(
mod
,
'copy'
)
self
.
assertEqual
(
args
,
dict
(
src
=
'a'
,
dest
=
'b'
))
self
.
assertIs
(
to
,
'localhost'
)
def
test_multiple_actions
(
self
):
self
.
assertRaises
(
AnsibleParserError
,
self
.
m
.
parse
,
dict
(
action
=
'shell echo hi'
,
local_action
=
'shell echo hi'
))
self
.
assertRaises
(
AnsibleParserError
,
self
.
m
.
parse
,
dict
(
action
=
'shell echo hi'
,
shell
=
'echo hi'
))
self
.
assertRaises
(
AnsibleParserError
,
self
.
m
.
parse
,
dict
(
local_action
=
'shell echo hi'
,
shell
=
'echo hi'
))
self
.
assertRaises
(
AnsibleParserError
,
self
.
m
.
parse
,
dict
(
ping
=
'data=hi'
,
shell
=
'echo hi'
))
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