grafana-ansible-collection/roles/grafana_agent/tasks/install/user-group.yaml

39 lines
1.4 KiB
YAML
Raw Permalink Normal View History

2023-03-03 09:53:02 +01:00
---
2023-03-10 06:45:00 +01:00
- name: Grafana Agent group creation
2023-03-03 09:53:02 +01:00
block:
- name: "Check if the group exists ({{ grafana_agent_user_group }})"
ansible.builtin.getent:
database: group
key: "{{ grafana_agent_user_group }}"
fail_key: false
- name: Set whether not the user group exists
ansible.builtin.set_fact:
__grafana_agent_user_group_exists: "{{ ansible_facts.getent_group[grafana_agent_user_group] is not none }}"
- name: Add user group "{{ grafana_agent_user_group }}"
ansible.builtin.group:
name: "{{ grafana_agent_user_group }}"
system: true
state: present
when: not __grafana_agent_user_group_exists and grafana_agent_user_group != 'root'
2023-03-10 06:45:00 +01:00
- name: Grafana Agent user group exists
2023-03-03 09:53:02 +01:00
ansible.builtin.debug:
msg: |-
The user group \"{{ grafana_agent_user_group }}\" already exists and will not be modified,
if modifying permissions please perform a separate task
when: __grafana_agent_user_group_exists
2023-03-10 06:45:00 +01:00
- name: Grafana Agent user creation
2023-03-03 09:53:02 +01:00
block:
- name: Add user "{{ grafana_agent_user }}"
ansible.builtin.user:
name: "{{ grafana_agent_user }}"
comment: "Grafana Agent account"
2023-04-10 07:39:52 +02:00
groups: "{{ [ grafana_agent_user_group ] + grafana_agent_user_groups }}"
2023-03-03 09:53:02 +01:00
system: true
shell: "{{ grafana_agent_user_shell }}"
createhome: "{{ grafana_agent_user_createhome }}"
when: grafana_agent_user != 'root'