Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status


xmledit (20) Versions 1.0.0

Provides a resource and provider for incremental editing of XML files

cookbook 'xmledit', '= 1.0.0', :supermarket
cookbook 'xmledit', '= 1.0.0'
knife supermarket install xmledit
knife supermarket download xmledit
Quality 0%


This cookbook allows incremental editing of XML files. You must include the
default recipe to ensure nokogiri and its dependencies are installed using the
upstream community xml cookbook.

Specifically, this library cookbooks offers a resource and provider that can be
called by the name xml_edit. This resource accepts XPath expressions and will
perform the expected action on the very first node found.

Important notes

  • If no XML nodes match the XPath expression, no actions will be performed. If a file cannot be found, this provider will raise an error by virtue of ::File raising an error.

  • This cookbook attempts to sidestep resource cloning issues by forcing the resource name to be something other than a path to a file to edit. This allows you to perform multiple edits to the same file by giving the resources unique names and providing the same path attribute value.

  • Including an XPath expression that is a match against the node's value that you want to replace (e.g. matching against [text=()=\'false\'] if you want to replace false with true) means that the underlying file resource will no longer be defined, vs. having a file resource that was defined but idempotently 'up to date'. Both styles are possible using this cookbook, depending on the XPath expressions you provide.

Supported actions

name description
replace replaces a target node (and all children) with a new fragment
append appends a new XML fragment to a parent target node
remove remove gets rid of a target node

Supported attributes

These have no default values, and will cause a no-op if they are not specified or don't match a valid file or target.

name required description
path true path to the XML file to edit
target true an xpath expression for the target node or parent of the target node (see actions above)
fragment true a string that will be parsed into an XML fragment, for actions that add or update


Replace false with true in a file at /etc/application.xml containing <config><foo>false</foo></config>.

xml_edit 'set foo to true' do
  path '/etc/application.xml'
  target '/config/foo[text()=\'false\']'
  fragment 'true'
  action :replace


  • Add an attribute for forcing an error when an xpath expr doesn't match


# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.


  • Rename actions to map better to nokogiri operations
  • Implement remove and append actions
  • Add missing xml cookbook dependency


  • Initial release.

Foodcritic Metric

1.0.0 failed this metric

FC031: Cookbook without metadata file: /tmp/cook/81debaf8cfe1c639a680d6b2/xmledit/metadata.rb:1
FC045: Consider setting cookbook name in metadata: /tmp/cook/81debaf8cfe1c639a680d6b2/xmledit/metadata.rb:1