Redone the patch changes from 2413/5 as repo upload had messed up the commit

Change-Id: I711f57d6ef11b863108432235a64fbc68718976f
diff --git a/xos/synchronizer/steps/monitoring_agent.yaml b/xos/synchronizer/steps/monitoring_agent.yaml
new file mode 100644
index 0000000..87cffde
--- /dev/null
+++ b/xos/synchronizer/steps/monitoring_agent.yaml
@@ -0,0 +1,61 @@
+---
+- hosts: {{ instance_name }}
+  gather_facts: False
+  connection: ssh
+  user: ubuntu
+  vars:
+      keystone_tenant_id: {{ keystone_tenant_id }}
+      keystone_user_id: {{ keystone_user_id }}
+      target_uri: {{ target_uri }}
+
+  tasks:
+  - name: Verify if monitoring_agent ([] is to avoid capturing the shell process) cron job is already running
+    shell: pgrep -f [m]onitoring_agent | wc -l
+    register: cron_job_pids_count
+
+  - name: DEBUG
+    debug: var=cron_job_pids_count.stdout
+
+  - name: make sure /usr/local/share/monitoring_agent exists
+    file: path=/usr/local/share/monitoring_agent state=directory owner=root group=root
+    become: yes
+    when: cron_job_pids_count.stdout == "0"
+
+  - name: Copy cron job to destination
+    copy: src=/opt/xos/synchronizers/exampleservice/monitoring_agent/
+      dest=/usr/local/share/monitoring_agent/
+    become: yes
+    when: cron_job_pids_count.stdout == "0"
+
+  - name: Installing python-pip
+    apt: name=python-pip state=present update_cache=yes
+    become: yes
+    when: cron_job_pids_count.stdout == "0"
+
+  - name: Installing Flask
+    pip: name=Flask
+    become: yes
+    when: cron_job_pids_count.stdout == "0"
+
+  - name: install python-kombu
+    apt: name=python-kombu state=present
+    become: yes
+    when: cron_job_pids_count.stdout == "0"
+
+  - name: Initiate monitoring agent cron job
+    command: python monitoring_agent.py &
+    async: 9999999999999999
+    poll: 0
+    become: yes
+    when: cron_job_pids_count.stdout == "0"
+    args:
+       chdir: /usr/local/share/monitoring_agent/
+
+  - name : starting monitoring agent
+    uri:
+      url: http://localhost:5004/monitoring/agent/exampleservice/start
+      method: POST
+      body: '{ "target":"{{target_uri}}", "keystone_user_id": "{{keystone_user_id}}", "keystone_tenant_id": "{{keystone_tenant_id}}" }'
+      force_basic_auth: yes
+      status_code: 200
+      body_format: json