diff --git a/hooks/hooks.py b/hooks/hooks.py index 24731833..d0e2bbef 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -46,7 +46,8 @@ from utils import ( from charmhelpers.contrib.openstack.alternatives import install_alternative from charmhelpers.contrib.network.ip import ( - is_ipv6 + is_ipv6, + get_ipv6_addr ) hooks = Hooks() @@ -86,6 +87,13 @@ def emit_cephconf(): 'ceph_cluster_network': config('ceph-cluster-network'), } + if config('prefer-ipv6'): + dynamic_ipv6_address = get_ipv6_addr()[0] + if not config('ceph-public-network'): + cephcontext['public_addr'] = dynamic_ipv6_address + if not config('ceph-cluster-network'): + cephcontext['cluster_addr'] = dynamic_ipv6_address + # Install ceph.conf as an alternative to support # co-existence with other charms that write this file charm_ceph_conf = "/var/lib/charm/{}/ceph.conf".format(service_name()) diff --git a/templates/ceph.conf b/templates/ceph.conf index def993c3..6177b050 100644 --- a/templates/ceph.conf +++ b/templates/ceph.conf @@ -21,6 +21,14 @@ cluster network = {{ ceph_cluster_network }} {%- endif %} +{% if public_addr %} +public addr = {{ public_addr }} +{% endif %} +{% if cluster_addr %} +cluster addr = {{ cluster_addr }} +{%- endif %} + + [mon] keyring = /var/lib/ceph/mon/$cluster-$id/keyring