I currently have a powershell script (deploy.ps1) which I use to manage files on a network drive. When running my script, I am successfully able to map to the drive and access the contents. However, when attempting to do this by via an Ansible playbook, I get problems relating to my network password not being correct.
deploy.ps1:
$mapPath = "\\computer\path\to\blah"
$username = "username"
$password = "password"
$securePassword = Convert-To-SecureString -String $password -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PScredential -ArgumentList $username, $securePassword
New-PSDrive -Name "TempDrive" -PSProvider "FileSystem" -root $mapPath -Credential $cred
playbook.yaml:
name: Deploy Report
hosts: myhost
tasks:
- name: Run Deployment Script
script: "../deploy.ps1"
register: out
I am sure that this is an Ansible-specific problem because it runs flawlessly every time without Ansible. Any help or advice is greatly appreciated.