cookbooks/mu-activedirectory/providers/domain_controller.rb in cloud-mu-2.0.0.pre.alpha7 vs cookbooks/mu-activedirectory/providers/domain_controller.rb in cloud-mu-2.0.0.pre.alpha8

- old
+ new

@@ -23,43 +23,39 @@ join_domain promote configure_network_interface set_replication_static_ports set_computer_name(admin_creds) - when platform_family?('rhel') - # To do: Do Active Directory on Linux else Chef::Log.info("Unsupported platform #{node['platform']}") end end action :remove do case node['platform'] when "windows" demote - when platform_family?('rhel') - # To do: Do Active Directory on Linux else Chef::Log.info("Unsupported platform #{node['platform']}") end end # def load_current_resource # @current_resource = @new_resource.dup # end def promote - unless is_domain_controller?(new_resource.computer_name) + unless domain_controller?(new_resource.computer_name) Chef::Log.info("Promoting #{new_resource.computer_name} to domain controller in #{new_resource.dns_name} domain") cmd = powershell_out("Stop-Process -ProcessName sshd -force -ErrorAction SilentlyContinue; Install-ADDSDomainController -InstallDns -DomainName #{new_resource.dns_name} -Credential #{admin_creds} -SafeModeAdministratorPassword (convertto-securestring '#{new_resource.restore_mode_password}' -asplaintext -force) -Force -Confirm:$false; Restart-Computer -Force") kill_ssh Chef::Application.fatal!("Failed to promote #{new_resource.computer_name} to Domain Controller in #{new_resource.dns_name} domain") unless cmd.exitstatus == 0 Chef::Application.fatal!("Promoted #{new_resource.computer_name} to Domain Controller in #{new_resource.dns_name} domain. Will have to run chef again") end end def demote - if is_domain_controller?(new_resource.computer_name) + if domain_controller?(new_resource.computer_name) Chef::Log.info("Demoting domain controller #{new_resource.computer_name} in #{new_resource.dns_name} domain") cmd = powershell_out("Stop-Process -ProcessName sshd -force -ErrorAction SilentlyContinue; Uninstall-WindowsFeature DNS; Uninstall-ADDSDomainController -Credential #{admin_creds} -LocalAdministratorPassword (convertto-securestring '#{new_resource.domain_admin_password}' -asplaintext -force) -Force -Confirm:$false; Restart-Computer -Force") kill_ssh Chef::Application.fatal!("Failed to demote Domain Controller #{new_resource.computer_name} in #{new_resource.dns_name} domain") unless cmd.exitstatus == 0 Chef::Application.fatal!("Demoted Domain Controller #{new_resource.computer_name} in #{new_resource.dns_name} domain. Will have to run chef again")