diff --git a/tests/ansible/ansible.cfg b/tests/ansible/ansible.cfg index 8c9f66e0..437e67b7 100644 --- a/tests/ansible/ansible.cfg +++ b/tests/ansible/ansible.cfg @@ -1,5 +1,5 @@ [defaults] -inventory = hosts +inventory = hosts,lib/inventory gathering = explicit strategy_plugins = ../../ansible_mitogen/plugins/strategy action_plugins = lib/action diff --git a/tests/ansible/gcloud-ansible-playbook.py b/tests/ansible/lib/inventory/gcloud.py similarity index 72% rename from tests/ansible/gcloud-ansible-playbook.py rename to tests/ansible/lib/inventory/gcloud.py index 77dd6d99..b537ae74 100755 --- a/tests/ansible/gcloud-ansible-playbook.py +++ b/tests/ansible/lib/inventory/gcloud.py @@ -1,8 +1,13 @@ #!/usr/bin/env python +import json import os import sys +if not os.environ.get('MITOGEN_GCLOUD_GROUP'): + sys.stdout.write('{}') + sys.exit(0) + import googleapiclient.discovery @@ -24,11 +29,12 @@ def main(): #for config in interface['accessConfigs'] ) - print 'Addresses:', ips - os.execvp('ansible-playbook', [ - 'anisble-playbook', - '--inventory-file=' + ','.join(ips) + ',' - ] + sys.argv[1:]) + sys.stderr.write('Addresses: %s\n' % (ips,)) + sys.stdout.write(json.dumps({ + os.environ['MITOGEN_GCLOUD_GROUP']: { + 'hosts': ips + } + }, indent=4)) if __name__ == '__main__':