diff --git a/.fixtures.yml b/.fixtures.yml index 63f3809..839ed5f 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -2,6 +2,8 @@ fixtures: repositories: stdlib: repo: "git://github.com/puppetlabs/puppetlabs-stdlib" - ref: "4.3.2" + ref: "a656880f13cc13a30baa892dcc4c8e3efefcc867" + reboot: "git://github.com/puppetlabs/puppetlabs-reboot" + powershell: "git://github.com/puppetlabs/puppetlabs-powershell" symlinks: domain_membership: "#{source_dir}" diff --git a/tests/init.pp b/examples/init.pp similarity index 100% rename from tests/init.pp rename to examples/init.pp diff --git a/manifests/init.pp b/manifests/init.pp index 167b75b..0afb1dd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -52,9 +52,9 @@ # class domain_membership ( Stdlib::Fqdn $domain, - Optional[Stdlib::Fqdn] $user_domain, String $username, String $password, + Optional[Stdlib::Fqdn] $user_domain = undef, Boolean $secure_password = false, String $machine_ou = '$null', Boolean $resetpw = true, @@ -72,15 +72,16 @@ # Allow an optional user_domain to accomodate multi-domain AD forests if $user_domain { + $_user_domain = $user_domain $_reset_username = "${user_domain}\\${username}" } else { - $user_domain = $domain + $_user_domain = $domain $_reset_username = $username } exec { 'join_domain': environment => [ "Password=${_password}" ], - command => "exit (Get-WmiObject -Class Win32_ComputerSystem).JoinDomainOrWorkGroup('${domain}',\$Password,'${username}@${user_domain}',${machine_ou},${join_options}).ReturnValue", + command => "exit (Get-WmiObject -Class Win32_ComputerSystem).JoinDomainOrWorkGroup('${domain}',\$Password,'${username}@${_user_domain}',${machine_ou},${join_options}).ReturnValue", unless => "if((Get-WmiObject -Class Win32_ComputerSystem).domain -ne '${domain}'){ exit 1 }", provider => powershell, } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb new file mode 100644 index 0000000..a8a1396 --- /dev/null +++ b/spec/classes/init_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' +require 'puppetlabs_spec_helper/module_spec_helper' + +describe 'domain_membership' do + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { facts } + let(:params) do + { + domain: 'test.domain', + username: 'testuser', + password: 'password1', + } + end + + it { is_expected.to compile.with_all_deps } + end + end +end