]> 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, 12 Dec 2017 08:03:40 +0000 (09:03 +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.

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 fb6a0cd05324982987206fe4442413e715b68415..3ca5f323ddc0a494eebad016a649196a461ad33d 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' -%}
@@ -89,14 +89,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' -%}
@@ -195,14 +195,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 3583640e235f3455b09d78268b8b0e86f712e920..bc2c00e1f2dea16f802a69771e60167822e0287b 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 0c46ae01b12f4e81f8ac9aa254a9072c6c4d5836..0c755bad0256a90127888aacd5707f1b728246aa 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' %}