Possible to pass options to yum on package install


#1

Hi,
I have this in a recipe:

package “tomcat7” do
action :install
options "–enablerepo=amzn-main"
end

but the options are not being passed to yum and the package fails to
install because it isn’t found in my regular yum repos that are enabled by
default. I can’t enable the amzn-main repo by default because then the
system starts using it for everything, and I end up with some messy
dependency conflicts. Plus, I strongly prefer to just use the CentOS-Base
repo wherever possible.

So… Looking at http://docs.opscode.com/resource_package.html and I see:
options Additional options that are added to the underlying package
command. Can be used with APT, dpkg, Gentoo, RPM Package Manager, and
RubyGems. Default value: nil.

So that would explain why Yum isn’t getting the options passed to it. So my
questions are: is there a way to do this, and why can’t chef pass options
to yum just like APT?

Thanks much for any help…

Jeremy


#2

I’ve had a similar situation where I needed one package out of repoforge, but it created dependency hell everywhere else. My solution was to create my own local repository (and I’m using a chef cookbook to set up this repository). For me, it particularly made sense because I also have a couple RPMs that I need but aren’t in available in any public repo at all.

I haven’t yet figured out a way to keep these RPMs updated automatically, though.

From: Jeremy Koerber [mailto:jkoerber@branchout.com]
Sent: Wednesday, March 27, 2013 2:39 PM
To: chef@lists.opscode.com
Subject: [chef] possible to pass options to yum on package install

Hi,

I have this in a recipe:

package “tomcat7” do
action :install
options "–enablerepo=amzn-main"
end

but the options are not being passed to yum and the package fails to install because it isn’t found in my regular yum repos that are enabled by default. I can’t enable the amzn-main repo by default because then the system starts using it for everything, and I end up with some messy dependency conflicts. Plus, I strongly prefer to just use the CentOS-Base repo wherever possible.

So… Looking at http://docs.opscode.com/resource_package.html http://docs.opscode.com/resource_package.html and I see:
options Additional options that are added to the underlying package command. Can be used with APT, dpkg, Gentoo, RPM Package Manager, and RubyGems. Default value: nil.

So that would explain why Yum isn’t getting the options passed to it. So my questions are: is there a way to do this, and why can’t chef pass options to yum just like APT?

Thanks much for any help…

Jeremy


#3

Im not sure if you saw this resource or not but if you are specifically using yum you can use the ‘yum_package’ resource and that allows yum options to be passed to it.

http://docs.opscode.com/resource_yum.html

Justin

-----Original Message-----
From: “Kevin Keane Subscription” subscription@kkeane.com
Sent: Wednesday, March 27, 2013 9:07pm
To: "chef@lists.opscode.com" chef@lists.opscode.com
Subject: [chef] RE: possible to pass options to yum on package install

I’ve had a similar situation where I needed one package out of repoforge, but it created dependency hell everywhere else. My solution was to create my own local repository (and I’m using a chef cookbook to set up this repository). For me, it particularly made sense because I also have a couple RPMs that I need but aren’t in available in any public repo at all.

I haven’t yet figured out a way to keep these RPMs updated automatically, though.

From: Jeremy Koerber [mailto:jkoerber@branchout.com]
Sent: Wednesday, March 27, 2013 2:39 PM
To: chef@lists.opscode.com
Subject: [chef] possible to pass options to yum on package install

Hi,
I have this in a recipe:

