All-
We have some custom types & providers related to mysql (mysql_user,
mysql_grant, mysql_db) written by an admin that's no longer here. The
provider just uses the mysql command to run various commands, e.g:
Puppet::Type.type(:mysql_user).provide(:mysql) do
desc "Provider for a mysql user"
optional_commands :mysql => 'mysql'
mk_resource_methods
def create
debug "mysql_user create"
@property_hash[:ensure] = :present
mysql('mysql','-e',"create user '%s' identified by '%s';" %
[@resource[:name].sub("@","'@'"),@resource[:password]])
end
def flush
debug "in flush"
mysql('mysql','-e','flush privileges;')
@property_hash.clear
end
# other stuff elided
end
For this particular provider/type to work, though, it requires that
you actually have root's environment, because it relies on reading some
config from /root/.my.cnf.
That means that on most of our hosts, doing
sudo puppet agent --test
works fine, but on hosts where we use our mysql module with the custom
types and provider, we can't do that. We instead have to
sudo su -
puppet agent --test
to make certain we've picked up root's environment, specifically HOME.
What I would like to do is augment the provider so that the mysql command
is always invoked with the environment augmented with HOME=/root or
(even better) HOME=roots_home_from_facter.
I'm not certain how to pass an environment variable to an external command
that's invoked as part of a puppet provider, though, and the searches I've
done so far haven't turned up anything helpful.
Can anyone that's familiar with writing types and providers shed some
light on what I should be doing to augment this? I know this is as much
ruby ignorance as puppet ignorance, but I have to believe that there are
people here that can point me in the right direction.
Thanks,
Tim
--
Tim Mooney [email protected]
Enterprise Computing & Infrastructure 701-231-1076 (Voice)
Room 242-J6, IACC Building 701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164
--
You received this message because you are subscribed to the Google Groups "Puppet
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.