Skip to content

Bugfix#19618 open needed ports for ips #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading