Takashi Kajinami c25cf05431 RabbitMQ: Override hostname to ensure correct IP version
Change fe83b5488d33b75be6a9bba97faa8ddd69210973 enforced usage of IPv6
in case the scenario requires IPv6, but this causes the following
failure during rabbitmq startup, because hostname is sometimes resolved
to IPv4 address in CI.

```
ERROR: epmd error for host np0033504771: badarg (unknown POSIX error)
```

This makes sure that hostname env is set according to IP address
version.

Change-Id: I4d876200f0fd8b2b84d893f243fe5615352ef11d
2023-03-19 21:58:13 +09:00

75 lines
1.9 KiB
Puppet

# Configure some common parameters
#
# [*ssl*]
# (optional) Boolean to enable or not SSL.
# Defaults to false.
#
# [*ipv6*]
# (optional) Boolean to enable or not IPv6.
# Defaults to false.
#
# [*rpc_backend*]
# (optional) The oslo.messaging backend to configure for rpc.
# Possible values include rabbit, amqp
# Defaults to 'rabbit'.
#
# [*notify_backend*]
# (optional) The oslo.messaging backend to configure for notify.
# Defaults to 'rabbit'.
#
class openstack_integration::config (
$ssl = false,
$ipv6 = false,
$rpc_backend = 'rabbit',
$notify_backend = 'rabbit',
) {
$messaging_default_proto = $rpc_backend
$messaging_notify_proto = $notify_backend
if $ssl {
$proto = 'https'
if $rpc_backend == 'amqp' {
$messaging_default_port = '31459'
} else {
$messaging_default_port = '5671'
}
$messaging_notify_port = '5671'
} else {
$proto = 'http'
if $rpc_backend == 'amqp' {
$messaging_default_port = '31459'
} else {
$messaging_default_port = '5672'
}
$messaging_notify_port = '5672'
}
$rabbit_port = $messaging_notify_port
if $ipv6 {
$host = '::1'
$hostname = 'localhost6'
$ip_version = '6'
# Note (dmsimard): ipv6 parsing in Swift and keystone_authtoken are
# different: https://bugs.launchpad.net/swift/+bug/1610064
$memcached_servers = ["inet6:[${host}]:11211"]
$swift_memcached_servers = ["[${host}]:11211"]
$tooz_url = "redis://[${host}]:6379"
} else {
$host = '127.0.0.1'
$hostname = 'localhost'
$ip_version = '4'
$memcached_servers = ["${host}:11211"]
$swift_memcached_servers = $memcached_servers
$tooz_url = "redis://${host}:6379"
}
# in URL, brackets are needed
$ip_for_url = normalize_ip_for_uri($host)
$base_url = "${proto}://${ip_for_url}"
$keystone_auth_uri = "${base_url}:5000"
$keystone_admin_uri = "${base_url}:5000"
}