Skip to content

Commit

Permalink
Quote the machine_ou param unless $null
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Vincent committed Nov 7, 2019
1 parent b0e1b6e commit c1d30eb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
Variant[String,Sensitive] $password,
Optional[Stdlib::Fqdn] $user_domain = undef,
Boolean $secure_password = false,
String $machine_ou = '$null',
Pattern[/\A[^\']+\z/] $machine_ou = undef,
Boolean $resetpw = true,
Boolean $reboot = true,
Enum['immediately', 'finished'] $reboot_apply = 'finished',
Expand Down Expand Up @@ -83,9 +83,14 @@
$_reset_username = $username
}
$_machine_ou = $machine_ou ? {
undef => '$null',
default => "'${machine_ou}'"
}
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,
}
Expand Down

0 comments on commit c1d30eb

Please sign in to comment.