diff options
| author | Sam Yaple <sam@yaple.net> | 2016-12-18 19:11:47 +0000 |
|---|---|---|
| committer | Mauricio Lima <mauriciolimab@gmail.com> | 2017-01-17 09:02:21 -0300 |
| commit | 58eee09c15dea81ec51bb366af23681de70ceaa1 (patch) | |
| tree | e84ce37d18be555e80e9c895789615ec60a37b5b /docker/macros.j2 | |
| parent | 3671d860af55d88804740f0420d5bc7e5bb92bd9 (diff) | |
| download | kolla-58eee09c15dea81ec51bb366af23681de70ceaa1.tar.gz kolla-58eee09c15dea81ec51bb366af23681de70ceaa1.zip | |
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 <klindgren@godaddy.com>
Change-Id: I120f26ab0683dc87d69727c3df8d4707e52a4543
Partially-Implements: blueprint static-uid-gid
Diffstat (limited to 'docker/macros.j2')
| -rw-r--r-- | docker/macros.j2 | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/docker/macros.j2 b/docker/macros.j2 index 89ce4ec2d..b60b6eb97 100644 --- a/docker/macros.j2 +++ b/docker/macros.j2 @@ -17,3 +17,39 @@ {% macro install_pip(packages) %} RUN /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt {% for package in packages %}{{ package }} {% endfor %} {% endmacro %} + + +{% macro configure_user(name, groups=None, shell=None, homedir=None) %} +{% set user=users[name] %} +{%- if not homedir %} +{% set homedir='/var/lib/' + name %} +{%- endif %} +RUN usermod --append --home {{ homedir }} --groups kolla {{ name }} \ + {%- if groups %} + && usermod --append --groups {{ groups }} {{ name }} \ + {%- endif %} + {%- if shell %} + && chsh --shell {{ shell }} {{ name }} \ + {%- endif %} + && mkdir -p {{ homedir }} \ + && chown -R {{ user.uid }}:{{ user.gid }} {{ homedir }} +{% endmacro %} + + +{% macro ubuntu_trove_bug_1651852() %} +{# NOTE(SamYaple): The postinst script breaks because it calls getenv instead of getent #} +{# TODO(SamYaple): Remove once issue is fixed -- https://bugs.launchpad.net/ubuntu/+source/openstack-trove/+bug/1651852 #} +RUN apt-get -y install --no-install-recommends trove-common \ + || sed -i 's/getenv/getent/g' /var/lib/dpkg/info/trove-common.postinst \ + && apt-get -y install -f \ + && apt-get clean +{% endmacro %} + + +{% macro debian_haproxy_existing_user_fix() %} +{# NOTE(SamYaple): The postinst script breaks if the user 'haproxy' already exists #} +RUN apt-get -y install --no-install-recommends haproxy \ + || sed -i '/^adduser/,+1 d' /var/lib/dpkg/info/haproxy.postinst \ + && apt-get -y install -f \ + && apt-get clean +{% endmacro %} |
