Remove explicit user creation check (#46)
This commit is contained in:
parent
bd351c719e
commit
d321c5477d
@ -18,7 +18,7 @@
|
|||||||
- _grafana_agent_systemd_unit not in services
|
- _grafana_agent_systemd_unit not in services
|
||||||
|
|
||||||
# these tasks are ran in both install and configure, as directories could have changed
|
# these tasks are ran in both install and configure, as directories could have changed
|
||||||
- name: Configure Directories
|
- name: Configure directories
|
||||||
ansible.builtin.import_tasks: install/directories.yaml
|
ansible.builtin.import_tasks: install/directories.yaml
|
||||||
|
|
||||||
- name: Create a symbolic link
|
- name: Create a symbolic link
|
||||||
@ -29,7 +29,7 @@
|
|||||||
group: root
|
group: root
|
||||||
state: link
|
state: link
|
||||||
|
|
||||||
- name: Overwrite/Create Grafana Agent Service
|
- name: Overwrite/Create Grafana Agent service
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: grafana-agent.service.j2
|
src: grafana-agent.service.j2
|
||||||
dest: "{{ _grafana_agent_systemd_dir }}/{{ _grafana_agent_systemd_unit }}"
|
dest: "{{ _grafana_agent_systemd_dir }}/{{ _grafana_agent_systemd_unit }}"
|
||||||
@ -37,7 +37,7 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
|
||||||
- name: Create the Service Environment File
|
- name: Create the Service Environment file
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: EnvironmentFile.j2
|
src: EnvironmentFile.j2
|
||||||
dest: "{{ grafana_agent_config_dir }}/{{ grafana_agent_env_file }}"
|
dest: "{{ grafana_agent_config_dir }}/{{ grafana_agent_env_file }}"
|
||||||
@ -45,7 +45,7 @@
|
|||||||
group: "{{ grafana_agent_user_group }}"
|
group: "{{ grafana_agent_user_group }}"
|
||||||
mode: 0640
|
mode: 0640
|
||||||
|
|
||||||
- name: Create Grafana Agent Config
|
- name: Create Grafana Agent config
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: config.yaml.j2
|
src: config.yaml.j2
|
||||||
dest: "{{ grafana_agent_config_dir }}/{{ grafana_agent_config_filename }}"
|
dest: "{{ grafana_agent_config_dir }}/{{ grafana_agent_config_filename }}"
|
||||||
@ -55,7 +55,7 @@
|
|||||||
mode: 0640
|
mode: 0640
|
||||||
when: grafana_agent_provisioned_config_file | length == 0
|
when: grafana_agent_provisioned_config_file | length == 0
|
||||||
|
|
||||||
- name: Copy Grafana Agent Config
|
- name: Copy Grafana Agent config
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ grafana_agent_provisioned_config_file }}"
|
src: "{{ grafana_agent_provisioned_config_file }}"
|
||||||
dest: "{{ grafana_agent_config_dir }}/{{ grafana_agent_config_filename }}"
|
dest: "{{ grafana_agent_config_dir }}/{{ grafana_agent_config_filename }}"
|
||||||
|
@ -27,29 +27,12 @@
|
|||||||
|
|
||||||
- name: Grafana Agent user creation
|
- name: Grafana Agent user creation
|
||||||
block:
|
block:
|
||||||
- name: "Check if the user exists ({{ grafana_agent_user }})"
|
|
||||||
ansible.builtin.getent:
|
|
||||||
database: passwd
|
|
||||||
key: "{{ grafana_agent_user }}"
|
|
||||||
fail_key: false
|
|
||||||
|
|
||||||
- name: Set whether not the user exists
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
__grafana_agent_user_exists: "{{ ansible_facts.getent_passwd[grafana_agent_user] is not none }}"
|
|
||||||
|
|
||||||
- name: Add user "{{ grafana_agent_user }}"
|
- name: Add user "{{ grafana_agent_user }}"
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{ grafana_agent_user }}"
|
name: "{{ grafana_agent_user }}"
|
||||||
comment: "Grafana Agent Account"
|
comment: "Grafana Agent account"
|
||||||
groups: "{{ [ grafana_agent_user_group ] + grafana_agent_user_groups }}"
|
groups: "{{ [ grafana_agent_user_group ] + grafana_agent_user_groups }}"
|
||||||
system: true
|
system: true
|
||||||
shell: "{{ grafana_agent_user_shell }}"
|
shell: "{{ grafana_agent_user_shell }}"
|
||||||
createhome: "{{ grafana_agent_user_createhome }}"
|
createhome: "{{ grafana_agent_user_createhome }}"
|
||||||
when: not __grafana_agent_user_exists and grafana_agent_user != 'root'
|
when: grafana_agent_user != 'root'
|
||||||
|
|
||||||
- name: Grafana Agent user exists
|
|
||||||
ansible.builtin.debug:
|
|
||||||
msg: |-
|
|
||||||
The user \"{{ grafana_agent_user }}\" already exists and will not be modified,
|
|
||||||
if modifying permissions please perform a separate task
|
|
||||||
when: __grafana_agent_user_exists
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
grafana_agent_version: "{{ _grafana_agent_version_request.stdout }}"
|
grafana_agent_version: "{{ _grafana_agent_version_request.stdout }}"
|
||||||
|
|
||||||
- name: Grafana Agent Version to Download
|
- name: Grafana Agent version to download
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: grafana_agent_version
|
var: grafana_agent_version
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user