Matteo Scandolo | aca8665 | 2017-08-08 13:05:27 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Srikanth Vavilapalli | cd9d9bd | 2016-12-03 22:53:42 +0000 | [diff] [blame] | 17 | --- |
| 18 | - hosts: {{ instance_name }} |
| 19 | gather_facts: False |
| 20 | connection: ssh |
Sapan Bhatia | af80b7c | 2017-02-07 11:32:57 -0800 | [diff] [blame] | 21 | become: ubuntu |
Srikanth Vavilapalli | cd9d9bd | 2016-12-03 22:53:42 +0000 | [diff] [blame] | 22 | vars: |
| 23 | keystone_tenant_id: {{ keystone_tenant_id }} |
| 24 | keystone_user_id: {{ keystone_user_id }} |
| 25 | rabbit_user: {{ rabbit_user }} |
| 26 | rabbit_password: {{ rabbit_password }} |
| 27 | rabbit_host: {{ rabbit_host }} |
| 28 | |
| 29 | tasks: |
Scott Baker | 645c0c5 | 2017-09-15 10:38:32 -0700 | [diff] [blame] | 30 | - name: Verify if vsg_stats_notifier ([] is to avoid capturing the shell process) cron job is already running |
| 31 | shell: pgrep -f [v]sg_stats_notifier | wc -l |
Srikanth Vavilapalli | cd9d9bd | 2016-12-03 22:53:42 +0000 | [diff] [blame] | 32 | register: cron_job_pids_count |
| 33 | |
| 34 | - name: DEBUG |
| 35 | debug: var=cron_job_pids_count.stdout |
| 36 | |
| 37 | - name: make sure /usr/local/share/vsg_monitoring_agent exists |
| 38 | file: path=/usr/local/share/vsg_monitoring_agent state=directory owner=root group=root |
| 39 | become: yes |
| 40 | when: cron_job_pids_count.stdout == "0" |
| 41 | |
| 42 | - name: Copy cron job to destination |
Scott Baker | 645c0c5 | 2017-09-15 10:38:32 -0700 | [diff] [blame] | 43 | copy: src=/opt/xos/synchronizers/vsg/vsg_stats_notifier.py |
| 44 | dest=/usr/local/share/vsg_monitoring_agent/vsg_stats_notifier.py |
Srikanth Vavilapalli | cd9d9bd | 2016-12-03 22:53:42 +0000 | [diff] [blame] | 45 | become: yes |
| 46 | when: cron_job_pids_count.stdout == "0" |
| 47 | |
| 48 | - name: install python-kombu |
| 49 | apt: name=python-kombu state=present |
| 50 | become: yes |
| 51 | when: cron_job_pids_count.stdout == "0" |
| 52 | |
Scott Baker | 645c0c5 | 2017-09-15 10:38:32 -0700 | [diff] [blame] | 53 | - name: Initiate vsg_stats_notifier cron job |
| 54 | command: sudo python /usr/local/share/vsg_monitoring_agent/vsg_stats_notifier.py --keystone_tenant_id={{ keystone_tenant_id }} --keystone_user_id={{ keystone_user_id }} --rabbit_user={{ rabbit_user }} --rabbit_password={{ rabbit_password }} --rabbit_host={{ rabbit_host }} --vcpeservice_rabbit_exchange='vcpeservice' |
Srikanth Vavilapalli | cd9d9bd | 2016-12-03 22:53:42 +0000 | [diff] [blame] | 55 | async: 9999999999999999 |
| 56 | poll: 0 |
| 57 | become: yes |
| 58 | when: cron_job_pids_count.stdout == "0" |
| 59 | |