Hi everyone, I have an interesting problem I think. I''m trying to install MySQL on FreeBSD. This is what I have in my init.pp of the module: ---------------- start ------------------ package { ''MySQL-server'' : name => $operatingsystem ? { freebsd => ''mysql51-server'', debian => ''mysql-server-5.0'', default => ''mysql51-server'', }, ensure => installed, } ----------------- end -------------------- When I run puppet this works fine, MySQL gets installed. But, when I run it a second time I get an error: debug: Puppet::Type::Package::ProviderFreebsd: Executing ''/usr/sbin/ pkg_add -r mysql51-server'' err: /Stage[main]/Mysql-server/Package[pkgMySQL-server]/ensure: change from absent to present failed: Execution of ''/usr/sbin/pkg_add -r mysql51-server'' returned 1: pkg_add: package ''mysql-server-5.1.48'' or its older version already installed I looks like Puppet is not able to figure out that MySQL 5.1 is already installed. If I list the packages installed (with pkg_info) I find MySQL there but it''s not called "mysql51-server" but "mysql- server-5.1.48". If I go back to my init.pp and change the name from "mysql51-server" to just "mysql-server", it works again (i.e. it will not try to install the package again). It is not possible to start with just "mysql-server", because there is no package called just "mysql-server". My conclusion is that FreeBSD''s inconsistent way of naming the packages fools Puppet to think it''s not installed. I''ve never written a line of ruby-code so I could use some help here. Can anyone think of a good workaround? BTW - my current, and not so pretty workaround is to link mysql- server.tbz to mysql51-server.tbz on my local FreeBSD-mirror-site. Thanks, Freddie -- 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.
Problem just keep hitting me... Can anyone see why this simple script fails: --------------- start ---------------- class mysql-server { Package[''mysql-server''] -> Service[''mysql''] package { mysql-server : name => "mysql-server", ensure => installed, } service { mysql : name => ''mysql-server'', require => Package[''mysql-server''], ensure => running, enable => true, } ----------- end ------------ When I run it, it alway ends with: err: Could not run Puppet configuration client: Could not find init script for ''mysql-server'' Which is becase it tries to start the service before it is installed... Might have something to do with FreeBSDs brilliant namingconvention, but that beats me. Br, Freddie On Sep 12, 4:32 pm, FreddieB <freddie.bra...@gmail.com> wrote:> Hi everyone, > > I have an interesting problem I think. > I''m trying to install MySQL on FreeBSD. This is what I have in my > init.pp of the module: > ---------------- start ------------------ > package { ''MySQL-server'' : > name => $operatingsystem ? { > freebsd => ''mysql51-server'', > debian => ''mysql-server-5.0'', > default => ''mysql51-server'', > }, > ensure => installed, > } > ----------------- end -------------------- > When I run puppet this works fine, MySQL gets installed. > But, when I run it a second time I get an error: > > debug: Puppet::Type::Package::ProviderFreebsd: Executing ''/usr/sbin/ > pkg_add -r mysql51-server'' > err: /Stage[main]/Mysql-server/Package[pkgMySQL-server]/ensure: change > from absent to present failed: Execution of ''/usr/sbin/pkg_add -r > mysql51-server'' returned 1: pkg_add: package ''mysql-server-5.1.48'' or > its older version already installed > > I looks like Puppet is not able to figure out that MySQL 5.1 is > already installed. If I list the packages installed (with pkg_info) I > find MySQL there but it''s not called "mysql51-server" but "mysql- > server-5.1.48". If I go back to my init.pp and change the name from > "mysql51-server" to just "mysql-server", it works again (i.e. it will > not try to install the package again). It is not possible to start > with just "mysql-server", because there is no package called just > "mysql-server". > > My conclusion is that FreeBSD''s inconsistent way of naming the > packages fools Puppet to think it''s not installed. I''ve never written > a line of ruby-code so I could use some help here. Can anyone think of > a good workaround? > > BTW - my current, and not so pretty workaround is to link mysql- > server.tbz to mysql51-server.tbz on my local FreeBSD-mirror-site. > > Thanks, > > Freddie-- 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.
On 09/12/2010 02:51 PM, FreddieB wrote:> Problem just keep hitting me... > > Can anyone see why this simple script fails: > --------------- start ---------------- > class mysql-server { > Package[''mysql-server''] -> Service[''mysql''] > > package { mysql-server : > name => "mysql-server", > ensure => installed, > } > > service { mysql : > name => ''mysql-server'', > require => Package[''mysql-server''], > ensure => running, > enable => true, > } > ----------- end ------------ >Removing the name parameter from the service definition lets it work. I understand why you set name, and it seems like you should be able to. This seems like a bug. Setting name on the service shouldn''t cause the resource title to not work. -- Russell A Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield -- 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.
On 09/12/2010 07:32 AM, FreddieB wrote:> I looks like Puppet is not able to figure out that MySQL 5.1 is > already installed. If I list the packages installed (with pkg_info) I > find MySQL there but it''s not called "mysql51-server" but "mysql- > server-5.1.48". If I go back to my init.pp and change the name from > "mysql51-server" to just "mysql-server", it works again (i.e. it will > not try to install the package again). It is not possible to start > with just "mysql-server", because there is no package called just > "mysql-server". > > My conclusion is that FreeBSD''s inconsistent way of naming the > packages fools Puppet to think it''s not installed. I''ve never written > a line of ruby-code so I could use some help here. Can anyone think of > a good workaround? > > BTW - my current, and not so pretty workaround is to link mysql- > server.tbz to mysql51-server.tbz on my local FreeBSD-mirror-site. >Yes. The package system has turned out to be a royal PITA for puppet. I don''t have any good work-a-rounds at the moment. I think we might be able to do something by specifying the package name as the port origin (pkg_info -o) and looking up the right package out of ports/INDEX. There''s been some discussion on the freebsd-ports list about improving the pkg_* tools and ports in general. I''m tempted to just say use APT and call it good. There''s zero chance of that happening due to licensing. -- Russell A Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield -- 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.
I can confirm Russels conclusion that it is a bug and if you don''t use "name => $operatingsystem..." is works. In my case I need to be able to distinguish between FreeBSD and Debian. A workaround that''s working for me is to set the variables outside the "package"-statement like this: ------------------------------------------------------------------------------------- #################### ### zabbix agent ### #################### class zabbix-agent { case $operatingsystem { freebsd: { $pkg_name = ''zabbix-agent'' $service_name ''zabbix_agentd'' $cfg_file = ''/usr/local/etc/zabbix/ zabbix_agentd.conf'' } debian: { $pkg_name = ''zabbix-agent'' $service_name ''zabbix_agent'' $cfg_file = ''/etc/zabbix/zabbix_agentd.conf'' } default: { $pkg_name = ''zabbix-agent'' $service_name ''zabbix_agent'' $cfg_file = ''/etc/zabbix/zabbix_agentd.conf'' } } Package[$pkg_name] -> File[$cfg_file] -> Service[$service_name] ####################### ### Install package ### ####################### package { $pkg_name : ensure => installed, } ####################### ### Get config-file ### ####################### file { $cfg_file : ensure => file, checksum => md5, owner => ''root'', group => $operatingsystem ? { freebsd => ''wheel'', debian => ''root'', default => ''wheel'', }, mode => 644, require => Package[$pkg_name], source => "puppet:///modules/zabbix-agent/$hostname/ zabbix_agentd.conf", } ##################### ### Start service ### ##################### service { $service_name : require => Package[$pkg_name], ensure => running, enable => true, } } ---------------------------------------------------------------------------------- Thanks for all your help. /Freddie On Sep 13, 6:59 pm, Russell Jackson <r...@csub.edu> wrote:> On 09/12/2010 07:32 AM, FreddieB wrote: > > > > > I looks like Puppet is not able to figure out that MySQL 5.1 is > > already installed. If I list the packages installed (with pkg_info) I > > find MySQL there but it''s not called "mysql51-server" but "mysql- > > server-5.1.48". If I go back to my init.pp and change the name from > > "mysql51-server" to just "mysql-server", it works again (i.e. it will > > not try to install the package again). It is not possible to start > > with just "mysql-server", because there is no package called just > > "mysql-server". > > > My conclusion is that FreeBSD''s inconsistent way of naming the > > packages fools Puppet to think it''s not installed. I''ve never written > > a line of ruby-code so I could use some help here. Can anyone think of > > a good workaround? > > > BTW - my current, and not so pretty workaround is to link mysql- > > server.tbz to mysql51-server.tbz on my local FreeBSD-mirror-site. > > Yes. The package system has turned out to be a royal PITA for puppet. I > don''t have any good work-a-rounds at the moment. I think we might be > able to do something by specifying the package name as the port origin > (pkg_info -o) and looking up the right package out of ports/INDEX. > > There''s been some discussion on the freebsd-ports list about improving > the pkg_* tools and ports in general. I''m tempted to just say use APT > and call it good. There''s zero chance of that happening due to licensing. > > -- > Russell A Jackson <r...@csub.edu> > Network Analyst > California State University, Bakersfield-- 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.
On 09/13/2010 09:59 AM, Russell Jackson wrote:> On 09/12/2010 07:32 AM, FreddieB wrote: >> I looks like Puppet is not able to figure out that MySQL 5.1 is >> already installed. If I list the packages installed (with pkg_info) I >> find MySQL there but it''s not called "mysql51-server" but "mysql- >> server-5.1.48". If I go back to my init.pp and change the name from >> "mysql51-server" to just "mysql-server", it works again (i.e. it will >> not try to install the package again). It is not possible to start >> with just "mysql-server", because there is no package called just >> "mysql-server". >> >> My conclusion is that FreeBSD''s inconsistent way of naming the >> packages fools Puppet to think it''s not installed. I''ve never written >> a line of ruby-code so I could use some help here. Can anyone think of >> a good workaround? >> >> BTW - my current, and not so pretty workaround is to link mysql- >> server.tbz to mysql51-server.tbz on my local FreeBSD-mirror-site. >> > > Yes. The package system has turned out to be a royal PITA for puppet. I > don''t have any good work-a-rounds at the moment. I think we might be > able to do something by specifying the package name as the port origin > (pkg_info -o) and looking up the right package out of ports/INDEX. >I imagine it could work something like this: # Download the ports index mkdir /tmp/ports-index cd /tmp/ports-index fetch ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.1-release/INDEX.bz2 bunzip2 INDEX # Lookup package name from origin path pkgname=$(awk -F\| ''{ if ($2 == "/usr/ports/databases/mysql51-server") print $1 }'' INDEX) pkg_add -r ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.1-release/All/${pkgname}.tbz Checking if the package was installed could be done with pkg_info -O: pkg_info -O databases/mysql51-server | tail -n+2 | grep -qc ''$'' && echo ''installed'' || echo ''not installed'' Then the resource definition would look like this: package { "mysql-server": name => $operatingsystem ? { FreeBSD => "databases/mysql51-server", default => "mysql-server", }, ensure => installed, } -- Russell A Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield -- 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.
On 09/13/2010 11:26 AM, Russell Jackson wrote:> On 09/13/2010 09:59 AM, Russell Jackson wrote: >> On 09/12/2010 07:32 AM, FreddieB wrote: >>> I looks like Puppet is not able to figure out that MySQL 5.1 is >>> already installed. If I list the packages installed (with pkg_info) I >>> find MySQL there but it''s not called "mysql51-server" but "mysql- >>> server-5.1.48". If I go back to my init.pp and change the name from >>> "mysql51-server" to just "mysql-server", it works again (i.e. it will >>> not try to install the package again). It is not possible to start >>> with just "mysql-server", because there is no package called just >>> "mysql-server". >>> >>> My conclusion is that FreeBSD''s inconsistent way of naming the >>> packages fools Puppet to think it''s not installed. I''ve never written >>> a line of ruby-code so I could use some help here. Can anyone think of >>> a good workaround? >>> >>> BTW - my current, and not so pretty workaround is to link mysql- >>> server.tbz to mysql51-server.tbz on my local FreeBSD-mirror-site. >>> >> >> Yes. The package system has turned out to be a royal PITA for puppet. I >> don''t have any good work-a-rounds at the moment. I think we might be >> able to do something by specifying the package name as the port origin >> (pkg_info -o) and looking up the right package out of ports/INDEX. >> > > I imagine it could work something like this: > > # Download the ports index > mkdir /tmp/ports-index > cd /tmp/ports-index > fetch > ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.1-release/INDEX.bz2 > bunzip2 INDEX > > # Lookup package name from origin path > pkgname=$(awk -F\| ''{ if ($2 == "/usr/ports/databases/mysql51-server") > print $1 }'' INDEX) > > pkg_add -r > ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.1-release/All/${pkgname}.tbz > > > Checking if the package was installed could be done with pkg_info -O: > > pkg_info -O databases/mysql51-server | tail -n+2 | grep -qc ''$'' && > echo ''installed'' || echo ''not installed'' > >Hum... I''m just realizing that the Latest tree on the ftp mirror sort of already is a mapping from the origin (without the category) to the package name. So the install method can stay the same and just modify the pkg_info lookup to use pkg_info -O ''*/<package_name>'' -- Russell A Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield -- 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.
Sorry to get this way late, but I''ve got a solution for you if you haven''t found it already. So I''m putting this into the archives. On Sun, Sep 12, 2010 at 10:32 AM, FreddieB <freddie.brandt@gmail.com> wrote:> Hi everyone, > > I have an interesting problem I think. > I''m trying to install MySQL on FreeBSD. This is what I have in my > init.pp of the module: > ---------------- start ------------------ > package { ''MySQL-server'' : > name => $operatingsystem ? { > freebsd => ''mysql51-server'', > debian => ''mysql-server-5.0'', > default => ''mysql51-server'', > }, > ensure => installed, > } > ----------------- end -------------------- > When I run puppet this works fine, MySQL gets installed. > But, when I run it a second time I get an error: > >I rewrote the freebsd package/port provider a while ago and it''s in the tree - if you can handle having the portupgrade system installed, it should fix your problem. Also "ensure => latest" works. Use the "portupgrade" provider, and specify the package name as the _full origin_ "database/mysql51-server". If you''ve got custom compile options, then you can just make a dependency to "/var/db/ports/<name>/options" so they get compiled correctly as well. Cheers, Ross. -- 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.
On 10/07/2010 10:43 AM, Ross W wrote:> Sorry to get this way late, but I''ve got a solution for you if you haven''t > found it already. So I''m putting this into the archives. > > On Sun, Sep 12, 2010 at 10:32 AM, FreddieB<freddie.brandt@gmail.com> wrote: > >> Hi everyone, >> >> I have an interesting problem I think. >> I''m trying to install MySQL on FreeBSD. This is what I have in my >> init.pp of the module: >> ---------------- start ------------------ >> package { ''MySQL-server'' : >> name => $operatingsystem ? { >> freebsd => ''mysql51-server'', >> debian => ''mysql-server-5.0'', >> default => ''mysql51-server'', >> }, >> ensure => installed, >> } >> ----------------- end -------------------- >> When I run puppet this works fine, MySQL gets installed. >> But, when I run it a second time I get an error: >> >> > I rewrote the freebsd package/port provider a while ago and it''s in the tree > - if you can handle having the portupgrade system installed, it should fix > your problem. Also "ensure => latest" works. > > Use the "portupgrade" provider, and specify the package name as the _full > origin_ "database/mysql51-server".I''d note that portupgrade is buggy when run non-interactively. You may have problems with puppet hanging and have "script" instances spinning on the CPU at 100%. YMMV.> If you''ve got custom compile options, then you can just make a dependency to > "/var/db/ports/<name>/options" so they get compiled correctly as well.The format of the files and layout of /var/db/ports is considered private. Only the ports framework should mess with it. If you''re going to set compile options by hand, they belong in /etc/make.conf. -- Russell A Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield -- 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.