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
2e680019
Commit
2e680019
authored
Jun 19, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'origin/devel' into devel
parents
faaa90ed
5ac1e7d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
lib/ansible/runner/lookup_plugins/first_found.py
+22
-9
No files found.
lib/ansible/runner/lookup_plugins/first_found.py
View file @
2e680019
...
@@ -83,6 +83,23 @@
...
@@ -83,6 +83,23 @@
# - files: foo.${inventory_hostname}
# - files: foo.${inventory_hostname}
# skip: true
# skip: true
# example a role with default configuration and configuration per host
# you can set multiple terms with their own files and paths to look through.
# consider a role that sets some configuration per host falling back on a default config.
#
#- name: some configuration template
# template: src={{ item }} dest=/etc/file.cfg mode=0444 owner=root group=root
# with_first_found:
# - files:
# - ${inventory_hostname}/etc/file.cfg
# paths:
# - ../../../templates.overwrites
# - ../../../templates
# - files:
# - etc/file.cfg
# paths:
# - templates
# the above will return an empty list if the files cannot be found at all
# the above will return an empty list if the files cannot be found at all
# if skip is unspecificed or if it is set to false then it will return a list
# if skip is unspecificed or if it is set to false then it will return a list
# error which can be caught bye ignore_errors: true for that action.
# error which can be caught bye ignore_errors: true for that action.
...
@@ -99,8 +116,6 @@
...
@@ -99,8 +116,6 @@
# - ../files/bar
# - ../files/bar
# - ../files/baz
# - ../files/baz
# ignore_errors: true
# ignore_errors: true
from
ansible
import
utils
,
errors
from
ansible
import
utils
,
errors
...
@@ -113,7 +128,7 @@ class LookupModule(object):
...
@@ -113,7 +128,7 @@ class LookupModule(object):
def
run
(
self
,
terms
,
inject
=
None
,
**
kwargs
):
def
run
(
self
,
terms
,
inject
=
None
,
**
kwargs
):
terms
=
utils
.
listify_lookup_plugin_terms
(
terms
,
self
.
basedir
,
inject
)
terms
=
utils
.
listify_lookup_plugin_terms
(
terms
,
self
.
basedir
,
inject
)
result
=
None
result
=
None
anydict
=
False
anydict
=
False
...
@@ -122,14 +137,15 @@ class LookupModule(object):
...
@@ -122,14 +137,15 @@ class LookupModule(object):
for
term
in
terms
:
for
term
in
terms
:
if
isinstance
(
term
,
dict
):
if
isinstance
(
term
,
dict
):
anydict
=
True
anydict
=
True
total_search
=
[]
if
anydict
:
if
anydict
:
for
term
in
terms
:
for
term
in
terms
:
if
isinstance
(
term
,
dict
):
if
isinstance
(
term
,
dict
):
files
=
term
.
get
(
'files'
,
[])
files
=
term
.
get
(
'files'
,
[])
paths
=
term
.
get
(
'paths'
,
[])
paths
=
term
.
get
(
'paths'
,
[])
skip
=
utils
.
boolean
(
term
.
get
(
'skip'
,
False
))
skip
=
utils
.
boolean
(
term
.
get
(
'skip'
,
False
))
filelist
=
files
filelist
=
files
if
isinstance
(
files
,
basestring
):
if
isinstance
(
files
,
basestring
):
files
=
files
.
replace
(
','
,
' '
)
files
=
files
.
replace
(
','
,
' '
)
...
@@ -143,9 +159,6 @@ class LookupModule(object):
...
@@ -143,9 +159,6 @@ class LookupModule(object):
paths
=
paths
.
replace
(
':'
,
' '
)
paths
=
paths
.
replace
(
':'
,
' '
)
paths
=
paths
.
replace
(
';'
,
' '
)
paths
=
paths
.
replace
(
';'
,
' '
)
pathlist
=
paths
.
split
(
' '
)
pathlist
=
paths
.
split
(
' '
)
total_search
=
[]
if
not
pathlist
:
if
not
pathlist
:
total_search
=
filelist
total_search
=
filelist
...
@@ -155,7 +168,7 @@ class LookupModule(object):
...
@@ -155,7 +168,7 @@ class LookupModule(object):
f
=
os
.
path
.
join
(
path
,
fn
)
f
=
os
.
path
.
join
(
path
,
fn
)
total_search
.
append
(
f
)
total_search
.
append
(
f
)
else
:
else
:
total_search
=
[
term
]
total_search
.
append
(
term
)
else
:
else
:
total_search
=
terms
total_search
=
terms
...
...
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