facing the problem in mapping network drive

瀏覽次數:681 次
跳到第一則未讀訊息

mahesh g o

未讀,
2020年5月14日 清晨6:49:012020/5/14
收件者:Ansible Project
Hi ,

help is appreciated

playbook:mount.yml

- hosts: localhost
  gather_facts: false
  vars_files:
    - /etc/ansible/group_vars/host_vars
  tasks:
    - name: create a mapped drive under Z
      win_mapped_drive:
        letter: Z
        path: \\10.237.163.116\test
        username: test
        password: Password123

host_vars:
windows machine details:

ip: "10.234.224.199"
username: "Administrator"
password: "netapp"
ansible_connection: "winrm"
ansible_winrm_server_cert_validation: "ignore"

i am getting below error when run the playbook:
fatal: [localhost]: UNREACHABLE! => {"changed": false, "msg": "ssl: auth method ssl requires a username", "unreachable": true}




Luca 'remix_tj' Lorenzetto

未讀,
2020年5月14日 清晨7:02:002020/5/14
收件者:ansible...@googlegroups.com
Hello,

On Thu, May 14, 2020 at 12:49 PM mahesh g o <mahe...@gmail.com> wrote:
> i am getting below error when run the playbook:
> fatal: [localhost]: UNREACHABLE! => {"changed": false, "msg": "ssl: auth method ssl requires a username", "unreachable": true}
>

are you setting (or asking) username somewhere? Because you specified
username and password, which are not the variables used by ansible
(ansible_user, ansible_pass).

Luca

--
"E' assurdo impiegare gli uomini di intelligenza eccellente per fare
calcoli che potrebbero essere affidati a chiunque se si usassero delle
macchine"
Gottfried Wilhelm von Leibnitz, Filosofo e Matematico (1646-1716)

"Internet è la più grande biblioteca del mondo.
Ma il problema è che i libri sono tutti sparsi sul pavimento"
John Allen Paulos, Matematico (1945-vivente)

Luca 'remix_tj' Lorenzetto, http://www.remixtj.net , <lorenze...@gmail.com>

mahesh g o

未讀,
2020年5月14日 清晨7:17:262020/5/14
收件者:Ansible Project
I am setting the username and password: 
i have a volume name "test" in my storage box and i want to map it windows machine:

details in host_vars are my machine details:

volume details:
letter: Z
        path: \\10.237.163.116\test
        username: test
        password: Password123

i am expecting the playbook use host_vars file to login to windows machine and mount the volume in z drive.

Jordan Borean

未讀,
2020年5月14日 下午5:06:132020/5/14
收件者:Ansible Project
The error you have is nothing to do with mapped drives but that Ansible is unable to authenticate itself over the WinRM connection. YOu need to set ansible_user and ansible_password for Ansible to use as the connection credentials.

Also please note that while you can map a network drive using win_mapped_drive in Ansible, you cannot use that mapped drive in Ansible tasks. That mapping is just for interactive logons. If you want to access files from a network path in Ansible you need to use the UNC path and potentially use become to add outbound creds to your process. We have an example of that here https://docs.ansible.com/ansible/latest/user_guide/become.html#become-flags-for-windows.

mahesh g o

未讀,
2020年5月15日 凌晨4:01:432020/5/15
收件者:Ansible Project
Thanks Jordan,

I used become in my playbook.

- hosts: [win]
  gather_facts: false
  tasks:
    - name: create a mapped drive
      win_mapped_drive:
       state: present
       letter: D
       path: \\10.237.163.116\test

  vars:
    # become is required to save and retrieve the credentials in the tasks
      ansible_become: yes
      ansible_become_method: runas
      ansible_become_user: test
      ansible_become_pass: password@123
      ansible_become_flags: logon_type=new_credentials logon_flags=netcredentials_only

Playbook is running without any errors.

But i am not seeing the network drive in my windows OS.
net use:
Unavailable  T:        \\10.237.163.116\test     Microsoft Windows Network

what is that i am missing here. what is the solution to map the network drive.

Jordan Borean

未讀,
2020年5月15日 下午4:00:552020/5/15
收件者:Ansible Project
So the drive mapping is present but Windows is unable to map the drive on logon. You can use the win_credential [1] to store a credential that Windows will use for mapped drives. There's even an example of this in the win_mapped_drive [2] docs. If you are running the net use command through Ansible and expecting to see that mapped drive available then you are out of luck. Mapped drives are only for use with interactive logons and not for use in Ansible, Ansible can only manage the mappings but not use them.

mahesh g o

未讀,
2020年5月26日 凌晨4:21:292020/5/26
收件者:ansible...@googlegroups.com
Hi Jordan,
 
I tried the below playbook to store the credential that Windows will use for mapped drives. But it is throwing the below error :

- hosts: [win]
  gather_facts: false
  tasks:
    - name: Save the network credentials required for the mapped drive
      win_credential:
        name: 10.224.233.199  -----> windows machine IP
        type: domain_password
        state: present
        #persistence: local
        #secret_format: text
        #update_secret: always
        username: Administrator-----> windows machine username
        secret: opteamix------> windows machine password
      become: yes
      become_method: runas


  vars:
    # become is required to save and retrieve the credentials in the tasks
        ansible_become_user:  apple ----- username of the drive to be mapped.
        ansible_become_pass: barharbour -----password  of the drive to be mapped.
        ansible_become_flags: logon_type=new_credentials logon_flags=netcredentials_only


fatal: [10.234.224.199]: FAILED! => {
    "changed": false,
    "msg": "Unhandled exception while executing module: Exception calling \"GetCredential\" with \"2\" argument(s): \"Failed to access the user's credential store, run the module with become\""

Thanks,
Mahesh

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d013a3e5-d5d0-4aa9-b809-7850cee84167%40googlegroups.com.

David Foley

未讀,
2020年5月26日 凌晨4:44:112020/5/26
收件者:Ansible Project
回覆所有人
回覆作者
轉寄
0 則新訊息