Skip to content
Snippets Groups Projects
Commit 56ae3bfe authored by Trond Hasle Amundsen's avatar Trond Hasle Amundsen Committed by Kubernetes Prow Robot
Browse files

Add support for IPv6 for Openstack in terraform.py via metadata (#4716)

* Add support for IPv6 for Openstack in terraform.py via metadata

* document terraform.py metadata variables for openstack
parent 4d5c4a13
No related branches found
No related tags found
No related merge requests found
......@@ -325,6 +325,30 @@ $ ssh-add ~/.ssh/id_rsa
If you have deployed and destroyed a previous iteration of your cluster, you will need to clear out any stale keys from your SSH "known hosts" file ( `~/.ssh/known_hosts`).
#### Metadata variables
The [python script](../terraform.py) that reads the
generated`.tfstate` file to generate a dynamic inventory recognizes
some variables within a "metadata" block, defined in a "resource"
block (example):
```
resource "openstack_compute_instance_v2" "example" {
...
metadata {
ssh_user = "ubuntu"
prefer_ipv6 = true
python_bin = "/usr/bin/python3"
}
...
}
```
As the example shows, these let you define the SSH username for
Ansible, a Python binary which is needed by Ansible if
`/usr/bin/python` doesn't exist, and whether the IPv6 address of the
instance should be preferred over IPv4.
#### Bastion host
Bastion access will be determined by:
......
......@@ -239,6 +239,12 @@ def openstack_host(resource, module_name):
attrs['private_ipv4'] = raw_attrs['network.0.fixed_ip_v4']
try:
if 'metadata.prefer_ipv6' in raw_attrs and raw_attrs['metadata.prefer_ipv6'] == "1":
attrs.update({
'ansible_ssh_host': re.sub("[\[\]]", "", raw_attrs['access_ip_v6']),
'publicly_routable': True,
})
else:
attrs.update({
'ansible_ssh_host': raw_attrs['access_ip_v4'],
'publicly_routable': True,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment