On Mar 22, 2009, at 9:28 PM, Barry J wrote:
>
> I''m new to puppet and am still wrapping my head around it, so
I''m sure
> this is a newbie question.
>
> Say I have a large number of mysql databases I want to host on a
> collection of database servers. I have a master database somewhere
> that says dbserv-1 hosts db-1, db-2, and db-3, and dbserv-2 hosts
> db-4, db-5, and db-6. I want puppet to set up the initial empty
> databases for me.
>
> I''ve made some progress. I am using an external classifier
script.
> When it sees the hostname dbserv-1, it knows the machine is a dbserv,
> so it outputs the mysql-server class. It also outputs a variable
> "databases" which contains the dbs for that server: [
"db-1", "db-2",
> "db-3" ]. I have a define which creates a database, and I pass
it
> that array as the title, so each database gets created if it does not
> already exist. This all works fine.
>
> However, when I create the database, I also want to create a user with
> a given password with access to it. My master database says what they
> should be: db-1/dbuser-1/dbpass-1, db-2/dbuser-2/dbpass-2, etc. So I
> need to pass to my database-creating define a tuple: database,
> username, password. I see how I can pass named arguments to a define,
> but I do not see how to do that in a useful way when the data is in
> arrays from a classifier script.
>
> Example: My database-creating define looks like this:
>
> define mysql::database($ensure) {
> case $ensure {
> present: { "createdb":
> exec { command to create db $name }
> }
> }
> }
>
> Inside my mysql-master class, I invoke this define:
>
> class mysql-master {
> # stuff to set up msqld goes here
>
> mysql::database { $databases:
> ensure => present
> }
> }
>
> This all works. But how do I pass to mysql::database information
> about the username and password to create in a way that is correlated
> with the right database name?
The only reasonable way to do this right now is to write your own
function that queries that information from the database. External
nodes don''t support passing actual resources, and we don''t
quite have
the ability to easily query for resources from any external source,
which is basically what you''re looking for here -- you''ve got
a bunch
of structured data that you want turned into resources.
I hope this will show up around 0.26, in the latter half of the year.
Ish.
--
The great aim of education is not knowledge but action.
-- Herbert Spencer
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---