77 lines
2.3 KiB
YAML
77 lines
2.3 KiB
YAML
- name: run influxdb in docker container
|
|
docker_container:
|
|
name: ed-influxdb
|
|
image: influxdb
|
|
hostname: "{{influx_hostname}}"
|
|
domainname: "{{influx_domainname}}"
|
|
networks:
|
|
- name: "{{ docker_network }}"
|
|
published_ports:
|
|
- "{{influx_pubport}}:8086"
|
|
volumes:
|
|
- "ed-influxdb-data:/var/lib/influxdb2"
|
|
- "ed-influxdb-config:/etc/influxdb2"
|
|
- "/container/volumes/influxdb-backup/:/backup"
|
|
env:
|
|
DOCKER_INFLUXDB_INIT_MODE: setup
|
|
DOCKER_INFLUXDB_INIT_USERNAME: "{{influx_admin_user}}"
|
|
DOCKER_INFLUXDB_INIT_PASSWORD: "{{influx_admin_pw}}"
|
|
DOCKER_INFLUXDB_INIT_ORG: "{{influx_org}}"
|
|
DOCKER_INFLUXDB_INIT_BUCKET: my-bucket
|
|
state: started
|
|
detach: True
|
|
cleanup: True
|
|
networks_cli_compatible: True
|
|
|
|
- name: add ansible connection to influxdb container
|
|
add_host:
|
|
name: ed-influxdb
|
|
ansible_connection: docker
|
|
ansible_docker_extra_args: "-H=ssh://{{ansible_host}}"
|
|
changed_when: False
|
|
|
|
- name: wait for influx to run
|
|
raw: until curl http://localhost:8086 ; do sleep 1 ; done
|
|
changed_when: False
|
|
delegate_to: ed-influxdb
|
|
|
|
- name: fetch influxdb auth token
|
|
raw: influx auth list --user my-user --hide-headers --json
|
|
register: influx_token_fetch
|
|
changed_when: False
|
|
delegate_to: ed-influxdb
|
|
|
|
- name: set influxdb admin token
|
|
set_fact:
|
|
influx_admin_token:
|
|
"{{(influx_token_fetch.stdout | from_json | first).token}}"
|
|
|
|
- name: create influxdb bucket for cobald
|
|
influx_bucket:
|
|
base: "http://localhost:{{influx_pubport}}"
|
|
org: "my-org"
|
|
auth_token: "{{influx_admin_token}}"
|
|
name: "{{influx_bucket}}"
|
|
|
|
- name: create influxdb dashboard
|
|
influx_dashboard:
|
|
base: "http://localhost:{{influx_pubport}}"
|
|
org: "my-org"
|
|
auth_token: "{{influx_admin_token}}"
|
|
data: "{{lookup('file', 'influxdb-dashboard-cobald.json')}}"
|
|
when: influxdb_dashboard | default(True)
|
|
|
|
- name: create influxdb write access token for telegraf
|
|
influx_token:
|
|
base: "http://localhost:{{influx_pubport}}"
|
|
org: "my-org"
|
|
auth_token: "{{influx_admin_token}}"
|
|
description: cobald tardis telegraf monitoring plugin
|
|
key: telegraf_cobaldtardis
|
|
permissions:
|
|
- action: write
|
|
resource:
|
|
type: buckets
|
|
name: "{{influx_bucket}}"
|
|
register: influx_telegraf_token
|