diff options
author | Tim Smith <tsmith@chef.io> | 2018-02-14 16:05:40 -0800 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-02-14 16:05:40 -0800 |
commit | e8f01e79670b43e9fa49955156de33154c741d2c (patch) | |
tree | 8ae8508c2f5ceaec4c15d46998902d7fed0ee71b | |
parent | 824427368748a2d23b9faf9101c5ce406c5cdae2 (diff) | |
download | chef-e8f01e79670b43e9fa49955156de33154c741d2c.tar.gz |
Swap out nokogiri for rexmlhostname_resource
Avoid the dep on nokogiri
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/resource/hostname.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/chef/resource/hostname.rb b/lib/chef/resource/hostname.rb index 9030c48f87..16986c09a3 100644 --- a/lib/chef/resource/hostname.rb +++ b/lib/chef/resource/hostname.rb @@ -53,12 +53,13 @@ class Chef # @return [String] def updated_ec2_config_xml begin - require "nokogiri" + require "rexml/document" config_file = 'C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml' - config = ::Nokogiri::XML(::File.read(config_file)) + config = REXML::Document.new(::File.read(config_file)) # find an element named State with a sibling element whose value is Ec2SetComputerName - setting = config.at_xpath("//Plugin/State[../Name/text() = 'Ec2SetComputerName']") - setting.content = "Disabled" + REXML::XPath.each(config, "//Plugin/State[../Name/text() = 'Ec2SetComputerName']") do |element| + element.text = "Disabled" + end rescue return "" end |