Custom resources and providers


#1

Hi,

I use Mercurial to manage my software repositories and would like to deploy
them with Chef. I have been unable to find any information about this online
and I have found limited documentation that explains how to roll your own
Resources and Providers.

Is it possible to write a Provider/Resource that implements SCM and is part
of a chef cookbook rather than the installed chef package? I found the
following page on the Opscode wiki
http://wiki.opscode.com/display/chef/Providers but it suggests that
implementing a Provider should be integrated into the chef package.

Any information you can provide would be greatly appreciated.

Niall Napier
London, United Kingdom
niall@napes.co.uk | www.napes.co.uk


#2

Hi Niall - the easiest way is to create an LWRP:

http://wiki.opscode.com/display/chef/Lightweight+Resources+and+Providers+(LWRP)

Adam

On Mon, Jan 17, 2011 at 12:48 PM, Niall Napier niall@napes.co.uk wrote:

Hi,
I use Mercurial to manage my software repositories and would like to deploy
them with Chef. I have been unable to find any information about this online
and I have found limited documentation that explains how to roll your own
Resources and Providers.
Is it possible to write a Provider/Resource that implements SCM and is part
of a chef cookbook rather than the installed chef package? I found the
following page on the Opscode wiki
http://wiki.opscode.com/display/chef/Providers but it suggests that
implementing a Provider should be integrated into the chef package.
Any information you can provide would be greatly appreciated.

Niall Napier
London, United Kingdom
niall@napes.co.uk | www.napes.co.uk


Opscode, Inc.
Adam Jacob, Chief Product Officer
T: (206) 619-7151 E: adam@opscode.com


#3

Hi Niall,

A lightweight resource provider that implemented mercurial calls would be amazingly valuable, especially as we seek to reach out to the Python/Django community. Not sure what your time constraints are, but we’re putting on Chef training at the end of the month, and Joshua would be around to give some direction on this. The training will cover LWRP at a high level - the advanced training in Ghent at the end of that week will cover it in more detail.

In the meantime, if you fancy meeting up for a coffee to chat about it, or to pair for a couple of hours, give me a shout - I’m in London a few days a week.

Best,

S.

On 17 Jan 2011, at 20:48, Niall Napier wrote:

Hi,

I use Mercurial to manage my software repositories and would like to deploy them with Chef. I have been unable to find any information about this online and I have found limited documentation that explains how to roll your own Resources and Providers.

Is it possible to write a Provider/Resource that implements SCM and is part of a chef cookbook rather than the installed chef package? I found the following page on the Opscode wiki http://wiki.opscode.com/display/chef/Providers but it suggests that implementing a Provider should be integrated into the chef package.

Any information you can provide would be greatly appreciated.
Niall Napier
London, United Kingdom
niall@napes.co.uk | www.napes.co.uk


#4

Well I have written a few custom Chef Resources in my cookbooks.

Those cookbooks are: dreamcat4/site-cookbooks/restart and
dreamcat4/site-cookbooks/rvm on GitHub. Actually the file is always in
/libraries/ subfolder of the cookbook.

But whatever your preconceptions - we all recommend that you give LWRP
a shot first of all. Its reasonably powerful and if you can do it in
LWRP then thats going to be the preferred / supported way.

Although im not sure exactly what Opscode would want from you in terms
of contributing an LWRP Mercurial VCS Resource back into their
codebase - its an afterthought. I assume thats what you were really
trying to figure out there.

On Mon, Jan 17, 2011 at 10:08 PM, Stephen Nelson-Smith
stephen@atalanta-systems.com wrote:

Hi Niall,

A lightweight resource provider that implemented mercurial calls would be amazingly valuable, especially as we seek to reach out to the Python/Django community. Not sure what your time constraints are, but we’re putting on Chef training at the end of the month, and Joshua would be around to give some direction on this. The training will cover LWRP at a high level - the advanced training in Ghent at the end of that week will cover it in more detail.

In the meantime, if you fancy meeting up for a coffee to chat about it, or to pair for a couple of hours, give me a shout - I’m in London a few days a week.

Best,

S.

On 17 Jan 2011, at 20:48, Niall Napier wrote:

Hi,

I use Mercurial to manage my software repositories and would like to deploy them with Chef. I have been unable to find any information about this online and I have found limited documentation that explains how to roll your own Resources and Providers.

Is it possible to write a Provider/Resource that implements SCM and is part of a chef cookbook rather than the installed chef package? I found the following page on the Opscode wiki http://wiki.opscode.com/display/chef/Providers but it suggests that implementing a Provider should be integrated into the chef package.

Any information you can provide would be greatly appreciated.
Niall Napier
London, United Kingdom
niall@napes.co.uk | www.napes.co.uk


#5

Thank you all for your replies,

After some head-scratching and with the help you provided above I’ve
implemented a basic resource/provider for Mercurial and would appreciate all
of your feedback.

I have uploaded it to https://bitbucket.org/niallsco/chef-cookbooks/ and
released it under an Apache 2.0 license.

I’ve also written a brief tutorial on how to use the chef-hg resource and
posted it online at http://napes.co.uk/blog/chef-hg/

Please let me know if you have any comments or questions, as mentioned all
feedback appreciated.

Regards,
*

Niall Napier
London, United Kingdom
niall@napes.co.uk | www.napes.co.uk
*

On 18 January 2011 21:35, Dreamcat4 dreamcat4@gmail.com wrote:

Well I have written a few custom Chef Resources in my cookbooks.

Those cookbooks are: dreamcat4/site-cookbooks/restart and
dreamcat4/site-cookbooks/rvm on GitHub. Actually the file is always in
/libraries/ subfolder of the cookbook.

But whatever your preconceptions - we all recommend that you give LWRP
a shot first of all. Its reasonably powerful and if you can do it in
LWRP then thats going to be the preferred / supported way.

Although im not sure exactly what Opscode would want from you in terms
of contributing an LWRP Mercurial VCS Resource back into their
codebase - its an afterthought. I assume thats what you were really
trying to figure out there.

On Mon, Jan 17, 2011 at 10:08 PM, Stephen Nelson-Smith
stephen@atalanta-systems.com wrote:

Hi Niall,

A lightweight resource provider that implemented mercurial calls would be
amazingly valuable, especially as we seek to reach out to the Python/Django
community. Not sure what your time constraints are, but we’re putting on
Chef training at the end of the month, and Joshua would be around to give
some direction on this. The training will cover LWRP at a high level - the
advanced training in Ghent at the end of that week will cover it in more
detail.

In the meantime, if you fancy meeting up for a coffee to chat about it,
or to pair for a couple of hours, give me a shout - I’m in London a few days
a week.

Best,

S.

On 17 Jan 2011, at 20:48, Niall Napier wrote:

Hi,

I use Mercurial to manage my software repositories and would like to
deploy them with Chef. I have been unable to find any information about this
online and I have found limited documentation that explains how to roll your
own Resources and Providers.

Is it possible to write a Provider/Resource that implements SCM and is
part of a chef cookbook rather than the installed chef package? I found the
following page on the Opscode wiki
http://wiki.opscode.com/display/chef/Providers but it suggests that
implementing a Provider should be integrated into the chef package.

Any information you can provide would be greatly appreciated.
Niall Napier
London, United Kingdom
niall@napes.co.uk | www.napes.co.uk