ansible-infra/ansible_collections/debops/debops/roles/influxdb_server/tasks/main.yml
Stefan Bethke 2aed20393f
Some checks failed
/ Ansible Lint (push) Failing after 5m45s
/ Ansible Lint (pull_request) Failing after 4m59s
Vendor Galaxy Roles and Collections
2026-02-06 22:07:16 +01:00

127 lines
4 KiB
YAML

---
# Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
# Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
# Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
# Copyright (C) 2020 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Import custom Ansible plugins
ansible.builtin.import_role:
name: 'ansible_plugins'
- name: Import DebOps global handlers
ansible.builtin.import_role:
name: 'global_handlers'
- name: Import DebOps secret role
ansible.builtin.import_role:
name: 'secret'
- name: Restart database server on first install (influx bug)
ansible.builtin.service:
name: 'influxdb'
state: 'restarted'
when: not (ansible_local.influxdb_server.installed | d(false) | bool)
- name: Wait for HTTP endpoint port to become open on the host on first install
ansible.builtin.wait_for:
port: '{{ influxdb_server__port }}'
when: not (ansible_local.influxdb_server.installed | d(false) | bool)
- name: Create default admin user on first install
community.general.influxdb_user:
user_name: 'root'
user_password: '{{ influxdb_server__root_password }}'
state: 'present'
admin: 'yes'
proxies:
http:
https:
when: not (ansible_local.influxdb_server.installed | d(false) | bool)
no_log: '{{ debops__no_log | d(True) }}'
- name: Stop database server on first install
ansible.builtin.service:
name: 'influxdb'
state: 'stopped'
when: not (ansible_local.influxdb_server.installed | d(false) | bool)
- name: Add InfluxDB server user to specified groups
ansible.builtin.user:
name: 'influxdb'
groups: '{{ influxdb_server__append_groups | join(",") | default(omit) }}'
append: True
createhome: False
when: influxdb_server__pki | bool
- name: Ensure InfluxDB server directory exists
ansible.builtin.file:
path: '{{ influxdb_server__directory }}'
state: 'directory'
owner: 'influxdb'
group: 'influxdb'
mode: '0750'
- name: Move InfluxDB data files to data directory
ansible.builtin.shell:
'mv {{ influxdb_server__default_directory }}/* {{ influxdb_server__directory }}'
register: influxdb_server__register_move
changed_when: influxdb_server__register_move.changed | bool
when: (not (ansible_local.influxdb_server.installed | d(false) | bool) and
influxdb_server__directory != influxdb_server__default_directory)
- name: Divert the original influxdb configuration file
debops.debops.dpkg_divert:
path: '/etc/influxdb/influxdb.conf'
state: 'present'
delete: True
tags: [ 'role::influxdb_server:config' ]
- name: Configure InfluxDB server
ansible.builtin.template:
src: 'etc/influxdb/influxdb.conf.j2'
dest: '/etc/influxdb/influxdb.conf'
owner: 'root'
group: 'root'
mode: '0644'
tags: [ 'role::influxdb_server:config' ]
notify: [ 'Restart influxdb' ]
- name: Start database server on first install
ansible.builtin.service:
name: 'influxdb'
state: 'started'
when: not (ansible_local.influxdb_server.installed | d(false) | bool)
- name: Configure autoinfluxdbbackup
ansible.builtin.include_tasks: 'autoinfluxdbbackup.yml'
when: influxdb_server__backup | bool
tags: [ 'role::influxdb_server:autoinfluxdbbackup' ]
- name: Make sure that Ansible local facts directory exists
ansible.builtin.file:
path: '/etc/ansible/facts.d'
state: 'directory'
mode: '0755'
- name: Save InfluxDB server local facts
ansible.builtin.template:
src: 'etc/ansible/facts.d/influxdb_server.fact.j2'
dest: '/etc/ansible/facts.d/influxdb_server.fact'
owner: 'root'
group: 'root'
mode: '0755'
notify: [ 'Refresh host facts' ]
tags: [ 'meta::facts' ]
- name: Save InfluxDB local facts
ansible.builtin.template:
src: 'etc/ansible/facts.d/influxdb.fact.j2'
dest: '/etc/ansible/facts.d/influxdb.fact'
owner: 'root'
group: 'root'
mode: '0644'
notify: [ 'Refresh host facts' ]
- name: Re-read local facts if they have been modified
ansible.builtin.meta: 'flush_handlers'