Sha256: f54dc327741bf070a9a8117a6a1aeea0cbe179292d70cf62ba0dfbaf0484f137

Contents?: true

Size: 1.51 KB

Versions: 15

Compression:

Stored size: 1.51 KB

Contents

namespace :rubber do

  desc <<-DESC
    Sets up the network security groups
    All defined groups will be created, and any not defined will be removed.
    Likewise, rules within a group will get created, and those not will be removed
  DESC
  required_task :setup_security_groups do
    servers = find_servers_for_task(current_task)

    cloud.setup_security_groups(servers.collect(&:host))
  end

  desc <<-DESC
    Describes the network security groups
  DESC
  required_task :describe_security_groups do
    groups = cloud.describe_security_groups()
    groups.each do |group|
      puts "#{group[:name]}, #{group[:description]}"
      group[:permissions].each do |perm|
        puts "  protocol: #{perm[:protocol]}"
        puts "  from_port: #{perm[:from_port]}"
        puts "  to_port: #{perm[:to_port]}"
        puts "  source_groups: #{perm[:source_groups].collect {|g| g[:name]}.join(", ") }" if perm[:source_groups]
        puts "  source_ips: #{perm[:source_ips].join(", ") }" if perm[:source_ips]
        puts "\n"
      end if group[:permissions]
      puts "\n"
    end
  end


  def get_assigned_security_groups(host=nil, roles=[])
    env = rubber_cfg.environment.bind(roles, host)
    security_groups = env.assigned_security_groups
    if env.auto_security_groups
      security_groups << host
      security_groups += roles
    end
    security_groups = security_groups.uniq.compact.reject {|x| x.empty? }
    security_groups = security_groups.collect {|x| cloud.isolate_group_name(x) }
    return security_groups
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rubber-2.6.5 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.6.4 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.6.3 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.6.2 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.6.1 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.6.0 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.5.5 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.5.4 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.5.3 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.5.2 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.5.1 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.5.0 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.4.2 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.4.1 lib/rubber/recipes/rubber/security_groups.rb
rubber-2.4.0 lib/rubber/recipes/rubber/security_groups.rb