# Story of yum module and the magic code

**URL:** <https://forum.ansible.com/t/story-of-yum-module-and-the-magic-code/11721>\
**Category:** Ansible Project\
**Created:** [July 25, 2012, 5:59am UTC](https://forum.ansible.com/t/story-of-yum-module-and-the-magic-code/11721 "2012-07-25T05:59:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nix85](https://avatars.discourse-cdn.com/v4/letter/n/f05b48/32.png) [@nix85](https://forum.ansible.com/u/nix85)\
**Post date:** [July 25, 2012, 5:59am UTC](https://forum.ansible.com/t/story-of-yum-module-and-the-magic-code/11721/1 "2012-07-25T05:59:21Z")

</div>

So I was working on changing the yum module to work with the magic module code and … we have a situation.

The yum module accepts the following arguments

# state=installed pkg=pkgspec

# state=removed pkg=pkgspec

# state=latest pkg=pkgspec

# informational commands:

# list=installed

# list=updates

# list=available

# list=repos

# list=pkgspec

Now, the above module has two required arguments and the presence of ANY ONE of them is valid. That means, atleast one of state= and list= should be supplied. To make things a little more complicated, if state= is specified, then we should also have pkg= specified.

Now the module magic code does not take all of this into account. We cannot specify things like “either one of these parameters must be specified”. I am wondering what would be a better way to handle such cases?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [July 25, 2012, 11:28am UTC](https://forum.ansible.com/t/story-of-yum-module-and-the-magic-code/11721/2 "2012-07-25T11:28:15Z")

</div>

Just handle it in the module code for now, I do not think the argument spec should deal with that kind of flow control. it does of course have defaults and choices, which are good to use.
