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
dead52cf
Commit
dead52cf
authored
Jul 03, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11478 from msabramo/serf_inventory_groups
Add groups to serf inventory plugin
parents
bdccfa71
48e15ea8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletions
+15
-1
plugins/inventory/serf.py
+15
-1
No files found.
plugins/inventory/serf.py
View file @
dead52cf
...
...
@@ -31,6 +31,7 @@
# These variables are described at https://www.serfdom.io/docs/commands/members.html#_rpc_addr
import
argparse
import
collections
import
os
import
sys
...
...
@@ -58,6 +59,16 @@ def get_nodes(data):
return
[
node
[
'Name'
]
for
node
in
data
]
def
get_groups
(
data
):
groups
=
collections
.
defaultdict
(
list
)
for
node
in
data
:
for
key
,
value
in
node
[
'Tags'
]
.
items
():
groups
[
value
]
.
append
(
node
[
'Name'
])
return
groups
def
get_meta
(
data
):
meta
=
{
'hostvars'
:
{}}
for
node
in
data
:
...
...
@@ -68,8 +79,11 @@ def get_meta(data):
def
print_list
():
data
=
get_serf_members_data
()
nodes
=
get_nodes
(
data
)
groups
=
get_groups
(
data
)
meta
=
get_meta
(
data
)
print
(
json
.
dumps
({
_key
:
nodes
,
'_meta'
:
meta
}))
inventory_data
=
{
_key
:
nodes
,
'_meta'
:
meta
}
inventory_data
.
update
(
groups
)
print
(
json
.
dumps
(
inventory_data
))
def
print_host
(
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