# Port and Process resource abstractions?

**URL:** <https://discourse.chef.io/t/port-and-process-resource-abstractions/2382>\
**Category:** Chef Infra (archive)\
**Created:** [January 25, 2012, 10:29am UTC](https://discourse.chef.io/t/port-and-process-resource-abstractions/2382 "2012-01-25T10:29:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Hodder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/tom_hodder/32/541_2.png) [@Tom\_Hodder](https://discourse.chef.io/u/Tom_Hodder)\
**Post date:** [January 25, 2012, 10:29am UTC](https://discourse.chef.io/t/port-and-process-resource-abstractions/2382/1 "2012-01-25T10:29:33Z")

</div>

Ohai Chefs,

I have downloaded the monit and firewall cookbooks, and I can see that  
they use various strategies to allow other cookbooks to configure  
monitoring or setup firewall rules.

That is the monit cookbooks, typically define a monitrc resource which  
can be used in other cookbooks such as mysql; so

monitrc “mysql” do  
port 3306  
pid /some/path/to/pid.file  
end

or the fire wall offers a rule like so;

firewall\_rule “mysql” do  
port 3306  
networks 10.0.0.0/8  
end

But wouldn’t it make sense to offer that abstraction at a higher level,  
and promote Process and Ports to the resource level, and rather than  
couple your app to monit as above, just have your mysql::server recipe  
declare the resources that monit might use.

port “mysql” do  
port 3306  
networks 10.0.0.0/8  
end

process “mysql” do  
pidfile /some/path/to/pid.file  
end

And monit can come and enumerate any ports and pids that it should be  
monitoring from the node in its monit::install recipe… The same  
applies to the firewall cookbook. Its not like there are not some very  
well used common abstractions in monitoring and fire-walling  
applications already…

Any suggestions on whether someone has done this already, and why it  
might not make sense to do this would be appreciated…?

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![Bryan\_McLellan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/bryan_mclellan/32/81_2.png) [@Bryan\_McLellan](https://discourse.chef.io/u/Bryan_McLellan)\
**Post date:** [January 25, 2012, 2:55pm UTC](https://discourse.chef.io/t/port-and-process-resource-abstractions/2382/2 "2012-01-25T14:55:13Z")

</div>

On Jan 25, 2012 5:29 AM, "Tom H" [tom@limepepper.co.uk](mailto:tom@limepepper.co.uk) wrote:

> Any suggestions on whether someone has done this already, and why it  
> might not make sense to do this would be appreciated...?

Initial thoughts while sitting at an airport. Where do you draw the line of  
what you include in this abstractation? What if you want to open a firewall  
rule but there is nothing for monit to monitor? If you use something more  
complex like nagios, where do you put the additional attributes for  
controlling the plugin that is used for monitoring or the notification  
levels?

As you generalize what you would do for every port, you have to choose  
between limiting your options or creating an interface that quickly grows  
complex.

In this situation we have added an 'options' attribute to some resources  
which passes unique options back to the providers.

Bryan
