tests: refactor gcloud.py to be dynamic inventory.

This commit is contained in:
David Wilson 2018-05-15 22:10:36 +01:00
parent a3995f8e5f
commit dbcee4041a
2 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,5 @@
[defaults] [defaults]
inventory = hosts inventory = hosts,lib/inventory
gathering = explicit gathering = explicit
strategy_plugins = ../../ansible_mitogen/plugins/strategy strategy_plugins = ../../ansible_mitogen/plugins/strategy
action_plugins = lib/action action_plugins = lib/action

View File

@ -1,8 +1,13 @@
#!/usr/bin/env python #!/usr/bin/env python
import json
import os import os
import sys import sys
if not os.environ.get('MITOGEN_GCLOUD_GROUP'):
sys.stdout.write('{}')
sys.exit(0)
import googleapiclient.discovery import googleapiclient.discovery
@ -24,11 +29,12 @@ def main():
#for config in interface['accessConfigs'] #for config in interface['accessConfigs']
) )
print 'Addresses:', ips sys.stderr.write('Addresses: %s\n' % (ips,))
os.execvp('ansible-playbook', [ sys.stdout.write(json.dumps({
'anisble-playbook', os.environ['MITOGEN_GCLOUD_GROUP']: {
'--inventory-file=' + ','.join(ips) + ',' 'hosts': ips
] + sys.argv[1:]) }
}, indent=4))
if __name__ == '__main__': if __name__ == '__main__':