[chef] RE: RE: Re: Puzzled about convergence, please advise?


Chronological Thread 
  • From: Steve Smith - CHQ < >
  • To: " " < >
  • Subject: [chef] RE: RE: Re: Puzzled about convergence, please advise?
  • Date: Thu, 13 Nov 2014 21:58:06 +0000
  • Accept-language: en-US

Try setting up your template with an action of nothing and then have the rpm_package resource notify the template.

 

rpm_package "Installing RPM" do

  action :install

  package_name myRPM.rpm

 

  notifies :create, "template[/opt/some_path/conf/myRPMconfig.xml]", :immediate

end       

 

template "/opt/some_path/conf/myRPMconfig.xml" do

  source "myRPMconfig.xml.erb"

  variable({

      "var1" => node.mycookbook.var1

  })

 

  action :nothing

end

 

From: Fouts, Chris [mailto:
Sent: Thursday, November 13, 2014 1:16 PM
To:
Subject: [chef] RE: Re: Puzzled about convergence, please advise?

 

Sorry, I should’ve shown this example to explain why I “need” a template.

 

rpm_package “Installing RPM” do

  action :install

  package_name myRPM.rpm

end       

 

template “/opt/some_path/conf/myRPMconfig.xml” do

  source “myRPMconfig.xml.erb”

  variable({

      “var1” => node.mycookbook.var1

  })

end

 

From: Ranjib Dey [ ">mailto: ]
Sent: Thursday, November 13, 2014 3:46 PM
To:
">
Subject: [chef] Re: Puzzled about convergence, please advise?

 

resources are executed at converge time, but they are built (resource collection) during compilation time. to build the template resource u need to read the template file, inject variables and finally in converge tim check if that differs from the existing one and replace it. so the resource building part itself requires the file to be present. 

you dont need template here, you want remote file with file:/// as source, can you try that?

hope this help

ranjib

 

On Thu, Nov 13, 2014 at 12:21 PM, Fouts, Chris < " target="_blank"> > wrote:

I thought I understood this, so I’m puzzled that it’s not working the way I think it should work. I have the following simple recipe.

 

rpm_package “Installing RPM” do

  action :install

  package_name myRPM.rpm

end       

 

template “/opt/some_path/conf/myRPMconfig.xml” do

  source “myRPMconfig.xml.erb”

end

 

I expect both resources to be executed during convergence (run time), correct?

 

If so, the rpm_package should install myRPM.rpm, which creates the /opt/some_path/conf directory, so when the template resource runs, the directory is already there. However, when I run chef-client, I get an error saying “No such file or directory  - /opt/some_path/conf”

 

I know that myRPM.rpm creates the directory because if I install it manually, it does create it.

 

Any advise?

 

Chris

 




Archive powered by MHonArc 2.6.16.

§