Matteo Scandolo | 6288d5a | 2017-08-08 13:05:26 -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 | |
Andrea Campanella | edfdbca | 2017-02-01 17:33:47 -0800 | [diff] [blame] | 17 | --- |
| 18 | - hosts: {{ instance_name }} |
| 19 | gather_facts: False |
| 20 | connection: ssh |
Andrea Campanella | 08c14ca | 2017-03-31 16:13:09 +0200 | [diff] [blame] | 21 | become: ubuntu |
| 22 | |
Andrea Campanella | edfdbca | 2017-02-01 17:33:47 -0800 | [diff] [blame] | 23 | vars: |
| 24 | keystone_tenant_id: {{ keystone_tenant_id }} |
| 25 | keystone_user_id: {{ keystone_user_id }} |
| 26 | rabbit_user: {{ rabbit_user }} |
| 27 | rabbit_password: {{ rabbit_password }} |
| 28 | rabbit_host: {{ rabbit_host }} |
| 29 | |
| 30 | tasks: |
| 31 | - name: Verify if veg_stats_notifier ([] is to avoid capturing the shell process) cron job is already running |
Andrea Campanella | 08c14ca | 2017-03-31 16:13:09 +0200 | [diff] [blame] | 32 | shell: pgrep -f [v]veg_stats_notifier | wc -l |
Andrea Campanella | edfdbca | 2017-02-01 17:33:47 -0800 | [diff] [blame] | 33 | register: cron_job_pids_count |
| 34 | |
| 35 | - name: DEBUG |
| 36 | debug: var=cron_job_pids_count.stdout |
| 37 | |
| 38 | - name: make sure /usr/local/share/veg_monitoring_agent exists |
| 39 | file: path=/usr/local/share/beg_monitoring_agent state=directory owner=root group=root |
| 40 | become: yes |
| 41 | when: cron_job_pids_count.stdout == "0" |
| 42 | |
| 43 | - name: Copy cron job to destination |
| 44 | copy: src=/opt/xos/synchronizers/veg/veg_stats_notifier.py |
| 45 | dest=/usr/local/share/veg_monitoring_agent/veg_stats_notifier.py |
| 46 | become: yes |
| 47 | when: cron_job_pids_count.stdout == "0" |
| 48 | |
| 49 | - name: install python-kombu |
| 50 | apt: name=python-kombu state=present |
| 51 | become: yes |
| 52 | when: cron_job_pids_count.stdout == "0" |
| 53 | |
| 54 | - name: Initiate veg_stats_notifier cron job |
| 55 | command: sudo python /usr/local/share/veg_monitoring_agent/veg_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 }} --vegservice_rabbit_exchange='vegservice' |
| 56 | async: 9999999999999999 |
| 57 | poll: 0 |
| 58 | become: yes |
| 59 | when: cron_job_pids_count.stdout == "0" |
| 60 | |