]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Common: Add ipv6 support
authorGuillaume Abrioux <gabrioux@redhat.com>
Wed, 7 Jun 2017 11:26:04 +0000 (13:26 +0200)
committerGuits <gabrioux@redhat.com>
Tue, 4 Jul 2017 08:57:26 +0000 (10:57 +0200)
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>
roles/ceph-common/tasks/checks/check_mandatory_vars.yml
roles/ceph-common/templates/ceph.conf.j2
roles/ceph-mon/templates/ceph-mon.service.j2

index 114f22ef23472356a5d04c7cfef5e7b7fa55e513..9565383b4ddb902f90ba4a9fc01de36662e2e086 100644 (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'
index 400baa268f424a983d29f99d54226ccb41ffa483..42d111532e581e2d45249ba1a042c9f484065094 100644 (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'] }}
-                 {%- endif %}
-               {% endfor %}
-             {% elif address != "0.0.0.0" -%}
-               {{ address }}
-             {%- endif %}
-             {%- if not loop.last %},{% endif %}
-           {% endfor %}
-{% endif %}
-{% endif %}
+{% 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 %}
+    {% 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 -%}
+      {% 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 }}
-             {%- endif %}
-             {%- if not loop.last %},{% endif %}
-           {% endfor %}
-{% endif %}
+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 %}
+    {% 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" %}
index daaebdfd73ccd5e3633f69b7bab96e82d437d943..74457aa2e581625510c651255bae4db6c588a31a 100644 (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