In regard to: Re: [Puppet Users] passing an environment variable to a...:
On Fri, Jun 28, 2013 at 2:03 PM, Tim Mooney <[email protected]> wrote: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.In Puppet 3, home environment can be passed something like: has_command(:brew, 'brew') do environment({ 'HOME' => ENV['HOME'] }) end
Thanks Nan. Even though I know better, I forgot to supply one bit of info -- we're still running puppet 2.7.x and I'm not certain when we're going to move to 3.2.x. Is there a puppet 2.7.x equivalent? 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.
