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
637d3070
Commit
637d3070
authored
Aug 29, 2013
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow default variables to be overridden by inventory variables
parent
f6668386
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
11 deletions
+13
-11
lib/ansible/playbook/__init__.py
+2
-2
lib/ansible/playbook/play.py
+3
-6
lib/ansible/playbook/task.py
+4
-3
lib/ansible/runner/__init__.py
+4
-0
No files found.
lib/ansible/playbook/__init__.py
View file @
637d3070
...
...
@@ -307,7 +307,7 @@ class PlayBook(object):
remote_pass
=
self
.
remote_pass
,
module_path
=
self
.
module_path
,
timeout
=
self
.
timeout
,
remote_user
=
task
.
play
.
remote_user
,
remote_port
=
task
.
play
.
remote_port
,
module_vars
=
task
.
module_vars
,
private_key_file
=
self
.
private_key_file
,
default_vars
=
task
.
default_vars
,
private_key_file
=
self
.
private_key_file
,
setup_cache
=
self
.
SETUP_CACHE
,
basedir
=
task
.
play
.
basedir
,
conditional
=
task
.
only_if
,
callbacks
=
self
.
runner_callbacks
,
sudo
=
task
.
sudo
,
sudo_user
=
task
.
sudo_user
,
...
...
@@ -447,7 +447,7 @@ class PlayBook(object):
remote_pass
=
self
.
remote_pass
,
remote_port
=
play
.
remote_port
,
private_key_file
=
self
.
private_key_file
,
setup_cache
=
self
.
SETUP_CACHE
,
callbacks
=
self
.
runner_callbacks
,
sudo
=
play
.
sudo
,
sudo_user
=
play
.
sudo_user
,
transport
=
play
.
transport
,
sudo_pass
=
self
.
sudo_pass
,
is_playbook
=
True
,
module_vars
=
play
.
vars
,
check
=
self
.
check
,
diff
=
self
.
diff
default_vars
=
play
.
default_vars
,
check
=
self
.
check
,
diff
=
self
.
diff
)
.
run
()
self
.
stats
.
compute
(
setup_results
,
setup
=
True
)
...
...
lib/ansible/playbook/play.py
View file @
637d3070
...
...
@@ -28,7 +28,7 @@ import os
class
Play
(
object
):
__slots__
=
[
'hosts'
,
'name'
,
'vars'
,
'vars_prompt'
,
'vars_files'
,
'hosts'
,
'name'
,
'vars'
,
'
default_vars'
,
'
vars_prompt'
,
'vars_files'
,
'handlers'
,
'remote_user'
,
'remote_port'
,
'sudo'
,
'sudo_user'
,
'transport'
,
'playbook'
,
'tags'
,
'gather_facts'
,
'serial'
,
'_ds'
,
'_handlers'
,
'_tasks'
,
...
...
@@ -70,7 +70,7 @@ class Play(object):
self
.
tags
=
[]
ds
=
self
.
_load_roles
(
self
.
roles
,
ds
)
self
.
vars_files
=
ds
.
get
(
'vars_files'
,
[])
self
.
vars_files
=
ds
.
get
(
'vars_files'
,
[])
self
.
_update_vars_files_for_host
(
None
)
...
...
@@ -295,10 +295,7 @@ class Play(object):
ds
[
'handlers'
]
=
new_handlers
ds
[
'vars_files'
]
=
new_vars_files
defaults
=
self
.
_load_role_defaults
(
defaults_files
)
# merge default vars with self.vars, with vars taking precedence.
if
defaults
:
self
.
vars
=
utils
.
combine_vars
(
defaults
,
self
.
vars
)
self
.
default_vars
=
self
.
_load_role_defaults
(
defaults_files
)
return
ds
...
...
lib/ansible/playbook/task.py
View file @
637d3070
...
...
@@ -24,7 +24,7 @@ class Task(object):
__slots__
=
[
'name'
,
'meta'
,
'action'
,
'only_if'
,
'when'
,
'async_seconds'
,
'async_poll_interval'
,
'notify'
,
'module_name'
,
'module_args'
,
'module_vars'
,
'notify'
,
'module_name'
,
'module_args'
,
'module_vars'
,
'default_vars'
,
'play'
,
'notified_by'
,
'tags'
,
'register'
,
'delegate_to'
,
'first_available_file'
,
'ignore_errors'
,
'local_action'
,
'transport'
,
'sudo'
,
'sudo_user'
,
'sudo_pass'
,
...
...
@@ -100,8 +100,9 @@ class Task(object):
elif
not
x
in
Task
.
VALID_KEYS
:
raise
errors
.
AnsibleError
(
"
%
s is not a legal parameter in an Ansible task or handler"
%
x
)
self
.
module_vars
=
module_vars
self
.
play
=
play
self
.
module_vars
=
module_vars
self
.
play
=
play
self
.
default_vars
=
play
.
default_vars
# load various attributes
self
.
name
=
ds
.
get
(
'name'
,
None
)
...
...
lib/ansible/runner/__init__.py
View file @
637d3070
...
...
@@ -131,6 +131,7 @@ class Runner(object):
sudo
=
False
,
# whether to run sudo or not
sudo_user
=
C
.
DEFAULT_SUDO_USER
,
# ex: 'root'
module_vars
=
None
,
# a playbooks internals thing
default_vars
=
None
,
# ditto
is_playbook
=
False
,
# running from playbook or not?
inventory
=
None
,
# reference to Inventory object
subset
=
None
,
# subset pattern
...
...
@@ -159,6 +160,7 @@ class Runner(object):
self
.
inventory
=
utils
.
default
(
inventory
,
lambda
:
ansible
.
inventory
.
Inventory
(
host_list
))
self
.
module_vars
=
utils
.
default
(
module_vars
,
lambda
:
{})
self
.
default_vars
=
utils
.
default
(
default_vars
,
lambda
:
{})
self
.
always_run
=
None
self
.
connector
=
connection
.
Connection
(
self
)
self
.
conditional
=
conditional
...
...
@@ -405,6 +407,7 @@ class Runner(object):
port
=
self
.
remote_port
inject
=
{}
inject
=
utils
.
combine_vars
(
inject
,
self
.
default_vars
)
inject
=
utils
.
combine_vars
(
inject
,
host_variables
)
inject
=
utils
.
combine_vars
(
inject
,
self
.
module_vars
)
inject
=
utils
.
combine_vars
(
inject
,
self
.
setup_cache
[
host
])
...
...
@@ -413,6 +416,7 @@ class Runner(object):
inject
[
'group_names'
]
=
host_variables
.
get
(
'group_names'
,
[])
inject
[
'groups'
]
=
self
.
inventory
.
groups_list
()
inject
[
'vars'
]
=
self
.
module_vars
inject
[
'defaults'
]
=
self
.
default_vars
inject
[
'environment'
]
=
self
.
environment
if
self
.
inventory
.
basedir
()
is
not
None
:
...
...
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