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
b6c52ce1
Commit
b6c52ce1
authored
9 years ago
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow role variables to be optionally kept in a private scope
parent
a155f65a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
2 deletions
+10
-2
examples/ansible.cfg
+5
-0
lib/ansible/constants.py
+1
-0
lib/ansible/vars/__init__.py
+4
-2
No files found.
examples/ansible.cfg
View file @
b6c52ce1
...
@@ -71,6 +71,11 @@ timeout = 10
...
@@ -71,6 +71,11 @@ timeout = 10
# this can also be set to 'merge'.
# this can also be set to 'merge'.
#hash_behaviour = replace
#hash_behaviour = replace
# by default, variables from roles will be visible in the global variable
# scope. To prevent this, the following option can be enabled, and only
# tasks and handlers within the role will see the variables there
#private_role_vars = yes
# list any Jinja2 extensions to enable here:
# list any Jinja2 extensions to enable here:
#jinja2_extensions = jinja2.ext.do,jinja2.ext.i18n
#jinja2_extensions = jinja2.ext.do,jinja2.ext.i18n
...
...
This diff is collapsed.
Click to expand it.
lib/ansible/constants.py
View file @
b6c52ce1
...
@@ -129,6 +129,7 @@ DEFAULT_MANAGED_STR = get_config(p, DEFAULTS, 'ansible_managed', None,
...
@@ -129,6 +129,7 @@ DEFAULT_MANAGED_STR = get_config(p, DEFAULTS, 'ansible_managed', None,
DEFAULT_SYSLOG_FACILITY
=
get_config
(
p
,
DEFAULTS
,
'syslog_facility'
,
'ANSIBLE_SYSLOG_FACILITY'
,
'LOG_USER'
)
DEFAULT_SYSLOG_FACILITY
=
get_config
(
p
,
DEFAULTS
,
'syslog_facility'
,
'ANSIBLE_SYSLOG_FACILITY'
,
'LOG_USER'
)
DEFAULT_KEEP_REMOTE_FILES
=
get_config
(
p
,
DEFAULTS
,
'keep_remote_files'
,
'ANSIBLE_KEEP_REMOTE_FILES'
,
False
,
boolean
=
True
)
DEFAULT_KEEP_REMOTE_FILES
=
get_config
(
p
,
DEFAULTS
,
'keep_remote_files'
,
'ANSIBLE_KEEP_REMOTE_FILES'
,
False
,
boolean
=
True
)
DEFAULT_HASH_BEHAVIOUR
=
get_config
(
p
,
DEFAULTS
,
'hash_behaviour'
,
'ANSIBLE_HASH_BEHAVIOUR'
,
'replace'
)
DEFAULT_HASH_BEHAVIOUR
=
get_config
(
p
,
DEFAULTS
,
'hash_behaviour'
,
'ANSIBLE_HASH_BEHAVIOUR'
,
'replace'
)
DEFAULT_PRIVATE_ROLE_VARS
=
get_config
(
p
,
DEFAULTS
,
'private_role_vars'
,
'ANSIBLE_PRIVATE_ROLE_VARS'
,
False
,
boolean
=
True
)
DEFAULT_JINJA2_EXTENSIONS
=
get_config
(
p
,
DEFAULTS
,
'jinja2_extensions'
,
'ANSIBLE_JINJA2_EXTENSIONS'
,
None
)
DEFAULT_JINJA2_EXTENSIONS
=
get_config
(
p
,
DEFAULTS
,
'jinja2_extensions'
,
'ANSIBLE_JINJA2_EXTENSIONS'
,
None
)
DEFAULT_EXECUTABLE
=
get_config
(
p
,
DEFAULTS
,
'executable'
,
'ANSIBLE_EXECUTABLE'
,
'/bin/sh'
)
DEFAULT_EXECUTABLE
=
get_config
(
p
,
DEFAULTS
,
'executable'
,
'ANSIBLE_EXECUTABLE'
,
'/bin/sh'
)
DEFAULT_GATHERING
=
get_config
(
p
,
DEFAULTS
,
'gathering'
,
'ANSIBLE_GATHERING'
,
'implicit'
)
.
lower
()
DEFAULT_GATHERING
=
get_config
(
p
,
DEFAULTS
,
'gathering'
,
'ANSIBLE_GATHERING'
,
'implicit'
)
.
lower
()
...
...
This diff is collapsed.
Click to expand it.
lib/ansible/vars/__init__.py
View file @
b6c52ce1
...
@@ -197,8 +197,10 @@ class VariableManager:
...
@@ -197,8 +197,10 @@ class VariableManager:
# whether or not vars files errors should be fatal at this
# whether or not vars files errors should be fatal at this
# stage, or just base it on whether a host was specified?
# stage, or just base it on whether a host was specified?
pass
pass
for
role
in
play
.
get_roles
():
all_vars
=
self
.
_combine_vars
(
all_vars
,
role
.
get_vars
())
if
not
C
.
DEFAULT_PRIVATE_ROLE_VARS
:
for
role
in
play
.
get_roles
():
all_vars
=
self
.
_combine_vars
(
all_vars
,
role
.
get_vars
())
if
host
:
if
host
:
all_vars
=
self
.
_combine_vars
(
all_vars
,
self
.
_vars_cache
.
get
(
host
.
get_name
(),
dict
()))
all_vars
=
self
.
_combine_vars
(
all_vars
,
self
.
_vars_cache
.
get
(
host
.
get_name
(),
dict
()))
...
...
This diff is collapsed.
Click to expand it.
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