# Ansible Omit filter behavior issue

**URL:** <https://forum.ansible.com/t/ansible-omit-filter-behavior-issue/24127>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [April 3, 2017, 2:58pm UTC](https://forum.ansible.com/t/ansible-omit-filter-behavior-issue/24127 "2017-04-03T14:58:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anderson\_Goulart](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Anderson\_Goulart](https://forum.ansible.com/u/Anderson_Goulart)\
**Post date:** [April 3, 2017, 2:58pm UTC](https://forum.ansible.com/t/ansible-omit-filter-behavior-issue/24127/1 "2017-04-03T14:58:30Z")

</div>

Hi,

I am trying to build a role which will help us to create new security groups on AWS based on a dictionary. But I have an issue with one to enable the rules parsing caused by a conflict between 2 args that are mutually exclusive.

Imagine the following lines:

rules:

cidr\_ip: “{{ item.1.cidr\_ip | default(omit) }}”  
group\_id: “{{ item.1.group\_id | default(omit) }}”

I can only have one or another, but not both defined. I though that ‘omit’ filter would do the job, removing the arg from the rules dictionary, but it is not working. The AWS module trigger this failure:

// ec2\_group.py

if ‘group\_id’ in rule and ‘cidr\_ip’ in rule:  
module.fail\_json(msg=‘Specify group\_id OR cidr\_ip, not both’)

Is there anyway that I can solve this issue? Or is this a bug?

Ansible version: 2.2.2.0

// Anderson
