Add influxdb role
This commit is contained in:
parent
1f5d2f6238
commit
d0f3d828df
2
roles/influxdb/files/config.toml
Normal file
2
roles/influxdb/files/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
reporting-disabled = true
|
||||
http-bind-address = "localhost:8087"
|
16
roles/influxdb/files/influxdb.initd
Normal file
16
roles/influxdb/files/influxdb.initd
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
command="influxd"
|
||||
command_background="yes"
|
||||
command_user="${command_user:-influxdb:influxdb}"
|
||||
directory="${data_path:-/var/lib/influxdb}"
|
||||
pidfile="/run/$RC_SVCNAME.pid"
|
||||
start_stop_daemon_args="--stdout-logger /usr/bin/logger"
|
||||
|
||||
depend() {
|
||||
use logger
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
checkpath -d -o "$command_user" -m755 "${data_path:-/var/lib/influxdb}"
|
||||
}
|
11
roles/influxdb/handlers/main.yml
Normal file
11
roles/influxdb/handlers/main.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
- name: restart influxdb
|
||||
service:
|
||||
name: influxdb
|
||||
state: restarted
|
||||
when: "'handler' not in ansible_skip_tags"
|
||||
|
||||
- name: reload nginx
|
||||
service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
when: "'handler' not in ansible_skip_tags"
|
48
roles/influxdb/tasks/main.yml
Normal file
48
roles/influxdb/tasks/main.yml
Normal file
|
@ -0,0 +1,48 @@
|
|||
- name: Create influxdb group
|
||||
group:
|
||||
name: influxdb
|
||||
system: yes
|
||||
|
||||
- name: Create influxdb user
|
||||
user:
|
||||
name: influxdb
|
||||
system: yes
|
||||
home: /var/lib/influxdb
|
||||
shell: /sbin/nologin
|
||||
|
||||
- name: Install tar
|
||||
package:
|
||||
name: tar
|
||||
|
||||
- name: Install influxdb
|
||||
unarchive:
|
||||
src: https://download.influxdata.com/influxdb/releases/influxdb2-{{ influxdb_version }}_linux_amd64.tar.gz
|
||||
dest: /
|
||||
remote_src: yes
|
||||
extra_opts:
|
||||
- '--strip-components=1'
|
||||
notify: restart influxdb
|
||||
|
||||
- name: Install influxdb initscript
|
||||
copy:
|
||||
dest: /etc/init.d/influxdb
|
||||
src: influxdb.initd
|
||||
mode: 0755
|
||||
notify: restart influxdb
|
||||
|
||||
- name: Configure influxdb
|
||||
copy:
|
||||
dest: /var/lib/influxdb/
|
||||
src: config.toml
|
||||
|
||||
- name: Set up nginx site
|
||||
template:
|
||||
dest: '/etc/nginx/http.d/influxdb.conf'
|
||||
src: 'nginx.conf.j2'
|
||||
notify: reload nginx
|
||||
|
||||
- name: Enable influxdb
|
||||
service:
|
||||
name: influxdb
|
||||
enabled: yes
|
||||
state: started
|
12
roles/influxdb/templates/nginx.conf.j2
Normal file
12
roles/influxdb/templates/nginx.conf.j2
Normal file
|
@ -0,0 +1,12 @@
|
|||
server {
|
||||
listen 8086 ssl;
|
||||
listen [::]:8086 ssl;
|
||||
server_name {{ dns_name }};
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/{{ dns_name }}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/{{ dns_name }}/privkey.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8087;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue