UID and GID need user to exist first

This commit is contained in:
Wojciech Kozlowski 2022-11-20 15:09:34 +01:00
parent 459e561a24
commit 260bc71939
3 changed files with 16 additions and 12 deletions

View File

@ -1,4 +1,5 @@
- block:
- import_tasks: ../vars.yml
- import_tasks: ../vars-user.yml
- import_tasks: service-deploy/service.yml
tags: "{{ service_name }}"

View File

@ -0,0 +1,15 @@
- name: Get user info
getent:
database: passwd
key: "{{ service_user_name }}"
- name: Set service variables
set_fact:
service_user_uid: "{{ ansible_facts.getent_passwd[service_user_name].1 }}"
service_user_gid: "{{ ansible_facts.getent_passwd[service_user_name].2 }}"
- name: Print service variables
debug:
msg:
- "service_user_uid: {{ service_user_uid }}"
- "service_user_gid: {{ service_user_gid }}"

View File

@ -10,22 +10,10 @@
set_fact:
local_service_home: "./filesystem/{{ ansible_hostname }}/{{ service_home }}"
- name: Get user info
getent:
database: passwd
key: "{{ service_user_name }}"
- name: Set service variables
set_fact:
service_user_uid: "{{ ansible_facts.getent_passwd[service_user_name].1 }}"
service_user_gid: "{{ ansible_facts.getent_passwd[service_user_name].2 }}"
- name: Print service variables
debug:
msg:
- "service_name: {{ service_name }}"
- "service_user_name: {{ service_user_name }}"
- "service_user_uid: {{ service_user_uid }}"
- "service_user_gid: {{ service_user_gid }}"
- "service_home: {{ service_home }}"
- "local_service_home: {{ local_service_home }}"