Browse Source

infrastructure: add the openstack_network paramter

So that the network to connect to can be chosen globally or on a
per-host basis.
keep-around/868700de9a4dcfc037093deebaa22560c994cb2e
singuliere 2 years ago
parent
commit
868700de9a
No known key found for this signature in database GPG Key ID: 900857755EF189C2
  1. 3
      enough/common/openstack.py
  2. 2
      inventory/group_vars/all/infrastructure.yml
  3. 8
      molecule/infrastructure/template-host.yaml

3
enough/common/openstack.py

@ -54,6 +54,8 @@ class Stack(OpenStackBase):
if 'volumes' in d and int(d['volumes'][0]['size']) > 0:
parameters.append(f"--parameter=volume_size={d['volumes'][0]['size']}")
parameters.append(f"--parameter=volume_name={d['volumes'][0]['name']}")
if 'network' in d:
parameters.append(f'--parameter=network={d["network"]}')
self.o.stack(action, d['name'],
'--wait', '--timeout=600',
'--template', self.get_template(),
@ -120,6 +122,7 @@ class Heat(OpenStackBase):
'name': host,
'port': h.get('ansible_port', '22'),
'flavor': h.get('openstack_flavor', 's1-2'),
'network': h.get('openstack_network', 'Ext-Net'),
}
if 'openstack_volumes' in h:
definition['volumes'] = h['openstack_volumes']

2
inventory/group_vars/all/infrastructure.yml

@ -1,4 +1,6 @@
---
infrastructure_driver: openstack
openstack_network: Ext-Net
# openstack_network: internal
# infrastructure_driver: docker
firewall_enabled: "{% if infrastructure_driver == 'openstack' %}true{% else %}false{% endif %}"

8
molecule/infrastructure/template-host.yaml

@ -11,6 +11,10 @@ parameters:
type: string
default: "s1-2"
network:
type: string
default: Ext-Net
public_key:
type: string
@ -42,6 +46,8 @@ resources:
flavor: { get_param: flavor }
security_groups:
- { get_resource: security_group }
networks:
- network: { get_param: network }
user_data:
str_replace:
template: |
@ -103,5 +109,5 @@ outputs:
# }
#
data:
ipv4: { get_attr: [ instance, addresses, Ext-Net ] }
ipv4: { get_attr: [ instance, addresses, { get_param: network } ] }
port: { get_param: port }

Loading…
Cancel
Save