Print yaml inventory instructions

We need to also add servers to the inventory. Print a snippet to
add.

Change-Id: I630cc9f68b570b517eba81f23b603d84a019b20a
This commit is contained in:
Monty Taylor 2019-02-28 17:26:23 +00:00
parent ecbe164bae
commit e4c4d108f5
1 changed files with 15 additions and 0 deletions

View File

@ -40,6 +40,7 @@ def print_dns(cloud, server):
print_dns_opendev(server.name.rsplit('.', 2)[0], ip4, ip6)
else:
print_dns_legacy(server, ip4, ip6)
print_inventory_yaml(server, ip4, ip6)
def print_dns_opendev(name, ip4, ip6):
@ -99,6 +100,20 @@ def print_legacy_dns(server, ip4, ip6):
" --ttl 3600 openstack.org" % (
server.name, ip4))
def print_inventory_yaml(server, ip4, ip6):
print("\n")
print("Put the following into inventory/openstack.yaml")
print("\n")
print(" {name}:".format(name=server.name))
print(" ansible_host: {ip}".format(ip=ip6 or ip4))
print(" location:")
print(" cloud: {cloud}".format(cloud=server.location['cloud']))
print(" region_name: {region_name}".format(
region_name=server.location['region_name']))
print(" public_v4: {ip4}".format(ip4=ip4))
if ip6:
print(" public_v6: {ip6}".format(ip6=ip6))
def main():
parser = argparse.ArgumentParser()