# setting ansible\_connection=winrm overrides connection: local in play

**URL:** <https://forum.ansible.com/t/setting-ansible-connection-winrm-overrides-connection-local-in-play/17815>\
**Category:** Ansible Project\
**Tags:** windows, aws\
**Created:** [March 23, 2015, 6:11pm UTC](https://forum.ansible.com/t/setting-ansible-connection-winrm-overrides-connection-local-in-play/17815 "2015-03-23T18:11:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andy2](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@andy2](https://forum.ansible.com/u/andy2)\
**Post date:** [March 23, 2015, 6:11pm UTC](https://forum.ansible.com/t/setting-ansible-connection-winrm-overrides-connection-local-in-play/17815/1 "2015-03-23T18:11:18Z")

</div>

We’re using playbooks to bring up AWS infrastructure, then provision within the OS

This works fine for linux hosts, as we just use connection: local in the plays that do instance provisioning etc. and can bring hosts up according to inventory vars set for the individual hosts.

We’re blocked when working with windows hosts at the moment though…  
Setting ansible\_connection=winrm in inventory seems to override subsequent attempts to use connection: local in a play.

Has anyone else seen this… any ideas how to get around it

Thanks,  
Andy

---

<div class="post-metadata">

**Author:** ![DS\_Morse](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DS\_Morse](https://forum.ansible.com/u/DS_Morse)\
**Post date:** [December 16, 2016, 10:12pm UTC](https://forum.ansible.com/t/setting-ansible-connection-winrm-overrides-connection-local-in-play/17815/2 "2016-12-16T22:12:51Z")

</div>

Yes I’m still seeing this error even with ansible 2.2.0 Once ansible\_connection is set in the inventory, I can not override it in a playbook nor from the command line. It feels like the inverse of the desired behavior as the closer settings are being ignored based on a config that is further away from the point of execution.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 16, 2016, 10:26pm UTC](https://forum.ansible.com/t/setting-ansible-connection-winrm-overrides-connection-local-in-play/17815/3 "2016-12-16T22:26:57Z")

</div>

The host specific connection variables trump the general settings and directives, this is on purpose as the hosts can require specifics that plays are unaware of. That said, there are several ways to override in command line and play.

I recommend using either `local_action` or `delegate_to: localhost` instead of `connection: local`, the latter does not override connection variables.

Another way is to just set that variable `ansible_connection=local` on the command line or in the play, which will override the inventory setting.
