yum_package resource problem


#1

Hi to all,

I’m facing some problems with a yum_package resource. Actually, what I’m trying
to do is install a package and then configure it. The package is munin-node. My
recipe contains the following resources, in the following order:

yum_package “munin-node” do
not_if "rpm -qa | grep munin-node"
end

template “/etc/munin/munin-node.conf” do
source "munin-node.conf.erb"
mode 0644
end

(chef-version: 10.14.4)

everything worked perfectly, up until yesterday. What happened was, when
running chef-client, the template resource through an exception and exited. The
reason was that the parent directory “/etc/munin/”, which is created when the
packaged is installed, was not found. When running “ls /etc/munin”, the
directory existed. And the next time chef-client ran, everything worked fine.
So, my questions are:

  • Does the yum_package resource run in the background?
  • When having 2 resources in a recipe, when does the second resource start
    executing? I had the impression that it would start execution right after, and
    only if, the previous resource completes successfully. What I seem to be
    getting here is the template resource starts executing before the yum_package
    resource has finished what it is doing.

BTW: I tried using “retries” and “retry_delay” and it did work, but I would
like to understand how things work.

Thanks!!


#2

I can’t say specifically about what’s happening, but I can provide some
insight into Chef. You are correct that the resources are going to be
executed in order. You don’t need to have the not_if on the yum_package
resource either - that’s what the package provider does internally
already, essentially.

As for /etc/munin not existing - what creates it? Is it actually part of
the post-install of the package? Is it created when the munin-node client
is started (which would explain your race?)

Either way, look at whats happening when the package itself is installed
for answers - your expectations about Chef are correct, and it’s how Chef
is behaving.

Best,
Adam

On 11/29/12 2:40 AM, “jfotop” ifot@forthnet.gr wrote:

Hi to all,

I’m facing some problems with a yum_package resource. Actually, what I’m
trying
to do is install a package and then configure it. The package is
munin-node. My
recipe contains the following resources, in the following order:

yum_package “munin-node” do
not_if "rpm -qa | grep munin-node"
end

template “/etc/munin/munin-node.conf” do
source "munin-node.conf.erb"
mode 0644
end

(chef-version: 10.14.4)

everything worked perfectly, up until yesterday. What happened was, when
running chef-client, the template resource through an exception and
exited. The
reason was that the parent directory “/etc/munin/”, which is created
when the
packaged is installed, was not found. When running “ls /etc/munin”, the
directory existed. And the next time chef-client ran, everything worked
fine.
So, my questions are:

  • Does the yum_package resource run in the background?
  • When having 2 resources in a recipe, when does the second resource start
    executing? I had the impression that it would start execution right
    after, and
    only if, the previous resource completes successfully. What I seem to be
    getting here is the template resource starts executing before the
    yum_package
    resource has finished what it is doing.

BTW: I tried using “retries” and “retry_delay” and it did work, but I
would
like to understand how things work.

Thanks!!


#3

Maybe SELinux denies access to the process that runs chef. You can test that by setting SELinux to permissive mode, and then test it again. Permissive mode will flag SELinux denials, but allow the process to access the file anyway.

Unfortunately, chef destroys SELinux contexts for templated files; you can fix that with restorecon -r /etc/munin . I put that into all my recipes (of course, you can also turn off SELinux, but that’s no longer a realistic option in today’s environment).

Try running ls -lahZ /etc/munin

-----Original message-----
From:Adam Jacob adam@opscode.com
Sent:Thu 11-29-2012 07:08 am
Subject:[chef] Re: yum_package resource problem
To:chef@lists.opscode.com;
I can’t say specifically about what’s happening, but I can provide some
insight into Chef. You are correct that the resources are going to be
executed in order. You don’t need to have the not_if on the yum_package
resource either - that’s what the package provider does internally
already, essentially.

As for /etc/munin not existing - what creates it? Is it actually part of
the post-install of the package? Is it created when the munin-node client
is started (which would explain your race?)

Either way, look at whats happening when the package itself is installed
for answers - your expectations about Chef are correct, and it’s how Chef
is behaving.

Best,
Adam

On 11/29/12 2:40 AM, “jfotop” ifot@forthnet.gr wrote:

Hi to all,

I’m facing some problems with a yum_package resource. Actually, what I’m
trying
to do is install a package and then configure it. The package is
munin-node. My
recipe contains the following resources, in the following order:

yum_package “munin-node” do
not_if "rpm -qa | grep munin-node"
end

template “/etc/munin/munin-node.conf” do
source "munin-node.conf.erb"
mode 0644
end

(chef-version: 10.14.4)

everything worked perfectly, up until yesterday. What happened was, when
running chef-client, the template resource through an exception and
exited. The
reason was that the parent directory “/etc/munin/”, which is created
when the
packaged is installed, was not found. When running “ls /etc/munin”, the
directory existed. And the next time chef-client ran, everything worked
fine.
So, my questions are:

  • Does the yum_package resource run in the background?
  • When having 2 resources in a recipe, when does the second resource start
    executing? I had the impression that it would start execution right
    after, and
    only if, the previous resource completes successfully. What I seem to be
    getting here is the template resource starts executing before the
    yum_package
    resource has finished what it is doing.

BTW: I tried using “retries” and “retry_delay” and it did work, but I
would
like to understand how things work.

Thanks!!