ansible/roles/influxdb/tasks/main.yml

76 lines
1.7 KiB
YAML

---
- name: Enable repository
ansible.builtin.yum_repository:
name: influxdb
baseurl: https://repos.influxdata.com/rhel/$releasever/$basearch/stable
description: InfluxDB
gpgcheck: true
gpgkey: https://repos.influxdata.com/influxdb.key
enabled: true
- name: Install packages
ansible.builtin.package:
name: "{{ item }}"
state: present
with_items:
- influxdb2
- influxdb2-cli
# https://github.com/influxdata/influxdb/issues/22435
- name: Fix logrotate errors
ansible.builtin.file:
path: /etc/logrotate.d/influxdb
state: file
mode: 0644
owner: root
group: "{{ ansible_wheel }}"
- name: Create data directory
ansible.builtin.file:
path: /export/influxdb
state: directory
mode: 0755
owner: influxdb
group: influxdb
- name: Link data directory
ansible.builtin.file:
path: /srv/influxdb
src: /export/influxdb
state: link
owner: root
group: "{{ ansible_wheel }}"
follow: false
- name: Create config.toml
ansible.builtin.copy:
dest: /etc/influxdb/config.toml
src: config.toml
mode: 0644
owner: root
group: "{{ ansible_wheel }}"
notify: Restart influxdb
- name: Enable service
ansible.builtin.service:
name: influxdb
state: started
enabled: true
- name: Allow nginx to connect influxdb
seboolean:
name: httpd_can_network_connect
state: true
persistent: true
- name: Create nginx config
copy:
dest: "/etc/nginx/conf.d/{{ inventory_hostname }}/influxdb.conf"
content: |
location / {
proxy_pass http://127.0.0.1:8086/;
}
mode: 0644
owner: root
group: "{{ ansible_wheel }}"
notify: Restart nginx