Common: Add ipv6 support

e8187f6 does not fix the ipv6 as expected since `ansible_default_*` are
filled with the IP address carried by the network interface used by the
default gateway route. By the way, it assumes that the MON_IP address will
be this IP address which is not always the case.

We need to keep using the previous fact but add some intelligence in the
template to determine how to retrieve the ipv4|ipv6 address since the path
to the fact in `hostvars` is not the same according to ipv4 vs ipv6 case.

Fix: 1569

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
pull/1594/head
Guillaume Abrioux 2017-06-07 13:26:04 +02:00 committed by Guits
parent 15b81bd255
commit 88df105d0b
3 changed files with 66 additions and 36 deletions

View File

@ -32,3 +32,9 @@
- ceph_origin != 'distro'
tags:
- package-install
- name: make sure monitor_interface is defined
fail:
msg: "you must set monitor_interface"
when:
- monitor_interface == 'interface'

View File

@ -30,41 +30,56 @@ mon initial members = {% for host in groups[mon_group_name] %}
{% endfor %}
{% endif %}
{% if not containerized_deployment and not containerized_deployment_with_kv %}
{% if monitor_address_block %}
mon host = {% for host in groups[mon_group_name] %}{{ hostvars[host]['ansible_all_ipv4_addresses'] | ipaddr(monitor_address_block) | first }}{% if not loop.last %},{% endif %}{% endfor %}
{% elif groups[mon_group_name] is defined %}
mon host = {% for host in groups[mon_group_name] %}
{% set address = hostvars[host]['monitor_address'] if hostvars[host]['monitor_address'] is defined else monitor_address %}
{% set interface = hostvars[host]['monitor_interface'] if hostvars[host]['monitor_interface'] is defined else monitor_interface %}
{% if interface != "interface" %}
{% for key in hostvars[host].keys() %}
{% if hostvars[host][key]['macaddress'] is defined and hostvars[host][key]['device'] is defined and hostvars[host][key]['device'] == interface -%}
{{ hostvars[host][key][ip_version]['address'] }}
{% if not containerized_deployment and not containerized_deployment_with_kv -%}
mon host = {% for host in groups[mon_group_name] -%}
{% if monitor_address_block is defined %}
{% if ip_version == 'ipv4' -%}
{{ hostvars[host]['ansible_all_' + ip_version + '_addresses'] | ipaddr(monitor_address_block) | first }}
{%- elif ip_version == 'ipv6' -%}
[{{ hostvars[host]['ansible_all_' + ip_version + '_addresses'] | ipaddr(monitor_address_block) | first }}]
{%- endif %}
{% endfor %}
{% elif address != "0.0.0.0" -%}
{{ address }}
{% elif hostvars[host]['monitor_address'] is defined and hostvars[host]['monitor_address'] != '0.0.0.0' -%}
{% if ip_version == 'ipv4' -%}
{{ hostvars[host]['monitor_address'] }}
{%- elif ip_version == 'ipv6' -%}
[{{ hostvars[host]['monitor_address'] }}]
{%- endif %}
{%- if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{%- else -%}
{% if ip_version == 'ipv4' -%}
{{ hostvars[host]['ansible_' + monitor_interface][ip_version]['address'] }}
{%- elif ip_version == 'ipv6' -%}
[{{ hostvars[host]['ansible_' + monitor_interface][ip_version][0]['address'] }}]
{%- endif %}
{%- endif %}
{% if not loop.last -%},{%- endif %}
{%- endfor %}
{%- endif %}
{% if containerized_deployment %}
fsid = {{ fsid }}
{% if groups[mon_group_name] is defined %}
mon host = {% for host in groups[mon_group_name] %}
{% set interface = ["ansible_",ceph_mon_docker_interface]|join %}
{% if containerized_deployment -%}
{{ hostvars[host][interface]['ipv4']['address'] }}
{%- elif hostvars[host]['monitor_address'] is defined -%}
{{ hostvars[host]['monitor_address'] }}
{%- elif monitor_address != "0.0.0.0" -%}
{{ monitor_address }}
mon host = {% for host in groups[mon_group_name] -%}
{% if monitor_address_block is defined %}
{% if ip_version == 'ipv4' -%}
{{ hostvars[host]['ansible_all_' + ip_version + '_addresses'] | ipaddr(monitor_address_block) | first }}
{%- elif ip_version == 'ipv6' -%}
[{{ hostvars[host]['ansible_all_' + ip_version + '_addresses'] | ipaddr(monitor_address_block) | first }}]
{%- endif %}
{%- if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
{% elif hostvars[host]['monitor_address'] is defined and hostvars[host]['monitor_address'] != '0.0.0.0' -%}
{% if ip_version == 'ipv4' -%}
{{ hostvars[host]['monitor_address'] }}
{%- elif ip_version == 'ipv6' -%}
[{{ hostvars[host]['monitor_address'] }}]
{%- endif %}
{%- else -%}
{% set interface = ["ansible_",ceph_mon_docker_interface]|join %}
{% if ip_version == 'ipv4' -%}
{{ hostvars[host][interface][ip_version]['address'] }}
{%- elif ip_version == 'ipv6' -%}
[{{ hostvars[host][interface][ip_version][0]['address'] }}]
{%- endif %}
{%- endif %}
{% if not loop.last -%},{%- endif %}
{%- endfor %}
{% endif %}
{% if public_network is defined %}
@ -85,12 +100,10 @@ admin socket = {{ rbd_client_admin_socket_path }}/$cluster-$type.$id.$pid.$cctid
log file = {{ rbd_client_log_file }} # must be writable by QEMU and allowed by SELinux or AppArmor
[osd]
{% if osd_objectstore != 'bluestore' %}
osd mkfs type = {{ osd_mkfs_type }}
osd mkfs options xfs = {{ osd_mkfs_options_xfs }}
osd mount options xfs = {{ osd_mount_options_xfs }}
osd journal size = {{ journal_size }}
{% endif %}
{% if filestore_xattr_use_omap != None %}
filestore xattr use omap = {{ filestore_xattr_use_omap }}
{% elif osd_mkfs_type == "ext4" %}

View File

@ -23,8 +23,19 @@ ExecStart=/usr/bin/docker run --rm --name ceph-mon-%i --net=host \
--net=host \
{% endif -%}
-e CEPH_DAEMON=MON \
-e MON_IP={{ hostvars[inventory_hostname]['ansible_default_' + ip_version]['address'] }} \
-e CEPH_PUBLIC_NETWORK={{ ceph_mon_docker_subnet }} \
-e IP_VERSION={{ ip_version[-1:] }} \
{% if monitor_address is defined and monitor_address != '0.0.0.0' %}
{% if ip_version == 'ipv4' -%}
-e MON_IP={{ monitor_address }} \
{% elif ip_version == 'ipv6' -%}
-e MON_IP=[{{ monitor_address }}] \
{% endif -%}
{% elif ip_version == 'ipv4' -%}
-e MON_IP={{ hostvars[inventory_hostname]['ansible_' + ceph_mon_docker_interface][ip_version]['address'] }} \
{% elif ip_version =='ipv6' -%}
-e MON_IP=[{{ hostvars[inventory_hostname]['ansible_' + ceph_mon_docker_interface][ip_version][0]['address'] }}] \
{% endif -%}
{{ ceph_mon_docker_extra_env }} \
{{ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
ExecStopPost=-/usr/bin/docker stop ceph-mon-%i