Skip to content

Instantly share code, notes, and snippets.

@7hunderbird
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7hunderbird/42ca240c72c44cced42f to your computer and use it in GitHub Desktop.
Save 7hunderbird/42ca240c72c44cced42f to your computer and use it in GitHub Desktop.
proto code for actions and filters for a fail2ban recipe
# 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"
# 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