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


firewalld (9) Versions 0.3.0

Installs/Configures firewalld

cookbook 'firewalld', '= 0.3.0', :supermarket
cookbook 'firewalld', '= 0.3.0'
knife supermarket install firewalld
knife supermarket download firewalld
Quality 0%

firewalld LWRP

Build Status
Code Climate

firewalld provides a LWRP for adding and removing ports and rules to your firewall.


<td>(name attribute) the port to manage</td>
<td><code>firewalld</code> zone to add or remove port from</td>
<td>(none, uses default zone)</td>

Resource Overview


Default action adds a port to the firewall:

firewalld_port '993/tcp'

This will allow access to TCP port 993 in the default zone.


Add the port to zone. If zone is omitted, default zone will be used.

firewalld_port '993/tcp' do
  action :add
  zone   'public'


Removes the port from zone. If zone is omitted, default zone will be used.

firewalld_port '993/tcp' do
    action :remove
    zone   'public'


The rich_rule allows you to create complex rules directly onto the firewall.
It will load the rule into the running config and pass it to firewalld with the
--permanent flag, to persist it after a reload.


# This opens the ssh service to ip `` and logs at a rate of 1 entry
# per minute with a prefix of ssh on each log entry.

firewalld_rich_rule "ssh_add" do
  zone 'public'
  family 'ipv4'
  source_address ''
  service_name 'ssh'
  log_prefix 'ssh'
  log_level 'info'
  limit_value '1/m'
  firewall_action 'accept'
  action :add


The parameters for rich_resource map directly to their commandline flag.
More can be read here: Complex Firewall Rules with Rich Language

  • name - The name of the resource. This is not passed to the firewall-cmd.

  • service-name - Name of the service defined by firewalld-cmd --get-services.

  • family - IPv family. Choice of 'ipv4' or 'ipv6'. Default: 'ipv4'

  • zone - Predefined zone into which a network interface is placed.

  • source_address - Limits the origin of a connection attempt to a specific
    range of IPs.

  • destination_address - Limits the target of a connection attempt to a
    specific range of IPs.

  • port_number - Can be a single integer or a port range, for example 5060-5062.
    The protocol can be specified. Depends on port_protocol parameter.

  • port_protocol - The protocol for the specified port, can be 'tcp' or 'udp'.
    Depends on port_number parameter and defaults to 'tcp'.

  • log_prefix - Logs new connection attempts with kernel logging. This will
    prepend the log lines with this prefix.

  • log_level - Can be one of 'emerg', 'alert', 'error', 'warning', 'notice',
    'info', or 'debug'.

  • limit_value - Limits the rate at which logs are written. Defaults to "1/m"
    one write per minute.

  • firewall_action - Can be one of 'accept', 'reject', or 'drop'. This is the
    behavior by which all traffic that matches the rule will be handled.


If you're using Berkshelf, just add firewalld to your Berksfile:

cookbook 'firewalld', git: ''
# metadata.rb
depends 'firewalld'


  1. Fork the project
  2. Create a feature branch corresponding to you change
  3. Commit and test thoroughly
  4. Create a Pull Request on github

License & Authors

Copyright 2015, Jeff Hutchison

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.


version (unreleased)


  • Add Rich Rule LWRP documentation to README. [Manny Toledo]

  • ChefSpec test added for Rich Rule LWRP. [Manny Toledo]

  • Integration tests added for Rich Rule LWRP. [Manny Toledo]

  • Add rules directly with Rich Rule LWRP! [Manny Toledo]


  • Correct IPs in tests to more common ranges. [Manny Toledo]

  • Update readme. [Manny Toledo]

  • Add missing defaults in resource file and clean up comment. [Manny Toledo]



  • Better README and send email for Travis. [Jeff Hutchison]

  • Update ruby version. [Jeff Hutchison]

  • Add chefspec custom matchers, other cleanup. [Jeff Hutchison]

  • Need berkshelf for chefspec tests in Travis. [Jeff Hutchison]

  • Add chefspec tests. [Jeff Hutchison]

  • Exclude dependencies not used by Travis. [Jeff Hutchison]

  • Enable Travis CI. [Jeff Hutchison]

  • Clean up syntax. [Jeff Hutchison]

  • Use bundler. [Jeff Hutchison]

  • Add more tests. [Jeff Hutchison]

  • Removed attributes not recognized by Berkshelf. [Jeff Hutchison]

  • Add issues url. [Jeff Hutchison]

  • Bump version. [Jeff Hutchison]

  • Update README. [Jeff Hutchison]

  • Update license to Apache v2. [Jeff Hutchison]

  • First version with tests. [Jeff Hutchison]

Foodcritic Metric

0.3.0 failed this metric

FC002: Avoid string interpolation where not required: /tmp/cook/f44b87035b2d2384c51caaff/firewalld/providers/rich_rule.rb:43