<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">1.7</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Centos 6.5</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Duplicate security group names (between different VPCs) cause issues with instance creation--</p>
<p dir="auto">When I run the ec2 module to create an instance in a VPC, it doesn't restrict the Security Group search to that VPC. So if I have the same SG name in 2 different VPCs (maybe bad practice), it can find the wrong one (and fail).</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<ol dir="auto">
<li>Create 2 VPCs with a subnet</li>
<li>Create a security group in each with the same name</li>
<li>Run: ansible localhost -m ec2 -a "image=ami-fb8e9292 instance_type=m3.medium keypair= group= wait=yes region=us-east-1 vpc_subnet_id=" -c local</li>
<li>If that works, try the other VPC/Subnet</li>
</ol>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">Identify the security group associated with the correct VPC/Subnet and create the instance</p>
<h5 dir="auto">Actual Results:</h5>
<pre class="notranslate">localhost | FAILED &gt;&gt; {
    "failed": true, 
    "msg": "Instance creation failed =&gt; InvalidParameter: Security group sg-xxxxxxx and subnet subnet-xxxxxxx belong to different networks."
}
</pre>
<h5 dir="auto">ISSUE TYPE</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto"><code class="notranslate">/lib/ansible/plugins/strategy/__init__.py</code></p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.5.0b1
  config file = None
  configured module search path = [u'/home/ec2-user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.13 (default, Jan 31 2018, 00:17:36) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]"><pre class="notranslate"><code class="notranslate">ansible 2.5.0b1
  config file = None
  configured module search path = [u'/home/ec2-user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.13 (default, Jan 31 2018, 00:17:36) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">no config changes</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Amazon Linux (essentially CentOS 7)</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">If a role has handlers defined in <code class="notranslate">ROLE/handlers/main.yaml</code> they are not loaded, however if the file extension is changed to <code class="notranslate">yml</code> the handlers are loaded. If both main.yml and main.yaml are present, ansible complains:<br>
<code class="notranslate">ERROR! found multiple main files at /home/ec2-user/ansible/roles/unicorn/handlers, only one allowed</code><br>
which suggests to me that it is processing the <code class="notranslate">main.yaml</code> still. The reason I believe it is not loading the handlers is my notify's began failing with:<br>
<code class="notranslate">ERROR! The requested handler 'HANDLER NAME' was not found in either the main handlers list nor in the listening handlers list</code></p>
<p dir="auto">I've been using the yaml extension for all of my other yaml files and they work just fine, this is the only case I have noticed where that file extension produced issues.</p>