mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Simplify serf inventory plugin
using newly added `EnvironmentConfig` class in `serfclient`. See https://github.com/KushalP/serfclient-py/pull/17
This commit is contained in:
parent
ce42c66e27
commit
dc63bbf0b9
1 changed files with 3 additions and 12 deletions
|
@ -35,7 +35,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# https://pypi.python.org/pypi/serfclient
|
# https://pypi.python.org/pypi/serfclient
|
||||||
from serfclient.client import SerfClient
|
from serfclient import SerfClient, EnvironmentConfig
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
@ -46,17 +46,8 @@ _key = 'serf'
|
||||||
|
|
||||||
|
|
||||||
def _serf_client():
|
def _serf_client():
|
||||||
kwargs = {}
|
env = EnvironmentConfig()
|
||||||
|
return SerfClient(host=env.host, port=env.port, rpc_auth=env.auth_key)
|
||||||
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():
|
||||||
|
|
Loading…
Reference in a new issue