Browse Source

enough: move the network_interface_* variables into ansible

keep-around/ae543bd8a0c700cf180555f24274463046aa78ac
Loïc Dachary 6 months ago
committed by some
parent
commit
49715620f5
Signed by: dachary GPG Key ID: 992D23B392F9E4F2
  1. 15
      enough/common/openstack.py
  2. 6
      inventory/group_vars/all/network.yml
  3. 2
      tests/enough/common/conftest.py

15
enough/common/openstack.py

@ -200,24 +200,15 @@ class Heat(OpenStackBase):
@staticmethod
def hostvars_to_stack(host, hv):
if hv.get('network_internal_only'):
network_interface_unconfigured = hv['network_primary_interface']
network_interface_routed = hv['network_secondary_interface']
network_interface_not_routed = 'noname'
else:
network_interface_unconfigured = 'noname'
network_interface_routed = hv['network_primary_interface']
network_interface_not_routed = hv['network_secondary_interface']
definition = {
'name': host,
'port': hv.get('ansible_port', '22'),
'flavor': hv['openstack_flavor'],
'image': hv['openstack_image'],
'network': hv.get('openstack_network'),
'network_internal_only': hv.get('network_internal_only'),
'network_interface_unconfigured': network_interface_unconfigured,
'network_interface_routed': network_interface_routed,
'network_interface_not_routed': network_interface_not_routed,
'network_interface_unconfigured': hv.get('network_interface_unconfigured'),
'network_interface_routed': hv.get('network_interface_routed'),
'network_interface_not_routed': hv.get('network_interface_not_routed'),
'internal_network': OpenStackBase.INTERNAL_NETWORK,
'internal_network_cidr': hv.get('openstack_internal_network_cidr',
OpenStackBase.INTERNAL_NETWORK_CIDR),

6
inventory/group_vars/all/network.yml

@ -18,6 +18,12 @@ network_internal_only: false
network_primary_interface: eth0
network_secondary_interface: eth1
#
# Only one of the two interfaces is routed
#
network_interface_unconfigured: "{{ network_internal_only | ternary(network_primary_interface, 'noname') }}"
network_interface_routed: "{{ network_internal_only | ternary(network_secondary_interface, network_primary_interface) }}"
network_interface_not_routed: "{{ network_internal_only | ternary('noname', network_secondary_interface) }}"
#
#############################################
#
# The name of the network with public IPs

2
tests/enough/common/conftest.py

@ -13,7 +13,7 @@ def pytest_configure(config):
def openstack_variables(request):
ansible = ansible_utils.Ansible(settings.CONFIG_DIR, settings.SHARE_DIR)
os_variables = ('openstack_flavor', 'openstack_image', 'openstack_network',
'network_primary_interface', 'network_secondary_interface',
'network_interface_routed', 'network_interface_not_routed',
'_provider')
os_variables = "{%s}" % ', '.join(f'"{x}": {x}' for x in os_variables)
# Any host could be used

Loading…
Cancel
Save