93 lines
2 KiB
YAML
93 lines
2 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/influxdata-archive.key
|
|
enabled: true
|
|
|
|
- name: Create group influxdb
|
|
ansible.builtin.group:
|
|
name: influxdb
|
|
gid: 301
|
|
system: true
|
|
|
|
- name: Create user influxdb
|
|
ansible.builtin.user:
|
|
name: influxdb
|
|
comment: Service InfluxDB
|
|
createhome: false
|
|
group: influxdb
|
|
home: /var/empty
|
|
shell: /sbin/nologin
|
|
system: true
|
|
uid: 301
|
|
|
|
- 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: "0750"
|
|
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
|
|
ansible.posix.seboolean:
|
|
name: httpd_can_network_connect
|
|
state: true
|
|
persistent: true
|
|
|
|
- name: Create nginx config
|
|
ansible.builtin.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
|