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

The chef-sugar cookbook has been deprecated

Author provided reason for deprecation:

The chef-sugar cookbook has been deprecated and is no longer being maintained by its authors. Use of the chef-sugar cookbook is no longer recommended.

RSS

chef-sugar (39) Versions 1.0.0

Installs chef-sugar. Please see the chef-sugar Ruby gem for more information.

Policyfile
Berkshelf
Knife
cookbook 'chef-sugar', '= 1.0.0', :supermarket
cookbook 'chef-sugar', '= 1.0.0'
knife supermarket install chef-sugar
knife supermarket download chef-sugar
README
Dependencies
Quality -%

Chef::Sugar

Build Status
Gem Version
Dependency Status
Code Climate

Chef Sugar is a Gem & Chef Recipe that includes series of helpful sugar of the Chef core and other resources to make a cleaner, more lean recipd DSL, enforce DRY principles, and make writing Chef recipes an awesome experience!

Installation

If you want to development/hack on chef-sugar, please see the Contributing.md.

If you are using Berkshelf, add chef-sugar to your Berksfile:

cookbook 'chef-sugar'

Otherwise, you can use knife or download the tarball directly from the community site:

knife cookbook site install chef-sugar

Usage

In order to use Chef Sugar in your Chef Recipes, you'll first need to include it:

include_recipe 'chef-sugar::default'

Alternatively you can put it in a base role or recipe and it will be included subsequently.

Requiring the Chef Sugar Gem will automatically extend the Recipe DSL, Chef::Resource, and Chef::Provider with helpful convienence methods.

Module Method

If you are working outside of the Recipe DSL, you can use the module methods instead of the Recipe DSL. In general, the module methods have the same name as their Recipe-DSL counterparts, but require the node object as a parameter. For example:

In a Recipe:
```ruby

cookbook/recipes/default.rb

do_something if windows?
```

In a Library as a singleton:

# cookbook/libraries/default.rb
def only_on_windows(&block)
  yield if Chef::Sugar::PlatformFamily.windows?(@node)
end

In a Library as a Mixin:

# cookbook/libraries/default.rb
include Chef::Sugar::PlatformFamily

def only_on_windows(&block)
  yield if windows?(@node)
end

API

Note: For the most extensive API documentation, please see the YARD documentation.

Architecture

Note: Some of the architecture commands begin with an underscore (_) because Ruby does not permit methods to start with a numeric.

  • _64_bit?
  • _32_bit?

Examples

execute 'build[my binary]' do
  command '...'
  not_if  { _64_bit? }
end

Cloud

  • azure?
  • cloud?
  • ec2?
  • eucalyptus?
  • gce?
  • linode?
  • openstack?
  • rackspace?

Examples

template '/tmp/config' do
  variables(
    # See also: best_ip_for
    ipaddress: cloud? ? node['local_ipv4'] : node['public_ipv4']
  )
end

IP

  • best_ip_for - determine the best IP address for the given "other" node, preferring local IP addresses over public ones.

Examples

redis = search('node', 'role:redis').first

template '/tmp/config' do
  variables(
    ipaddress: best_ip_for(redis)
  )
end

Node

  • in? - determine if the node is in the given Chef environment.
  • includes_recipe?

Examples

credentials = if in?('production')
                Chef::EncryptedDataBag.new('...')
              else
                data_bag('...')
              end
if includes_recipe?('apache2::default')
  apache_module 'my_module' do
    # ...
  end
end

Platform

  • amazon_linux?
  • centos?
  • linux_mint?
  • oracle_linux?
  • redhat_enterprise_linux?
  • scientific_linux?
  • ubuntu?

There are also a series of dynamically defined matchers that map named operating system release versions and comparison operators in the form "#{platform}_#{operator}_#{name}?". For example:

  • debian_after_squeeze?
  • linuxmint_after_or_at_olivia?
  • mac_os_x_lion?
  • ubuntu_before_lucid?
  • ubuntu_before_or_at_maverick?

