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
6ba72854
Commit
6ba72854
authored
Jun 30, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3296 from ninetythirty/devel
Added flexible filename handling for main files
parents
fafb3c10
7b1e87b6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
lib/ansible/playbook/play.py
+24
-3
No files found.
lib/ansible/playbook/play.py
View file @
6ba72854
...
...
@@ -170,9 +170,12 @@ class Play(object):
path
=
path2
elif
not
os
.
path
.
isdir
(
path
):
raise
errors
.
AnsibleError
(
"cannot find role in
%
s"
%
(
path
))
task
=
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
path
,
'tasks'
,
'main.yml'
))
handler
=
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
path
,
'handlers'
,
'main.yml'
))
vars_file
=
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
path
,
'vars'
,
'main.yml'
))
task_basepath
=
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
path
,
'tasks'
))
handler_basepath
=
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
path
,
'handlers'
))
vars_basepath
=
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
path
,
'vars'
))
task
=
self
.
_resolve_main
(
task_basepath
)
handler
=
self
.
_resolve_main
(
handler_basepath
)
vars_file
=
self
.
_resolve_main
(
vars_basepath
)
library
=
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
path
,
'library'
))
if
not
os
.
path
.
isfile
(
task
)
and
not
os
.
path
.
isfile
(
handler
)
and
not
os
.
path
.
isfile
(
vars_file
)
and
not
os
.
path
.
isdir
(
library
):
raise
errors
.
AnsibleError
(
"found role at
%
s, but cannot find
%
s or
%
s or
%
s or
%
s"
%
(
path
,
task
,
handler
,
vars_file
,
library
))
...
...
@@ -226,6 +229,24 @@ class Play(object):
# *************************************************
def
_resolve_main
(
self
,
basepath
):
''' flexibly handle variations in main filenames '''
# these filenames are acceptable:
mains
=
(
os
.
path
.
join
(
basepath
,
'main'
),
os
.
path
.
join
(
basepath
,
'main.yml'
),
os
.
path
.
join
(
basepath
,
'main.yaml'
),
)
if
sum
([
os
.
path
.
isfile
(
x
)
for
x
in
mains
])
>
1
:
raise
errors
.
AnsibleError
(
"found multiple main files at
%
s, only one allowed"
%
(
basepath
))
else
:
for
m
in
mains
:
if
os
.
path
.
isfile
(
m
):
return
m
# exactly one main file
return
mains
[
0
]
# zero mains (we still need to return something)
# *************************************************
def
_load_tasks
(
self
,
tasks
,
vars
=
{},
additional_conditions
=
[],
original_file
=
None
):
''' handle task and handler include statements '''
...
...
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