Skip to content

Commit

Permalink
RANGER-4221: Enable File Sync Source for Ranger Usersync in Docker (#251
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kumaab authored May 5, 2023
1 parent bd4e82c commit 9f1dc5b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
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
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,
8 changes: 8 additions & 0 deletions unixauthservice/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ else
fi

./setup.py

if [ "${ENABLE_FILE_SYNC_SOURCE}" == "true" ]
then
# shellcheck disable=SC2164
cd "${RANGER_HOME}"/usersync/conf
xmlstarlet ed -L -u "//property[name='ranger.usersync.source.impl.class']/value" -v "org.apache.ranger.unixusersync.process.FileSourceUserGroupBuilder" 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

0 comments on commit 9f1dc5b

Please sign in to comment.