Skip to content

Instantly share code, notes, and snippets.

@jeremymv2
Last active February 24, 2016 14:05
Show Gist options
  • Save jeremymv2/e2af325204232d642483 to your computer and use it in GitHub Desktop.
Save jeremymv2/e2af325204232d642483 to your computer and use it in GitHub Desktop.
include_recipe 'chef-vault'
user_data_bag = chef_vault_item("passwords", node['domain-vault_id'])
username = user_data_bag["username"]
password = user_data_bag["password"]
[
"Microsoft-Windows-GroupPolicy-ServerAdmintools-Update",
"ServerManager-Core-RSAT",
"ServerManager-Core-RSAT-Role-Tools",
"RSAT-AD-Tools-Feature",
"RSAT-ADDS-Tools-Feature",
"ActiveDirectory-Powershell",
"DirectoryServices-DomainController-Tools",
"DirectoryServices-AdministrativeCenter",
"DirectoryServices-DomainController"
].each do |feature|
windows_feature feature do
action :install
end
end
netdom_join node['domain-name'] do
ou node['domain-ou']
domain_admin username
domain_admin_password password
retries 5
retry_delay 2
end
include_recipe 'chef-vault'
user_data_bag = chef_vault_item("passwords", node['domain-vault_id'])
username = user_data_bag["username"]
password = user_data_bag["password"]
ruby_block "Remove from AD" do
block do
Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
test = Mixlib::ShellOut.new("dsrm -u #{username} -p #{password} -s #{node['domain-name']} CN=#{node['machinename']},#{node['domain-ou']} -noprompt")
test.run_command
end
end
netdom_remove node['domain-name'] do
domain_admin username
domain_admin_password password
retries 5
retry_delay 2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment