Use alerta user permissions

This commit is contained in:
Luke Murphy 2020-04-16 13:04:19 +02:00
parent 2b0cab6145
commit 543233b381
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 7 additions and 23 deletions

View File

@ -14,6 +14,9 @@ vars:
smtp_port: "587" smtp_port: "587"
smtp_starttls: "True" smtp_starttls: "True"
smtp_username: "alerta-noreply" smtp_username: "alerta-noreply"
alerta_user_gid: "0"
# See https://github.com/alerta/docker-alerta/blob/858fa5f799835e0b62dd98e6859faf201b146e9e/Dockerfile#L78
alerta_user_uid: "1001"
dirs: dirs:
- path: /var/lib/alerta/ - path: /var/lib/alerta/
@ -26,15 +29,15 @@ db:
files: files:
- src: email.tmpl - src: email.tmpl
dest: /var/lib/alerta/email.tmpl dest: /var/lib/alerta/email.tmpl
owner: "{{ vars.docker_user_uid }}" owner: "{{ vars.alerta_user_uid }}"
group: "{{ vars.docker_user_gid }}" group: "{{ vars.alerta_user_gid }}"
mode: "664" mode: "664"
templates: templates:
- src: config.json - src: config.json
dest: /var/lib/alerta/config.json dest: /var/lib/alerta/config.json
owner: "{{ vars.docker_user_uid }}" owner: "{{ vars.alerta_user_uid }}"
group: "{{ vars.docker_user_gid }}" group: "{{ vars.alerta_user_gid }}"
mode: "664" mode: "664"
- src: alerta.conf - src: alerta.conf
dest: /var/lib/alerta/alerta.conf dest: /var/lib/alerta/alerta.conf

View File

@ -1,19 +0,0 @@
---
- name: Get uid/guid of the Docker user
become: true
getent:
database: passwd
key: docker
split: ":"
- name: Prepare docker user information dictionary
set_fact:
docker_user_info:
{
"docker_user_uid": "{{ getent_passwd['docker'][1] }}",
"docker_user_gid": "{{ getent_passwd['docker'][2] }}",
}
- name: Store docker user uid/guid in config.vars dictionary
set_fact:
config: "{{ config | update_vars(docker_user_info) }}"