module Landrush::Cap::Linux::AddIptablesRule
Public Class Methods
_run(machine, command)
click to toggle source
# File lib/landrush/cap/guest/linux/add_iptables_rule.rb, line 9 def self._run(machine, command) machine.communicate.sudo(command) do |data, type| if %i[stderr stdout].include?(type) color = type == :stdout ? :green : :red machine.env.ui.info(data.chomp, color: color, prefix: false) end end end
add_iptables_rule(machine, rule)
click to toggle source
# File lib/landrush/cap/guest/linux/add_iptables_rule.rb, line 5 def self.add_iptables_rule(machine, rule) _run(machine, %(iptables -C #{rule} 2> /dev/null || iptables -A #{rule})) end