realizing virtual packages with different provider (gem)

32 views
Skip to first unread message

gary

unread,
Dec 26, 2008, 2:38:15 AM12/26/08
to Puppet Users
Hello,

I'm starting to add gems as virtual resources. Some of them have the
same name as default provider packages. If I want to realize them,
should I define the package with an alias? Like:

@package {'mysql':
ensure => present,
alias => 'mysqlgem',
provider => gem,
}

Joshua Timberman

unread,
Dec 26, 2008, 10:04:32 AM12/26/08
to puppet...@googlegroups.com

I'd use a define.

define gem_package($ensure = 'true', $version) {
exec { "gem-package-$name":
path => "/path/to/gem_command",
command => "gem install --version $version $name",
unless => "gem list --local rails | grep '${name}.*${version}'
}

You can add more command options too, such as handling a different gem
server. Or disable ri and rdoc.

--
Joshua Timberman
http://twitter.com/jtimberman

Joshua Timberman

unread,
Dec 26, 2008, 10:05:54 AM12/26/08
to puppet...@googlegroups.com
Argh. Thats what I get pre-coffee. I'd also check the syntax and add
the missing brace in the exec:

> unless => "gem list --local rails | grep '${name}.*${version}'
}
> }

--
Joshua Timberman
http://twitter.com/jtimberman

gary

unread,
Jan 8, 2009, 4:59:58 AM1/8/09
to Puppet Users
Hello Joshua,

Thank you very much. I finally got around to trying this out and it
works nicely! But for some reason the unless grep didn't work. I had
it test for the installed gem directory:

define rubygems::install ( $ensure = 'true', $version ) {
exec { "gem-$name":
command => "/usr/local/bin/gem install $name --version $version",
onlyif => "test -f /usr/local/bin/gem",
unless => "test -d /usr/local/lib/ruby/gems/1.8/gems/${name}-$
{version}",
}
}




On Dec 26 2008, 11:05 pm, "Joshua Timberman"
<joshua.timber...@gmail.com> wrote:
> Argh. Thats what I get pre-coffee. I'd also check the syntax and add
> the missing brace in the exec:
>
>
>
> >    unless => "gemlist --local rails | grep '${name}.*${version}'
>      }
> > }
>
> --
> Joshua Timbermanhttp://twitter.com/jtimberman
Reply all
Reply to author
Forward
0 new messages