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 supermarket mailing list.

Select Badges

Select Supported Platforms

RSS

iptables (19) Versions 2.2.0

Installs the iptables daemon and provides a LWRP for managing rules

Berkshelf
Librarian
Knife
cookbook 'iptables', '~> 2.2.0'
cookbook 'iptables', '~> 2.2.0'
knife cookbook site install iptables
knife cookbook site download iptables
README
Dependencies
Changelog
Quality

iptables Cookbook

Build Status Cookbook Version

Installs iptables and provides a custom resource for adding and removing iptables rules

Requirements

Platforms

  • Ubuntu/Debian
  • RHEL/CentOS and derivatives

Chef

  • Chef 12.5+

Cookbooks

  • none

Recipes

default

The default recipe will install iptables and provides a ruby script (installed in /usr/sbin/rebuild-iptables) to manage rebuilding firewall rules from files dropped off in /etc/iptables.d.

disabled

The disabled recipe will install iptables, disable the iptables service (on RHEL platforms), and delete the rules directory /etc/iptables.d.

Attributes

default['iptables']['iptables_sysconfig'] and default['iptables']['iptables_sysconfig'] are hashes that are used to template /etc/sysconfig/iptables-config and /etc/sysconfig/ip6tables-config. The keys must be upper case and any key / value pair included will be added to the config file.

Custom Resource

rule

The custom resource drops off a template in /etc/iptables.d after the name parameter. The rule will get added to the local system firewall through notifying the rebuild-iptables script. See Examples below.

NOTE: In the 1.0 release of this cookbook the iptables_rule definition was converted to a custom resource. This changes the behavior of disabling iptables rules. Previously a rule could be disabled by specifying enable false. You must now specify action :disable

Usage

Add recipe[iptables] to your runlist to ensure iptables is installed / running and to ensure that the rebuild-iptables script is on the system. Then create use iptables_rule to add individual rules. See Examples.

Since certain chains can be used with multiple tables (e.g., PREROUTING), you might have to include the name of the table explicitly (i.e., *nat, *mangle, etc.), so that the /usr/sbin/rebuild-iptables script can infer how to assemble final ruleset file that is going to be loaded. Please note, that unless specified otherwise, rules will be added under the filter table by default.

Examples

To enable port 80, e.g. in an my_httpd cookbook, create the following template:

# Port 80 for http
-A FWR -p tcp -m tcp --dport 80 -j ACCEPT

This template would be located at: my_httpd/templates/default/http.erb. Then within your recipe call:

iptables_rule 'http' do
  action :enable
end

To redirect port 80 to local port 8080, e.g., in the aforementioned my_httpd cookbook, create the following template:

*nat
# Redirect anything on eth0 coming to port 80 to local port 8080
-A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

Please note, that we explicitly add name of the table (being *nat in this example above) where the rules should be added.

This would most likely go in the cookbook, my_httpd/templates/default/http_8080.erb. Then to use it in recipe[httpd]:

iptables_rule 'http_8080' do
  action :enable
end

Chefspec Matchers

  • enable_iptables_rule(resource_name)
  • disable_iptables_rule(resource_name)

License & Authors

Author: Cookbook Engineering Team (cookbooks@chef.io)

Copyright: 2008-2015, Chef Software, Inc.

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

abiquo Applicable Versions
aem Applicable Versions
amiga-ppp Applicable Versions
apache2 Applicable Versions
arcgis Applicable Versions
arcgis-server Applicable Versions
cassandra Applicable Versions
chef-manageiq Applicable Versions
cloudless-box Applicable Versions
common_linux Applicable Versions
concourse Applicable Versions
confd-iptables Applicable Versions
cookbook-openshift3 Applicable Versions
docker Applicable Versions
drupal-cookbook Applicable Versions
extended_drbd Applicable Versions
ganglia Applicable Versions
hypertable Applicable Versions
jenkins Applicable Versions
kimchi Applicable Versions
openssh Applicable Versions
piwik Applicable Versions
redmine2 Applicable Versions
riak Applicable Versions
sanitize Applicable Versions
sensu Applicable Versions
spacewalk-server Applicable Versions
sshguard Applicable Versions
teamforge Applicable Versions

