Ansible 1.8.4 on ubuntu 12.04 to connect to windows 8.1 guest vm using literally the exact same windows module examples from the ansible documentation.
ansible -m win_ping and -m setup work great.
2 Problems standing in my way
- I am trying to mount a network drive using ansible. The play is simply:
- name: ‘Mount drive to T’
hosts: windows
tasks:
script: mount_drive.ps1
mount_drive.ps1 is simply
New-PSDrive -Name T -PSProvider FileSystem -Root \some_mountable_drive\dir -Persist
When this is executed, ansible happily reports the play recap it was “ok” which is a lie.
I know that this works because I have run the command while logged in on the windows guest as the user in question and the drive is mounted immediately.
I also used the win_rm python module to execute this command with success. I define “success” a little looser here because the drive doesn’t appear immediately, but after logout/login but I chalk that up to windows bs.
If the command works (almost) perfectly with the python win_rm module. I can’t figure out what am i doing wrong with the ansible play.
Problem 2:
- name: Add user
hosts: windows
tasks: - name: Add newuser
win_user:
name: anewuser
password: “shhhh”
groups_action: replace # with or without this matters not
groups: [“Users”,“Administrators”]
The user is created fine via inspection with lsusrmgr, however the user is not added to those groups
please point me in the right direction. Also some way to get meaningful output from the remote commands would be nice. win_rm captures the stdout and err from powershell commands, which is how I debugged the win_rm python module to mount the drive just fine.