# mutually exclusive options

**URL:** <https://forum.ansible.com/t/mutually-exclusive-options/15411>\
**Category:** Ansible Developer\
**Created:** [June 5, 2014, 4:07pm UTC](https://forum.ansible.com/t/mutually-exclusive-options/15411 "2014-06-05T16:07:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stanley\_Kamithi](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Stanley\_Kamithi](https://forum.ansible.com/u/Stanley_Kamithi)\
**Post date:** [June 5, 2014, 4:07pm UTC](https://forum.ansible.com/t/mutually-exclusive-options/15411/1 "2014-06-05T16:07:47Z")

</div>

Need some advice on module syntax

I want to do this:

cl\_interface name=br0 bridgemems=(list of bridge ports) ipv4=‘10.1.1.1/24’  
cl\_interface name=bond0 bondmems=(list of bond members) ipv4=‘10.2.2.2/24’

the bondmems and bridgemems keywords are mutually exclusive.

Question: Can AnsibleModule handle this mutual exclusive condition, like I can with ‘docopt’. With docopt I can say ‘cl\_interface [(–bridgemems | --bondmems)] [–ipv4]’.

If not, I guess I have to code this logic and execute AnsibleModule.fail\_json to warn the user.

Or, is it better to write

cl\_bridge name=br0 bridgemems=(list of bridges ports) ipv4=2.2.2.2/24  
cl\_bond name=br0 bondmems=(list of bonds) ipv4=1.1.1.1/24

I do prefer to use just ‘cl\_interface’ keyword, because I can cover all types of switch interfaces, i.e bond, bridges, loopbacks, and management ports with one module.

Thanks in advance for your help

Stanley K.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [June 5, 2014, 4:13pm UTC](https://forum.ansible.com/t/mutually-exclusive-options/15411/2 "2014-06-05T16:13:07Z")

</div>

Yes, when specifying the module arguments, you can use the mutually\_exclusive option to specify options that should not be used together. For instance, from the library/cloud/ec2 module:

mutually\_exclusive = [  
[‘exact\_count’, ‘count’],  
[‘exact\_count’, ‘state’],  
[‘exact\_count’, ‘instance\_ids’]  
],

You can grep for “mutually\_exclusive” in the library/ directory to see how other modules are using.
