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
24226646
Commit
24226646
authored
Jun 28, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When loading the play hosts list, enforce some consistency
Fixes #9580
parent
9d9cd0c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletions
+25
-1
lib/ansible/playbook/play.py
+25
-1
No files found.
lib/ansible/playbook/play.py
View file @
24226646
...
...
@@ -19,6 +19,8 @@
from
__future__
import
(
absolute_import
,
division
,
print_function
)
__metaclass__
=
type
from
six
import
string_types
from
ansible.errors
import
AnsibleError
,
AnsibleParserError
from
ansible.playbook.attribute
import
Attribute
,
FieldAttribute
...
...
@@ -57,7 +59,7 @@ class Play(Base, Taggable, Become):
# Connection
_gather_facts
=
FieldAttribute
(
isa
=
'string'
,
default
=
'smart'
)
_hosts
=
FieldAttribute
(
isa
=
'list'
,
default
=
[],
required
=
True
)
_hosts
=
FieldAttribute
(
isa
=
'list'
,
default
=
[],
required
=
True
,
listof
=
string_types
)
_name
=
FieldAttribute
(
isa
=
'string'
,
default
=
''
)
# Variable Attributes
...
...
@@ -121,6 +123,28 @@ class Play(Base, Taggable, Become):
return
super
(
Play
,
self
)
.
preprocess_data
(
ds
)
def
_load_hosts
(
self
,
attr
,
ds
):
'''
Loads the hosts from the given datastructure, which might be a list
or a simple string. We also switch integers in this list back to strings,
as the YAML parser will turn things that look like numbers into numbers.
'''
if
isinstance
(
ds
,
(
string_types
,
int
)):
ds
=
[
ds
]
if
not
isinstance
(
ds
,
list
):
raise
AnsibleParserError
(
"'hosts' must be specified as a list or a single pattern"
,
obj
=
ds
)
# YAML parsing of things that look like numbers may have
# resulted in integers showing up in the list, so convert
# them back to strings to prevent problems
for
idx
,
item
in
enumerate
(
ds
):
if
isinstance
(
item
,
int
):
ds
[
idx
]
=
"
%
s"
%
item
return
ds
def
_load_vars
(
self
,
attr
,
ds
):
'''
Vars in a play can be specified either as a dictionary directly, or
...
...
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