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
6975e5fd
Commit
6975e5fd
authored
Aug 20, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'svg_issue_8621_8664' into devel
parents
e6be6192
cecfede8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
lib/ansible/inventory/__init__.py
+9
-13
lib/ansible/runner/action_plugins/group_by.py
+1
-0
No files found.
lib/ansible/inventory/__init__.py
View file @
6975e5fd
...
...
@@ -146,7 +146,7 @@ class Inventory(object):
# get host vars from host_vars/ files and vars plugins
for
host
in
self
.
get_hosts
():
host
.
vars
=
utils
.
combine_vars
(
host
.
vars
,
self
.
get_variables
(
host
.
name
,
vault_password
=
self
.
_vault_password
))
host
.
vars
=
utils
.
combine_vars
(
host
.
vars
,
self
.
get_
host_
variables
(
host
.
name
,
vault_password
=
self
.
_vault_password
))
def
_match
(
self
,
str
,
pattern_str
):
...
...
@@ -324,6 +324,7 @@ class Inventory(object):
if
ungrouped
is
None
:
self
.
add_group
(
Group
(
'ungrouped'
))
ungrouped
=
self
.
get_group
(
'ungrouped'
)
self
.
get_group
(
'all'
)
.
add_child_group
(
ungrouped
)
ungrouped
.
add_host
(
new_host
)
return
new_host
...
...
@@ -429,20 +430,22 @@ class Inventory(object):
if
updated
is
not
None
:
vars
=
utils
.
combine_vars
(
vars
,
updated
)
# get group variables set by Inventory Parsers
vars
=
utils
.
combine_vars
(
vars
,
group
.
get_variables
())
# Read group_vars/ files
vars
=
utils
.
combine_vars
(
vars
,
self
.
get_group_vars
(
group
))
return
vars
def
get_variables
(
self
,
hostname
,
update_cached
=
False
,
vault_password
=
None
):
return
self
.
get_host
(
hostname
)
.
get_variables
()
def
get_host_variables
(
self
,
hostname
,
update_cached
=
False
,
vault_password
=
None
):
if
hostname
not
in
self
.
_vars_per_host
or
update_cached
:
self
.
_vars_per_host
[
hostname
]
=
self
.
_get_variables
(
hostname
,
vault_password
=
vault_password
)
self
.
_vars_per_host
[
hostname
]
=
self
.
_get_
host_
variables
(
hostname
,
vault_password
=
vault_password
)
return
self
.
_vars_per_host
[
hostname
]
def
_get_variables
(
self
,
hostname
,
vault_password
=
None
):
def
_get_
host_
variables
(
self
,
hostname
,
vault_password
=
None
):
host
=
self
.
get_host
(
hostname
)
if
host
is
None
:
...
...
@@ -450,10 +453,6 @@ class Inventory(object):
vars
=
{}
# special case for ungrouped hosts, make sure group_vars/all is loaded
if
len
(
host
.
groups
)
==
1
and
host
.
groups
[
0
]
.
name
==
'ungrouped'
:
vars
=
self
.
get_group_variables
(
'all'
,
vault_password
=
self
.
_vault_password
)
# plugin.run retrieves all vars (also from groups) for host
vars_results
=
[
plugin
.
run
(
host
,
vault_password
=
vault_password
)
for
plugin
in
self
.
_vars_plugins
if
hasattr
(
plugin
,
'run'
)]
for
updated
in
vars_results
:
...
...
@@ -466,9 +465,6 @@ class Inventory(object):
if
updated
is
not
None
:
vars
=
utils
.
combine_vars
(
vars
,
updated
)
# get host variables set by Inventory Parsers
vars
=
utils
.
combine_vars
(
vars
,
host
.
get_variables
())
# still need to check InventoryParser per host vars
# which actually means InventoryScript per host,
# which is not performant
...
...
lib/ansible/runner/action_plugins/group_by.py
View file @
6975e5fd
...
...
@@ -93,6 +93,7 @@ class ActionModule(object):
if
not
inv_group
:
inv_group
=
ansible
.
inventory
.
Group
(
name
=
group
)
inventory
.
add_group
(
inv_group
)
inventory
.
get_group
(
'all'
)
.
add_child_group
(
inv_group
)
inv_group
.
vars
=
inventory
.
get_group_variables
(
group
,
update_cached
=
False
,
vault_password
=
inventory
.
_vault_password
)
for
host
in
hosts
:
if
host
in
self
.
runner
.
inventory
.
_vars_per_host
:
...
...
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