Finding variable collision in Ansible from group_vars

When you start building large complicated Ansible deployments the likely hood that your using group_vars in new and exiting ways is VERY high due to the desire to co-locate configuration for nodes based on group membership into once place. If you are at the point where nodes are members of multiple groups all within a single deployment this quick BASH one-liner should help you search for your group vars and find potential disasters before they're impacting your production environment.

for i in $(grep -hv '^#' inventory/group_vars/*.yml | grep -v '^\s' | awk -F':' '/:/ {print $1}'); do  
  VAR="$(grep -l "^$i" inventory/group_vars/*.yml)"
  if [[ "$(echo -e ${VAR} | sed 's/\s/\n/g' | wc -l)" -gt 1 ]];then
    echo -e "\n$i:"
    echo -e "${VAR}"
  fi
done

If your deployment has group_var collisions the output will look similar to something like this.

lxc_container_config_list:
playbooks/inventory/group_vars/all_containers.yml
playbooks/inventory/group_vars/cinder_volume.yml
playbooks/inventory/group_vars/neutron_agent.yml

memcached_port:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/keystone_all.yml

memcached_servers:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/keystone_all.yml

galera_address:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/neutron_all.yml

rabbitmq_port:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/neutron_all.yml

rabbitmq_servers:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/neutron_all.yml

rabbitmq_use_ssl:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/neutron_all.yml

openstack_external_ssl:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/gnocchi_all.yml
playbooks/inventory/group_vars/horizon_all.yml
playbooks/inventory/group_vars/keystone_all.yml
playbooks/inventory/group_vars/nova_all.yml

openstack_service_publicuri_proto:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/aodh_all.yml
playbooks/inventory/group_vars/ceilometer_all.yml

service_region:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/ceilometer_all.yml
playbooks/inventory/group_vars/cinder_all.yml
playbooks/inventory/group_vars/glance_all.yml
playbooks/inventory/group_vars/gnocchi_all.yml
playbooks/inventory/group_vars/heat_all.yml
playbooks/inventory/group_vars/horizon_all.yml
playbooks/inventory/group_vars/swift_all.yml

dhcp_domain:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/neutron_all.yml
playbooks/inventory/group_vars/nova_all.yml

service_ldap_backend_enabled:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/aodh_all.yml
playbooks/inventory/group_vars/ceilometer_all.yml
playbooks/inventory/group_vars/cinder_all.yml
playbooks/inventory/group_vars/glance_all.yml
playbooks/inventory/group_vars/heat_all.yml
playbooks/inventory/group_vars/keystone_all.yml
playbooks/inventory/group_vars/neutron_all.yml
playbooks/inventory/group_vars/nova_all.yml
playbooks/inventory/group_vars/swift_all.yml

cinder_backends_rbd_inuse:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/cinder_all.yml

cinder_ceph_client:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/nova_all.yml

glance_api_servers:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/cinder_all.yml
playbooks/inventory/group_vars/nova_all.yml

neutron_rabbitmq_userid:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/neutron_all.yml

neutron_rabbitmq_vhost:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/neutron_all.yml

neutron_rabbitmq_port:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/neutron_all.yml

neutron_plugin_type:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/horizon_all.yml

lxc_container_config_list:
playbooks/inventory/group_vars/all_containers.yml
playbooks/inventory/group_vars/cinder_volume.yml
playbooks/inventory/group_vars/neutron_agent.yml

galera_client_drop_config_file:
playbooks/inventory/group_vars/galera_all.yml
playbooks/inventory/group_vars/utility_all.yml

lxc_container_config_list:
playbooks/inventory/group_vars/all_containers.yml
playbooks/inventory/group_vars/cinder_volume.yml
playbooks/inventory/group_vars/neutron_agent.yml

neutron_rabbitmq_userid:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/neutron_all.yml

neutron_rabbitmq_vhost:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/neutron_all.yml

neutron_rabbitmq_port:
playbooks/inventory/group_vars/all.yml
playbooks/inventory/group_vars/neutron_all.yml

galera_client_drop_config_file:
playbooks/inventory/group_vars/galera_all.yml
playbooks/inventory/group_vars/utility_all.yml

Sadly a fix which would've solved for variable collisions was rejected by Ansible proper and the less than desirable interface group_vars provides still exists.