aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Juszkiewicz <marcin@juszkiewicz.com.pl>2017-11-13 14:48:29 +0000
committerMarcin Juszkiewicz <marcin@juszkiewicz.com.pl>2017-12-14 11:24:52 +0000
commitb6162f9f1691a992999ff07d0063e4431ae52b68 (patch)
tree2358fb20368e499420699f22702b86adc315424e
parent3a5503f83c22be867f74a8d131d6ed91ea54e7b1 (diff)
downloadkolla-b6162f9f1691a992999ff07d0063e4431ae52b68.tar.gz
kolla-b6162f9f1691a992999ff07d0063e4431ae52b68.zip
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
-rw-r--r--docker/macros.j229
-rw-r--r--docker/mongodb/Dockerfile.j25
2 files changed, 23 insertions, 11 deletions
diff --git a/docker/macros.j2 b/docker/macros.j2
index dfb85447b..616172ea6 100644
--- a/docker/macros.j2
+++ b/docker/macros.j2
@@ -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() %}
diff --git a/docker/mongodb/Dockerfile.j2 b/docker/mongodb/Dockerfile.j2
index 73d6f265e..cf842f615 100644
--- a/docker/mongodb/Dockerfile.j2
+++ b/docker/mongodb/Dockerfile.j2
@@ -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