blob: 87cffdef28c9be16fe3bd4e204e406e84388c0bd [file] [log] [blame]
Andy Bavierf80542f2017-03-31 11:57:48 -04001---
2- hosts: {{ instance_name }}
3 gather_facts: False
4 connection: ssh
5 user: ubuntu
6 vars:
7 keystone_tenant_id: {{ keystone_tenant_id }}
8 keystone_user_id: {{ keystone_user_id }}
9 target_uri: {{ target_uri }}
10
11 tasks:
12 - name: Verify if monitoring_agent ([] is to avoid capturing the shell process) cron job is already running
13 shell: pgrep -f [m]onitoring_agent | wc -l
14 register: cron_job_pids_count
15
16 - name: DEBUG
17 debug: var=cron_job_pids_count.stdout
18
19 - name: make sure /usr/local/share/monitoring_agent exists
20 file: path=/usr/local/share/monitoring_agent state=directory owner=root group=root
21 become: yes
22 when: cron_job_pids_count.stdout == "0"
23
24 - name: Copy cron job to destination
25 copy: src=/opt/xos/synchronizers/exampleservice/monitoring_agent/
26 dest=/usr/local/share/monitoring_agent/
27 become: yes
28 when: cron_job_pids_count.stdout == "0"
29
30 - name: Installing python-pip
31 apt: name=python-pip state=present update_cache=yes
32 become: yes
33 when: cron_job_pids_count.stdout == "0"
34
35 - name: Installing Flask
36 pip: name=Flask
37 become: yes
38 when: cron_job_pids_count.stdout == "0"
39
40 - name: install python-kombu
41 apt: name=python-kombu state=present
42 become: yes
43 when: cron_job_pids_count.stdout == "0"
44
45 - name: Initiate monitoring agent cron job
46 command: python monitoring_agent.py &
47 async: 9999999999999999
48 poll: 0
49 become: yes
50 when: cron_job_pids_count.stdout == "0"
51 args:
52 chdir: /usr/local/share/monitoring_agent/
53
54 - name : starting monitoring agent
55 uri:
56 url: http://localhost:5004/monitoring/agent/exampleservice/start
57 method: POST
58 body: '{ "target":"{{target_uri}}", "keystone_user_id": "{{keystone_user_id}}", "keystone_tenant_id": "{{keystone_tenant_id}}" }'
59 force_basic_auth: yes
60 status_code: 200
61 body_format: json