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
9fe0f21f
Commit
9fe0f21f
authored
Jul 15, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow omit to be used on Playbook-level fields
Fixes #11173
parent
d6b058ea
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletions
+10
-1
lib/ansible/playbook/base.py
+10
-1
No files found.
lib/ansible/playbook/base.py
View file @
9fe0f21f
...
@@ -250,6 +250,9 @@ class Base:
...
@@ -250,6 +250,9 @@ class Base:
if
self
.
_loader
is
not
None
:
if
self
.
_loader
is
not
None
:
basedir
=
self
.
_loader
.
get_basedir
()
basedir
=
self
.
_loader
.
get_basedir
()
# save the omit value for later checking
omit_value
=
templar
.
_available_variables
.
get
(
'omit'
)
for
(
name
,
attribute
)
in
iteritems
(
self
.
_get_base_attributes
()):
for
(
name
,
attribute
)
in
iteritems
(
self
.
_get_base_attributes
()):
if
getattr
(
self
,
name
)
is
None
:
if
getattr
(
self
,
name
)
is
None
:
...
@@ -268,6 +271,12 @@ class Base:
...
@@ -268,6 +271,12 @@ class Base:
# if the attribute contains a variable, template it now
# if the attribute contains a variable, template it now
value
=
templar
.
template
(
getattr
(
self
,
name
))
value
=
templar
.
template
(
getattr
(
self
,
name
))
# if this evaluated to the omit value, set the value back to
# the default specified in the FieldAttribute and move on
if
omit_value
is
not
None
and
value
==
omit_value
:
value
=
attribute
.
default
continue
# and make sure the attribute is of the type it should be
# and make sure the attribute is of the type it should be
if
value
is
not
None
:
if
value
is
not
None
:
if
attribute
.
isa
==
'string'
:
if
attribute
.
isa
==
'string'
:
...
@@ -284,7 +293,7 @@ class Base:
...
@@ -284,7 +293,7 @@ class Base:
if
not
isinstance
(
item
,
attribute
.
listof
):
if
not
isinstance
(
item
,
attribute
.
listof
):
raise
AnsibleParserError
(
"the field '
%
s' should be a list of
%
s, but the item '
%
s' is a
%
s"
%
(
name
,
attribute
.
listof
,
item
,
type
(
item
)),
obj
=
self
.
get_ds
())
raise
AnsibleParserError
(
"the field '
%
s' should be a list of
%
s, but the item '
%
s' is a
%
s"
%
(
name
,
attribute
.
listof
,
item
,
type
(
item
)),
obj
=
self
.
get_ds
())
elif
attribute
.
isa
==
'dict'
and
not
isinstance
(
value
,
dict
):
elif
attribute
.
isa
==
'dict'
and
not
isinstance
(
value
,
dict
):
raise
TypeError
()
raise
TypeError
(
"
%
s is not a dictionary"
%
value
)
# and assign the massaged value back to the attribute field
# and assign the massaged value back to the attribute field
setattr
(
self
,
name
,
value
)
setattr
(
self
,
name
,
value
)
...
...
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