summaryrefslogtreecommitdiff
path: root/ee/lib
diff options
context:
space:
mode:
authorHarish Ramachandran <harish@gitlab.com>2019-07-19 17:40:41 -0400
committerHarish Ramachandran <harish@gitlab.com>2019-07-19 17:40:41 -0400
commitd4f9e951560934cddd954d6f0488735041351fb5 (patch)
treeb13395b576f61a201dc2855808351dbd0492a4da /ee/lib
parentf16f315dc3cfc9fc82571e6d3ef39922ca66ba7c (diff)
downloadgitlab-ce-d4f9e951560934cddd954d6f0488735041351fb5.tar.gz
Start a rake task to run a manual GroupSync
Diffstat (limited to 'ee/lib')
-rw-r--r--ee/lib/tasks/gitlab/ldap.rake29
1 files changed, 29 insertions, 0 deletions
diff --git a/ee/lib/tasks/gitlab/ldap.rake b/ee/lib/tasks/gitlab/ldap.rake
new file mode 100644
index 00000000000..41ccb7cbde7
--- /dev/null
+++ b/ee/lib/tasks/gitlab/ldap.rake
@@ -0,0 +1,29 @@
+namespace :gitlab do
+ namespace :ldap do
+ desc 'GitLab | LDAP | Run a GroupSync'
+ task :group_sync => :gitlab_environment do |_, args|
+ def execute
+ return unless group_sync_enabled?
+ group_sync
+ end
+
+ def group_sync
+ $stdout.puts 'Starting GroupSync...'
+ EE::Gitlab::Auth::LDAP::Sync::Groups.execute
+ $stdout.puts 'Finished GroupSync.'
+ rescue => e
+ $stderr.puts e
+ end
+
+ def group_sync_enabled?
+ if Gitlab::Auth::LDAP::Config.group_sync_enabled?
+ $stdout.puts 'LDAP GroupSync is enabled.'
+ else
+ $stdout.puts 'LDAP GroupSync is not enabled.'
+ end
+ end
+
+ execute
+ end
+ end
+end