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

RSS

poise-file (1) Versions 1.0.0

A Chef cookbook for advanced file managent.

Berkshelf/Librarian
Policyfile
Knife
cookbook 'poise-file', '~> 1.0.0'
cookbook 'poise-file', '~> 1.0.0', :supermarket
knife cookbook site install poise-file
knife cookbook site download poise-file
README
Dependencies
Changelog
Quality

Poise-File Cookbook

Build Status Gem Version Cookbook Version Coverage Gemnasium License

A Chef cookbook to do something.

Quick Start

To write out a JSON file from node attributes:

poise_file '/etc/myapp.json' do
  content node['myapp']
end

To update a file in place:

poise_file '/etc/hosts' do
  content 'otherhostname'
  pattern 'myhostname'
  pattern_location :replace
end

Resources

poise_file

The poise_file resource extends the core file resource to support formats and patterns.

Formats

If the file path ends with .json or .yaml/.yml and the content property is a Hash or Array object, it will be automatically converted. You can also explicitly set the format property to :json or :yaml to force formatting.

Patterns

Using replacement patterns allows editing files in-place in a structured manner. This is similar to the FileEdit API or line cookbook/resource. The pattern property takes a RegExp object or string pattern to match against. The value of pattern_location controls how the content gets used relative to the pattern.

  • :replacecontent replaces the matching section. If the pattern does not match, the content is not changed.
  • :replace_or_addcontent replaces the matching section. If the pattern does not match, the content is appended to the end of the file.
  • :beforecontent is inserted immediately before the matching section. If the pattern does not match, the content is not changed.
  • :aftercontent is inserted immediately after the matching section. If the pattern does not match, the content is not changed.

You can also pass a Proc to perform arbitrary manipulations:

poise_file '/etc/myapp.conf' do
  pattern proc {|existing_content| existing_content.tr('a-z', 'n-za-m') }
end

If you have an in-place editing scenario not handled by these operations, please let me know by filing an issue.

Actions

All actions are the same as the core file resource.

Properties

  • format – File serialization format. One of :text, :json, or :yaml. (default: auto-detect)
  • pattern – Regular expression pattern or object to search for.
  • pattern_location – Mode to use for the pattern replacement. One of :replace, :replace_or_add, :before, :after. (default: :replace_or_add)

All other properties as the same as the core file resource.

Sponsors

Development sponsored by SAP.

The Poise test server infrastructure is sponsored by Rackspace.

License

Copyright 2017, Noah Kantrowitz

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

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Dependent cookbooks

poise ~> 2.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

Poise-File Changelog

v1.0.0

  • Initial release!

Collaborator Number Metric
            

1.0.0 failed this metric

Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric
            

1.0.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

1.0.0 passed this metric

License Metric
            

1.0.0 passed this metric

No Binaries Metric
            

1.0.0 passed this metric

Publish Metric
            

1.0.0 passed this metric

Supported Platforms Metric
            

1.0.0 passed this metric

Testing File Metric
            

1.0.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

1.0.0 passed this metric