Skip to content

Commit

Permalink
Check if needs to reload or not
Browse files Browse the repository at this point in the history
  • Loading branch information
pperezredborder committed Dec 16, 2024
1 parent 28b9bf2 commit f6ae60e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Chef::Log.error "\n\n\n\n\nis_manager #{is_manager?}\nsync_ip #{sync_ip}\nip_addr #{ip_addr}\n\n\n\n"

12 changes: 12 additions & 0 deletions resources/providers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@
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 f6ae60e

Please sign in to comment.