-
-
Save joewilliams/266404 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'ostruct' | |
UFW_SECTIONS = [:ufw_new_resource, :ufw_protocol, :ufw_src_addr, :ufw_src_port, :ufw_dest_addr, :ufw_dest_port] | |
def build_cmd | |
UFW_SECTIONS.collect{ |action| self.send(action)}.join(" ") | |
end | |
def ufw_new_resource | |
"ufw #{new_resource.action}" | |
end | |
def ufw_protocol | |
(new_resource.protocol && "proto #{new_resource.protocol}") || "" | |
end | |
def ufw_src_addr | |
"from #{(new_resource.src_addr || 'any')}" | |
end | |
def ufw_src_port | |
(new_resource.src_port && "port #{new_resource.src_port} ") || "" | |
end | |
def ufw_dest_addr | |
"to #{new_resource.dest_addr || 'any'}" | |
end | |
def ufw_dest_port | |
(new_resource.dest_port && "port #{new_resource.dest_port}") || "" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment