setting ansible_connection=winrm overrides connection: local in play

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

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.

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.