# Optional dependencies

**URL:** <https://forum.ansible.com/t/optional-dependencies/16699>\
**Category:** Ansible Developer\
**Tags:** galaxy-ng\
**Created:** [November 5, 2014, 11:59am UTC](https://forum.ansible.com/t/optional-dependencies/16699 "2014-11-05T11:59:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephen\_Gargan](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Stephen\_Gargan](https://forum.ansible.com/u/Stephen_Gargan)\
**Post date:** [November 5, 2014, 11:59am UTC](https://forum.ansible.com/t/optional-dependencies/16699/1 "2014-11-05T11:59:02Z")

</div>

I’d like to float the idea of having optional dependencies. For the most part I use supervisor to control the services that I install on my linux hosts, I’ve found that it is almost a prequisite dependency and its’s included in the meta dependencies list of many of my roles. I’d like to share some of my roles through galaxy, but I’m not sure that I want to tie their usage to the supervisor role, which others might not find as useful as I do. I also find that if I download a role which has a dependency I don’t use or have implemented differently, I have to hack it to remove the offender. It would be useful to have a way for users to avoid installing a dependency.

I know this can be achieved using tags, but rather than everyone rolling their own solution, it would be useful I think if there was a uniform way of doing so, particularly for roles shared using galaxy.

What I’d suggest is the ability to veto a dependency when you invoke the role, possibly as follows

- {role: my\_managed\_service, without: ‘sgargan.supervisor’}

Using a role would would set a variable {rolename}\_applied (or something to that effect) to true or false depending on whether a dependency had been applied so that the parts of the role that utilized the dependency could be skipped

- name: install the supervisor config for my\_managed\_service  
template: src=my\_managed\_service.conf dest={{supervisor.d\_config}}  
when: sgargan.supervisor\_applied

To avoid suprises, optional dependencies could be marked as such when they are defined, with everything else being mandatory.

- dependencies:
- {role: sgargan.supervisord, optional: true}

What are people’s thoughts on this?

thanks,

Steve

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [November 5, 2014, 2:34pm UTC](https://forum.ansible.com/t/optional-dependencies/16699/2 "2014-11-05T14:34:05Z")

</div>

I think we’d want to avoid this level of complexity at this time - role dependencies are already a source of confusion.
