# How to deal with cookbook dependence for other Distro/OS's

**URL:** <https://discourse.chef.io/t/how-to-deal-with-cookbook-dependence-for-other-distro-oss/2127>\
**Category:** Chef Infra (archive)\
**Created:** [October 20, 2011, 8:32pm UTC](https://discourse.chef.io/t/how-to-deal-with-cookbook-dependence-for-other-distro-oss/2127 "2011-10-20T20:32:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zuhaib\_Siddique](https://avatars.discourse-cdn.com/v4/letter/z/d9b06d/32.png) [@Zuhaib\_Siddique](https://discourse.chef.io/u/Zuhaib_Siddique)\
**Post date:** [October 20, 2011, 8:32pm UTC](https://discourse.chef.io/t/how-to-deal-with-cookbook-dependence-for-other-distro-oss/2127/1 "2011-10-20T20:32:19Z")

</div>

Hey,

So it seems some of the cookbooks from Opscode by default set depends statements in their metadata.rb for cookbooks that are required by a particular OS/Distro. In the case of say tomcat cookbook it sets jpackage as a dependence but you only need that for RPM base Distro’s. Since I am deploying on a Ubuntu box I am not included jpackage in the run list and that made it very unhappy. So I just removed it from the metadata.rb but I am just wondering if this is what is expected to be done by the cookbook provided by opscode?

Thanks  
Zuhaib

---

<div class="post-metadata">

**Author:** ![AJ\_Christensen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/aj_christensen/32/525_2.png) [@AJ\_Christensen](https://discourse.chef.io/u/AJ_Christensen)\
**Post date:** [October 20, 2011, 8:57pm UTC](https://discourse.chef.io/t/how-to-deal-with-cookbook-dependence-for-other-distro-oss/2127/2 "2011-10-20T20:57:35Z")

</div>

I've been using the "suggests" metadata field, but this also sucks.

We really want/need a platform-specific "depends" metadata.

like, maybe take a hash of platforms?

depends { "ubuntu" =\> ["apt", "ubuntu", "reprepro"],  
"redhat" =\> ["yum", "redhat", "some\_repo\_software"] }

–AJ

On 21 October 2011 09:32, Zuhaib Siddique [zuhaib.siddique@leapfile.com](mailto:zuhaib.siddique@leapfile.com) wrote:

> Hey,
> 
> So it seems some of the cookbooks from Opscode by default set depends statements in their metadata.rb for cookbooks that are required by a particular OS/Distro. In the case of say tomcat cookbook it sets jpackage as a dependence but you only need that for RPM base Distro's. Since I am deploying on a Ubuntu box I am not included jpackage in the run list and that made it very unhappy. So I just removed it from the metadata.rb but I am just wondering if this is what is expected to be done by the cookbook provided by opscode?
> 
> Thanks  
> Zuhaib

---

<div class="post-metadata">

**Author:** ![Aaron\_Abramson](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@Aaron\_Abramson](https://discourse.chef.io/u/Aaron_Abramson)\
**Post date:** [October 20, 2011, 9:04pm UTC](https://discourse.chef.io/t/how-to-deal-with-cookbook-dependence-for-other-distro-oss/2127/3 "2011-10-20T21:04:42Z")

</div>

Can't you wrap the depends in an if block?

On Oct 20, 2011, at 3:57 PM, AJ Christensen wrote:

> I've been using the "suggests" metadata field, but this also sucks.
> 
> We really want/need a platform-specific "depends" metadata.
> 
> like, maybe take a hash of platforms?
> 
> depends { "ubuntu" =\> ["apt", "ubuntu", "reprepro"],  
> "redhat" =\> ["yum", "redhat", "some\_repo\_software"] }
> 
> –AJ
> 
> On 21 October 2011 09:32, Zuhaib Siddique [zuhaib.siddique@leapfile.com](mailto:zuhaib.siddique@leapfile.com) wrote:
> 
> > Hey,
> > 
> > So it seems some of the cookbooks from Opscode by default set depends statements in their metadata.rb for cookbooks that are required by a particular OS/Distro. In the case of say tomcat cookbook it sets jpackage as a dependence but you only need that for RPM base Distro's. Since I am deploying on a Ubuntu box I am not included jpackage in the run list and that made it very unhappy. So I just removed it from the metadata.rb but I am just wondering if this is what is expected to be done by the cookbook provided by opscode?
> > 
> > Thanks  
> > Zuhaib

---

<div class="post-metadata">

**Author:** ![Brad\_Knowles](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/brad_knowles/32/716_2.png) [@Brad\_Knowles](https://discourse.chef.io/u/Brad_Knowles)\
**Post date:** [October 20, 2011, 9:49pm UTC](https://discourse.chef.io/t/how-to-deal-with-cookbook-dependence-for-other-distro-oss/2127/4 "2011-10-20T21:49:12Z")

</div>

On Oct 20, 2011, at 3:32 PM, Zuhaib Siddique wrote:

> So it seems some of the cookbooks from Opscode by default set depends statements in their metadata.rb for cookbooks that are required by a particular OS/Distro.

Yup. I see that throughout all (or almost all) of the cookbooks.

> In the case of say tomcat cookbook it sets jpackage as a dependence but you only need that for RPM base Distro's. Since I am deploying on a Ubuntu box I am not included jpackage in the run list and that made it very unhappy. So I just removed it from the metadata.rb but I am just wondering if this is what is expected to be done by the cookbook provided by opscode?

I have the reverse problem -- I'm on CentOS, but all (or almost all) of the cookbooks I pull down have massive Ubuntu/Debian dependencies built into them. I end up having to figure out how to port the cookbook over to CentOS before I can actually use it. Sometimes this isn't a great deal of hassle, and sometimes it is quite a bit more hassle than I had anticipated.

I generally wrap all the obvious stuff in "case node['platform'] ... when" statements. But, for example, there are some cookbooks that depend on things like apt, even though they don't actually use apt to install packages -- at least, not on CentOS.

I've tried to contribute all my changes back to the project, so that hopefully others won't have to go through quite as much pain as I have done. But this is a young company and there is a lot of work to do.

--  
Brad Knowles [bknowles@ihiji.com](mailto:bknowles@ihiji.com)  
SAGE Level IV, Chef Level 0.0.1

---

<div class="post-metadata">

**Author:** ![Andrea\_Campi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/andrea_campi/32/514_2.png) [@Andrea\_Campi](https://discourse.chef.io/u/Andrea_Campi)\
**Post date:** [October 21, 2011, 7:03am UTC](https://discourse.chef.io/t/how-to-deal-with-cookbook-dependence-for-other-distro-oss/2127/5 "2011-10-21T07:03:34Z")

</div>

A trick I've used when in a rush:  
If the dependency is only In the manifest, and you're positive you don't need eg jpackage on any of your nodes, you can just stub it out.  
That is, create a new empty jpackage cookbook and upload that one.  
Not a long-term solution, but it may help in the short term. YMMV

On Oct 20, 2011, at 10:32 PM, Zuhaib Siddique [zuhaib.siddique@leapfile.com](mailto:zuhaib.siddique@leapfile.com) wrote:

> Hey,
> 
> So it seems some of the cookbooks from Opscode by default set depends statements in their metadata.rb for cookbooks that are required by a particular OS/Distro. In the case of say tomcat cookbook it sets jpackage as a dependence but you only need that for RPM base Distro's. Since I am deploying on a Ubuntu box I am not included jpackage in the run list and that made it very unhappy. So I just removed it from the metadata.rb but I am just wondering if this is what is expected to be done by the cookbook provided by opscode?
> 
> Thanks  
> Zuhaib
