Matthew Macdonald-Wallace
2010-Sep-02 12:49 UTC
[Puppet Users] Using FACTER in other ruby code
Hi all, I''m trying to write a ruby script to setup MySQL replication base on facts that we can distribute at runtime. I have two facts(mysql_master and mysql_repl_dbs) that show up when I run facter --puppet, however they do not appear to be imported in the following script: ================================ #!/usr/bin/ruby # # mysql-replication.rb # # This script uses facter to setup mysql replication based upon the facts mysql_master and mysql_repl_dbs # # It is currently in beta # # 1) Require the relevant libraries require ''rubygems'' require ''facter'' require ''mysql'' # 2) Get the relevant facts and echo them to the screen puts "Getting facts" begin Facter.mysql_master puts "Facts received" rescue Facter.loadfacts() puts "running rescue" end mysql_master = Facter.value(''mysql_master'') mysql_repl_dbs = Facter.value(''mysql_master'') puts "Master Server: #{mysql_master}\nDatabases: #{mysql_repl_dbs}" ================= The output from the script is as follows: Getting facts running rescue Master Server: Databases: where as facter --puppet mysql_master shows the correct hostname. Am I missing a trick here? Thanks, Matt -- 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.
----- "Matthew Macdonald-Wallace" <mattmacwall@gmail.com> wrote:> Hi all, > > I''m trying to write a ruby script to setup MySQL replication base on > facts that we can distribute at runtime. > > I have two facts(mysql_master and mysql_repl_dbs) that show up when I > run facter --puppet, however they do not appear to be imported in the > following script: > > ================================> > #!/usr/bin/ruby > # > # mysql-replication.rb > # > # This script uses facter to setup mysql replication based upon the > facts mysql_master and mysql_repl_dbs > # > # It is currently in beta > # > > > # 1) Require the relevant libraries > require ''rubygems'' > require ''facter'' > require ''mysql''add around here: ENV[''FACTERLIB''] = "/var/lib/puppet/lib/facter:/var/lib/puppet/facts" substitute with wherever your pluginsync is putting the facts -- 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.
Matthew Macdonald-Wallace
2010-Sep-02 13:09 UTC
Re: [Puppet Users] Using FACTER in other ruby code
On 2 September 2010 13:52, R.I.Pienaar <rip@devco.net> wrote:> > add around here: > > ENV[''FACTERLIB''] = "/var/lib/puppet/lib/facter:/var/lib/puppet/facts" > > substitute with wherever your pluginsync is putting the factsWorks a treat. (as always!) Thanks for the heads-up. How do I get this into the puppet/facter documentation? Matt -- 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.
----- "Matthew Macdonald-Wallace" <mattmacwall@gmail.com> wrote:> On 2 September 2010 13:52, R.I.Pienaar <rip@devco.net> wrote: > > > > add around here: > > > > ENV[''FACTERLIB''] > "/var/lib/puppet/lib/facter:/var/lib/puppet/facts" > > > > substitute with wherever your pluginsync is putting the facts > > Works a treat. (as always!) > > Thanks for the heads-up. > > How do I get this into the puppet/facter documentation?not sure where would be appropriate, I just got that from the facter code - looked what it does for --puppet :) -- R.I.Pienaar -- 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.
Matthew Macdonald-Wallace
2010-Sep-02 13:28 UTC
Re: [Puppet Users] Using FACTER in other ruby code
On 2 September 2010 14:14, R.I.Pienaar <rip@devco.net> wrote:> not sure where would be appropriate, I just got that from the facter code - looked what it does for --puppet :)Doh! M. -- 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.
Charlotte McLaughlin
2013-May-14 18:34 UTC
Re: [Puppet Users] Using FACTER in other ruby code
Matt Did you ever get puppet to automate replication between a master mysql db and a slave mysql db. For example my host for the master is db01.xxx.xxx and the slave is db01.xxx.xxx. This seems to be an issue Puppet Labs does not support. Once I get a working solution I would like to present a presentation to San Francisco Puppet Master''s group as a demo to spread the knowledge. Thanks Mac On Thursday, September 2, 2010 6:09:00 AM UTC-7, macwall wrote:> > On 2 September 2010 13:52, R.I.Pienaar <r...@devco.net <javascript:>> > wrote: > > > > add around here: > > > > ENV[''FACTERLIB''] = "/var/lib/puppet/lib/facter:/var/lib/puppet/facts" > > > > substitute with wherever your pluginsync is putting the facts > > Works a treat. (as always!) > > Thanks for the heads-up. > > How do I get this into the puppet/facter documentation? > > Matt > >-- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.