Config: allow to set group for user

According to recent IRC discussions is could be useful for haclient.
Partial-Bug: #1934753

Change-Id: I670fa84476e35e55cbed2d22e48836ed5e28495f
This commit is contained in:
Marcin Juszkiewicz 2021-07-28 09:25:45 +02:00 committed by Michal Arbet
parent ea6ceef686
commit 6568425017
4 changed files with 12 additions and 3 deletions

View File

@ -21,7 +21,7 @@ ENV LANG en_US.UTF-8
{# Specifics required such as homedir or shell are configured within the service specific image #}
{%- for name, user in users | dictsort() %}
{% if loop.first -%}RUN {% else %} && {% endif -%}
groupadd --force --gid {{ user.gid }} {{ name }} \
groupadd --force --gid {{ user.gid }} {{ user.group }} \
&& useradd -l -M --shell /usr/sbin/nologin --uid {{ user.uid }} --gid {{ user.gid }} {{ name }}
{%- if not loop.last %} \{% endif -%}
{%- endfor %}

View File

@ -954,10 +954,11 @@ def get_source_opts(type_=None, location=None, reference=None):
'or branch name'))]
def get_user_opts(uid, gid):
def get_user_opts(uid, gid, group):
return [
cfg.IntOpt('uid', default=uid, help='The user id'),
cfg.IntOpt('gid', default=gid, help='The group id'),
cfg.StrOpt('group', default=group, help='The group name'),
]
@ -965,7 +966,11 @@ def gen_all_user_opts():
for name, params in USERS.items():
uid = params['uid']
gid = params['gid']
yield name, get_user_opts(uid, gid)
try:
group = params['group']
except KeyError:
group = name[:-5]
yield name, get_user_opts(uid, gid, group)
def gen_all_source_opts():

View File

@ -852,6 +852,7 @@ class KollaWorker(object):
ret[match.group(0)[:-5]] = {
'uid': user.uid,
'gid': user.gid,
'group': user.group,
}
return ret

View File

@ -0,0 +1,3 @@
---
features:
- Allow to set group for user.