package “tomcat7” do
action :install
options "–enablerepo=amzn-main"
end
but the options are not being passed to yum and the package fails to install because it isn’t found in my regular yum repos that are enabled by default. I can’t enable the amzn-main repo by default because then the system starts using it for everything, and I end up with some messy dependency conflicts. Plus, I strongly prefer to just use the CentOS-Base repo wherever possible.
So… Looking at [http://docs.opscode.com/resource_package.html] http://docs.opscode.com/resource_package.html and I see:
options Additional options that are added to the underlying package command. Can be used with APT, dpkg, Gentoo, RPM Package Manager, and RubyGems. Default value: nil.

So that would explain why Yum isn’t getting the options passed to it. So my questions are: is there a way to do this, and why can’t chef pass options to yum just like APT?

Thanks much for any help…

Jeremy


#4

Thanks for the reply, Justin. I just tried yum_package instead of package,
and unfortunately it seems that it doesn’t honor the options either. Here’s
what I have in the recipe:

yum_package “tomcat7” do
options "–enablerepo=amzn-main"
action :install
end

and here is the chef-client error:
[2013-03-27T22:25:17-07:00] DEBUG: Processing yum_package[tomcat7] on
qa-app-searchsvc-1-i-a9ea7fc9
[2013-03-27T22:25:17-07:00] INFO: Processing yum_package[tomcat7] action
install (tomcat7::default line 50)
[2013-03-27T22:25:17-07:00] DEBUG: yum_package[tomcat7] couldn’t match
tomcat7 in installed Provides, loading available Provides - this may take a
moment
[2013-03-27T22:25:52-07:00] DEBUG: yum_package[tomcat7] checking yum info
for tomcat7
[2013-03-27T22:25:52-07:00] DEBUG: yum_package[tomcat7] installed version:
(none) candidate version: (none)
[2013-03-27T22:25:52-07:00] ERROR: yum_package[tomcat7] (tomcat7::default
line 50) has had an error
[2013-03-27T22:25:52-07:00] ERROR: yum_package[tomcat7]
(/var/chef/cache/cookbooks/tomcat7/recipes/default.rb:50:in from_file') had an error: yum_package[tomcat7] (tomcat7::default line 50) had an error: Chef::Exceptions::Package: No version specified, and no candidate version available for tomcat7 /usr/lib/ruby/gems/1.8/gems/chef-10.12.0/bin/../lib/chef/provider/package.rb:50:inaction_install’

And here is the info in the failed-run-data.json - you can see it has my
disablerepo option in there:
{
“json_class”: “Chef::Resource::YumPackage”,
“instance_vars”: {
“arch”: null,
“delayed_notifications”: [

    ],
    "resource_name": "yum_package",
    "response_file": null,
    "enclosing_provider": null,
    "allowed_actions": [
      "nothing",
      "install",
      "upgrade",
      "remove",
      "purge",
      "reconfig"
    ],
    "flush_cache": {
      "before": false,
      "after": false
    },
    "source_line":

“/var/chef/cache/cookbooks/tomcat7/recipes/default.rb:50:in `from_file’”,
“provider”: “Chef::Provider::package::Yum”,
“ignore_failure”: false,
“action”: [
“install”
],
“package_name”: “tomcat7”,
“noop”: null,
“supports”: {
},
“before”: null,
“retry_delay”: 2,
“candidate_version”: null,
“version”: null,
“source”: null,
“allow_downgrade”: false,
“recipe_name”: “default”,
“updated_by_last_action”: false,
“params”: {
},
“immediate_notifications”: [

    ],
    "updated": false,
    "retries": 0,
    "name": "tomcat7",
   * "options": "--enablerepo=amzn-main",*
    "cookbook_name": "tomcat7"
  }
}

I think it isn’t using the enablerepo option when it’s looking for the
candidates, which needs to happen since I have the repo disabled
otherwise. I also tried setting up the yum-priorities-plugin and that gets
me around this issue, but then I run into some other dependency mess. The
ideal option is to just be able to temporarily enable the repo at the time
of package install.

Any ideas?

Thanks

On Wed, Mar 27, 2013 at 8:03 PM, Justin Witrick <
justin.witrick@rackspace.com> wrote:

Im not sure if you saw this resource or not but if you are specifically
using yum you can use the ‘yum_package’ resource and that allows yum
options to be passed to it.

http://docs.opscode.com/resource_yum.html

Justin

-----Original Message-----
From: “Kevin Keane Subscription” subscription@kkeane.com
Sent: Wednesday, March 27, 2013 9:07pm
To: "chef@lists.opscode.com" chef@lists.opscode.com
Subject: [chef] RE: possible to pass options to yum on package install

I’ve had a similar situation where I needed one package out of
repoforge, but it created dependency hell everywhere else. My solution was
to create my own local repository (and I’m using a chef cookbook to set up
this repository). For me, it particularly made sense because I also have a
couple RPMs that I need but aren’t in available in any public repo at all.

I haven’t yet figured out a way to keep these RPMs updated
automatically, though.

From: Jeremy Koerber [mailto:jkoerber@branchout.com]
Sent: Wednesday, March 27, 2013 2:39 PM
To: chef@lists.opscode.com
Subject: [chef] possible to pass options to yum on package install

Hi,

I have this in a recipe:

package “tomcat7” do
action :install
options "–enablerepo=amzn-main"
end

but the options are not being passed to yum and the package fails to
install because it isn’t found in my regular yum repos that are enabled by
default. I can’t enable the amzn-main repo by default because then the
system starts using it for everything, and I end up with some messy
dependency conflicts. Plus, I strongly prefer to just use the CentOS-Base
repo wherever possible.

So… Looking at http://docs.opscode.com/resource_package.html and I see:
options Additional options that are added to the underlying package
command. Can be used with APT, dpkg, Gentoo, RPM Package Manager, and
RubyGems. Default value: nil.

So that would explain why Yum isn’t getting the options passed to it. So
my questions are: is there a way to do this, and why can’t chef pass
options to yum just like APT?

Thanks much for any help…

Jeremy


Jeremy Koerber
Director - Tech Ops
branchout.com/jeremy.koerber


#5

What happens if you run yum install tomcat7 --enablerepo=amzn-main directly? Try adding flush_cache :before to the package provider call.

On Wednesday, March 27, 2013 at 10:36 PM, Jeremy Koerber wrote:

Thanks for the reply, Justin. I just tried yum_package instead of package, and unfortunately it seems that it doesn’t honor the options either. Here’s what I have in the recipe:

yum_package “tomcat7” do
options "–enablerepo=amzn-main"
action :install
end

and here is the chef-client error:
[2013-03-27T22:25:17-07:00] DEBUG: Processing yum_package[tomcat7] on qa-app-searchsvc-1-i-a9ea7fc9
[2013-03-27T22:25:17-07:00] INFO: Processing yum_package[tomcat7] action install (tomcat7::default line 50)
[2013-03-27T22:25:17-07:00] DEBUG: yum_package[tomcat7] couldn’t match tomcat7 in installed Provides, loading available Provides - this may take a moment
[2013-03-27T22:25:52-07:00] DEBUG: yum_package[tomcat7] checking yum info for tomcat7
[2013-03-27T22:25:52-07:00] DEBUG: yum_package[tomcat7] installed version: (none) candidate version: (none)
[2013-03-27T22:25:52-07:00] ERROR: yum_package[tomcat7] (tomcat7::default line 50) has had an error
[2013-03-27T22:25:52-07:00] ERROR: yum_package[tomcat7] (/var/chef/cache/cookbooks/tomcat7/recipes/default.rb:50:in from_file') had an error: yum_package[tomcat7] (tomcat7::default line 50) had an error: Chef::Exceptions::Package: No version specified, and no candidate version available for tomcat7 /usr/lib/ruby/gems/1.8/gems/chef-10.12.0/bin/../lib/chef/provider/package.rb:50:inaction_install’

And here is the info in the failed-run-data.json - you can see it has my disablerepo option in there:
{
“json_class”: “Chef::Resource::YumPackage”,
“instance_vars”: {
“arch”: null,
“delayed_notifications”: [

    ],
    "resource_name": "yum_package",
    "response_file": null,
    "enclosing_provider": null,
    "allowed_actions": [
      "nothing",
      "install",
      "upgrade",
      "remove",
      "purge",
      "reconfig"
    ],
    "flush_cache": {
      "before": false,
      "after": false
    },
    "source_line": "/var/chef/cache/cookbooks/tomcat7/recipes/default.rb:50:in `from_file'",
    "provider": "Chef::Provider::Package::Yum",
    "ignore_failure": false,
    "action": [
      "install"
    ],
    "package_name": "tomcat7",
    "noop": null,
    "supports": {
    },
    "before": null,
    "retry_delay": 2,
    "candidate_version": null,
    "version": null,
    "source": null,
    "allow_downgrade": false,
    "recipe_name": "default",
    "updated_by_last_action": false,
    "params": {
    },
    "immediate_notifications": [

    ],
    "updated": false,
    "retries": 0,
    "name": "tomcat7",
    "options": "--enablerepo=amzn-main",
    "cookbook_name": "tomcat7"
  }
}

I think it isn’t using the enablerepo option when it’s looking for the candidates, which needs to happen since I have the repo disabled otherwise. I also tried setting up the yum-priorities-plugin and that gets me around this issue, but then I run into some other dependency mess. The ideal option is to just be able to temporarily enable the repo at the time of package install.

Any ideas?

Thanks

On Wed, Mar 27, 2013 at 8:03 PM, Justin Witrick <justin.witrick@rackspace.com (mailto:justin.witrick@rackspace.com)> wrote:

Im not sure if you saw this resource or not but if you are specifically using yum you can use the ‘yum_package’ resource and that allows yum options to be passed to it.

http://docs.opscode.com/resource_yum.html

Justin

-----Original Message-----
From: “Kevin Keane Subscription” <subscription@kkeane.com (mailto:subscription@kkeane.com)>
Sent: Wednesday, March 27, 2013 9:07pm
To: "chef@lists.opscode.com (mailto:chef@lists.opscode.com)" <chef@lists.opscode.com (mailto:chef@lists.opscode.com)>
Subject: [chef] RE: possible to pass options to yum on package install

I’ve had a similar situation where I needed one package out of repoforge, but it created dependency hell everywhere else. My solution was to create my own local repository (and I’m using a chef cookbook to set up this repository). For me, it particularly made sense because I also have a couple RPMs that I need but aren’t in available in any public repo at all.

I haven’t yet figured out a way to keep these RPMs updated automatically, though.

From: Jeremy Koerber [mailto:jkoerber@branchout.com]
Sent: Wednesday, March 27, 2013 2:39 PM
To: chef@lists.opscode.com (mailto:chef@lists.opscode.com)
Subject: [chef] possible to pass options to yum on package install

Hi,

I have this in a recipe:

package “tomcat7” do
action :install
options "–enablerepo=amzn-main"
end
but the options are not being passed to yum and the package fails to install because it isn’t found in my regular yum repos that are enabled by default. I can’t enable the amzn-main repo by default because then the system starts using it for everything, and I end up with some messy dependency conflicts. Plus, I strongly prefer to just use the CentOS-Base repo wherever possible.

So… Looking at http://docs.opscode.com/resource_package.html and I see:
options Additional options that are added to the underlying package command. Can be used with APT, dpkg, Gentoo, RPM Package Manager, and RubyGems. Default value: nil.

So that would explain why Yum isn’t getting the options passed to it. So my questions are: is there a way to do this, and why can’t chef pass options to yum just like APT?

Thanks much for any help…

Jeremy


Jeremy Koerber
Director - Tech Ops
branchout.com/jeremy.koerber (http://branchout.com/jeremy.koerber)


#6

Daniel,
It works fine when I pass the option at the command line:

[root@qa-app-searchsvc-1 chef]# yum install --enablerepo=amzn-main tomcat7
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

I tried adding flush_cache :before to the yum_package call, and I get a
Fatal error early on in the chef run:
[2013-03-27T23:37:12-07:00] FATAL: NoMethodError: undefined method `any?'
for :before:Symbol

Here’s the recipe:

yum_package “tomcat7” do
options "–enablerepo=amzn-main"
flush_cache :before
action :install
end

Thanks

On Wed, Mar 27, 2013 at 11:03 PM, Daniel Condomitti
daniel@condomitti.comwrote:

What happens if you run yum install tomcat7 --enablerepo=amzn-main
directly? Try adding flush_cache :before to the package provider call.

On Wednesday, March 27, 2013 at 10:36 PM, Jeremy Koerber wrote:

Thanks for the reply, Justin. I just tried yum_package instead of package,
and unfortunately it seems that it doesn’t honor the options either. Here’s
what I have in the recipe:

yum_package “tomcat7” do
options "–enablerepo=amzn-main"
action :install
end

and here is the chef-client error:
[2013-03-27T22:25:17-07:00] DEBUG: Processing yum_package[tomcat7] on
qa-app-searchsvc-1-i-a9ea7fc9
[2013-03-27T22:25:17-07:00] INFO: Processing yum_package[tomcat7] action
install (tomcat7::default line 50)
[2013-03-27T22:25:17-07:00] DEBUG: yum_package[tomcat7] couldn’t match
tomcat7 in installed Provides, loading available Provides - this may take a
moment
[2013-03-27T22:25:52-07:00] DEBUG: yum_package[tomcat7] checking yum info
for tomcat7
[2013-03-27T22:25:52-07:00] DEBUG: yum_package[tomcat7] installed version:
(none) candidate version: (none)
[2013-03-27T22:25:52-07:00] ERROR: yum_package[tomcat7] (tomcat7::default
line 50) has had an error
[2013-03-27T22:25:52-07:00] ERROR: yum_package[tomcat7]
(/var/chef/cache/cookbooks/tomcat7/recipes/default.rb:50:in from_file') had an error: yum_package[tomcat7] (tomcat7::default line 50) had an error: Chef::Exceptions::Package: No version specified, and no candidate version available for tomcat7 /usr/lib/ruby/gems/1.8/gems/chef-10.12.0/bin/../lib/chef/provider/package.rb:50:inaction_install’

And here is the info in the failed-run-data.json - you can see it has my
disablerepo option in there:
{
“json_class”: “Chef::Resource::YumPackage”,
“instance_vars”: {
“arch”: null,
“delayed_notifications”: [

    ],
    "resource_name": "yum_package",
    "response_file": null,
    "enclosing_provider": null,
    "allowed_actions": [
      "nothing",
      "install",
      "upgrade",
      "remove",
      "purge",
      "reconfig"
    ],
    "flush_cache": {
      "before": false,
      "after": false
    },
    "source_line":

“/var/chef/cache/cookbooks/tomcat7/recipes/default.rb:50:in `from_file’”,
“provider”: “Chef::Provider::package::Yum”,
“ignore_failure”: false,
“action”: [
“install”
],
“package_name”: “tomcat7”,
“noop”: null,
“supports”: {
},
“before”: null,
“retry_delay”: 2,
“candidate_version”: null,
“version”: null,
“source”: null,
“allow_downgrade”: false,
“recipe_name”: “default”,
“updated_by_last_action”: false,
“params”: {
},
“immediate_notifications”: [

    ],
    "updated": false,
    "retries": 0,
    "name": "tomcat7",
   * "options": "--enablerepo=amzn-main",*
    "cookbook_name": "tomcat7"
  }
}

I think it isn’t using the enablerepo option when it’s looking for the
candidates, which needs to happen since I have the repo disabled
otherwise. I also tried setting up the yum-priorities-plugin and that gets
me around this issue, but then I run into some other dependency mess. The
ideal option is to just be able to temporarily enable the repo at the time
of package install.

Any ideas?

Thanks

On Wed, Mar 27, 2013 at 8:03 PM, Justin Witrick <
justin.witrick@rackspace.com> wrote:

Im not sure if you saw this resource or not but if you are specifically
using yum you can use the ‘yum_package’ resource and that allows yum
options to be passed to it.

http://docs.opscode.com/resource_yum.html

Justin

-----Original Message-----
From: “Kevin Keane Subscription” subscription@kkeane.com
Sent: Wednesday, March 27, 2013 9:07pm
To: "chef@lists.opscode.com" chef@lists.opscode.com
Subject: [chef] RE: possible to pass options to yum on package install

I’ve had a similar situation where I needed one package out of
repoforge, but it created dependency hell everywhere else. My solution was
to create my own local repository (and I’m using a chef cookbook to set up
this repository). For me, it particularly made sense because I also have a
couple RPMs that I need but aren’t in available in any public repo at all.

I haven’t yet figured out a way to keep these RPMs updated
automatically, though.

From: Jeremy Koerber [mailto:jkoerber@branchout.com]
Sent: Wednesday, March 27, 2013 2:39 PM
To: chef@lists.opscode.com
Subject: [chef] possible to pass options to yum on package install

Hi,

I have this in a recipe:

package “tomcat7” do
action :install
options "–enablerepo=amzn-main"
end

but the options are not being passed to yum and the package fails to
install because it isn’t found in my regular yum repos that are enabled by
default. I can’t enable the amzn-main repo by default because then the
system starts using it for everything, and I end up with some messy
dependency conflicts. Plus, I strongly prefer to just use the CentOS-Base
repo wherever possible.

So… Looking at http://docs.opscode.com/resource_package.html and I see:
options Additional options that are added to the underlying package
command. Can be used with APT, dpkg, Gentoo, RPM Package Manager, and
RubyGems. Default value: nil.

So that would explain why Yum isn’t getting the options passed to it. So
my questions are: is there a way to do this, and why can’t chef pass
options to yum just like APT?

Thanks much for any help…

Jeremy


Jeremy Koerber
Director - Tech Ops
branchout.com/jeremy.koerber


Jeremy Koerber
Director - Tech Ops
branchout.com/jeremy.koerber


#7

On Thu, Mar 28, 2013 at 12:11 PM, Jeremy Koerber jkoerber@branchout.comwrote:

I tried adding flush_cache :before to the yum_package call, and I get a
Fatal error early on in the chef run:
[2013-03-27T23:37:12-07:00] FATAL: NoMethodError: undefined method `any?'
for :before:Symbol

Here’s the recipe:

yum_package “tomcat7” do
options "–enablerepo=amzn-main"
flush_cache :before
action :install
end

Try flush_cache [:before]

  • Ketan

#8

That doesn’t work either, as it’s not a problem with the cache. Apparently
it’s a bug that was fixed in 10.18…
http://tickets.opscode.com/browse/CHEF-2427

Thanks for the help, everyone.

On Thu, Mar 28, 2013 at 4:42 AM, Ketan Padegaonkar <
ketanpadegaonkar@gmail.com> wrote:

On Thu, Mar 28, 2013 at 12:11 PM, Jeremy Koerber jkoerber@branchout.comwrote:

I tried adding flush_cache :before to the yum_package call, and I get a
Fatal error early on in the chef run:
[2013-03-27T23:37:12-07:00] FATAL: NoMethodError: undefined method `any?'
for :before:Symbol

Here’s the recipe:

yum_package “tomcat7” do
options "–enablerepo=amzn-main"
flush_cache :before
action :install
end

Try flush_cache [:before]

  • Ketan


Jeremy Koerber
Director - Tech Ops
branchout.com/jeremy.koerber