Sha256: f0e5010e3e6b3b210c85cbe646b226ddf520f6c48917c94924ae5cbeadb30556

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

module Pvcglue
  class Packages
    class Firewall < Pvcglue::Packages
      # Reference:  http://manpages.ubuntu.com/manpages/xenial/en/man8/ufw-framework.8.html
      # Examples:  https://help.ubuntu.com/community/UFW
      def installed?
        get_minion_state
      end

      def install!
        connection.run!(:root, '', 'ufw disable; ufw --force reset; ufw allow ssh; ufw --force enable')
        # connection.run!(:root, '', 'ufw logging off')
        connection.run!(:root, '', 'ufw logging low')

        if has_role?(:lb)
          connection.run!(:root, '', 'ufw allow http')
          connection.run!(:root, '', 'ufw allow https')
        end

        unless has_role?(:manager)
          minion.cloud.minions.each do |other_minion_name, other_minion|
            next if other_minion_name == minion.machine_name
            next unless other_minion.provisioned?
            connection.run!(:root, '', "ufw allow from #{other_minion.private_ip}")
          end
        end

        set_minion_state
      end

      def post_install_check?
        result = connection.run_get_stdout!(:root, '', 'ufw status verbose')
        result =~ /Status: active/ && result =~ /Default: deny \(incoming\), allow \(outgoing\)/
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pvcglue-0.9.6 lib/pvcglue/packages/firewall.rb
pvcglue-0.9.5 lib/pvcglue/packages/firewall.rb