From 58eee09c15dea81ec51bb366af23681de70ceaa1 Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Sun, 18 Dec 2016 19:11:47 +0000 Subject: use static uid/gid in images This centralizes all user and group creation into a single source. This will fix any current and furture uid/gid mismatches (such as with nova-libvirt). In the process, we also unify users between the distros in a standard way. The users in the following containers change from thier defaults: Ubuntu: _chrony user is now chrony Ubuntu: memcache user is now memcached All: qemu user is used for ownership and socket permissions All uid and gid numbers are customizable via kolla-build.conf Co-Authored-By: Kris Lindgren Change-Id: I120f26ab0683dc87d69727c3df8d4707e52a4543 Partially-Implements: blueprint static-uid-gid --- kolla/image/build.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'kolla/image') diff --git a/kolla/image/build.py b/kolla/image/build.py index 35029f198..8760b46cb 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -631,6 +631,20 @@ class KollaWorker(object): 'debian_package_install': jinja_methods.debian_package_install, } + def get_users(self): + all_sections = (set(six.iterkeys(self.conf._groups)) | + set(self.conf.list_all_sections())) + ret = dict() + for section in all_sections: + match = re.search('^.*-user$', section) + if match: + user = self.conf[match.group(0)] + ret[match.group(0)[:-5]] = { + 'uid': user.uid, + 'gid': user.gid, + } + return ret + def create_dockerfiles(self): kolla_version = version.version_info.cached_version_string() supported_distro_release = common_config.DISTRO_RELEASE.get( @@ -650,6 +664,7 @@ class KollaWorker(object): 'maintainer': self.maintainer, 'kolla_version': kolla_version, 'image_name': image_name, + 'users': self.get_users(), 'rpm_setup': self.rpm_setup} env = jinja2.Environment( # nosec: not used to render HTML loader=jinja2.FileSystemLoader(self.working_dir)) -- cgit v1.2.3