aboutsummaryrefslogtreecommitdiff
path: root/roles/influxdb/tasks/main.yml
blob: bc908bf98f8a67f3206f69d2cda4464e56673779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
- name: Install GnuPG
  apt:
    update_cache: yes
    name:
      - gnupg2
  become: yes

- name: APT Key
  apt_key:
    url: 'https://repos.influxdata.com/influxdb.key'
    state: present
  become: yes

- name: Install repos
  template:
    src: influxdb.list.j2
    dest: /etc/apt/sources.list.d/influxdb.list
  become: yes

- name: Install Packages
  apt:
    update_cache: yes
    name:
      - curl
      - python3-influxdb
      - influxdb
  become: yes

- name: InfluxDB user setup
  user:
    name: influxdb
    groups:
      - ssl-cert
    append: yes
  become: yes

- name: Install configuration
  template:
    src: influxdb.conf.j2
    dest: /etc/influxdb/influxdb.conf
  become: yes
  notify: Restart influxdb

- name: Check for changed cert
  command: /bin/true
  when:
    - cert_changed
  notify:
    - Restart influxdb

- name: Flush handlers
  meta: flush_handlers

- name: create Influx DBs
  influxdb_database:
    database_name: '{{ item }}'
    hostname: localhost
    port: 8086
    ssl: yes
    validate_certs: no
    state: present
  with_items: '{{ influx_dbs }}'
  become: yes

- name: create Influx Users
  influxdb_user:
    user_name: '{{ item.key }}'
    user_password: '{{ item.value.password }}'
    grants: '{{ item.value.grants }}'
    hostname: localhost
    port: 8086
    ssl: yes
    validate_certs: no
    state: present
  with_dict: '{{ influx_users }}'
  no_log: yes
  become: yes