Re: [ansible-project] facing the problem in mapping network drive

2020-05-26 Thread mahesh g o
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

On Sat, May 16, 2020 at 1:31 AM Jordan Borean  wrote:

> 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.
>
> [1]
> https://docs.ansible.com/ansible/latest/modules/win_credential_module.html
> [2]
> https://docs.ansible.com/ansible/latest/modules/win_mapped_drive_module.html
>
> --
> 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-project+unsubscr...@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
> 
> .
>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGWu8HwXP%3DbA%2BPJYVxMV3KJK6cF6t_CbVt6Zt0H_DynPPTZUMQ%40mail.gmail.com.


Re: [ansible-project] facing the problem in mapping network drive

2020-05-15 Thread Jordan Borean
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.

[1] 
https://docs.ansible.com/ansible/latest/modules/win_credential_module.html
[2] 
https://docs.ansible.com/ansible/latest/modules/win_mapped_drive_module.html

-- 
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-project+unsubscr...@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.


Re: [ansible-project] facing the problem in mapping network drive

2020-05-15 Thread mahesh g o
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.


On Friday, 15 May 2020 02:36:13 UTC+5:30, Jordan Borean wrote:
>
> 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
> .
>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/18f5b50d-415a-4fc4-8e0b-0c7d383f0dae%40googlegroups.com.


Re: [ansible-project] facing the problem in mapping network drive

2020-05-14 Thread Jordan Borean
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.

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/50432530-6dfa-45a5-b8eb-9cc128378fc5%40googlegroups.com.


Re: [ansible-project] facing the problem in mapping network drive

2020-05-14 Thread mahesh g o
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.


On Thursday, 14 May 2020 16:32:00 UTC+5:30, Luca 'remix_tj' Lorenzetto 
wrote:
>
> Hello, 
>
> On Thu, May 14, 2020 at 12:49 PM mahesh g o  > 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 ,  > 
>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3f67a270-e24d-494b-bd65-57fe30eceb7d%40googlegroups.com.


Re: [ansible-project] facing the problem in mapping network drive

2020-05-14 Thread Luca 'remix_tj' Lorenzetto
Hello,

On Thu, May 14, 2020 at 12:49 PM mahesh g o  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 , 

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAKuX69rC391HYrS%2BvBwH-JHyLP5s2p980Lw6qHbzNiwaxkpsWw%40mail.gmail.com.


[ansible-project] facing the problem in mapping network drive

2020-05-14 Thread mahesh g o
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}




-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f513a44c-255b-4a34-bcce-ebe93efccdfb%40googlegroups.com.