Lukasz1  
                
                  
                    November 18, 2020,  8:07pm
                   
                  1 
               
             
            
              Hello, I am having trouble connecting ansible via winrm. Something is wrongly defined and ansible connects to windows via ssh.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
 
“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” 
} 
 
             
            
              
            
           
          
            
              
                Jerin_J  
              
                  
                    November 18, 2020,  9:36pm
                   
                  2 
               
             
            
              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
             
            
              
            
           
          
            
              
                Lukasz1  
              
                  
                    November 19, 2020,  6:21am
                   
                  3 
               
             
            
              In ~/.ansible/group_vars/
i have a file named firma_city_dit_test.yml
ansible_connection: winrm
now there really is a problem
ansible-inventory all -i ~/.ansible/group_vars/ldap_inventory.yaml --list
             
            
              
            
           
          
            
              
                Lukasz1  
              
                  
                    November 19, 2020,  9:23am
                   
                  4 
               
             
            
              Thank you for your answer and hints.
Complete the data https://dpaste.org/vHS2 
The main ansible file i have in ~/ansible.cfg
The inventory of hosts is automatic so what would I enter in the “inventory” option in ansible.cfg
I’d like the variables to be included in group_vars, how do I define an ansible.cfg ?
I save a file in group_vars with content :