iptables Cookbook CHANGELOG

This file is used to list changes made in each version of the iptables cookbook.

v2.2.0 (2016-02-17)

  • Remove the dependency on compat_resource cookbook. This fixes RHEL systems, but increases the required Chef version to 12.5 or later

v2.1.1 (2016-01-26)

  • Fixed failures on RHEL in the disabled recipe

v2.1.0 (2016-01-25)

  • Improved compatbility with Fedora
  • Added management of the iptables sysconfig files using 2 new attributes. See the readme for more information

v2.0.2 (2016-01-15)

  • Fixed rules not being rebuilt when using the disable action in the custom resource

v2.0.1 (2015-11-16)

  • Added Chefspec matchers

v2.0.0 (2015-10-21)

  • Migrated LWRP to Chef 12.5 custom resources format with backwards compatibility provided via compat_resource cookbook to 12.X family
  • Added Start / enable of iptables service in the default recipe when on RHEL based systems and the management of /etc/sysconfig/iptables so the service can start
  • Added removal of /etc/iptables.d/ to the disabled recipe to allow for reenabling later on
  • Modified the iptables service disable in the disable recipe to only run when on RHEL based systems
  • Expanded the serverspec tests and test kitchen suites to better test rules custom resource and disable recipe

v1.1.0 (2015-10-05)

  • Fixed metadata description of the default recipe
  • Added Kitchen CI config
  • Added Chefspec unit tests
  • Updated to our standard Rubocop config and resolve all warnings
  • Added Travis CI config for lint / unit testing on Ruby 2/2.1/2.2
  • Updated Contributing and Testing docs
  • Added a maintainers doc
  • Added a Gemfile with development and testing dependencies
  • Added cookbook version and Travis CI badges to the readme
  • Clarified in the readme that the minimum supported Chef release is 11.0
  • Added a Rakefile easier testing
  • Added a chefignore file to limit files that are uploaded to the Chef server
  • Update to modern notification format to resolve Foodcritic warnings
  • Added source_url and issues_url to the metadata for Supermarket
  • Removed pre-Ruby 1.9 hash rockets

v1.0.0 (2015-04-29)

NOTE: This release includes breaking changes to the behavior of this cookbook. The iptables_rule definition was converted to a LWRP. This changes the behavior of disabling iptables rules. Previously a rule could be disabled by specifying enable false. You must now specify action :disable. Additionally the cookbook no longer installs the out of the box iptables rules. These were rules made assumptions about the operating environment and should not have been installed out of the box. This makes this recipe a library cookbook that can be better wrapped to meet the needs or your particular environment. - Definition converted to a LWRP to providing why-run support and - The out of the box iptables rules are no longer installed. If you need these rules you'll need to wrap the cookbook and use the LWRP to define these same rules. - Removed all references to the roadmap and deprecation of the cookbook. It's not going anywhere any time soon - Use platform_family to better support Debian derivatives - Converted file / directory modes to strings to preserve the leading 0 - Added additional RHEL derivitive distributions to the metadata - Expanded excluded files in the gitignore and chefignore files - Included the latest contributing documentation to match the current process

v0.14.1 (2015-01-01)

  • Fixing File.exists is deprecated for File.exist

v0.14.0 (2014-08-31)

  • [#14] Adds basic testing suite including Berksfile
  • [#14] Adds basic integration/post-converge tests
  • [#14] Adds default prefix and postfix rules to disalow traffic

v0.13.2 (2014-04-09)

  • [COOK-4496] Added Amazon Linux support

v0.13.0 (2014-03-19)

  • [COOK-3927] Substitute Perl version of rebuild-iptables with Ruby version

v0.12.2 (2014-03-18)

  • [COOK-4411] - Add newling to iptables.snat

v0.12.0

  • [COOK-2213] - iptables disabled recipe

v0.11.0

  • [COOK-1883] - add perl package so rebuild script works

v0.10.0

  • [COOK-641] - be able to save output on rhel-family
  • [COOK-655] - use a template from other cookbooks

v0.9.3

  • Current public release.

Foodcritic Metric

FC016: LWRP does not declare a default action: /tmp/cook/5ae738926f0f96bc71d3847a/iptables/resources/rule.rb:1