- From: Jenn Fountain <
>
- To:
- Subject: [chef] Re: Re: Re: Re: Nokogiri Woes
- Date: Mon, 10 Jun 2013 13:26:31 -0400
On Jun 10, 2013, at 12:55 PM, Noah Kantrowitz
<
>
wrote:
>
>
On Jun 10, 2013, at 9:45 AM, Jenn Fountain wrote:
>
>
>
>
> On Jun 10, 2013, at 12:35 PM, Noah Kantrowitz
>
> <
>
>
> wrote:
>
>
>
>>
>
>> On Jun 10, 2013, at 9:32 AM, Jenn Fountain wrote:
>
>>
>
>>> Hi Chefs,
>
>>> I am trying to get Chef to work with Nokogiri but not having any
>
>>> success. The docs I am finding aren't helping me. Would someone be
>
>>> able to point me to the correct docs? I am sure I am missing it. Thanks!
>
>>
>
>> Can you be more specific about what you are trying to do? Do you just
>
>> mean using the nokogiri gem in a Chef recipe?
>
>>
>
>> --Noah
>
>>
>
>
>
>
>
>
>
> Yes, I have a ruby block that changes some nodes in an xml file and it
>
> works fine via the command line but not in my chef recipe.
>
>
>
> IE:
>
>
>
> ruby_block "edit config" do
>
> block do
>
> f = File.open("config.xml")
>
> fw = File.open("config.xml.1", 'w')
>
>
>
> config = Nokogiri::XML(f)
>
>
>
> config.css("server").each do |node|
>
> puts "\r\n[debug] Before: server= \r\n#{node}"
>
> node.children.remove
>
> node.content = "jennie.ldap.server.com"
>
> puts "\r\n[debug] After: server=\r\n#{node}"
>
> fw.print config.to_s
>
> end
>
> end
>
>
>
> I get the following errors:
>
>
>
> NameError: uninitialized constant Chef::Recipe::Nokogiri
>
>
>
> If I add requires nokogiri:
>
>
>
> undefined method `nokogiri' for Chef::Resource::RubyBlock
>
>
>
> Being a newbie in chef/ruby, I am sure I am issuing something but not sure
>
> where to look Thanks! :D
>
>
Add this to the top of the recipe:
>
>
chef_gem 'nokogiri'
>
require 'nokogiri'
>
>
--Noah
>
That did it! Thank you so much!
--------------------------------
Jenn Fountain
Archive powered by MHonArc 2.6.16.