]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Convert interface names to underscores for facts
authorMajor Hayden <major@mhtx.net>
Mon, 11 Dec 2017 15:56:56 +0000 (09:56 -0600)
committerGuillaume Abrioux <gabrioux@redhat.com>
Tue, 6 Feb 2018 04:11:47 +0000 (05:11 +0100)
If a deployer uses an interface name with a dash/hyphen in it, such
as 'br-storage' for the monitor_interface group_var, the ceph.conf.j2
template fails to find the right facts. It looks for
'ansible_br-storage' but only 'ansible_br_storage' exists.

This patch converts the interface name to underscores when the
template does the fact lookup.

(cherry picked from commit 5676fa23b169e0ca3af7d4f9b804bbe90d1cccc6)
Signed-off-by: Sébastien Han <seb@redhat.com>
roles/ceph-config/templates/ceph.conf.j2
roles/ceph-defaults/templates/restart_rgw_daemon.sh.j2
roles/ceph-mon/templates/ceph-mon.service.j2
roles/ceph-rgw/templates/ceph-radosgw.service.j2

index 1d5893ee2f26695311b16ba75727b79efd383cb9..9c551444106c28d9745d9981e70b383f9a36ebfa 100644 (file)
@@ -51,14 +51,14 @@ mon host = {% if nb_mon > 0 %}
         [{{ hostvars[host]['monitor_address'] }}]
       {%- endif %}
     {%- elif hostvars[host]['monitor_interface'] is defined -%}
-      {% set interface = 'ansible_' + hostvars[host]['monitor_interface'] %}
+      {% set interface = 'ansible_' + (hostvars[host]['monitor_interface'] | replace('-', '_')) %}
       {% if ip_version == 'ipv4' -%}
         {{ hostvars[host][interface][ip_version]['address'] }}
       {%- elif ip_version == 'ipv6' -%}
         [{{ hostvars[host][interface][ip_version][0]['address'] }}]
       {%- endif %}
     {%- else -%}
-      {% set interface = 'ansible_' + monitor_interface %}
+      {% set interface = 'ansible_' + (monitor_interface | replace('-', '_')) %}
       {% if ip_version == 'ipv4' -%}
         {{ hostvars[host][interface][ip_version]['address'] }}
       {%- elif ip_version == 'ipv6' -%}
@@ -90,14 +90,14 @@ mon host = {% if nb_mon > 0 %}
         [{{ hostvars[host]['monitor_address'] }}]
       {%- endif %}
     {%- elif hostvars[host]['monitor_interface'] is defined -%}
-      {% set interface = 'ansible_' + hostvars[host]['monitor_interface'] %}
+      {% set interface = 'ansible_' + (hostvars[host]['monitor_interface'] | replace('-', '_')) %}
       {% if ip_version == 'ipv4' -%}
         {{ hostvars[host][interface][ip_version]['address'] }}
       {%- elif ip_version == 'ipv6' -%}
         [{{ hostvars[host][interface][ip_version][0]['address'] }}]
       {%- endif %}
     {%- else -%}
-      {% set interface = 'ansible_' + monitor_interface %}
+      {% set interface = 'ansible_' + (monitor_interface | replace('-', '_')) %}
       {% if ip_version == 'ipv4' -%}
         {{ hostvars[host][interface][ip_version]['address'] }}
       {%- elif ip_version == 'ipv6' -%}
@@ -196,14 +196,14 @@ rgw frontends = civetweb port={{ radosgw_address }}:{{ radosgw_civetweb_port }}
 rgw frontends = civetweb port=[{{ radosgw_address }}]:{{ radosgw_civetweb_port }} {{ radosgw_civetweb_options }}
     {% endif %}
 {% elif hostvars[host]['radosgw_interface'] is defined -%}
-    {% set interface='ansible_' + hostvars[host]['radosgw_interface'] %}
+    {% set interface='ansible_' + (hostvars[host]['radosgw_interface'] | replace('-', '_')) %}
     {% if ip_version == 'ipv4' %}
 rgw frontends = civetweb port={{ hostvars[host][interface][ip_version]['address'] }}:{{ radosgw_civetweb_port }} {{ radosgw_civetweb_options }}
     {% elif ip_version == 'ipv6' %}
 rgw frontends = civetweb port=[{{ hostvars[host][interface][ip_version][0]['address'] }}]:{{ radosgw_civetweb_port }} {{ radosgw_civetweb_options }}
     {% endif %}
 {% else %}
