ansible-role-influxdb/tasks/main.yml

104 lines
2.9 KiB
YAML
Raw Normal View History

2019-04-12 17:14:25 +00:00
---
2023-09-07 08:36:42 +00:00
- name: Install depencies packages
ansible.builtin.package:
name:
- apt-transport-https
- python3-requests
tags: influxdb
- name: Add key for influxdb repository
ansible.builtin.get_url:
url: https://repos.influxdata.com/influxdata-archive_compat.key
dest: /etc/apt/keyrings/influx.asc
checksum: sha256:393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c
owner: root
group: root
mode: "0644"
tags: influxdb
- name: Add influxdb repository
ansible.builtin.apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/influx.asc] https://repos.influxdata.com/debian stable main"
tags: influxdb
- name: Install package
ansible.builtin.package:
name:
- influxdb2
tags: influxdb
- name: Start and enable service
ansible.builtin.service:
name: influxdb
state: started
enabled: true
tags: influxdb
- name: Wait http api is up
ansible.builtin.wait_for:
port: 8086
timeout: 10
tags: influxdb
- name: Setup server
influxdb_setup:
api_url: http://127.0.0.1:8086
username: "{{ influxdb_init_username }}"
org: "{{ influxdb_init_org }}"
bucket: "{{ influxdb_init_bucket }}"
token: "{{ influxdb_api_token }}"
tags: influxdb
- name: Manage organisations
influxdb_org:
name: "{{ item.key }}"
description: "{{ item.value.description | default(omit) }}"
api_url: http://127.0.0.1:8086
api_token: "{{ influxdb_api_token }}"
state: "{{ item.value.state | default('present') }}"
loop: "{{ influxdb_orgs | dict2items }}"
loop_control:
label: "{{ item.key }}"
tags: influxdb
- name: Manage buckets
influxdb_bucket:
name: "{{ item.key }}"
org: "{{ item.value.org }}"
description: "{{ item.value.description | default(omit) }}"
retention: "{{ item.value.retention | default(omit) }}"
api_url: http://127.0.0.1:8086
api_token: "{{ influxdb_api_token }}"
state: "{{ item.value.state | default('present') }}"
loop: "{{ influxdb_buckets | dict2items }}"
loop_control:
label: "{{ item.key }}"
tags: influxdb
- name: Manage users
influxdb_user:
name: "{{ item.key }}"
status: "{{ item.value.status | default('active') }}"
api_url: http://127.0.0.1:8086
api_token: "{{ influxdb_api_token }}"
state: "{{ item.value.state | default('present') }}"
loop: "{{ influxdb_users | dict2items }}"
loop_control:
label: "{{ item.key }}"
tags: influxdb
- name: Manage authorizations
influxdb_auth:
org: "{{ item.org }}"
user: "{{ item.user }}"
description: "{{ item.description | default(omit) }}"
permissions: "{{ item.permissions }}"
status: "{{ item.status | default('active') }}"
api_url: http://127.0.0.1:8086
api_token: "{{ influxdb_api_token }}"
state: "{{ item.state | default('present') }}"
loop: "{{ influxdb_authorizations }}"
loop_control:
label: "{{ item.org }}/{{ item.user }}"
tags: influxdb