mongodb: handle "user already exists" error on Debian
When we install 'mongodb-server' package in Debian/stable it errors out because 'mongodb' user already exists. It was reported [1] and got resolved in Debian/testing. 1. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=858903 Change-Id: Iabfcbf68a3aea9d7b09b72eb3e8325f09c2f9d31
This commit is contained in:
parent
3a5503f83c
commit
b6162f9f16
@ -47,24 +47,31 @@ RUN usermod --append --home {{ homedir }} --groups kolla {{ name }} \
|
||||
&& chown -R {{ user.uid }}:{{ user.gid }} {{ homedir }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro debian_haproxy_existing_user_fix() %}
|
||||
{# NOTE(SamYaple): The postinst script breaks if the user 'haproxy' already exists #}
|
||||
{% macro debian_fix_existing_user(package, lines) %}
|
||||
RUN apt-get update \
|
||||
&& 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 -y install --no-install-recommends {{ package }} \
|
||||
|| sed -i '/adduser/,+{{ lines }} d' /var/lib/dpkg/info/{{ package }}.postinst \
|
||||
&& echo "configuring packages" \
|
||||
&& dpkg --configure -a \
|
||||
&& echo "done" \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
{% endmacro %}
|
||||
|
||||
{% macro debian_haproxy_existing_user_fix() %}
|
||||
{# NOTE(SamYaple): The postinst script breaks if the user 'haproxy' already exists #}
|
||||
{{ debian_fix_existing_user('haproxy', 1) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro debian_mongodb_existing_user_fix() %}
|
||||
{# NOTE(hrw): The postinst script breaks if the user 'mongodb' already exists #}
|
||||
{# TODO(hrw): Version in Debian 'testing' checks does user exists #}
|
||||
{{ debian_fix_existing_user('mongodb-server', 3) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro debian_opendaylight_existing_user_fix() %}
|
||||
{# NOTE(egonzalez): The postinst script breaks if the user 'odl' already exists #}
|
||||
RUN apt-get update \
|
||||
&& apt-get -y install --no-install-recommends opendaylight \
|
||||
|| sed -i '/^\s*adduser/,+1 d' /var/lib/dpkg/info/opendaylight.postinst \
|
||||
&& apt-get -y install -f \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
{{ debian_fix_existing_user('opendaylight', 1) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro install_kubectl() %}
|
||||
|
@ -18,6 +18,11 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
|
||||
] %}
|
||||
{% endif %}
|
||||
|
||||
{% if base_distro in ['debian'] %}
|
||||
{# NOTE(hrw) Ubuntu does not need that #}
|
||||
{{ macros.debian_mongodb_existing_user_fix() }}
|
||||
{% endif %}
|
||||
|
||||
{{ macros.install_packages(mongodb_packages | customizable("packages")) }}
|
||||
|
||||
COPY mongodb_sudoers /etc/sudoers.d/kolla_mongodb_sudoers
|
||||
|
Loading…
Reference in New Issue
Block a user