Sha256: 8d1ee164657af62134554874fe3f3deb794b5cc3ba9a2e36c78cba17850f3e07

Contents?: true

Size: 591 Bytes

Versions: 1

Compression:

Stored size: 591 Bytes

Contents

module Landrush
  module Cap
    module Suse
      module AddIptablesRule
        def self.add_iptables_rule(machine, rule)
          _run(machine, %(/usr/sbin/iptables -C #{rule} 2> /dev/null || /usr/sbin/iptables -A #{rule}))
        end

        def self._run(machine, command)
          machine.communicate.sudo(command) do |data, type|
            if [:stderr, :stdout].include?(type)
              color = (type == :stdout) ? :green : :red
              machine.env.ui.info(data.chomp, color: color, prefix: false)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
landrush-1.2.0 lib/landrush/cap/guest/suse/add_iptables_rule.rb