Skip to content

Commit

Permalink
Merge pull request #8 from redBorder/development
Browse files Browse the repository at this point in the history
Release 0.1.2
  • Loading branch information
malvads authored Dec 19, 2024
2 parents 28b9bf2 + 899162a commit 2dcd667
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
cookbook-rb-firewall CHANGELOG
===============

## 0.1.2

- Pablo Pérez
- [d7ab30b] delete random file
- [39f0883] deleted unnecesary notifies
- [f6ae60e] Check if needs to reload or not

## 0.1.1

- manegron
Expand Down
2 changes: 1 addition & 1 deletion resources/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
maintainer_email 'git@redborder.com'
license 'AGPL-3.0'
description 'Installs/Configures Firewall'
version '0.1.1'
version '0.1.2'
14 changes: 12 additions & 2 deletions resources/providers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
action :delete
permanent true
only_if "firewall-cmd --permanent --zone=public --query-rich-rule='rule family=\"ipv4\" source address=\"#{ip}\" port port=\"9092\" protocol=\"tcp\" accept'"
notifies :reload, 'service[firewalld]', :delayed
end
end
end
Expand All @@ -93,11 +92,22 @@
action :create
permanent true
not_if "firewall-cmd --permanent --zone=public --query-rich-rule='rule family=\"ipv4\" source address=\"#{ip}\" port port=\"9092\" protocol=\"tcp\" accept'"
notifies :reload, 'service[firewalld]', :delayed
end
end
end

# Reload firewalld only if the runtime rules are different than the permanent rules
# (a rule has been added/deleted and the service needs to be reloaded)
execute 'reload_firewalld' do
command 'firewall-cmd --reload'
only_if do
runtime_rules = `firewall-cmd --zone=public --list-rich-rules`.strip
permanent_rules = `firewall-cmd --permanent --zone=public --list-rich-rules`.strip
runtime_rules != permanent_rules
end
action :run
end

Chef::Log.info('Firewall configuration has been applied.')
end

Expand Down

0 comments on commit 2dcd667

Please sign in to comment.