| |
| # Copyright 2017-present Open Networking Foundation |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| |
| --- |
| - hosts: {{ instance_name }} |
| gather_facts: False |
| connection: ssh |
| become: ubuntu |
| vars: |
| keystone_tenant_id: {{ keystone_tenant_id }} |
| keystone_user_id: {{ keystone_user_id }} |
| rabbit_user: {{ rabbit_user }} |
| rabbit_password: {{ rabbit_password }} |
| rabbit_host: {{ rabbit_host }} |
| |
| tasks: |
| - name: Verify if vcpe_stats_notifier ([] is to avoid capturing the shell process) cron job is already running |
| shell: pgrep -f [v]cpe_stats_notifier | wc -l |
| register: cron_job_pids_count |
| |
| - name: DEBUG |
| debug: var=cron_job_pids_count.stdout |
| |
| - name: make sure /usr/local/share/vsg_monitoring_agent exists |
| file: path=/usr/local/share/vsg_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/vsg/vcpe_stats_notifier.py |
| dest=/usr/local/share/vsg_monitoring_agent/vcpe_stats_notifier.py |
| 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 vcpe_stats_notifier cron job |
| command: sudo python /usr/local/share/vsg_monitoring_agent/vcpe_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' |
| async: 9999999999999999 |
| poll: 0 |
| become: yes |
| when: cron_job_pids_count.stdout == "0" |
| |