To get a full list, run the following in IRB:

require 'chef/sugar'
puts Chef::Sugar::Platform.instance_methods

Examples

if ubuntu?
  execute 'apt-get update'
end

Platform Family

  • arch_linux?
  • debian?
  • fedora?
  • gentoo?
  • linux?
  • mac_os_x?
  • openbsd?
  • rhel?
  • slackware?
  • suse?
  • windows?

Examples

node['attribute'] = if windows?
                      'C:\Foo\BarDrive'
                    else
                      '/foo/bar_drive'
                    end

Ruby

Note: The applies to the the Ruby found at node['languages']['ruby'].

  • ruby_20?
  • ruby_19?

Examples

log 'This has been known to fail on Ruby 2.0' if ruby_20?

Shell

  • which
  • dev_null
  • installed?
  • installed_at_version?
  • version_for

Examples

log "Using `mongo` at `#{which('mongo')}`"

if installed?('apt')
  execute 'apt-get update'
end

execute 'install[thing]' do
  command "... 2>&1 #{dev_null}"
  not_if  { installed_at_version?('thing', node['thing']['version']) }
end

log "Skipping git install, version is at #{version_for('mongo', '-v')}"

Vagrant

  • vagrant?

Examples

http_request 'http://...' do
  not_if { vagrant? }
end

License & Authors

Copyright 2013 Seth Vargo

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

This cookbook has no specified dependencies.

Contingent cookbooks

aegir3 Applicable Versions
amazon-ecs-agent Applicable Versions
asdf Applicable Versions
autofs Applicable Versions
automatic_updates Applicable Versions
aws-vpc-nat-instance Applicable Versions
blp-gemrc Applicable Versions
bosun Applicable Versions
boundary_meter Applicable Versions
ceph-chef Applicable Versions
chamber-kibana Applicable Versions
chef-updater Applicable Versions
cobblerd Applicable Versions
consul Applicable Versions
devopsdance-consul-template Applicable Versions
devopsdance-dnsmasq Applicable Versions
devopsdance-policyrcd Applicable Versions
devopsdance-rinetd Applicable Versions
devopsdance-tinyproxy Applicable Versions
elasticsearch Applicable Versions
elk Applicable Versions
elkstack Applicable Versions
embulk Applicable Versions
etcd Applicable Versions
firewall Applicable Versions
frog Applicable Versions
gogs Applicable Versions
hollandbackup Applicable Versions
ice Applicable Versions
ignite-openfire Applicable Versions
il-base Applicable Versions
jenkinsstack Applicable Versions
jmeter Applicable Versions
languages Applicable Versions
machine_tag Applicable Versions
macos Applicable Versions
magentostack Applicable Versions
mesos Applicable Versions
mw_mysql Applicable Versions
mysql-multi Applicable Versions
netrc Applicable Versions
nodestack Applicable Versions
omnibus Applicable Versions
openbazaar Applicable Versions
openssh-lpk Applicable Versions
openssl Applicable Versions
openvpnas Applicable Versions
paramount Applicable Versions
phpstack Applicable Versions
platformstack Applicable Versions
puncha-kibana Applicable Versions
pythonstack Applicable Versions
qgis Applicable Versions
qpdf Applicable Versions
rackops_rolebook Applicable Versions
rackspace_apache_php Applicable Versions
rackspace_gluster Applicable Versions
rackspace_iptables Applicable Versions
rackspace_nginx_php Applicable Versions
rancher Applicable Versions
redis-multi Applicable Versions
rhsm Applicable Versions
rubyinstaller Applicable Versions
sanitize Applicable Versions
snipeit_api Applicable Versions
stack-marathon Applicable Versions
stack_commons Applicable Versions
the_silver_searcher Applicable Versions
ut_base Applicable Versions
varnish Applicable Versions
vscode Applicable Versions
wazuh Applicable Versions
wazuh_agent Applicable Versions
wazuh_manager Applicable Versions
weblogic Applicable Versions
xml Applicable Versions

No quality metric results found