main.yml 1.93 KB
Newer Older
Tobias Winchen's avatar
Tobias Winchen committed
1
2
---
- name: Build side car container
Tobias Winchen's avatar
Tobias Winchen committed
3
  include_role:
Tobias Winchen's avatar
Tobias Winchen committed
4
5
    name: common
    tasks_from: build_tasks.yml
Tobias Winchen's avatar
Tobias Winchen committed
6
7
8
    apply:
      tags:
        - build
9
10
  run_once: true

Tobias Winchen's avatar
Tobias Winchen committed
11
12
13
14
  vars:
    image_name: katcp2influx_sidecar
  tags:
    - never         # only run when build tag is specified
15
    - buildsidecar
Tobias Winchen's avatar
Tobias Winchen committed
16
17


18
19
20
21
22
23
- name: Stop already running side car
  # An async block would be great here but is not possible yet. See ansible
  # feature request https://github.com/ansible/ansible/issues/28997
  docker_container:
    name: "{{ pipeline_id }}_influx_sidecar"
    state: absent
Tobias Winchen's avatar
Tobias Winchen committed
24
    force_kill: yes
25
26

- name: Start new side car
27
28
29
30
  block:
    - docker_container:
        name: "{{ pipeline_id }}_influx_sidecar"
        image: "{{ docker_registry }}:{{ docker_registry_port }}/katcp2influx_sidecar"
31
        command: "python katcp_monitor/influxdb_exporter.py --host {{ katcp_host }} --port {{ katcp_port }} --db-host={{ influx_host }} --db-port {{ influxdb_port }} --idb-db=monitor --measurement={{ measurement }} --idb-tags pipeline_id={{ pipeline_id }} {% if influx_exclude_sensors is defined and influx_exclude_sensors %}--exclude_sensors {{ influx_exclude_sensors | join(' ')}}{%endif%}{% if include_sensors is defined and include_sensors %}--include_sensors {{ include_sensors | join(' ')}}{%endif%} --interval={{ interval }} --strategy={{ strategy }}"
Tobias Winchen's avatar
Tobias Winchen committed
32

33
34
        state: started            # ensure that is running
        pull: yes
35
        # auto_remove: yes
36
37
38
39
40
41
42
        force_kill: yes # avoid lag between rm and restart
      async: 300
      poll: 0
      register: async_results_tmp

    - set_fact:
        async_list: "{{ async_list + [ async_results_tmp.ansible_job_id ] }} "
Tobias Winchen's avatar
Tobias Winchen committed
43
44

- name: Stop sidecar
45
46
47
48
49
50
51
52
53
54
  block:
    - docker_container:
        name: "{{ pipeline_id }}_influx_sidecar"
        state: absent
      async: 300
      poll: 0
      register: async_results_tmp

    - set_fact:
        async_list: "{{ async_list + [ async_results_tmp.ansible_job_id ] }} "
Tobias Winchen's avatar
Tobias Winchen committed
55
56
57
  tags:
    - never
    - stop