[ansible] Use collectd_config for default_read_plugins
[barometer.git] / docker / ansible / roles / config_files / tasks / ovs.yml
1 # Copyright 2018-21 Anuket, Intel Corporation and others
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 ---
15
16 - name: Check if vswitchd is running
17   shell: ps -ef | grep vswitchd | grep -v grep > /dev/null
18   register: vswitchd_running
19   ignore_errors: True
20   tags:
21      - ovs_stats
22      - ovs_events
23
24 - name: Check if db.sock exists
25   stat:
26     path: /var/run/openvswitch/db.sock
27   register: dbsock_exists
28   ignore_errors: True
29   tags:
30      - ovs_stats
31      - ovs_events
32
33 - name: enable ovs_stats plugin
34   set_fact:
35     collectd_plugins: '{{ collectd_plugins | union(["ovs_stats"]) | unique }}'
36     collectd_plugin_ovs_stats_port: "{{ ovs_stats_port if ovs_stats_port is defined else omit }}"
37     collectd_plugin_ovs_stats_address: "{{ ovs_stats_ip_addr if ovs_stats_ip_addr is defined else omit }}"
38     collectd_plugin_ovs_stats_interval: "{{ ovs_stats_interval if ovs_stats_interval is defined else omit }}"
39   when: (vswitchd_running is succeeded) and (dbsock_exists is succeeded)
40   tags:
41     - ovs_stats
42
43 - name: enable ovs_events plugin
44   set_fact:
45     collectd_plugins: '{{ collectd_plugins | union(["ovs_events"]) | unique }}'
46     collectd_plugin_ovs_events_interval: "{{ ovs_events_interval if ovs_events_interval is defined else omit }}"
47     collectd_plugin_ovs_events_address: "{{ ovs_events_ip_addr if ovs_events_ip_addr is defined else omit }}"
48     collectd_plugin_ovs_events_port: "{{ ovs_events_port if ovs_events_port is defined else omit }}"
49   when: (vswitchd_running is succeeded) and (dbsock_exists is succeeded)
50   tags:
51     - ovs_events
52
53