From 8320085a663aa154a5245e00e8152205c53bf7c8 Mon Sep 17 00:00:00 2001 From: Huamin Chen Date: Mon, 6 Jun 2016 17:34:51 +0000 Subject: [PATCH] ceph.conf.j2: check if interface is defined before using it ceph-mon.service.j2: remove redundant --name option from docker command Signed-off-by: Huamin Chen --- roles/ceph-common/templates/ceph.conf.j2 | 12 ++++++++---- roles/ceph-mon/templates/ceph-mon.service.j2 | 1 - 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/roles/ceph-common/templates/ceph.conf.j2 b/roles/ceph-common/templates/ceph.conf.j2 index ca2c55b06..12370bdbe 100644 --- a/roles/ceph-common/templates/ceph.conf.j2 +++ b/roles/ceph-common/templates/ceph.conf.j2 @@ -30,13 +30,17 @@ host = {{ hostvars[host]['ansible_fqdn'] }} host = {{ hostvars[host]['ansible_hostname'] }} {% endif %} # we need to check if monitor_interface is defined in the inventory per host or if it's set in a group_vars file -{% if mon_containerized_deployment or mon_containerized_deployment_with_kv %} +{% if mon_containerized_deployment %} {% set interface = ["ansible_",ceph_mon_docker_interface]|join %} -{% if (hostvars[host][interface] is defined and hostvars[host][interface] != "interface") or interface != "interface" %} +{% if interface in hostvars[host] and 'ipv4' in hostvars[host][interface] %} # user address from interface {{ ceph_mon_docker_interface }} mon addr = {{ hostvars[host][interface]['ipv4']['address'] }} - {% else %} -mon addr = {{ hostvars[host]['monitor_address'] if hostvars[host]['monitor_address'] is defined else monitor_address }} + {% elif hostvars[host]['monitor_address'] is defined %} + # use host monitor address +mon addr = {{ hostvars[host]['monitor_address'] }} + {% elif monitor_address != "0.0.0.0" %} + # use group_var monitor address +mon addr = monitor_address {% endif %} {% elif (hostvars[host]['monitor_interface'] is defined and hostvars[host]['monitor_interface'] != "interface") or monitor_interface != "interface" %} {% include 'mon_addr_interface.j2' %} diff --git a/roles/ceph-mon/templates/ceph-mon.service.j2 b/roles/ceph-mon/templates/ceph-mon.service.j2 index ab9c384ad..110cee457 100644 --- a/roles/ceph-mon/templates/ceph-mon.service.j2 +++ b/roles/ceph-mon/templates/ceph-mon.service.j2 @@ -24,7 +24,6 @@ ExecStart=/usr/bin/docker run --rm --name %i --net=host \ -e MON_IP={{ hostvars[inventory_hostname]['ansible_' + ceph_mon_docker_interface]['ipv4']['address'] }} \ -e CEPH_PUBLIC_NETWORK={{ ceph_mon_docker_subnet }} \ -e MON_NAME={{ ansible_hostname }} \ - --name={{ ansible_hostname }} \ {{ ceph_mon_docker_username }}/{{ ceph_mon_docker_imagename }} ExecStopPost=-/usr/bin/docker stop %i Restart=always -- 2.39.5