From eab00effc3e55f4e82412761a62432141544f1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Vydra?= <80331839+vydrazde@users.noreply.github.com> Date: Thu, 16 Jan 2025 14:23:50 +0100 Subject: [PATCH] Openstack add public IP options (#263) * Add options to set auto_ip and floating_ip_pools * Fix typo in openstack documentation * Make condition more explicit --- doc/openstack/platforms.rst | 11 ++++++++++- src/molecule_plugins/openstack/driver.py | 2 ++ src/molecule_plugins/openstack/playbooks/create.yml | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/openstack/platforms.rst b/doc/openstack/platforms.rst index ae2b0bad..4e774094 100644 --- a/doc/openstack/platforms.rst +++ b/doc/openstack/platforms.rst @@ -43,6 +43,12 @@ security_group.rules[].port_min Starting port (can't be used with port) security_group.rules[].port_max Ending port (can't be used with port) security_group.rules[].type IPv4 or IPv6, default 'IPv4' user Default user of image +auto_ip Ensure instance has public IP, mutually \ + exclusive with floating_ip_pools, \ + default = true +floating_ip_pools List of floating pool IP names to choose a \ + floating IP from, mutually exclusive with \ + auto_ip, (optional) volume Mapping of volume settings (optional if \ flavor provides volume) volume.size Size of volume (GB) @@ -96,6 +102,8 @@ Examples flavor: m1.small image: Debian_10 user: debian + floating_ip_pools: # mutually exclusive with auto_ip + - 1.2.3.4 network: name: molecule router: @@ -139,9 +147,10 @@ Examples network: name: molecule # use network from debian10 instance - name: ubuntu2004 - falvor: m1.tiny + flavor: m1.tiny image: Ubuntu_2004 user: ubuntu + auto_ip: false # do not assign a public IP security_group: name: molecule # use security group from debian10 instance network: diff --git a/src/molecule_plugins/openstack/driver.py b/src/molecule_plugins/openstack/driver.py index 4739b2f0..748d6d44 100644 --- a/src/molecule_plugins/openstack/driver.py +++ b/src/molecule_plugins/openstack/driver.py @@ -27,6 +27,8 @@ class Openstack(Driver): flavor: m1.small image: Ubuntu_20.04 user: ubuntu + floating_ip_pools: # mutually exclusive with auto_ip + - 1.2.3.4 security_group: name: molecule-sec description: Molecule test diff --git a/src/molecule_plugins/openstack/playbooks/create.yml b/src/molecule_plugins/openstack/playbooks/create.yml index d9596952..35ef845a 100644 --- a/src/molecule_plugins/openstack/playbooks/create.yml +++ b/src/molecule_plugins/openstack/playbooks/create.yml @@ -102,6 +102,8 @@ image: "{{ item.image }}" key_name: "{{ key_name }}" flavor: "{{ item.flavor }}" + floating_ip_pools: "{{ item.floating_ip_pools if item.floating_ip_pools is defined and item.floating_ip_pools | length > 0 else omit }}" + auto_ip: "{{ item.auto_ip if item.auto_ip is defined else omit }}" boot_from_volume: "{{ true if item.volume is defined and item.volume.size else false }}" terminate_volume: "{{ true if item.volume is defined and item.volume.size else false }}" volume_size: "{{ item.volume.size if item.volume is defined and item.volume.size else omit }}"