Hi, David

Thanks for your reply. I have been more clear about the compiling of puppet.
Do you have any good method to get the package version after installing if 
with Package resource? I need the version to configure the my.cnf file.

I know a method to get the version of packages that already installed, 
which are as follows.

Puppet::Parser::Functions::newfunction(:get_pkg_version, :type => :rvalue) 
do |args|
  pkg_name = args[0]
  pkg = Puppet::Type.type(:package).new(:name => pkg_name)
  version = pkg.retrieve[pkg.property(:ensure)].to_s
  version.split(/-|\+/).at 0
end

But is there any function of Package type that can get the latest version 
in the software repository (e.g. yum or zypper)? So that I can get the 
version of a package which will be installed and configure its conf file.

Really looking forward for your answer!

Thanks
Apple

在 2012年10月23日星期二UTC+8下午10时49分03秒,David Schmitt写道:
>
> Hi, 
>
> the function is executed on the puppet master at the time of compiling 
> the catalog. 
>
> The catalog is then transferred to the agent where all resources are 
> applied. 
>
> Depending on your setup this might not only be two different stages in 
> the process, but also two different machines! 
>
> This is explained in more depth here: 
>
> > http://docs.puppetlabs.com/learning/manifests.html 
>
>
> Best Regards, David 
>
> On 23.10.2012 11:09, Apple Wang wrote: 
> > Hi, all 
> > I'm confused about the execution sequence in puppet. 
> > *The background:* 
> > ** I want to get mysql package version after installing it with the 
> > Package resource. And I'll configure /etc/my.cnf according the version 
> > of mysql package. The code is as following. 
> >      ----------------------------------------------- 
> >      class mysql{ 
> >          package { "mysql": 
> >             ensure => latest, 
> >          } 
> >          $mysql_version = get_pkg_version("mysql") 
> > 
> >          file { '/etc/my.cnf': 
> >               ensure => present, 
> >               content => template('mysql/mysql.cnf'), 
> >               require => Package["mysql"], 
> >           } 
> >      } 
> >      ----------------------------- 
> >     Note: get_pkg_version is a user defined function written by me. It 
> > can get mysql rpm version when mysql is installed. 
> > 
> > *Issue:* 
> >      First time I executed /*puppet agent -t*, /the variable 
> > */mysql_version/* didn't get the value of mysql rpm version. 
> >      But the second time, after mysql is installed. 
> > */mysql_version/* can get the value of mysql rpm version. 
> > 
> > Can anyone help me with the problem? 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Puppet Users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/puppet-users/-/4uL89crPzDsJ. 
> > To post to this group, send email to 
> > puppet...@googlegroups.com<javascript:>. 
>
> > To unsubscribe from this group, send email to 
> > puppet-users...@googlegroups.com <javascript:>. 
> > For more options, visit this group at 
> > http://groups.google.com/group/puppet-users?hl=en. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/2qqLpZthbU4J.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to