<p dir="auto">Hi</p>
<p dir="auto">I am having the following issue when applying the variable set below:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ec2_security_groups_test:
    - sg_name: test-grup
      sg_description: test-group
      vpc_id: &quot;vpc-XXXXXX&quot;
      region: &quot;{{ region }}&quot;
      sg_rules:
       - proto: 50
         from_port: -1
         to_port: -1
         cidr_ip: 12.12.12.12/32
       - proto: 50
         from_port: -1
         to_port: -1
         cidr_ip: 13.13.13.13/32
       - proto: 50
         from_port: -1
         to_port: -1
         group_name: test-group
"><pre class="notranslate"><code class="notranslate">ec2_security_groups_test:
    - sg_name: test-grup
      sg_description: test-group
      vpc_id: "vpc-XXXXXX"
      region: "{{ region }}"
      sg_rules:
       - proto: 50
         from_port: -1
         to_port: -1
         cidr_ip: 12.12.12.12/32
       - proto: 50
         from_port: -1
         to_port: -1
         cidr_ip: 13.13.13.13/32
       - proto: 50
         from_port: -1
         to_port: -1
         group_name: test-group

</code></pre></div>
<p dir="auto">it will work on the 1st run, but on the second I will have:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;Response&gt;&lt;Errors&gt;&lt;Error&gt;&lt;Code&gt;InvalidPermission.Duplicate&lt;/Code&gt;&lt;Message&gt;the specified rule &quot;peer: 12.12.12.12/32, protocol: 50, ALLOW&quot; already exists&lt;/Message&gt;&lt;/Error&gt;&lt;/Errors&gt;&lt;RequestID&gt;e890595b-9609-4c31-a611-87da7b5de7ae&lt;/RequestID&gt;&lt;/Response&gt;

"><pre class="notranslate"><code class="notranslate">&lt;Response&gt;&lt;Errors&gt;&lt;Error&gt;&lt;Code&gt;InvalidPermission.Duplicate&lt;/Code&gt;&lt;Message&gt;the specified rule "peer: 12.12.12.12/32, protocol: 50, ALLOW" already exists&lt;/Message&gt;&lt;/Error&gt;&lt;/Errors&gt;&lt;RequestID&gt;e890595b-9609-4c31-a611-87da7b5de7ae&lt;/RequestID&gt;&lt;/Response&gt;


</code></pre></div>
<p dir="auto">I have tried specifying Ports, also "-1".. Nothing seems to work.<br>
If I say TCP or UDP it works fine, but when I specify a numeric port as above I got the issue:</p>
<p dir="auto">Any possible workaround?</p>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.1.0
  config file =
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.1.1.0
  config file =
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Amazon Linux 4.4.11-23.53.amzn1.x86_64</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">In v2.1.1.0, the add_host module will no longer pick up group_vars if the group name includes a forward slash. This worked in v2.1.0.0 and v2.0.0.1.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>

<p dir="auto">Create a simple playbook structure as follows:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="group_vars/dir1/foo.yml
play.yml"><pre class="notranslate"><code class="notranslate">group_vars/dir1/foo.yml
play.yml
</code></pre></div>
<p dir="auto">Run <code class="notranslate">ansible-playbook play.yml</code></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#######
# play.yml
#######
- hosts: localhost
  gather_facts: no
  tasks:
    - add_host:
        name: '{{inventory_hostname}}'
        groups: 'dir1/foo'
    - debug: var=bar"><pre class="notranslate"><code class="notranslate">#######
# play.yml
#######
- hosts: localhost
  gather_facts: no
  tasks:
    - add_host:
        name: '{{inventory_hostname}}'
        groups: 'dir1/foo'
    - debug: var=bar
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#######
# foo.yml
#######
bar: 'abc'"><pre class="notranslate"><code class="notranslate">#######
# foo.yml
#######
bar: 'abc'
</code></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">With this playbook, we would expect to see the value of bar printed.<br>
These are the results when running Ansible v2.1.0.0:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook play.yml -vvvv
No config file found; using defaults
 [WARNING]: Host file not found: /etc/ansible/hosts
 [WARNING]: provided hosts list is empty, only localhost is available
Loaded callback default of type stdout, v2.0

PLAYBOOK: play.yml *************************************************************
1 plays in play.yml

