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
50f54f6b
Commit
50f54f6b
authored
Sep 02, 2013
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Making variable names more descriptive for the default variables work
parent
02b7b79d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
lib/ansible/playbook/play.py
+13
-13
No files found.
lib/ansible/playbook/play.py
View file @
50f54f6b
...
@@ -170,9 +170,9 @@ class Play(object):
...
@@ -170,9 +170,9 @@ class Play(object):
if
vars_data
:
if
vars_data
:
role_vars
=
utils
.
combine_vars
(
vars_data
,
role_vars
)
role_vars
=
utils
.
combine_vars
(
vars_data
,
role_vars
)
defaults
=
self
.
_resolve_main
(
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
role_path
,
'defaults'
)))
defaults
=
self
.
_resolve_main
(
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
role_path
,
'defaults'
)))
defs_data
=
{}
def
ault
s_data
=
{}
if
os
.
path
.
isfile
(
defaults
):
if
os
.
path
.
isfile
(
defaults
):
defs_data
=
utils
.
parse_yaml_from_file
(
defaults
)
def
ault
s_data
=
utils
.
parse_yaml_from_file
(
defaults
)
# the meta directory contains the yaml that should
# the meta directory contains the yaml that should
# hold the list of dependencies (if any)
# hold the list of dependencies (if any)
meta
=
self
.
_resolve_main
(
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
role_path
,
'meta'
)))
meta
=
self
.
_resolve_main
(
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
role_path
,
'meta'
)))
...
@@ -201,17 +201,17 @@ class Play(object):
...
@@ -201,17 +201,17 @@ class Play(object):
if
vars_data
:
if
vars_data
:
dep_vars
=
utils
.
combine_vars
(
vars_data
,
dep_vars
)
dep_vars
=
utils
.
combine_vars
(
vars_data
,
dep_vars
)
defaults
=
self
.
_resolve_main
(
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
dep_path
,
'defaults'
)))
defaults
=
self
.
_resolve_main
(
utils
.
path_dwim
(
self
.
basedir
,
os
.
path
.
join
(
dep_path
,
'defaults'
)))
dep_defs_data
=
{}
dep_def
ault
s_data
=
{}
if
os
.
path
.
isfile
(
defaults
):
if
os
.
path
.
isfile
(
defaults
):
dep_defs_data
=
utils
.
parse_yaml_from_file
(
defaults
)
dep_def
ault
s_data
=
utils
.
parse_yaml_from_file
(
defaults
)
if
'role'
in
dep_vars
:
if
'role'
in
dep_vars
:
del
dep_vars
[
'role'
]
del
dep_vars
[
'role'
]
self
.
_build_role_dependencies
([
dep
],
dep_stack
,
passed_vars
=
dep_vars
,
level
=
level
+
1
)
self
.
_build_role_dependencies
([
dep
],
dep_stack
,
passed_vars
=
dep_vars
,
level
=
level
+
1
)
dep_stack
.
append
([
dep
,
dep_path
,
dep_vars
,
dep_defs_data
])
dep_stack
.
append
([
dep
,
dep_path
,
dep_vars
,
dep_def
ault
s_data
])
# only add the current role when we're at the top level,
# only add the current role when we're at the top level,
# otherwise we'll end up in a recursive loop
# otherwise we'll end up in a recursive loop
if
level
==
0
:
if
level
==
0
:
dep_stack
.
append
([
role
,
role_path
,
role_vars
,
defs_data
])
dep_stack
.
append
([
role
,
role_path
,
role_vars
,
def
ault
s_data
])
return
dep_stack
return
dep_stack
def
_load_role_defaults
(
self
,
defaults_files
):
def
_load_role_defaults
(
self
,
defaults_files
):
...
@@ -257,7 +257,7 @@ class Play(object):
...
@@ -257,7 +257,7 @@ class Play(object):
roles
=
self
.
_build_role_dependencies
(
roles
,
[],
self
.
vars
)
roles
=
self
.
_build_role_dependencies
(
roles
,
[],
self
.
vars
)
for
(
role
,
role_path
,
role_vars
,
def_vars
)
in
roles
:
for
(
role
,
role_path
,
role_vars
,
def
ault
_vars
)
in
roles
:
# special vars must be extracted from the dict to the included tasks
# special vars must be extracted from the dict to the included tasks
special_keys
=
[
"sudo"
,
"sudo_user"
,
"when"
,
"with_items"
]
special_keys
=
[
"sudo"
,
"sudo_user"
,
"when"
,
"with_items"
]
special_vars
=
{}
special_vars
=
{}
...
@@ -280,7 +280,7 @@ class Play(object):
...
@@ -280,7 +280,7 @@ class Play(object):
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
):
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"
%
(
role_path
,
task
,
handler
,
vars_file
,
library
))
raise
errors
.
AnsibleError
(
"found role at
%
s, but cannot find
%
s or
%
s or
%
s or
%
s"
%
(
role_path
,
task
,
handler
,
vars_file
,
library
))
if
os
.
path
.
isfile
(
task
):
if
os
.
path
.
isfile
(
task
):
nt
=
dict
(
include
=
pipes
.
quote
(
task
),
vars
=
role_vars
,
def
_vars
=
def
_vars
)
nt
=
dict
(
include
=
pipes
.
quote
(
task
),
vars
=
role_vars
,
def
ault_vars
=
default
_vars
)
for
k
in
special_keys
:
for
k
in
special_keys
:
if
k
in
special_vars
:
if
k
in
special_vars
:
nt
[
k
]
=
special_vars
[
k
]
nt
[
k
]
=
special_vars
[
k
]
...
@@ -350,7 +350,7 @@ class Play(object):
...
@@ -350,7 +350,7 @@ class Play(object):
# *************************************************
# *************************************************
def
_load_tasks
(
self
,
tasks
,
vars
=
{},
def_vars
=
{},
sudo_vars
=
{},
additional_conditions
=
[],
original_file
=
None
):
def
_load_tasks
(
self
,
tasks
,
vars
=
{},
def
ault
_vars
=
{},
sudo_vars
=
{},
additional_conditions
=
[],
original_file
=
None
):
''' handle task and handler include statements '''
''' handle task and handler include statements '''
results
=
[]
results
=
[]
...
@@ -396,12 +396,12 @@ class Play(object):
...
@@ -396,12 +396,12 @@ class Play(object):
included_additional_conditions
.
insert
(
0
,
utils
.
compile_when_to_only_if
(
"
%
s
%
s"
%
(
k
[
5
:],
x
[
k
])))
included_additional_conditions
.
insert
(
0
,
utils
.
compile_when_to_only_if
(
"
%
s
%
s"
%
(
k
[
5
:],
x
[
k
])))
elif
k
==
'when'
:
elif
k
==
'when'
:
included_additional_conditions
.
insert
(
0
,
utils
.
compile_when_to_only_if
(
"jinja2_compare
%
s"
%
x
[
k
]))
included_additional_conditions
.
insert
(
0
,
utils
.
compile_when_to_only_if
(
"jinja2_compare
%
s"
%
x
[
k
]))
elif
k
in
(
"include"
,
"vars"
,
"def_vars"
,
"only_if"
,
"sudo"
,
"sudo_user"
):
elif
k
in
(
"include"
,
"vars"
,
"def
ault
_vars"
,
"only_if"
,
"sudo"
,
"sudo_user"
):
pass
pass
else
:
else
:
raise
errors
.
AnsibleError
(
"parse error: task includes cannot be used with other directives:
%
s"
%
k
)
raise
errors
.
AnsibleError
(
"parse error: task includes cannot be used with other directives:
%
s"
%
k
)
def
_vars
=
utils
.
combine_vars
(
self
.
default_vars
,
x
.
get
(
'def
_vars'
,
{}))
def
ault_vars
=
utils
.
combine_vars
(
self
.
default_vars
,
x
.
get
(
'default
_vars'
,
{}))
if
'vars'
in
x
:
if
'vars'
in
x
:
task_vars
=
utils
.
combine_vars
(
task_vars
,
x
[
'vars'
])
task_vars
=
utils
.
combine_vars
(
task_vars
,
x
[
'vars'
])
if
'only_if'
in
x
:
if
'only_if'
in
x
:
...
@@ -419,9 +419,9 @@ class Play(object):
...
@@ -419,9 +419,9 @@ class Play(object):
include_file
=
template
(
dirname
,
tokens
[
0
],
mv
)
include_file
=
template
(
dirname
,
tokens
[
0
],
mv
)
include_filename
=
utils
.
path_dwim
(
dirname
,
include_file
)
include_filename
=
utils
.
path_dwim
(
dirname
,
include_file
)
data
=
utils
.
parse_yaml_from_file
(
include_filename
)
data
=
utils
.
parse_yaml_from_file
(
include_filename
)
results
+=
self
.
_load_tasks
(
data
,
mv
,
def_vars
,
included_sudo_vars
,
included_additional_conditions
,
original_file
=
include_filename
)
results
+=
self
.
_load_tasks
(
data
,
mv
,
def
ault
_vars
,
included_sudo_vars
,
included_additional_conditions
,
original_file
=
include_filename
)
elif
type
(
x
)
==
dict
:
elif
type
(
x
)
==
dict
:
results
.
append
(
Task
(
self
,
x
,
module_vars
=
task_vars
,
default_vars
=
def_vars
,
additional_conditions
=
additional_conditions
))
results
.
append
(
Task
(
self
,
x
,
module_vars
=
task_vars
,
default_vars
=
def
ault
_vars
,
additional_conditions
=
additional_conditions
))
else
:
else
:
raise
Exception
(
"unexpected task type"
)
raise
Exception
(
"unexpected task type"
)
...
...
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