i CANT connect to a windows server

103 views
Skip to first unread message

Aitor Gómez

unread,
Nov 14, 2016, 10:42:57 AM11/14/16
to Ansible Project
i configured host



Windows.yml

ansible_user: domain\user
ansible_password: passw
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore

I've tried it too:
ansible_user: localuser (in the server)

BUT when i run the playbook:
  1. <server.domain.es> ESTABLISH SSH CONNECTION FOR USER: USER
  2. <server.domain.es> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
  3. <server.domain.es> SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no)
  4. <server.domain.es> SSH: ANSIBLE_REMOTE_USER/remote_user/ansible_user/user/-u set: (-o)(User=USER)
  5. <server.domain.es> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
  6. <server.domain.es> SSH: PlayContext set ssh_common_args: ()
  7. <server.domain.es> SSH: PlayContext set ssh_extra_args: ()
  8. <server.domain.es> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/tmp/ansible_tower_CMbKBj/cp/ansible-ssh-%h-%p-%r)
  9. <server.domain.es> SSH: EXEC sshpass -d19 ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=USER -o ConnectTimeout=10 -o ControlPath=/tmp/ansible_tower_CMbKBj/cp/ansible-ssh-%h-%p-%r server.domain.es '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479111892.51-133707384640152 `" && echo ansible-tmp-1479111892.51-133707384640152="` echo $HOME/.ansible/tmp/ansible-tmp-1479111892.51-133707384640152 `" ) && sleep 0'"'"''
  10. fatal: [server.domain.es]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
  11.  [WARNING]: Could not create

Mike Fennemore

unread,
Nov 14, 2016, 2:39:41 PM11/14/16
to Ansible Project
The user isn't in the correct user@domain format firstly. Have you setup kerberos as per the Ansible documentation? It might also be an idea to check what version of pywinrm you're running. What version of Ansible is the server running?

Aitor Gómez

unread,
Nov 15, 2016, 3:02:41 AM11/15/16
to Ansible Project
No i not configure kerberos (other partner install ansible ansible 2.1.1.0 in our organization and tell us is not necesary install kerberos). pywinrm-0.2.1

Mike Fennemore

unread,
Nov 15, 2016, 3:06:42 AM11/15/16
to Ansible Project
It might be an idea to take a look at the Ansible documentation in that case http://docs.ansible.com/ansible/intro_windows.html . That will give you the rundown of what is needed.

J Hawkesworth

unread,
Nov 15, 2016, 3:07:32 AM11/15/16
to Ansible Project
Please show us your playbook.

Your group_vars file must be called 'windows.yml' not 'Windows.yml' otherwise the group name you have defined will not match (it is case-sensitive) and ansible will default to ssh connection.

Also check your playbook looks like

--
hosts
: windows



Hope this helps,

Jon
Message has been deleted

Aitor Gómez

unread,
Nov 15, 2016, 3:37:20 AM11/15/16
to Ansible Project
yes the file name windows.yml

This is my playbook

- name: raw module example
  hosts: server.domain.es
  tasks:
     - name: Move file on remote Windows Server from one location to another
       raw: CMD /C "MOVE /Y D:\origen\prueba.txt D:\destino\prueba.txt"

RESULT:
.
.
.
.
fatal: [server.domain.is]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}


if i change to 

- name: raw module example
  hosts: windows
  tasks:
     - name: Move file on remote Windows Server from one location to another
       raw: CMD /C "MOVE /Y D:\origen\prueba.txt D:\destino\prueba.txt"

RESULT:succesfull but all skipped

Using /etc/ansible/ansible.cfg as config file 
SSH password: 
Loaded callback default of type stdout, v2.0 
PLAYBOOK: pruebaaitorwin.yml *************************************************** 
1 plays in pruebaaitorwin.yml 
PLAY [raw module example] ****************************************************** 
skipping: no hosts matched 
PLAY RECAP *********************************************************************  

Aitor Gómez

unread,
Nov 15, 2016, 3:52:19 AM11/15/16
to Ansible Project
yeah thanks.. i will ask if i can install kerbeos module.. but the partnet said me is not neccesary.. im very begginer with this.. thanks

J Hawkesworth

unread,
Nov 15, 2016, 7:54:25 AM11/15/16
to Ansible Project
Ok it looks like your inventory and group vars aren't matching up at the moment.

Please show your ansible-playbook command line.

Your ansible hosts file should be in in 
/etc/ansible/hosts

and group vars in 
/etc/ansible/group_vars/windows.yml

(You can use other locations but must use -i /path/to/ansible/hosts/file and the group_vars must be in sub directory under wherever your ansible inventory file is).

You can also configure in ansible.cfg so worth checking that ansible is configured in the default way.

Also you must use a local account name e.g. Administrator if you have not set up kerberos. 

If you are using kerberos, please use username@realm (not username\realm or username/realm) otherwise kerberos will not be used.

Hope this helps,

Jon

Aitor Gómez

unread,
Nov 15, 2016, 8:27:36 AM11/15/16
to Ansible Project
thanks ok y will try with a local administrator

In host file... i must configure servername.domain.es or IP ?

Aitor Gómez

unread,
Nov 15, 2016, 9:59:05 AM11/15/16
to Ansible Project
ok.. works when i execute in ansible (whit local user)

But in Tower not works.... i will check again the Tower configuration




El martes, 15 de noviembre de 2016, 13:54:25 (UTC+1), J Hawkesworth escribió:

Aitor Gómez

unread,
Nov 18, 2016, 7:43:27 AM11/18/16
to Ansible Project
is posible confugure LDAP and not Kerberos?

J Hawkesworth

unread,
Nov 25, 2016, 8:11:05 AM11/25/16
to Ansible Project
Not something I have heard of anyone trying.

If you have working on command line but not in Tower, I suggest you contact Tower support for help.

Jon
Reply all
Reply to author
Forward
0 new messages