mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-07-25 09:14:31 +00:00
Merge "add an option to use only IPv4 only for ansible_host and ansible_ssh_host"
This commit is contained in:
@@ -96,6 +96,12 @@ options:
|
|||||||
only.
|
only.
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
|
only_ipv4:
|
||||||
|
description:
|
||||||
|
- Use only ipv4 addresses for ansible_host and ansible_ssh_host.
|
||||||
|
- Using I(only_ipv4) helps when running Ansible in a ipv4 only setup.
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
show_all:
|
show_all:
|
||||||
description:
|
description:
|
||||||
- Whether all servers should be listed or not.
|
- Whether all servers should be listed or not.
|
||||||
@@ -384,6 +390,13 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
if address['OS-EXT-IPS:type'] == 'floating'),
|
if address['OS-EXT-IPS:type'] == 'floating'),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
|
if self.get_option('only_ipv4'):
|
||||||
|
fixed_ip = next(
|
||||||
|
(address['addr'] for address in addresses
|
||||||
|
if (address['OS-EXT-IPS:type'] == 'fixed' and address['version'] == 4)),
|
||||||
|
None)
|
||||||
|
|
||||||
|
else:
|
||||||
fixed_ip = next(
|
fixed_ip = next(
|
||||||
(address['addr'] for address in addresses
|
(address['addr'] for address in addresses
|
||||||
if address['OS-EXT-IPS:type'] == 'fixed'),
|
if address['OS-EXT-IPS:type'] == 'fixed'),
|
||||||
|
|||||||
Reference in New Issue
Block a user