Merge "docker.userguide: Add a note about bar-collectd run without DPDK/RDT"
[barometer.git] / docker / ansible / roles / run_prometheus / tasks / main.yml
1 #Copyright 2018 OPNFV and Intel Corporation
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: remove bar-prometheus container
17   docker_container:
18     name: bar-prometheus
19     state: absent
20   tags:
21     - rm_containers
22     - rm_prometheus_cont
23   when: rm_containers|default(false)|bool == true
24
25 - name: Create prometheus directory
26   file:
27     path: /etc/prometheus
28     state: directory
29
30 - name: copy prometheus config
31   template:
32     src: prometheus.yml
33     dest: "/etc/prometheus/prometheus.yml"
34
35 - name: modify prometheus.yml to add prometheus_hosts
36   lineinfile:
37     dest: /etc/prometheus/prometheus.yml
38     insertafter: targets
39     line: "        - '{{ item }}:{{ prometheus_port }}'"
40   with_items: "{{ groups['collectd_hosts'] }}"
41
42 - name: Remove prom-prometheus image
43   docker_image:
44     name: prom/prometheus
45     state: absent
46   tags:
47     - rm_images
48     - rm_prometheus_cont
49   when: rm_images|default(false)|bool == true
50
51 - name: launch bar-prometheus container
52   docker_container:
53     name: bar-prometheus
54     image: prom/prometheus
55     volumes:
56        - /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
57     exposed:
58      - 9090
59      - "{{ prometheus_port }}"
60     ports:
61        - 9090:9090
62        - "{{ prometheus_port }}:{{ prometheus_port }}"
63     detach: yes
64     restart: yes
65     network_mode: host