Ask Your Question

How to create a dependency on a puppetlabs/mysql binding

asked 2014-11-30 03:07:37 -0600

ChrisR gravatar image

I have a module containing a resource (of type exec, to run an installer) which has a dependency on the python bindings for MySQL.

I'm using the latest PuppetLabs MySQL module and struggling to figure out how to create this dependency. I can use the anchor pattern (or 'contains') to create a dependency on ::mysql::bindings, however that class doesn't have a dependency on the individual language bindings (which are marked as 'private' classes) and so there's nothing to stop puppet applying the resources for the binding after the installer has attempted to run. At the moment I can only think of two options which don't involve modifying the MySQL module:

  • stop using ::mysql::bindings and manage the language bindings for python manually (which defeats the point of using a third-party module); or
  • create a dependency directly on the private ::mysql::bindings::python class (which is not ideal as I shouldn't have to know about the 'internals' of a third-party module, especially if the class I'm depending upon is private).

The other option is to modify the ::mysql::bindings class to create a harder dependency on the individual bindings (and potentially submit a PR).

Is there something that I'm missing here? How should I be creating this dependency? Is there a way to create this dependency using the existing module and functionality or am I going to have to do something nasty or modify the third-party module?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-12-01 18:16:27 -0600

inhumantsar gravatar image

updated 2014-12-01 18:18:33 -0600

Seems like the ideal solution would be to modify the mysql::bindings class and submit a PR with your changes.

Personally, I don't see anything wrong with using require => Class['::mysql::bindings::python'] on your file resource. It's not ideal but it's far from kludgy or bad form. You already have to know about the internals of the module you're using as you require a specific binding out of it and you have an expected end result to look for. If this were a traditional programming project, I might side with you but being the Puppet DSL, I feel like violating the (completely arbitrary and non-binding) "private" attribute of the class is too minor to get hung up on.

edit flag offensive delete link more

answered 2014-12-03 08:36:03 -0600

The ideas around "private" classes are that while you can know of their existence and can include them directly, you should not depend on any resources inside them.

Take a look at razorsedge/cloudera's cloudera::cm5::server class to get an idea of what I have done for the MySQL (and PostgreSQL) bindings.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-11-30 03:07:37 -0600

Seen: 161 times

Last updated: Dec 03 '14