Last active
August 29, 2015 14:04
-
-
Save 7hunderbird/42ca240c72c44cced42f to your computer and use it in GitHub Desktop.
proto code for actions and filters for a fail2ban recipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cookbooks/fail2ban/attributes/default.rb | |
# This is an attribute file snippet | |
default[:fail2ban][:dir] = "/etc/fail2ban/" | |
default[:fail2ban][:action_path] = "cookbooks/fail2ban/files/default/action" | |
default[:fail2ban][:filters_path] = "cookbooks/fail2ban/files/default/filters" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cookbooks/fail2ban/recipes/default.rb | |
# This is a recipe file snippet | |
filters = # Create an array of filter filenames. | |
actions = # Create an array of action filenames. | |
filters.each do |filename| | |
filepath = "#{Chef::Config['file_cache_path']}/#{filename}" # this maps from attributes default[:fail2ban][:dir] | |
remote_file filepath do | |
source "#{node['fail2ban']['filters_path']}/#{filename}" | |
owner 'root' | |
group 'root' | |
mode "0644" | |
action :create_if_missing | |
end | |
end | |
actions.each do |filename| | |
filepath = "#{Chef::Config['file_cache_path']}/#{filename}" | |
remote_file filepath do | |
source "#{node['fail2ban']['action_path']}/#{filename}" | |
owner 'root' | |
group 'root' | |
mode "0644" | |
action :create_if_missing | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment