Repository: ansible/ansible

Issue:
azure_rm inventory should add "ansible_connection: winrm" in host_vars for windows hosts
##### ISSUE TYPE

 - Bug Report

##### COMPONENT NAME

azure_rm inventory 

##### ANSIBLE VERSION

```
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/fft/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/fft/.fftpython2/local/lib/python2.7/site-packages/ansible
  executable location = /home/fft/.fftpython2/bin/ansible
  python version = 2.7.14rc1 (default, Sep  5 2017, 18:16:23) [GCC 7.2.0]

```

##### CONFIGURATION

N/A

##### OS / ENVIRONMENT

Target hosts: Windows

##### SUMMARY

azure_rm inventory should add "ansible_connection: winrm" in host_vars for windows hosts

##### STEPS TO REPRODUCE

Run azure_rm (Microsoft Azure Resource Manager Inventory in AWX) to inventory a Windows host.

Look at the variables in the output.

##### EXPECTED RESULTS

A windows host should be reached with winrm. 

I expect this variable to be present in the host variables:

```
ansible_connection: winrm
```

##### ACTUAL RESULTS

The variable ```ansible_connection: winrm``` is missing. 

Ansible will use the standard SSH connexion mechanism, which will obviously fail.

We get information about the OS from Azure, though:

```
os_disk: 
  operating_system_type: Windows
```

So when this information is present, azure_rm inventory should also set the variable ```ansible_connection: winrm```.


Discussion:
Files identified in the description:
* [contrib/inventory/azure_rm.py](https://github.com/ansible/ansible/blob/devel/contrib/inventory/azure_rm.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @haroldwongms @nitzmahone @tstringer @xscript @yuwzho @zikalino
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Here the complete host_vars of the host that I receive (and is displayed in AWX):
```
powerstate: running
resource_group: test-rg
tags:
  displayName: test-vm
image:
  sku: 2012-R2-Datacenter
  publisher: MicrosoftWindowsServer
  version: latest
  offer: WindowsServer
public_ip_alloc_method: null
provisioning_state: Succeeded
public_ip: null
public_ip_name: null
private_ip: X.X.X.X
computer_name: test-vm
public_ip_id: null
plan: null
windows_timezone: null
id: >-
  /subscriptions/XXXX/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/test-vm
fqdn: null
name: test-vm
windows_rm: null
os_disk:
  operating_system_type: Windows
  name: test-vmosdisk
ansible_host: null
virtual_machine_size: Standard_F2
network_interface_id: >-
  /subscriptions/XXXX/resourceGroups/test-rg/providers/Microsoft.Network/networkInterfaces/test-vm-nic
private_ip_alloc_method: Static
location: northeurope
windows_auto_updates_enabled: true
mac_address: XXXX
type: Microsoft.Compute/virtualMachines
network_interface: test-vm-nic
```

Resolving patch:
diff --git a/contrib/inventory/azure_rm.py b/contrib/inventory/azure_rm.py
--- a/contrib/inventory/azure_rm.py
+++ b/contrib/inventory/azure_rm.py
@@ -620,6 +620,7 @@ def _load_machines(self, machines):
 
             # Add windows details
             if machine.os_profile is not None and machine.os_profile.windows_configuration is not None:
+                host_vars['ansible_connection'] = 'winrm'
                 host_vars['windows_auto_updates_enabled'] = \
                     machine.os_profile.windows_configuration.enable_automatic_updates
                 host_vars['windows_timezone'] = machine.os_profile.windows_configuration.time_zone


Test patch: