|
|
@ -1,4 +1,5 @@
|
|
|
|
# (c) 2013, Jan-Piet Mens <jpmens(at)gmail.com>
|
|
|
|
# (c) 2013, Jan-Piet Mens <jpmens(at)gmail.com>
|
|
|
|
|
|
|
|
# (m) 2016, Mihai Moldovanu <mihaim@tfm.ro>
|
|
|
|
# (m) 2017, Juan Manuel Parrilla <jparrill@redhat.com>
|
|
|
|
# (m) 2017, Juan Manuel Parrilla <jparrill@redhat.com>
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# This file is part of Ansible
|
|
|
|
# This file is part of Ansible
|
|
|
@ -78,6 +79,29 @@ from ansible.plugins.lookup import LookupBase
|
|
|
|
from ansible.module_utils.urls import open_url
|
|
|
|
from ansible.module_utils.urls import open_url
|
|
|
|
|
|
|
|
|
|
|
|
# this can be made configurable, not should not use ansible.cfg
|
|
|
|
# this can be made configurable, not should not use ansible.cfg
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Made module configurable from playbooks:
|
|
|
|
|
|
|
|
# If etcd v2 running on host 192.168.1.21 on port 2379
|
|
|
|
|
|
|
|
# we can use the following in a playbook to retrieve /tfm/network/config key
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# - debug: msg={{lookup('etcd','/tfm/network/config', url='http://192.168.1.21:2379' , version='v2')}}
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Example Output:
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# TASK [debug] *******************************************************************
|
|
|
|
|
|
|
|
# ok: [localhost] => {
|
|
|
|
|
|
|
|
# "msg": {
|
|
|
|
|
|
|
|
# "Backend": {
|
|
|
|
|
|
|
|
# "Type": "vxlan"
|
|
|
|
|
|
|
|
# },
|
|
|
|
|
|
|
|
# "Network": "172.30.0.0/16",
|
|
|
|
|
|
|
|
# "SubnetLen": 24
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
ANSIBLE_ETCD_URL = 'http://127.0.0.1:4001'
|
|
|
|
ANSIBLE_ETCD_URL = 'http://127.0.0.1:4001'
|
|
|
|
if os.getenv('ANSIBLE_ETCD_URL') is not None:
|
|
|
|
if os.getenv('ANSIBLE_ETCD_URL') is not None:
|
|
|
|
ANSIBLE_ETCD_URL = os.environ['ANSIBLE_ETCD_URL']
|
|
|
|
ANSIBLE_ETCD_URL = os.environ['ANSIBLE_ETCD_URL']
|
|
|
@ -148,8 +172,10 @@ class LookupModule(LookupBase):
|
|
|
|
def run(self, terms, variables, **kwargs):
|
|
|
|
def run(self, terms, variables, **kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
validate_certs = kwargs.get('validate_certs', True)
|
|
|
|
validate_certs = kwargs.get('validate_certs', True)
|
|
|
|
|
|
|
|
url = kwargs.get('url', '')
|
|
|
|
|
|
|
|
version = kwargs.get('version', '')
|
|
|
|
|
|
|
|
|
|
|
|
etcd = Etcd(validate_certs=validate_certs)
|
|
|
|
etcd = Etcd(url=url, version=version, validate_certs=validate_certs)
|
|
|
|
|
|
|
|
|
|
|
|
ret = []
|
|
|
|
ret = []
|
|
|
|
for term in terms:
|
|
|
|
for term in terms:
|
|
|
|