blob: 87cffdef28c9be16fe3bd4e204e406e84388c0bd [file] [log] [blame]
---
- 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