Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RANGER-4221: Enable File Sync Source for Ranger Usersync in Docker #251

Merged
merged 4 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
RANGER-4221: Enable File Sync Source for Ranger Usersync in Docker
  • Loading branch information
abhishek-kumar committed May 4, 2023
commit cdf8d97d543e65cfba911b9781c4376fc9f130f3
4 changes: 4 additions & 0 deletions dev-support/ranger-docker/Dockerfile.ranger-usersync
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ COPY ./dist/ranger-${RANGER_VERSION}-usersync.tar.gz /home/ranger/dist/

COPY ./scripts/ranger-usersync.sh ${RANGER_SCRIPTS}/
COPY ./scripts/ranger-usersync-install.properties ${RANGER_SCRIPTS}/
COPY ./scripts/ugsync-file-source.csv ${RANGER_SCRIPTS}/

#Install xmlstarlet
RUN apt-get -y install xmlstarlet

RUN tar xvfz /home/ranger/dist/ranger-${RANGER_VERSION}-usersync.tar.gz --directory=${RANGER_HOME} && \
ln -s ${RANGER_HOME}/ranger-${RANGER_VERSION}-usersync ${RANGER_HOME}/usersync && \
Expand Down
5 changes: 3 additions & 2 deletions dev-support/ranger-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,16 @@ Docker files in this folder create docker images and run them to build Apache Ra
~~~
docker-compose -f docker-compose.ranger-base.yml build --no-cache
~~~
7. To enable file based sync source for usersync execute: ```export ENABLE_FILE_SYNC_SOURCE=true```

7. Execute following command to start Ranger, Ranger enabled HDFS/YARN/HBase/Hive/Kafka/Knox and dependent services (Solr, DB) in containers:
8. Execute following command to start Ranger, Ranger enabled HDFS/YARN/HBase/Hive/Kafka/Knox and dependent services (Solr, DB) in containers:
~~~
docker-compose -f docker-compose.ranger-base.yml -f docker-compose.ranger.yml -f docker-compose.ranger-${RANGER_DB_TYPE}.yml -f docker-compose.ranger-usersync.yml -f docker-compose.ranger-tagsync.yml -f docker-compose.ranger-kms.yml -f docker-compose.ranger-hadoop.yml -f docker-compose.ranger-hbase.yml -f docker-compose.ranger-kafka.yml -f docker-compose.ranger-hive.yml -f docker-compose.ranger-knox.yml up -d
~~~

- valid values for RANGER_DB_TYPE: mysql or postgres

8. To rebuild specific images and start containers with the new image, use following command:
9. To rebuild specific images and start containers with the new image, use following command:
~~~
docker-compose -f docker-compose.ranger-base.yml -f docker-compose.ranger.yml -f docker-compose.ranger-usersync.yml -f docker-compose.ranger-tagsync.yml -f docker-compose.ranger-kms.yml -f docker-compose.ranger-hadoop.yml -f docker-compose.ranger-hbase.yml -f docker-compose.ranger-kafka.yml -f docker-compose.ranger-hive.yml -f docker-compose.ranger-knox.yml up -d --no-deps --force-recreate --build <service-1> <service-2>
~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
condition: service_started
environment:
- RANGER_VERSION
- ENABLE_FILE_SYNC_SOURCE

networks:
ranger:
Expand Down
9 changes: 9 additions & 0 deletions dev-support/ranger-docker/scripts/ranger-usersync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ then
fi
fi

if [ "${ENABLE_FILE_SYNC_SOURCE}" == "true" ]
then
# shellcheck disable=SC2164
cd "${RANGER_HOME}"/usersync/conf
xmlstarlet ed -u "//property[name='ranger.usersync.source.impl.class']/value" -v "org.apache.ranger.unixusersync.process.FileSourceUserGroupBuilder" ranger-ugsync-site.xml > temp.xml
mv temp.xml ranger-ugsync-site.xml
xmlstarlet ed -L -s "//configuration" -t elem -n "property" -s "//property[last()]" -t elem -n "name" -v "ranger.usersync.filesource.file" -s "//property[last()]" -t elem -n "value" -v "${RANGER_SCRIPTS}/ugsync-file-source.csv" ranger-ugsync-site.xml
fi

cd ${RANGER_HOME}/usersync && ./start.sh

RANGER_USERSYNC_PID=`ps -ef | grep -v grep | grep -i "org.apache.ranger.authentication.UnixAuthenticationService" | awk '{print $2}'`
Expand Down
10 changes: 10 additions & 0 deletions dev-support/ranger-docker/scripts/ugsync-file-source.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
testuser_1,testgroup_1A,testgroup_1B,testgroup_3A,testgroup_3B,
testuser_2,testgroup_2A,testgroup_2B,testgroup_3A,testgroup_3B,
testuser_3,testgroup_3A,testgroup_3B,testgroup_3A,testgroup_3B,
testuser_4,testgroup_4A,testgroup_4B,testgroup_3A,testgroup_3B,
testuser_5,testgroup_5A,testgroup_5B,testgroup_3A,testgroup_3B,
testuser_6,testgroup_6A,testgroup_6B,testgroup_3A,testgroup_3B,
testuser_7,testgroup_7A,testgroup_7B,testgroup_3A,testgroup_3B,
testuser_8,testgroup_8A,testgroup_8B,testgroup_3A,testgroup_3B,
testuser_9,testgroup_9A,testgroup_9B,testgroup_3A,testgroup_3B,
testuser_10,testgroup_10A,testgroup_10B,testgroup_3A,testgroup_3B,