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
b6c3670f
Commit
b6c3670f
authored
Nov 17, 2014
by
Toshio Kuratomi
Committed by
James Cammarata
Dec 09, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark some inventory methods that I'm thinking should go away (and their
replacements)
parent
b4dfcc2d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
8 deletions
+38
-8
v2/ansible/inventory/__init__.py
+34
-8
v2/ansible/vars/__init__.py
+4
-0
No files found.
v2/ansible/inventory/__init__.py
View file @
b6c3670f
...
...
@@ -21,9 +21,6 @@
from
__future__
import
(
absolute_import
,
division
,
print_function
)
__metaclass__
=
type
from
.
group
import
Group
from
.
host
import
Host
### List of things to change in Inventory
### Replace some lists with sets/frozensets.
...
...
@@ -120,18 +117,36 @@ from . host import Host
### group = Group(name)
### inven.add_or_merge(group)
from
..
plugins
.
inventory
.
aggregate
import
InventoryAggregateParser
from
.
group
import
Group
from
.
host
import
Host
class
Inventory
:
'''
Collect variables for hosts and groups from inventory
Create hosts and groups from inventory
Retrieve the hosts and groups that ansible knows about from this
class.
Retrieve raw variables (non-expanded) from the Group and Host classes
returned from here.
'''
def
__init__
(
self
,
host
_list
=
C
.
DEFAULT_HOST_LIST
,
vault_password
=
None
):
def
__init__
(
self
,
inventory
_list
=
C
.
DEFAULT_HOST_LIST
,
vault_password
=
None
):
'''
:kwarg host_list: A filename for an inventory file or script or a list
of hosts
:kwarg inventory_list: A list of inventory sources. This may be file
names which will be parsed as ini-like files, executable scripts
which return inventory data as json, directories of both of the above,
or hostnames. Files and directories are
:kwarg vault_password: Password to use if any of the inventory sources
are in an ansible vault
'''
pass
self
.
vault_password
=
vault_password
self
.
parser
=
InventoryAggregateParser
(
inventory_list
)
self
.
parser
.
parse
()
self
.
hosts
=
self
.
parser
.
hosts
self
.
groups
=
self
.
parser
.
groups
def
get_hosts
(
self
,
pattern
=
"all"
):
'''
...
...
@@ -158,6 +173,8 @@ class Inventory:
pass
def
groups_for_host
(
self
,
host
):
### Remove in favour of
### inventory.hosts[host].groups.keys()
'''
Return the groupnames to which a host belongs
...
...
@@ -175,6 +192,7 @@ class Inventory:
pass
def
get_groups
(
self
):
### Remove in favour of inventory.groups.values()
'''
Retrieve the Group objects known to the Inventory
...
...
@@ -183,6 +201,7 @@ class Inventory:
pass
def
get_host
(
self
,
hostname
):
### Remove in favour of inventory.hosts.values()
'''
Retrieve the Host object for a hostname
...
...
@@ -192,6 +211,7 @@ class Inventory:
pass
def
get_group
(
self
,
groupname
):
### Revmoe in favour of inventory.groups.groupname
'''
Retrieve the Group object for a groupname
...
...
@@ -201,6 +221,7 @@ class Inventory:
pass
def
get_group_variables
(
self
,
groupname
,
update_cached
=
False
,
vault_password
=
None
):
### Remove in favour of inventory.groups[groupname].get_vars()
'''
Retrieve the variables set on a group
...
...
@@ -214,6 +235,7 @@ class Inventory:
pass
def
get_variables
(
self
,
hostname
,
update_cached
=
False
,
vault_password
=
None
):
### Remove in favour of inventory.hosts[hostname].get_vars()
'''
Retrieve the variables set on a host
...
...
@@ -228,6 +250,7 @@ class Inventory:
pass
def
get_host_variables
(
self
,
hostname
,
update_cached
=
False
,
vault_password
=
None
):
### Remove in favour of inventory.hosts[hostname].get_vars()
'''
Retrieve the variables set on a host
...
...
@@ -241,6 +264,7 @@ class Inventory:
pass
def
add_group
(
self
,
group
):
### Possibly remove in favour of inventory.groups[groupname] = group
'''
Add a new group to the inventory
...
...
@@ -249,6 +273,7 @@ class Inventory:
pass
def
list_hosts
(
self
,
pattern
=
"all"
):
### Remove in favour of: inventory.hosts.keys()? Maybe not as pattern is here
'''
Retrieve a list of hostnames for a pattern
...
...
@@ -263,6 +288,7 @@ class Inventory:
pass
def
list_groups
(
self
):
### Remove in favour of: inventory.groups.keys()
'''
Retrieve list of groupnames
:returns: list of groupnames
...
...
v2/ansible/vars/__init__.py
View file @
b6c3670f
...
...
@@ -141,6 +141,10 @@ class VariableManager:
return
vars
### Note:
### Planning to move this into the inventory.
### So when you query the host for the variables in its context, it
### loads the vars_files and then returns those to the VariableManager.
def
_get_inventory_basename
(
self
,
path
):
'''
Returns the bsaename minus the extension of the given path, so the
...
...
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