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?
Thanks,
Barry
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---