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
888f3236
Commit
888f3236
authored
Jun 17, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11294 from msabramo/serf_plugin_use_env_vars
plugins/inventory/serf.py: Use SERF_RPC_* env vars
parents
ff998b60
ce42c66e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
4 deletions
+25
-4
plugins/inventory/serf.py
+25
-4
No files found.
plugins/inventory/serf.py
View file @
888f3236
...
@@ -20,10 +20,18 @@
...
@@ -20,10 +20,18 @@
# Dynamic inventory script which lets you use nodes discovered by Serf
# Dynamic inventory script which lets you use nodes discovered by Serf
# (https://serfdom.io/).
# (https://serfdom.io/).
#
#
# Requires host to be a member of a Serf cluster and the `serfclient` Python
# Requires the `serfclient` Python module from
# module from https://pypi.python.org/pypi/serfclient
# https://pypi.python.org/pypi/serfclient
#
# Environment variables
# ---------------------
# - `SERF_RPC_ADDR`
# - `SERF_RPC_AUTH`
#
# These variables are described at https://www.serfdom.io/docs/commands/members.html#_rpc_addr
import
argparse
import
argparse
import
os
import
sys
import
sys
# https://pypi.python.org/pypi/serfclient
# https://pypi.python.org/pypi/serfclient
...
@@ -37,9 +45,22 @@ except ImportError:
...
@@ -37,9 +45,22 @@ except ImportError:
_key
=
'serf'
_key
=
'serf'
def
_serf_client
():
kwargs
=
{}
rpc_addr
=
os
.
getenv
(
'SERF_RPC_ADDR'
)
if
rpc_addr
:
kwargs
[
'host'
],
kwargs
[
'port'
]
=
rpc_addr
.
split
(
':'
)
rpc_auth
=
os
.
getenv
(
'SERF_RPC_AUTH'
)
if
rpc_auth
:
kwargs
[
'rpc_auth'
]
=
rpc_auth
return
SerfClient
(
**
kwargs
)
def
get_serf_members_data
():
def
get_serf_members_data
():
serf
=
SerfClient
()
return
_serf_client
()
.
members
()
.
body
[
'Members'
]
return
serf
.
members
()
.
body
[
'Members'
]
def
get_nodes
(
data
):
def
get_nodes
(
data
):
...
...
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