-    {% set interface='ansible_' + radosgw_interface %}
+    {% set interface='ansible_' + (radosgw_interface | replace('-', '_')) %}
     {% if ip_version == 'ipv4' %}
 rgw frontends = civetweb port={{ hostvars[host][interface][ip_version]['address'] }}:{{ radosgw_civetweb_port }} {{ radosgw_civetweb_options }}
     {% elif ip_version == 'ipv6' %}
index 0ac0ce821a14d2658acdd82ba6ded82906b9bdf8..9f8317edd3bb139c7afaac8a5f4d6e98029dce5f 100644 (file)
@@ -33,14 +33,14 @@ RGW_IP={{ radosgw_address }} \
 RGW_IP=[{{ radosgw_address }}] \
     {% endif %}
 {% elif hostvars[inventory_hostname]['radosgw_interface'] is defined -%}
-    {% set interface = 'ansible_' + hostvars[inventory_hostname]['radosgw_interface'] %}
+    {% set interface = 'ansible_' + (hostvars[inventory_hostname]['radosgw_interface'] | replace('-', '_')) %}
     {% if ip_version == 'ipv4' %}
 RGW_IP={{ hostvars[inventory_hostname][interface][ip_version]['address'] }} \
     {% elif ip_version == 'ipv6' %}
 RGW_IP=[{{ hostvars[inventory_hostname][interface][ip_version][0]['address'] }}] \
     {% endif %}
 {% else %}
-    {% set interface = 'ansible_' + radosgw_interface %}
+    {% set interface = 'ansible_' + (radosgw_interface | replace('-', '_')) %}
     {% if ip_version == 'ipv4' %}
 RGW_IP={{ hostvars[inventory_hostname][interface][ip_version]['address'] }} \
     {% elif ip_version == 'ipv6' %}
index 2007ac157fcba626717532f60f98ebf848e0f202..9fe9d6774d7630087796409a21283948ec08c043 100644 (file)
@@ -42,14 +42,14 @@ ExecStart=/usr/bin/docker run --rm --name ceph-mon-%i --net=host \
   -e MON_IP=[{{ hostvars[inventory_hostname]['monitor_address'] }}] \
     {% endif -%}
 {% elif hostvars[inventory_hostname]['monitor_interface'] is defined %}
-    {% set interface = 'ansible_' + hostvars[inventory_hostname]['monitor_interface'] %}
+    {% set interface = 'ansible_' + (hostvars[inventory_hostname]['monitor_interface'] | replace('-', '_')) %}
     {% if ip_version == 'ipv4' -%}
   -e MON_IP={{ hostvars[inventory_hostname][interface][ip_version]['address'] }} \
     {% elif ip_version == 'ipv6' -%}
   -e MON_IP=[{{ hostvars[inventory_hostname][interface][ip_version][0]['address'] }}] \
     {% endif -%}
 {% else %}
-    {% set interface = 'ansible_' + monitor_interface %}
+    {% set interface = 'ansible_' + (monitor_interface | replace('-', '_')) %}
     {% if ip_version == 'ipv4' -%}
   -e MON_IP={{ hostvars[inventory_hostname][interface][ip_version]['address'] }} \
     {% elif ip_version == 'ipv6' -%}
index 044f5f3883b906c96daccc80d8315ace2ed783fb..a8ccead792547c939f1b342e901ad9f9a9e1b23a 100644 (file)
@@ -46,14 +46,14 @@ ExecStart=/usr/bin/docker run --rm --net=host \
   -e RGW_CIVETWEB_IP=[{{ radosgw_address }}] \
     {% endif %}
 {% elif hostvars[inventory_hostname]['radosgw_interface'] is defined -%}
-    {% set interface = 'ansible_' + hostvars[inventory_hostname]['radosgw_interface'] %}
+    {% set interface = 'ansible_' + (hostvars[inventory_hostname]['radosgw_interface'] | replace('-', '_')) %}
     {% if ip_version == 'ipv4' %}
   -e RGW_CIVETWEB_IP={{ hostvars[inventory_hostname][interface][ip_version]['address'] }} \
     {% elif ip_version == 'ipv6' %}
   -e RGW_CIVETWEB_IP=[{{ hostvars[inventory_hostname][interface][ip_version][0]['address'] }}] \
     {% endif %}
 {% else %}
-    {% set interface = 'ansible_' + radosgw_interface %}
+    {% set interface = 'ansible_' + (radosgw_interface | replace('-', '_')) %}
     {% if ip_version == 'ipv4' %}
   -e RGW_CIVETWEB_IP={{ hostvars[inventory_hostname][interface][ip_version]['address'] }} \
     {% elif ip_version == 'ipv6' %}