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
733d40a7
Commit
733d40a7
authored
Aug 05, 2015
by
Yannig Perré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When value does not exist, return default value instead of stopping ansible with an exception.
parent
c2968d6d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
lib/ansible/runner/lookup_plugins/ini.py
+4
-2
test/integration/test_lookup_properties.yml
+2
-1
No files found.
lib/ansible/runner/lookup_plugins/ini.py
View file @
733d40a7
...
@@ -43,9 +43,11 @@ class LookupModule(object):
...
@@ -43,9 +43,11 @@ class LookupModule(object):
# Retrieve all values from a section using a regexp
# Retrieve all values from a section using a regexp
if
is_regexp
:
if
is_regexp
:
return
[
v
for
k
,
v
in
self
.
cp
.
items
(
section
)
if
re
.
match
(
key
,
k
)]
return
[
v
for
k
,
v
in
self
.
cp
.
items
(
section
)
if
re
.
match
(
key
,
k
)]
value
=
None
# Retrieve a single value
# Retrieve a single value
value
=
self
.
cp
.
get
(
section
,
key
)
try
:
if
value
==
None
:
value
=
self
.
cp
.
get
(
section
,
key
)
except
ConfigParser
.
NoOptionError
,
e
:
return
dflt
return
dflt
return
value
return
value
...
...
test/integration/test_lookup_properties.yml
View file @
733d40a7
...
@@ -26,4 +26,5 @@
...
@@ -26,4 +26,5 @@
with_items
:
[
'
value_section'
,
'
other_section'
]
with_items
:
[
'
value_section'
,
'
other_section'
]
-
name
:
"
Reading
unknown
value"
-
name
:
"
Reading
unknown
value"
set_fact
:
set_fact
:
value2_section2
:
"
{{lookup('ini',
'value2
section=section1
file=lookup.ini')}}"
unknown
:
"
{{lookup('ini',
'value2
default=unknown
section=section1
file=lookup.ini')}}"
-
debug
:
var=unknown
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