Last active
February 24, 2016 14:05
-
-
Save jeremymv2/e2af325204232d642483 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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