chef-provisioning-aws 0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76f0514d962d5789033fb18a43ef72ee0e837a01
4
- data.tar.gz: 7e9a266dc9dad08d2cc96c43723e9e3e3d5c952b
3
+ metadata.gz: 3acb67df3a046b0298b40a390a7cacee7e700b51
4
+ data.tar.gz: 0e7d8231c5a682d1b25c6c8ca138abbec7422494
5
5
  SHA512:
6
- metadata.gz: 868772f85f647b4cd65db9e6c1d150b232b32544923d3a3116c1fddd957c392f48d66a0a6e74e5f55da30241b345a89e68f10ecb2b59cb3a6d84bd2933d6cf15
7
- data.tar.gz: 88d0e115dc23de3a093dd5dafebae2f450237b2b591c1bb1feab84992eb86aad7480622c08eb044e1eb8c4996d0d295b5367572a38ef757f34c983c510ac879c
6
+ metadata.gz: dca5eec228b058b87d02c7da2098806073c904e1369672f724a2dfd4ad5115b248241defe1aa5a8dd9c5b1d1b18340fbdabe9e4c66bff7a3f9099e8eae8e4729
7
+ data.tar.gz: 821c4ba12a4dedba7cdd7da366f277e2c32ab14215a9de36d30078dc9c1ea1eb9c3bb9619bec6aad11b27922fdf6d94566d89747dd55a1cc0347cb07257c488e
@@ -60,11 +60,22 @@ module AWSDriver
60
60
  'host_node' => action_handler.host_node,
61
61
  }
62
62
 
63
+ security_group_name = lb_options[:security_group_name] || 'default'
64
+ security_group_id = lb_options[:security_group_id]
65
+
66
+ default_sg = ec2.security_groups.filter('group-name', 'default')
67
+ security_group = if security_group_id.nil?
68
+ ec2.security_groups.filter('group-name', security_group_name).first
69
+ else
70
+ ec2.security_groups[security_group_id]
71
+ end
72
+
63
73
  availability_zones = lb_options[:availability_zones]
64
74
  listeners = lb_options[:listeners]
65
75
  elb.load_balancers.create(lb_spec.name,
66
76
  :availability_zones => availability_zones,
67
- :listeners => listeners)
77
+ :listeners => listeners,
78
+ :security_groups => [security_group])
68
79
  end
69
80
  end
70
81
 
@@ -74,32 +85,44 @@ module AWSDriver
74
85
  def destroy_load_balancer(action_handler, lb_spec, lb_options)
75
86
  end
76
87
 
88
+ # TODO update listeners and zones, and other bits
77
89
  def update_load_balancer(action_handler, lb_spec, lb_options, opts = {})
78
90
  existing_elb = load_balancer_for(lb_spec)
79
- # TODO update listeners and zones?
80
- if existing_elb.exists?
81
- machines = opts[:machines]
82
- existing_instance_ids = existing_elb.instances.collect { |i| i.instance_id }
83
- new_instance_ids = machines.keys.collect do |machine_name|
84
- machine_spec = machines[machine_name]
85
- machine_spec.location['instance_id']
86
- end
87
91
 
88
- instance_ids_to_add = new_instance_ids - existing_instance_ids
89
- instance_ids_to_remove = existing_instance_ids - new_instance_ids
92
+ # Try to recreate it if it doesn't exist in AWS
93
+ action_handler.report_progress "Checking for ELB named #{lb_spec.name}..."
94
+ allocate_load_balancer(action_handler, lb_spec, lb_options) unless existing_elb.exists?
95
+
96
+ # Try to find it again -- if we can't, consider it fatal
97
+ existing_elb = load_balancer_for(lb_spec)
98
+ fail "Unable to find specified ELB instance. Already tried to recreate it!" if !existing_elb.exists?
99
+
100
+ action_handler.report_progress "Updating ELB named #{lb_spec.name}..."
101
+
102
+ machines = opts[:machines]
103
+ existing_instance_ids = existing_elb.instances.collect { |i| i.instance_id }
90
104
 
91
- if instance_ids_to_add && instance_ids_to_add.size > 0
105
+ new_instance_ids = machines.keys.collect do |machine_name|
106
+ machine_spec = machines[machine_name]
107
+ machine_spec.location['instance_id']
108
+ end
109
+
110
+ instance_ids_to_add = new_instance_ids - existing_instance_ids
111
+ instance_ids_to_remove = existing_instance_ids - new_instance_ids
112
+
113
+ if instance_ids_to_add && instance_ids_to_add.size > 0
114
+ action_handler.perform_action "Adding instances: #{instance_ids_to_add}" do
92
115
  existing_elb.instances.add(instance_ids_to_add)
93
116
  end
117
+ end
94
118
 
95
- if instance_ids_to_remove && instance_ids_to_remove.size > 0
119
+ if instance_ids_to_remove && instance_ids_to_remove.size > 0
120
+ action_handler.perform_action "Removing instances: #{instance_ids_to_remove}" do
96
121
  existing_elb.instances.remove(instance_ids_to_remove)
97
122
  end
98
-
99
123
  end
100
124
  end
101
125
 
102
-
103
126
  # Image methods
104
127
  def allocate_image(action_handler, image_spec, image_options, machine_spec)
105
128
  end
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  module Provisioning
3
3
  module AWSDriver
4
- VERSION = '0.1'
4
+ VERSION = '0.1.1'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-provisioning-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Ewart