Fixes in monitoring service VM-2

Change-Id: I4a35a300c9fa97d5f79467f2688aeef6d52a88a9
diff --git a/xos/synchronizer/ceilometer/ceilometer_service_custom_image/kafka-installer/install_zookeeper_kafka.sh b/xos/synchronizer/ceilometer/ceilometer_service_custom_image/kafka-installer/install_zookeeper_kafka.sh
index be950cd..f21a353 100755
--- a/xos/synchronizer/ceilometer/ceilometer_service_custom_image/kafka-installer/install_zookeeper_kafka.sh
+++ b/xos/synchronizer/ceilometer/ceilometer_service_custom_image/kafka-installer/install_zookeeper_kafka.sh
@@ -3,7 +3,6 @@
 BASE_KAFKA_VERSION=0.9.0.0
 KAFKA_VERSION=2.11-0.9.0.0
 export CONF_BASE=$PWD
-export SERVICE_HOST=$(hostname)
 echo $CONF_BASE
 sudo sed -i "s/.*127.0.0.1.*/127.0.0.1 localhost $(hostname)/" /etc/hosts
 
@@ -124,8 +123,7 @@
 
     if [[ ${SERVICE_HOST} ]]; then
 
-        sudo sed -i "s/host\.name=127\.0\.0\.1/host.name=0.0.0.0/g" /etc/kafka/server.properties
-        sudo sed -i "s/^#advertised\.host\.name=.*$/advertised.host.name=${SERVICE_HOST}/g" /etc/kafka/server.properties
+        sudo sed -i "s/host\.name=127\.0\.0\.1/host.name=${SERVICE_HOST}/g" /etc/kafka/server.properties
         sudo sed -i "s/zookeeper\.connect=127\.0\.0\.1:2181/zookeeper.connect=${SERVICE_HOST}:2181/g" /etc/kafka/server.properties
 
     fi
diff --git a/xos/synchronizer/steps/sync_ceilometerservice.yaml b/xos/synchronizer/steps/sync_ceilometerservice.yaml
index f532e79..f05ce45 100644
--- a/xos/synchronizer/steps/sync_ceilometerservice.yaml
+++ b/xos/synchronizer/steps/sync_ceilometerservice.yaml
@@ -34,6 +34,19 @@
     become: yes
     shell: update-keystone-endpoints.py --username root --password password --host localhost --endpoint {{ private_ip }} --endpoint-type admin 
 
+  - name: Update host specific configs in /etc/kafka/server.properties
+    become: yes
+    lineinfile:
+      dest=/etc/kafka/server.properties
+      regexp="{{ '{{' }} item.regexp {{ '}}' }}"
+      line="{{ '{{' }} item.line {{ '}}' }}"
+    with_items:
+      - { regexp: '^[#]{0,}host\.name=', line: 'host.name=0.0.0.0' }
+      - { regexp: '^[#]{0,}advertised\.host\.name=', line: 'advertised.host.name={{ instance_hostname }}' }
+      - { regexp: '^[#]{0,}zookeeper\.connect=', line: 'zookeeper.connect={{ instance_hostname }}:2181' }
+    notify:
+     - restart kafka service
+
   - name: Enabling/Disabling kafka publishing
     become: yes
     template: src=/opt/xos/synchronizers/monitoring/templates/ceilometer_pipeline.yaml.j2 dest=/etc/ceilometer/pipeline.yaml owner=root group=root mode=0777
@@ -48,6 +61,9 @@
 #     - restart ceilometer-agent-notification service
 
   handlers:
+  - name: restart kafka service
+    become: yes
+    service: name=kafka state=restarted
   - name: restart ceilometer-agent-notification service
     become: yes
     service: name=ceilometer-agent-notification state=restarted