2022-05-06 19:16:15 +02:00
|
|
|
---
|
2022-05-07 19:56:56 +02:00
|
|
|
- name: Manage the Influxdata repository and packages
|
|
|
|
block:
|
|
|
|
- name: Install the deb repo key
|
|
|
|
apt_key:
|
|
|
|
url: '{{ influxdb_repo_key }}'
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Install the deb repository
|
|
|
|
apt_repository:
|
|
|
|
repo: '{{ influxdb_deb_repo }}'
|
|
|
|
state: present
|
|
|
|
update_cache: true
|
|
|
|
|
|
|
|
- name: Install the influxdb deb package
|
|
|
|
apt:
|
|
|
|
pkg: '{{ influxdb_pkgs }}'
|
|
|
|
state: present
|
|
|
|
cache_valid_time: 1800
|
|
|
|
|
|
|
|
when: ansible_distribution_file_variety == "Debian"
|
|
|
|
tags: ['influxdb', 'influxdb_repository']
|
|
|
|
|
2022-05-08 15:12:53 +02:00
|
|
|
- name: Manage the Influxd configuration
|
|
|
|
block:
|
2022-05-09 12:00:13 +02:00
|
|
|
- name: Influxdb 1.x configuration {{ influxdb_config_file }}
|
2022-05-08 15:12:53 +02:00
|
|
|
ini_file:
|
|
|
|
path: '{{ influxdb_config_file }}'
|
|
|
|
section: '{{ item.section }}'
|
|
|
|
option: '{{ item.option }}'
|
|
|
|
value: '{{ item.value }}'
|
|
|
|
state: "{{ item.state | default('present') }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
loop: '{{ influxdb_config }}'
|
2022-05-08 15:18:16 +02:00
|
|
|
notify: restart influxdb
|
2022-05-09 12:00:13 +02:00
|
|
|
when: influxdb_major_version < 2
|
|
|
|
|
|
|
|
- name: Influxdb 2+ configuration {{ influxdb_2_config_file }}
|
|
|
|
lineinfile:
|
|
|
|
path: '{{ influxdb_2_config_file }}'
|
|
|
|
regexp: '^{{ item.option }}\s'
|
|
|
|
line: '{{ item.option }} = "{{ item.value }}"'
|
|
|
|
state: "{{ item.state | default('present') }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
create: true
|
|
|
|
loop: '{{ influxdb_2_config }}'
|
|
|
|
notify: restart influxdb
|
|
|
|
when: influxdb_major_version < 2
|
2022-05-08 15:12:53 +02:00
|
|
|
|
|
|
|
tags: ['influxdb', 'influxdb_config']
|
|
|
|
|
|
|
|
- name: Letsencrypt tls management
|
|
|
|
block:
|
|
|
|
- name: Create the acme hooks directory if it does not yet exist
|
|
|
|
file:
|
|
|
|
dest: '{{ letsencrypt_acme_services_scripts_dir }}'
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
|
|
|
- name: Create the influxdb certificate directory
|
|
|
|
file:
|
|
|
|
dest: '{{ influxdb_tls_cert_dir }}'
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: influxdb
|
|
|
|
mode: 0750
|
|
|
|
|
|
|
|
- name: Copy the key file where influxdb expects it
|
|
|
|
copy:
|
|
|
|
src: '{{ letsencrypt_acme_sh_certificates_install_path }}/privkey'
|
|
|
|
dest: '{{ influxdb_tls_key_path }}'
|
|
|
|
owner: root
|
|
|
|
group: influxdb
|
|
|
|
mode: 0640
|
|
|
|
remote_src: true
|
|
|
|
notify: restart influxdb
|
|
|
|
|
2022-05-09 12:00:13 +02:00
|
|
|
- name: Influxdb 1.x configuration for TLS {{ influxdb_config_file }}
|
2022-05-08 15:12:53 +02:00
|
|
|
ini_file:
|
|
|
|
path: '{{ influxdb_config_file }}'
|
|
|
|
section: '{{ item.section }}'
|
|
|
|
option: '{{ item.option }}'
|
|
|
|
value: '{{ item.value }}'
|
|
|
|
state: "{{ item.state | default('present') }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
loop: '{{ influxdb_tls_config }}'
|
|
|
|
notify: restart influxdb
|
2022-05-09 12:00:13 +02:00
|
|
|
when: influxdb_major_version < 2
|
|
|
|
|
|
|
|
- name: Influxdb 2+ configuration for TLS {{ influxdb_2_config_file }}
|
|
|
|
lineinfile:
|
|
|
|
path: '{{ influxdb_2_config_file }}'
|
|
|
|
regexp: '^{{ item.option }}\s'
|
|
|
|
line: '{{ item.option }} = "{{ item.value }}"'
|
|
|
|
state: "{{ item.state | default('present') }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
create: true
|
|
|
|
loop: '{{ influxdb_2_tls_config }}'
|
|
|
|
notify: restart influxdb
|
|
|
|
when: influxdb_major_version < 2
|
2022-05-08 15:12:53 +02:00
|
|
|
|
|
|
|
- name: Install a script that fixes the letsencrypt certificate for influxdb and then restarts the service
|
|
|
|
template:
|
|
|
|
src: influxdb-letsencrypt-hook.j2
|
|
|
|
dest: '{{ letsencrypt_acme_services_scripts_dir }}/influxdb'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 4555
|
|
|
|
|
|
|
|
when:
|
|
|
|
- influxdb_tls_enabled
|
|
|
|
- influxdb_tls_letsencrypt_managed
|
|
|
|
- letsencrypt_acme_install
|
|
|
|
tags: ['influxdb', 'letsencrypt', 'influxdb_letsencrypt']
|
|
|
|
|
2022-05-07 19:56:56 +02:00
|
|
|
- name: Manage the Influxdata repository and packages
|
|
|
|
block:
|
|
|
|
- name: Ensure that influxdb is enabled and running
|
|
|
|
service:
|
2023-02-10 13:07:19 +01:00
|
|
|
name: influxd
|
2022-05-07 19:56:56 +02:00
|
|
|
state: started
|
|
|
|
enabled: true
|
|
|
|
|
|
|
|
tags: ['influxdb', 'influxdb_repository']
|