PLAY [localhost] ***************************************************************

TASK [add_host] ****************************************************************
task path: /tmp/test/play.yml:4
creating host via 'add_host': hostname=localhost
changed: [localhost] =&gt; {&quot;add_host&quot;: {&quot;groups&quot;: [&quot;dir1/foo&quot;], &quot;host_name&quot;: &quot;localhost&quot;, &quot;host_vars&quot;: {}}, &quot;changed&quot;: true, &quot;invocation&quot;: {&quot;module_args&quot;: {&quot;groups&quot;: &quot;dir1/foo&quot;, &quot;name&quot;: &quot;localhost&quot;}, &quot;module_name&quot;: &quot;add_host&quot;}}

TASK [debug] *******************************************************************
task path: /tmp/test/play.yml:7
ok: [localhost] =&gt; {
    &quot;bar&quot;: &quot;abc&quot;
}

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0"><pre class="notranslate"><code class="notranslate">ansible-playbook play.yml -vvvv
No config file found; using defaults
 [WARNING]: Host file not found: /etc/ansible/hosts
 [WARNING]: provided hosts list is empty, only localhost is available
Loaded callback default of type stdout, v2.0

PLAYBOOK: play.yml *************************************************************
1 plays in play.yml

PLAY [localhost] ***************************************************************

TASK [add_host] ****************************************************************
task path: /tmp/test/play.yml:4
creating host via 'add_host': hostname=localhost
changed: [localhost] =&gt; {"add_host": {"groups": ["dir1/foo"], "host_name": "localhost", "host_vars": {}}, "changed": true, "invocation": {"module_args": {"groups": "dir1/foo", "name": "localhost"}, "module_name": "add_host"}}

TASK [debug] *******************************************************************
task path: /tmp/test/play.yml:7
ok: [localhost] =&gt; {
    "bar": "abc"
}

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">In v2.1.1.0, bar is undefined, implying the group_vars/dir1/foo.yml is not being included.<br>
This is what happens when running the same playbook using v2.1.1.0</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook play.yml -vvvv
No config file found; using defaults
 [WARNING]: Host file not found: /etc/ansible/hosts
 [WARNING]: provided hosts list is empty, only localhost is available
Loaded callback default of type stdout, v2.0

PLAYBOOK: play.yml *************************************************************
1 plays in play.yml

PLAY [localhost] ***************************************************************

TASK [add_host] ****************************************************************
task path: /tmp/test/play.yml:4
creating host via 'add_host': hostname=localhost
changed: [localhost] =&gt; {&quot;add_host&quot;: {&quot;groups&quot;: [&quot;dir1/foo&quot;], &quot;host_name&quot;: &quot;localhost&quot;, &quot;host_vars&quot;: {}}, &quot;changed&quot;: true, &quot;invocation&quot;: {&quot;module_args&quot;: {&quot;groups&quot;: &quot;dir1/foo&quot;, &quot;name&quot;: &quot;localhost&quot;}, &quot;module_name&quot;: &quot;add_host&quot;}}

TASK [debug] *******************************************************************
task path: /tmp/test/play.yml:7
ok: [localhost] =&gt; {
    &quot;bar&quot;: &quot;VARIABLE IS NOT DEFINED!&quot;
}

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0"><pre class="notranslate"><code class="notranslate">ansible-playbook play.yml -vvvv
No config file found; using defaults
 [WARNING]: Host file not found: /etc/ansible/hosts
 [WARNING]: provided hosts list is empty, only localhost is available
Loaded callback default of type stdout, v2.0

PLAYBOOK: play.yml *************************************************************
1 plays in play.yml

PLAY [localhost] ***************************************************************

TASK [add_host] ****************************************************************
task path: /tmp/test/play.yml:4
creating host via 'add_host': hostname=localhost
changed: [localhost] =&gt; {"add_host": {"groups": ["dir1/foo"], "host_name": "localhost", "host_vars": {}}, "changed": true, "invocation": {"module_args": {"groups": "dir1/foo", "name": "localhost"}, "module_name": "add_host"}}

TASK [debug] *******************************************************************
task path: /tmp/test/play.yml:7
ok: [localhost] =&gt; {
    "bar": "VARIABLE IS NOT DEFINED!"
}

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0
</code></pre></div>