Skip to content

Commit 95f06c4

Browse files
authored
RANGER-5455: Move Kerberos related scripts to base image (#7)
1 parent de9303f commit 95f06c4

3 files changed

Lines changed: 74 additions & 3 deletions

File tree

docker/Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,22 @@ ENV RANGER_HOME=/opt/ranger
4848
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
4949

5050
# create directories and setup perms
51-
RUN mkdir -p /home/ranger/dist /home/ranger/scripts /opt/ranger && \
52-
chmod +rx /home/ranger /home/ranger/dist /home/ranger/scripts
51+
RUN mkdir -p ${RANGER_DIST} ${RANGER_SCRIPTS} ${RANGER_HOME} && \
52+
chmod +rx /home/ranger ${RANGER_DIST} ${RANGER_SCRIPTS}
5353

5454
# setup groups and users
5555
COPY docker/create_users_and_groups.sh ${RANGER_SCRIPTS}
5656
RUN chmod +x /home/ranger/scripts/create_users_and_groups.sh && \
57-
./home/ranger/scripts/create_users_and_groups.sh
57+
/home/ranger/scripts/create_users_and_groups.sh
58+
59+
# Create opensearch user and group
60+
RUN groupadd -g 3002 opensearch && \
61+
useradd -u 3002 -g opensearch -G hadoop -s /bin/bash opensearch
62+
63+
# copy kerberos utility scripts
64+
COPY docker/krb/* ${RANGER_SCRIPTS}
65+
RUN chmod 755 ${RANGER_SCRIPTS}/wait_for_keytab.sh && \
66+
chmod 755 ${RANGER_SCRIPTS}/wait_for_testusers_keytab.sh
5867

5968
# change ownerships
6069
RUN chown -R ranger:ranger /home/ranger /opt/ranger

docker/krb/wait_for_keytab.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
RETRY_COUNT="${KEYTAB_RETRY_COUNT:-5}"
20+
KEYTABS_DIR=/etc/keytabs
21+
22+
KEYTAB=${KEYTABS_DIR}/$1
23+
24+
for i in {1..RETRY_COUNT}; do
25+
if [ -f ${KEYTAB} ]
26+
then
27+
break
28+
else
29+
echo [INFO] "Waiting for keytab ${KEYTAB}.."
30+
sleep 5
31+
fi
32+
done
33+
34+
if [ -f ${KEYTAB} ]
35+
then
36+
echo "[INFO] Found keytab ${KEYTAB}"
37+
exit 0
38+
else
39+
echo "[ERROR] Keytab not found: ${KEYTAB}"
40+
exit 1
41+
fi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
${RANGER_SCRIPTS}/wait_for_keytab.sh testuser1.keytab
20+
${RANGER_SCRIPTS}/wait_for_keytab.sh testuser2.keytab
21+
${RANGER_SCRIPTS}/wait_for_keytab.sh testuser3.keytab

0 commit comments

Comments
 (0)