I have an application which requires a local account to be required for the configuration. I have created a module inside that I have 2 folders:
filesmanifests
Under manifests init file I have the below code:
class xyz {
exec { ' app_config':
command => ' C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe -file c:\provisioning\modules\xyz\files\config1.ps1 '
}
}
Under files folder there are 2 files:
config1.ps1app_execute.bat
In config1.ps1 I am creating a local user:
$user = $env:COMPUTERNAME/Testing
$Credentials = New-Object -TypeName System.Management.Automation.PScredential -ArgumentList $user, ("test@3456", | ConvertTo-SecureString -AsPlainText -Force)
Start-Process C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe -Credential $Credentials -ArgumentList " Start-Process C:\Windows\System32\cmd.exe -File c:\provisioning\c:\provisioning\modules\xyz\files\app_execute.bat "
In app_execute.bat
c:\puppet\app.bat -f c:\puppet\responsefile.rsp
The log file shows that the PowerShell file config1.ps1 got executed successfully, but the application log file is not getting generated, but when executed manually the config1.ps1 the app will get configured.
Not sure, in config1.ps1, I am using a Start-Process which will create a separate process using the local account.
I think Puppet is not waiting for the above config1.ps1 to be completed succesfully.
Not sure why it is coming out without executing fully, Is there any condition, as we need to execute only one file inside init, as I am initiating 2 processes.
execresource, which starts a powershell script, which starts a PowerShell process, which starts a CMD process, which runs a batch file (with an invalid path), which runs another batch file, which processes some kind of response file. Wow. Just ... wow! My recommendation is: throw it away and start over. Like, from scratch. Consider usinguserresources for creating local users this time. - Ansgar Wiechers