The ufw cookbook provides a single custom resource, ufw_firewall, for managing
Uncomplicated Firewall on Debian and Ubuntu with the firewall cookbook's UFW provider.
- Debian 12+
- Ubuntu 22.04+
- Chef 15.3+
firewall2.0+
ufw_firewall installs and enables UFW, optionally opens SSH, and applies the provided rule set.
It can also merge in rules discovered from a data bag or from legacy recipe-level firewall
attributes during migration.
ufw_firewall 'default' do
allow_ssh true
rules(
[
{ 'http' => { 'port' => '80' } },
{ 'https' => { 'port' => '443' } },
{
'block-admin' => {
'port' => '8443',
'source' => '192.0.2.10',
'action' => 'deny',
},
},
]
)
action :create
endufw_firewall 'default' do
data_bag_name 'firewall'
action :create
endufw_firewall 'default' do
collect_recipe_rules true
action :create
endufw_firewall 'default' do
action :delete
endSee documentation/ufw_ufw_firewall.md for the full
resource API.
Author: Cookbook Engineering Team (cookbooks@chef.io)
Copyright: 2011-2014, 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.