Ansible works with hyper-v. permission denied

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

Fixed it by added below as variables

    ansible_become: yes
    ansible_become_method: runas
    ansible_become_user: DOMAIN\user
    ansible_become_pass: Password01
    ansible_become_flags: logon_type=new_credentials logon_flags=netcredentials_only