Bootstrap influx role

This commit is contained in:
Wilfried OLLIVIER 2019-07-10 17:11:36 +02:00
commit d182651637
13 changed files with 1917 additions and 0 deletions

33
tasks/admin.yml Normal file
View file

@ -0,0 +1,33 @@
---
- name: Push influxdb config, with auth disable, for admin setup
template:
src: influxdb.admin.conf.j2
dest: /etc/influxdb/influxdb.conf
notify: reload influxdb
register: conf
- name: Reload influxdb, with auth disable, for admin setup
service:
name: influxdb
state: restarted
when: conf.changed
- name: Ensure Influx is up
uri:
url: http://localhost:{{ influx_port }}
status: 204
retries: 3
delay: 2
ignore_errors: true
- name: Ensure admin user
influxdb_user:
user_name: "{{ admin_name }}"
user_password: "{{ admin_pass }}"
admin: yes
- name: Leave a trace of admin setup
file:
path: /etc/influxdb/admin
state: touch

57
tasks/main.yml Normal file
View file

@ -0,0 +1,57 @@
---
# https://www.influxdata.com/blog/deploying-influxdb-with-ansible/
- name: Ensure apt-transport-https
apt:
name: apt-transport-https
state: present
update_cache: yes
- name: Ensure python dependencies
apt:
name: [ 'python-requests', 'python-pip' ]
state: present
- name: Ensure python-influxdb
pip:
name: influxdb
state: present
- name: Ensure Influx Data signing key
apt_key:
url: "{{ influx.repo }}"
state: present
- name: Ensure Influx Data repo
apt_repository:
repo: deb https://repos.influxdata.com/debian {{ ansible_distribution_release }} stable
state: present
filename: influxdata
- name: Ensure Influx pkg
apt:
name: influxdb
state: present
update_cache: yes
- name: Ensure influx is started and enabled
systemd:
name: influxdb
state: started
enabled: yes
- name: Check if admin user is created
stat:
path: /etc/influxdb/admin
register: admin
- name: Create admin user
import_tasks: admin.yml
when: admin.stat.exists == False
- name: Push influxdb config, with auth enable
template:
src: influxdb.conf.j2
dest: /etc/influxdb/influxdb.conf
notify: reload influxdb