In ~/.ansible/group_vars/ 
i have a file named firma_city_dit_test.yml
with content:

ansible_connection: winrm
ansible_port: 5986
ansible_user: ansible
ansible_winrm_scheme: https
ansible_password: *****
ansible_winrm_transport: kerberos
ansible_winrm_server_cert_validation: ignore

now there really is a problem

ansible-inventory all -i ~/.ansible/group_vars/ldap_inventory.yaml --list
{
    "_meta": {
        "hostvars": {}
    },
    "all": {
        "children": [
            "firma",
            "ungrouped"
        ]
    },
    "firma": {
        "children": [
            "firma_city"
        ]
    },
    "firma_city": {
        "children": [
            "firma_city_dit"
        ]
    },
    "firma_city_dit": {
        "children": [
            "firma_city_dit_test"
        ]
    },
    "firma_city_dit_test": {
        "hosts": [
            "ansible-win.leme.lcl"
        ]
    }
}



środa, 18 listopada 2020 o 22:37:17 UTC+1 [email protected] napisał(a):

> How did you define your group vars ? Are you using both windows and Linux 
> servers and defined connection in vars in all vars ?? If so you need to 
> segregate the vars per group .. 
>
> Simple solution would be to have connection details in your host file 
> ...let's say -i inventory/environment/host or environment.ini 
> In environment.ini 
> [Environment]
> Server ansible-connection=winrm winrm port=5986 ..etc .
> Define this here instead of defining it at vars if you using both windows 
> and *nix servers 
>
> On Thu, 19 Nov, 2020, 1:37 am Lukasz, <[email protected]> wrote:
>
>>
>> Hello, I am having trouble connecting ansible via winrm. Something is 
>> wrongly defined and ansible connects to windows via ssh. 
>> ( more https://dpaste.org/6LdQ )
>>
>> Where else can I look for problems?
>> ...
>>
>>    - ansible-playbook -vvv -i ~/.ansible/group_vars/ldap_inventory.yaml 
>>    ~/.ansible/playbook/zabbix-agent.a.yml 
>>    ....
>>    fatal: [ansible-win.leme.lcl]: UNREACHABLE! => {
>>    - "changed": false,
>>    - "msg": "Failed to connect to the host via ssh: ssh: connect to host 
>>    ansible-win.leme.lcl port 22: Connection timed out",
>>    - "unreachable": true
>>    - }
>>
>> ....
>>
>>    - ansible ansible-win.leme.lcl -m debug -a "var=ansible_connection"
>>    - ansible-win.leme.lcl | SUCCESS => {
>>    - "ansible_connection": "winrm"
>>    - }
>>    - 
>>    - -----
>>    - 
>>    - ansible -v ansible-win.leme.lcl -m ansible.windows.win_ping
>>    - Using /home/ansible/.ansible/ansible.cfg as config file
>>    - ansible-win.leme.lcl | SUCCESS => {
>>    - "changed": false,
>>    - "ping": "pong"
>>    - }
>>    ....
>>    - 
>>    
>>
>>    - ansible-inventory all -i ~/.ansible/group_var/ldap_inventory.yaml --
>>    list
>>    - {
>>    - "_meta": {
>>    - "hostvars": {
>>    - "ansible-win.leme.lcl": {
>>    - "ansible_connection": "winrm",
>>    - "ansible_password": "invisible-password;)",
>>    - "ansible_port": 5986,
>>    - "ansible_user": "ansible",
>>    - "ansible_winrm_scheme": "https",
>>    - "ansible_winrm_server_cert_validation": "ignore",
>>    - "ansible_winrm_transport": "kerberos"
>>    - }
>>    - }
>>    - },
>>    ....
>>    
>>
>> -- 
>> 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 [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/775ff29c-2df2-4ba0-b762-85f179326f6en%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/775ff29c-2df2-4ba0-b762-85f179326f6en%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f748046a-5ac7-43e2-8b56-4252a96b4239n%40googlegroups.com.

Reply via email to