| --- |
| - hosts: {{ instance_name }} |
| gather_facts: False |
| connection: ssh |
| user: 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 veg_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/veg_monitoring_agent exists |
| file: path=/usr/local/share/beg_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/veg/veg_stats_notifier.py |
| dest=/usr/local/share/veg_monitoring_agent/veg_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 veg_stats_notifier cron job |
| 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' |
| async: 9999999999999999 |
| poll: 0 |
| become: yes |
| when: cron_job_pids_count.stdout == "0" |
| |