Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.42 KB | None | 0 0
  1. #
  2. # Cookbook Name:: edunav-nexus
  3. # Recipe:: default
  4. #
  5. # Copyright 2014, EduNav
  6. #
  7. # All rights reserved - Do Not Redistribute
  8. #
  9.  
  10. include_recipe 'nexus::default'
  11. admin_creds = Chef::EncryptedDataBagItem.load('nexus', '_wildcard')
  12. service "nexus" do
  13.   action :start
  14. end
  15.  
  16. nexus_user "admin" do
  17.   email 'devops@edunav.com'
  18.   old_password admin_creds['credentials']['default_admin']['password']
  19.   password admin_creds['credentials']['updated_admin']['password']
  20.   action [:change_password]
  21. end
  22.  
  23. ruby_block 'set_admin_creds' do
  24.   block do
  25.     node.set['nexus']['cli']['default_admin_credentials_updated'] = true
  26.     node.save
  27.   end
  28.   action :nothing
  29. end
  30.  
  31. #node.set['nexus']['cli']['default_admin_credentials_updated'] = true
  32. #node.save
  33.  
  34. users_data_bag = node['edunav-nexus']['users']['data_bag']
  35. users_search_group = node['edunav-nexus']['users']['search_group']
  36. users_default_password = Chef::EncryptedDataBagItem.load('users', 'default_password')['password']
  37.  
  38. search(node['edunav-nexus']['users']['data_bag'], "groups:#{users_search_group} AND NOT action:remove").each do |user|
  39.     user['name'] ||= user['id']
  40.     user['email'] ||= "#{user['id']}@#{node['domain']}"
  41.     user['ssh_keys'] ||= []
  42.  
  43.     nexus_user user['id'] do
  44.         username user['id']
  45.         email user['email']
  46.         enabled TRUE
  47.         password users_default_password
  48.         roles ['nx-admin']
  49.         action [:create]
  50.     end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement