I would like to export vm running on hyper-v to a remote shared file system. I make it manually, by saying that is I right clicked powershell and choosing “run as administrator” and run the command in the cmd. But I failed when run my ansible playbook with the same command with the error of : "Export-VM : Failed to create export directory. I use kerberos to authenticate.
The user I used in ansible to talk to hyper-v hosts does have the shared file system access permission. My playbook like below. The DIR variable is the path to the remote shared file system.
Anybody has an idea to workaround it? The administrator here is local administrator user. Should I use domain admin user here to escalate the right? .
- hosts: xxxx
gather_facts: False
become_method: runas
vars:
ansible_become_password: xxxxx
tasks:
- name: Export the vm to remote directory
win_shell: Export-VM -Name {{ VM }} -Path {{ DIR }}
become: yes
become_user: Administrator
Thanks
Ming