chef-provisioning-aws 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +176 -61
- data/lib/chef/provider/aws_dhcp_options.rb +1 -1
- data/lib/chef/provider/aws_ebs_volume.rb +4 -1
- data/lib/chef/provider/aws_network_acl.rb +1 -1
- data/lib/chef/provider/aws_network_interface.rb +5 -2
- data/lib/chef/provider/aws_route_table.rb +1 -1
- data/lib/chef/provider/aws_sqs_queue.rb +1 -5
- data/lib/chef/provider/aws_subnet.rb +4 -2
- data/lib/chef/provider/aws_vpc.rb +4 -2
- data/lib/chef/provisioning/aws_driver/aws_provider.rb +9 -2
- data/lib/chef/provisioning/aws_driver/driver.rb +31 -2
- data/lib/chef/provisioning/aws_driver/version.rb +1 -1
- data/lib/chef/resource/aws_cache_cluster.rb +45 -0
- data/lib/chef/resource/aws_cache_replication_group.rb +42 -0
- data/lib/chef/resource/aws_cache_subnet_group.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 152994be990de9eda227b6a5be1179acea932c78
|
4
|
+
data.tar.gz: 1c58f8b2be7da9e3a779dae16ba2ff445de4370d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aba82b6a79304d5786b8b686aad781c18add3fac6b1d52c52b300dffd38ec93b2262cda6be721de582f5382cea04a08435f3a3001bd4857415743713a0ca4e66
|
7
|
+
data.tar.gz: 2e70c7a272b3902b7b8a96a70f4a70a99f9a6ee3d38e1ef3c329efef09f055129d2a97202d00dcc08f6ec0e3d32e171f908dea6eef093de97c853cb37ac9e9f3
|
data/README.md
CHANGED
@@ -18,6 +18,39 @@ because users can look at the resource model.
|
|
18
18
|
TODO: document `aws_object` and `get_aws_object` and how you can get the aws object for a base
|
19
19
|
chef-provisioning resource like machine or load_balancer
|
20
20
|
|
21
|
+
## aws_key_pair
|
22
|
+
|
23
|
+
You can specify an existing key pair to upload by specifying the following:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
aws_key_pair 'my-aws-key' do
|
27
|
+
private_key_path "~boiardi/.ssh/my-aws-key.pem"
|
28
|
+
public_key_path "~boiardi/.ssh/my-aws-key.pub"
|
29
|
+
overwrite false # Set to true if you want to regenerate this each chef run
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
## aws_launch_configuration
|
34
|
+
|
35
|
+
In the AWS SDK V1, you must specify `key_pair` instead of `key_name` when specifying the key name to use for machines in the auto scaling group. This is fixed in V2 and uses `key_name` like machines do.
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
aws_launch_configuration 'example-windows-launch-configuration' do
|
39
|
+
image 'example-windows-image'
|
40
|
+
instance_type 't2.medium'
|
41
|
+
options security_groups: 'example-windows-sg',
|
42
|
+
key_pair: 'my-key-name',
|
43
|
+
ebs_optimized: false,
|
44
|
+
detailed_instance_monitoring: false,
|
45
|
+
iam_instance_profile: 'example-windows-role',
|
46
|
+
user_data: <<-EOF
|
47
|
+
<powershell>
|
48
|
+
# custom powershell code goes here, executed at instance creation time
|
49
|
+
</powershell>
|
50
|
+
EOF
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
21
54
|
## aws_vpc
|
22
55
|
|
23
56
|
If you specify `internet_gateway true` the VPC will create and manage its own internet gateway.
|
@@ -66,11 +99,9 @@ If you `:purge` a VPC and it has `aws_route_table[ref-route]` in it, the data ba
|
|
66
99
|
`ref-route` is not automatically destroyed. Purge is most useful for testing to ensure no objects
|
67
100
|
are left that AWS can charge for.
|
68
101
|
|
69
|
-
|
70
|
-
|
71
|
-
TODO - document how to specify an existing local key
|
102
|
+
# Machine Options
|
72
103
|
|
73
|
-
|
104
|
+
TODO - Finish documenting these
|
74
105
|
|
75
106
|
You can pass machine options that will be used by `machine`, `machine_batch` and `machine_image` to
|
76
107
|
configure the machine. These are all the available options:
|
@@ -78,9 +109,52 @@ configure the machine. These are all the available options:
|
|
78
109
|
```ruby
|
79
110
|
with_machine_options({
|
80
111
|
bootstrap_options: {
|
81
|
-
|
112
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Resource.html#create_instances-instance_method
|
113
|
+
# lists the available options. The below options are the default
|
114
|
+
image_id: "ami-5915e11d", # default for us-west-1
|
115
|
+
instance_type: "t2.micro",
|
116
|
+
key_name: "chef_default", # If not specified, this will be used and generated
|
117
|
+
key_path: "~/.chef/keys/chef_default", # only necessary if storing keys some other location
|
118
|
+
user_data: "...", # Only defaulted on Windows instances to start winrm
|
119
|
+
},
|
120
|
+
convergence_options: {
|
121
|
+
chef_version: "12.4.1",
|
122
|
+
prerelease: "false",
|
123
|
+
chef_client_timeout: 120*60, # Default: 2 hours
|
124
|
+
chef_config: "log_level :debug\\n", # String containing additional text to inject into client.rb
|
125
|
+
chef_server: "http://my.chef.server/", # TODO could conflict with https://github.com/chef/chef-provisioning#pointing-boxes-at-chef-servers
|
126
|
+
bootstrap_proxy: "http://localhost:1234",
|
127
|
+
ssl_verify_mode: :verify_peer,
|
128
|
+
client_rb_path: "/etc/chef/client.rb", # <- DEFAULT, overwrite if necessary
|
129
|
+
client_pem_path: "/etc/chef/client.pem", # <- DEFAULT, overwrite if necessary
|
130
|
+
allow_overwrite_keys: false, # If there is an existing client.pem this needs to be true to overwrite it
|
131
|
+
private_key_options: {}, # TODO ????? Something to do with creating node object
|
132
|
+
source_key: "", # ?????
|
133
|
+
source_key_pass_phrase: "", # ?????
|
134
|
+
source_key_path: "", # ?????
|
135
|
+
public_key_path: "", # ?????
|
136
|
+
public_key_format: "", # ?????
|
137
|
+
admin: "", # ?????
|
138
|
+
validator: "", # ?????
|
139
|
+
ohai_hints: { :ec2 => { :key => :value } }, # Map from hint file name to file contents, this would create /etc/chef/ohai/hints/ec2.json
|
140
|
+
# The following are only available for Linux machines
|
141
|
+
install_sh_url: "https://www.chef.io/chef/install.sh", # <- DEFAULT, overwrite if necessary
|
142
|
+
install_sh_path: "/tmp/chef-install.sh", # <- DEFAULT, overwrite if necessary
|
143
|
+
install_sh_arguments: "-P chef-dk", # Additional commands to pass to install.sh
|
144
|
+
# The following are only available for Windows machines
|
145
|
+
install_msi_url: "foo://bar.com"
|
146
|
+
},
|
147
|
+
ssh_options: {
|
82
148
|
...
|
83
149
|
},
|
150
|
+
cached_installer: false, # ???
|
151
|
+
aws_tags: { :key1 => "value", "key2" => "value"},
|
152
|
+
source_dest_check: false, # Specifies whether to enable an instance launched in a VPC to perform NAT
|
153
|
+
is_windows: false, # set to true if using a Windows AMI
|
154
|
+
ssh_username: "ubuntu",
|
155
|
+
ssh_gateway: "localhost"
|
156
|
+
sudo: true,
|
157
|
+
use_private_ip_for_ssh: false, # If set to true, we will access the instance with its private_ip (usually requires VPN access)
|
84
158
|
...
|
85
159
|
})
|
86
160
|
```
|
@@ -88,9 +162,102 @@ with_machine_options({
|
|
88
162
|
This options hash can be supplied to either `with_machine_options` or directly into the `machine_options`
|
89
163
|
attribute.
|
90
164
|
|
91
|
-
|
165
|
+
# Load Balancer Options
|
166
|
+
|
167
|
+
You can configure the ELB options by setting `with_load_balancer_options` or specifying them on each `load_balancer` resource.
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
machine 'test1'
|
171
|
+
m2 = machine 'test2'
|
172
|
+
load_balancer "my_elb" do
|
173
|
+
machines ['test1', m2]
|
174
|
+
load_balancer_options({
|
175
|
+
subnets: subnets,
|
176
|
+
security_groups: [load_balancer_sg],
|
177
|
+
listeners: [
|
178
|
+
{
|
179
|
+
instance_port: 8080,
|
180
|
+
protocol: 'HTTP',
|
181
|
+
instance_protocol: 'HTTP',
|
182
|
+
port: 80
|
183
|
+
},
|
184
|
+
{
|
185
|
+
instance_port: 8080,
|
186
|
+
protocol: 'HTTPS',
|
187
|
+
instance_protocol: 'HTTP',
|
188
|
+
port: 443,
|
189
|
+
ssl_certificate_id: "arn:aws:iam::360965486607:server-certificate/cloudfront/foreflight-2015-07-09"
|
190
|
+
}
|
191
|
+
]
|
192
|
+
})
|
193
|
+
```
|
194
|
+
|
195
|
+
The available parameters for `load_balancer_options` can be viewed at http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ELB/Client.html#create_load_balancer-instance_method .
|
196
|
+
|
197
|
+
NOTES:
|
198
|
+
|
199
|
+
1. You can specify either `ssl_certificate_id` or `server_certificate` in a listener but the value to both parameters should be the ARN of an existing IAM::ServerCertificate object.
|
200
|
+
2. Instead of specifying `tags` in the `load_balancer_options`, you should specify `aws_tags`. See the note on [tagging base resources](https://github.com/chef/chef-provisioning-aws#base-resources).
|
201
|
+
|
202
|
+
# Specifying a Chef Server
|
203
|
+
|
204
|
+
See [Pointing Boxes at Chef Servers](https://github.com/chef/chef-provisioning/blob/master/README.md#pointing-boxes-at-chef-servers)
|
205
|
+
|
206
|
+
# Tagging Resources
|
207
|
+
|
208
|
+
## Aws Resources
|
209
|
+
|
210
|
+
All resources which extend Chef::Provisioning::AWSDriver::AWSResourceWithEntry support the ability
|
211
|
+
to add tags, except AwsEipAddress. AWS does not support tagging on AwsEipAddress. To add a tag
|
212
|
+
to any aws resource, us the `aws_tags` attribute and provide it a hash:
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
aws_ebs_volume 'ref-volume' do
|
216
|
+
aws_tags company: 'my_company', 'key_as_string' => :value_as_symbol
|
217
|
+
end
|
218
|
+
|
219
|
+
aws_vpc 'ref-vpc' do
|
220
|
+
aws_tags 'Name' => 'custom-vpc-name'
|
221
|
+
end
|
222
|
+
```
|
223
|
+
|
224
|
+
The hash of tags can use symbols or strings for both keys and values. The tags will be converged
|
225
|
+
idempotently, meaning no write will occur if no tags are changing.
|
226
|
+
|
227
|
+
We will not touch the `'Name'` tag UNLESS you specifically pass it. If you do not pass it, we
|
228
|
+
leave it alone.
|
229
|
+
|
230
|
+
## Base Resources
|
231
|
+
|
232
|
+
Because base resources from chef-provisioning do not have the `aws_tag` attribute, they must be
|
233
|
+
tagged in their options:
|
234
|
+
|
235
|
+
```ruby
|
236
|
+
machine 'ref-machine-1' do
|
237
|
+
machine_options :aws_tags => {:marco => 'polo', :happyhappy => 'joyjoy'}
|
238
|
+
end
|
239
|
+
|
240
|
+
machine_batch "ref-batch" do
|
241
|
+
machine 'ref-machine-2' do
|
242
|
+
machine_options :aws_tags => {:marco => 'polo', :happyhappy => 'joyjoy'}
|
243
|
+
converge false
|
244
|
+
end
|
245
|
+
machine 'ref-machine-3' do
|
246
|
+
machine_options :aws_tags => {:othercustomtags => 'byebye'}
|
247
|
+
converge false
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
load_balancer 'ref-elb' do
|
252
|
+
load_balancer_options :aws_tags => {:marco => 'polo', :happyhappy => 'joyjoy'}
|
253
|
+
end
|
254
|
+
```
|
255
|
+
|
256
|
+
See `docs/examples/aws_tags.rb` for further examples.
|
257
|
+
|
258
|
+
# Looking up AWS objects
|
92
259
|
|
93
|
-
|
260
|
+
## \#aws\_object
|
94
261
|
|
95
262
|
All chef-provisioning-aws resources have a `aws_object` method that will return the AWS object. The AWS
|
96
263
|
object won't exist until the resource converges, however. An example of how to do this looks like:
|
@@ -131,7 +298,7 @@ end
|
|
131
298
|
Note the use of the `lazy` attribute modifier. This is necessary because when the resources are compiled
|
132
299
|
the aws_objects do not exist yet, so we must wait to reference them until the converge phase.
|
133
300
|
|
134
|
-
|
301
|
+
## \#lookup\_options
|
135
302
|
|
136
303
|
You have access to the aws object when necessary, but often it isn't needed. The above example is better
|
137
304
|
written as:
|
@@ -168,7 +335,7 @@ perform [lookup_options](https://github.com/chef/chef-provisioning-aws/blob/mast
|
|
168
335
|
This tries to turn elements with names like `vpc`, `security_group_ids`, `machines`, `launch_configurations`,
|
169
336
|
`load_balancers`, etc. to the correct AWS object.
|
170
337
|
|
171
|
-
|
338
|
+
## Looking up chef-provisioning resources
|
172
339
|
|
173
340
|
The base chef-provisioning resources (machine, machine_batch, load_balancer, machine_image) don't
|
174
341
|
have the `aws_object` method defined on them because they are not `AWSResource` classes. To
|
@@ -216,55 +383,3 @@ you!
|
|
216
383
|
If you find the tests leaving behind resources during normal conditions (IE, not when there is an
|
217
384
|
unexpected exception) please file a bug. Most objects can be cleaned up by deleting the `test_vpc`
|
218
385
|
from within the AWS browser console.
|
219
|
-
|
220
|
-
# Tagging Resources
|
221
|
-
|
222
|
-
## Aws Resources
|
223
|
-
|
224
|
-
All resources which extend Chef::Provisioning::AWSDriver::AWSResourceWithEntry support the ability
|
225
|
-
to add tags, except AwsEipAddress. AWS does not support tagging on AwsEipAddress. To add a tag
|
226
|
-
to any aws resource, us the `aws_tags` attribute and provide it a hash:
|
227
|
-
|
228
|
-
```ruby
|
229
|
-
aws_ebs_volume 'ref-volume' do
|
230
|
-
aws_tags company: 'my_company', 'key_as_string' => :value_as_symbol
|
231
|
-
end
|
232
|
-
|
233
|
-
aws_vpc 'ref-vpc' do
|
234
|
-
aws_tags 'Name' => 'custom-vpc-name'
|
235
|
-
end
|
236
|
-
```
|
237
|
-
|
238
|
-
The hash of tags can use symbols or strings for both keys and values. The tags will be converged
|
239
|
-
idempotently, meaning no write will occur if no tags are changing.
|
240
|
-
|
241
|
-
We will not touch the `'Name'` tag UNLESS you specifically pass it. If you do not pass it, we
|
242
|
-
leave it alone.
|
243
|
-
|
244
|
-
## Base Resources
|
245
|
-
|
246
|
-
Because base resources from chef-provisioning do not have the `aws_tag` attribute, they must be
|
247
|
-
tagged in their options:
|
248
|
-
|
249
|
-
```ruby
|
250
|
-
machine 'ref-machine-1' do
|
251
|
-
machine_options :aws_tags => {:marco => 'polo', :happyhappy => 'joyjoy'}
|
252
|
-
end
|
253
|
-
|
254
|
-
machine_batch "ref-batch" do
|
255
|
-
machine 'ref-machine-2' do
|
256
|
-
machine_options :aws_tags => {:marco => 'polo', :happyhappy => 'joyjoy'}
|
257
|
-
converge false
|
258
|
-
end
|
259
|
-
machine 'ref-machine-3' do
|
260
|
-
machine_options :aws_tags => {:othercustomtags => 'byebye'}
|
261
|
-
converge false
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
load_balancer 'ref-elb' do
|
266
|
-
load_balancer_options :aws_tags => {:marco => 'polo', :happyhappy => 'joyjoy'}
|
267
|
-
end
|
268
|
-
```
|
269
|
-
|
270
|
-
See `docs/examples/aws_tags.rb` for further examples.
|
@@ -12,7 +12,7 @@ class Chef::Provider::AwsDhcpOptions < Chef::Provisioning::AWSDriver::AWSProvide
|
|
12
12
|
|
13
13
|
converge_by "create new dhcp_options #{new_resource.name} in #{region}" do
|
14
14
|
dhcp_options = new_resource.driver.ec2.dhcp_options.create(options)
|
15
|
-
|
15
|
+
retry_with_backoff(AWS::EC2::Errors::InvalidDhcpOptionsID::NotFound) do
|
16
16
|
dhcp_options.tags['Name'] = new_resource.name
|
17
17
|
end
|
18
18
|
dhcp_options
|
@@ -36,7 +36,10 @@ class Chef::Provider::AwsEbsVolume < Chef::Provisioning::AWSDriver::AWSProvider
|
|
36
36
|
volume = nil
|
37
37
|
converge_by "create new #{new_resource} in #{region}" do
|
38
38
|
volume = new_resource.driver.ec2.volumes.create(initial_options)
|
39
|
-
|
39
|
+
retry_with_backoff(AWS::EC2::Errors::InvalidVolumeID::NotFound) do
|
40
|
+
volume.tags['Name'] = new_resource.name
|
41
|
+
end
|
42
|
+
volume
|
40
43
|
end
|
41
44
|
|
42
45
|
converge_by "wait for new #{new_resource} in #{region} to become available" do
|
@@ -20,7 +20,7 @@ class Chef::Provider::AwsNetworkAcl < Chef::Provisioning::AWSDriver::AWSProvider
|
|
20
20
|
Chef::Log.debug("VPC: #{options[:vpc]}")
|
21
21
|
|
22
22
|
network_acl = new_resource.driver.ec2.network_acls.create(options)
|
23
|
-
|
23
|
+
retry_with_backoff(AWS::EC2::Errors::InvalidNetworkAclID::NotFound) do
|
24
24
|
network_acl.tags['Name'] = new_resource.name
|
25
25
|
end
|
26
26
|
network_acl
|
@@ -36,7 +36,10 @@ class Chef::Provider::AwsNetworkInterface < Chef::Provisioning::AWSDriver::AWSPr
|
|
36
36
|
eni = nil
|
37
37
|
converge_by "create new #{new_resource} in #{region}" do
|
38
38
|
eni = new_resource.driver.ec2.network_interfaces.create(options)
|
39
|
-
|
39
|
+
retry_with_backoff(AWS::EC2::Errors::InvalidNetworkInterfaceID::NotFound) do
|
40
|
+
eni.tags['Name'] = new_resource.name
|
41
|
+
end
|
42
|
+
eni
|
40
43
|
end
|
41
44
|
|
42
45
|
converge_by "wait for new #{new_resource} in #{region} to become available" do
|
@@ -149,7 +152,7 @@ class Chef::Provider::AwsNetworkInterface < Chef::Provisioning::AWSDriver::AWSPr
|
|
149
152
|
end
|
150
153
|
eni
|
151
154
|
end
|
152
|
-
|
155
|
+
|
153
156
|
def wait_for_eni_status(eni, expected_status)
|
154
157
|
initial_status = eni.status
|
155
158
|
log_callback = proc {
|
@@ -23,7 +23,7 @@ class Chef::Provider::AwsRouteTable < Chef::Provisioning::AWSDriver::AWSProvider
|
|
23
23
|
|
24
24
|
converge_by "create new route table #{new_resource.name} in VPC #{new_resource.vpc} (#{vpc.id}) and region #{region}" do
|
25
25
|
route_table = new_resource.driver.ec2.route_tables.create(options)
|
26
|
-
|
26
|
+
retry_with_backoff(AWS::EC2::Errors::InvalidRouteTableID::NotFound) do
|
27
27
|
route_table.tags['Name'] = new_resource.name
|
28
28
|
end
|
29
29
|
route_table
|
@@ -4,12 +4,8 @@ class Chef::Provider::AwsSqsQueue < Chef::Provisioning::AWSDriver::AWSProvider
|
|
4
4
|
|
5
5
|
def create_aws_object
|
6
6
|
converge_by "create new SQS queue #{new_resource.name} in #{region}" do
|
7
|
-
|
8
|
-
begin
|
7
|
+
retry_with_backoff(AWS::SQS::Errors::QueueDeletedRecently) do
|
9
8
|
new_resource.driver.sqs.queues.create(new_resource.name, new_resource.options || {})
|
10
|
-
rescue AWS::SQS::Errors::QueueDeletedRecently
|
11
|
-
sleep 5
|
12
|
-
retry
|
13
9
|
end
|
14
10
|
end
|
15
11
|
end
|
@@ -32,8 +32,10 @@ class Chef::Provider::AwsSubnet < Chef::Provisioning::AWSDriver::AWSProvider
|
|
32
32
|
|
33
33
|
converge_by "create new subnet #{new_resource.name} with CIDR #{cidr_block} in VPC #{new_resource.vpc} (#{options[:vpc]}) in #{region}" do
|
34
34
|
subnet = new_resource.driver.ec2.subnets.create(cidr_block, options)
|
35
|
-
|
36
|
-
|
35
|
+
retry_with_backoff(AWS::EC2::Errors::InvalidSubnetID::NotFound) do
|
36
|
+
subnet.tags['Name'] = new_resource.name
|
37
|
+
subnet.tags['VPC'] = new_resource.vpc
|
38
|
+
end
|
37
39
|
subnet
|
38
40
|
end
|
39
41
|
end
|
@@ -5,6 +5,8 @@ require 'retryable'
|
|
5
5
|
|
6
6
|
class Chef::Provider::AwsVpc < Chef::Provisioning::AWSDriver::AWSProvider
|
7
7
|
|
8
|
+
class NeverObtainedExistence < RuntimeError; end
|
9
|
+
|
8
10
|
def action_create
|
9
11
|
vpc = super
|
10
12
|
|
@@ -165,8 +167,8 @@ class Chef::Provider::AwsVpc < Chef::Provisioning::AWSDriver::AWSProvider
|
|
165
167
|
if !current_ig
|
166
168
|
converge_by "attach new Internet Gateway to VPC #{vpc.id}" do
|
167
169
|
current_ig = AWS.ec2(config: vpc.config).internet_gateways.create
|
168
|
-
|
169
|
-
raise "internet gateway for VPC #{vpc.id} never obtained existence" unless current_ig.exists?
|
170
|
+
retry_with_backoff(NeverObtainedExistence) do
|
171
|
+
raise NeverObtainedExistence.new("internet gateway for VPC #{vpc.id} never obtained existence") unless current_ig.exists?
|
170
172
|
end
|
171
173
|
action_handler.report_progress "create Internet Gateway #{current_ig.id}"
|
172
174
|
current_ig.tags['OwnedByVPC'] = vpc.id
|
@@ -276,7 +276,7 @@ class AWSProvider < Chef::Provider::LWRPBase
|
|
276
276
|
expected_status = [expected_status].flatten
|
277
277
|
current_status = aws_object.status
|
278
278
|
|
279
|
-
Retryable.retryable(:tries => tries, :sleep => sleep
|
279
|
+
Retryable.retryable(:tries => tries, :sleep => sleep) do |retries, exception|
|
280
280
|
action_handler.report_progress "waited #{retries*sleep}/#{tries*sleep}s for #{aws_object.id} status to change to #{expected_status.inspect}..."
|
281
281
|
begin
|
282
282
|
current_status = aws_object.status
|
@@ -301,7 +301,7 @@ class AWSProvider < Chef::Provider::LWRPBase
|
|
301
301
|
expected_states = [expected_states].flatten
|
302
302
|
current_state = aws_object.state
|
303
303
|
|
304
|
-
Retryable.retryable(:tries => tries, :sleep => sleep
|
304
|
+
Retryable.retryable(:tries => tries, :sleep => sleep) do |retries, exception|
|
305
305
|
action_handler.report_progress "waited #{retries*sleep}/#{tries*sleep}s for #{aws_object.id} state to change to #{expected_states.inspect}..."
|
306
306
|
begin
|
307
307
|
current_state = aws_object.state
|
@@ -313,5 +313,12 @@ class AWSProvider < Chef::Provider::LWRPBase
|
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
316
|
+
# Retry a block with an doubling backoff time (maximum wait of 10 seconds).
|
317
|
+
# @param retry_on [Exception] An exception to retry on, defaults to RuntimeError
|
318
|
+
#
|
319
|
+
def retry_with_backoff(retry_on = RuntimeError, &block)
|
320
|
+
Retryable.retryable(:tries => 10, :sleep => lambda { |n| [2**n, 10].min }, :on => retry_on, &block)
|
321
|
+
end
|
322
|
+
|
316
323
|
end
|
317
324
|
end
|
@@ -254,7 +254,8 @@ module AWSDriver
|
|
254
254
|
listener.delete
|
255
255
|
actual_elb.listeners.create(desired_listener)
|
256
256
|
end
|
257
|
-
elsif listener.server_certificate
|
257
|
+
elsif ! server_certificate_eql?(listener.server_certificate,
|
258
|
+
server_cert_from_spec(desired_listener))
|
258
259
|
# Server certificate is mutable - if no immutable changes required a full recreate, update cert
|
259
260
|
perform_action.call(" update server certificate from #{listener.server_certificate} to #{desired_listener[:server_certificate]}") do
|
260
261
|
listener.server_certificate = desired_listener[:server_certificate]
|
@@ -360,6 +361,34 @@ module AWSDriver
|
|
360
361
|
end
|
361
362
|
end
|
362
363
|
|
364
|
+
# Compare two server certificates by casting them both to strings.
|
365
|
+
#
|
366
|
+
# The parameters should either be a String containing the
|
367
|
+
# certificate ARN, or a IAM::ServerCertificate object.
|
368
|
+
def server_certificate_eql?(cert1, cert2)
|
369
|
+
server_cert_to_string(cert1) == server_cert_to_string(cert2)
|
370
|
+
end
|
371
|
+
|
372
|
+
def server_cert_to_string(cert)
|
373
|
+
if cert.respond_to?(:arn)
|
374
|
+
cert.arn
|
375
|
+
else
|
376
|
+
cert
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
# Retreive the server certificate from a listener spec, prefering
|
381
|
+
# the server_certificate key.
|
382
|
+
def server_cert_from_spec(spec)
|
383
|
+
if spec[:server_certificate]
|
384
|
+
spec[:server_certificate]
|
385
|
+
elsif spec[:ssl_certificate_id]
|
386
|
+
spec[:ssl_certificate_id]
|
387
|
+
else
|
388
|
+
nil
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
363
392
|
def ready_load_balancer(action_handler, lb_spec, lb_options, machine_spec)
|
364
393
|
end
|
365
394
|
|
@@ -626,7 +655,7 @@ EOD
|
|
626
655
|
|
627
656
|
if machine_options[:is_windows]
|
628
657
|
Chef::Log.debug "Setting WinRM userdata..."
|
629
|
-
bootstrap_options[:user_data] = user_data
|
658
|
+
bootstrap_options[:user_data] = user_data if bootstrap_options[:user_data].nil?
|
630
659
|
else
|
631
660
|
Chef::Log.debug "Non-windows, not setting userdata"
|
632
661
|
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'chef/provisioning/aws_driver/aws_resource'
|
2
2
|
require 'chef/resource/aws_security_group'
|
3
3
|
|
4
|
+
# AWS Elasticache Cluster
|
5
|
+
#
|
6
|
+
# @see http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_cache_cluster-instance_method
|
4
7
|
class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResource
|
5
8
|
# Note: There isn't actually an SDK class for Elasticache.
|
6
9
|
aws_sdk_type AWS::ElastiCache
|
@@ -9,17 +12,59 @@ class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResour
|
|
9
12
|
# for information on possible values for each attribute. Values are passed
|
10
13
|
# straight through to AWS, with the exception of security_groups, which
|
11
14
|
# may contain a reference to a Chef aws_security_group resource.
|
15
|
+
|
16
|
+
|
17
|
+
# Cluster Name
|
18
|
+
#
|
19
|
+
# @param :cluster_name [String] unique name for a cluster
|
12
20
|
attribute :cluster_name, kind_of: String, name_attribute: true
|
21
|
+
|
22
|
+
# Availability Zone
|
23
|
+
#
|
24
|
+
# @param :az_mode [String] Specifies whether the nodes in this Memcached node group are created in a single Availability Zone or created across multiple Availability Zones in the cluster's region. This parameter is only supported for Memcached cache clusters. If the AZMode and PreferredAvailabilityZones are not specified, ElastiCache assumes single-az mode.
|
13
25
|
attribute :az_mode, kind_of: String
|
26
|
+
|
27
|
+
# Preferred Availability Zone
|
28
|
+
#
|
29
|
+
# @param :preferred_availability_zone [String] preferred availability zone of the cache cluster
|
14
30
|
attribute :preferred_availability_zone, kind_of: String
|
31
|
+
|
32
|
+
# Preferred Availability Zones
|
33
|
+
#
|
34
|
+
# @param :preferred_availability_zones [String, Array] One or more preferred availability zones
|
15
35
|
attribute :preferred_availability_zones,
|
16
36
|
kind_of: [ String, Array ],
|
17
37
|
coerce: proc { |v| [v].flatten }
|
38
|
+
|
39
|
+
|
40
|
+
# Number of Nodes
|
41
|
+
#
|
42
|
+
# @param :number_nodes [Integer] Number of nodes in the cache
|
18
43
|
attribute :number_nodes, kind_of: Integer, default: 1
|
44
|
+
|
45
|
+
# Node type
|
46
|
+
#
|
47
|
+
# @param :node_type [String] AWS node type for each cache cluster node
|
19
48
|
attribute :node_type, kind_of: String, required: true
|
49
|
+
|
50
|
+
# Engine
|
51
|
+
#
|
52
|
+
# @param :engine [String] Valid values are `memcached` or `redis`
|
20
53
|
attribute :engine, kind_of: String, required: true
|
54
|
+
|
55
|
+
# Engine Version
|
56
|
+
#
|
57
|
+
# @param :engine_version [String] The version number of the cache engine to be used for this cache cluster.
|
21
58
|
attribute :engine_version, kind_of: String, required: true
|
59
|
+
|
60
|
+
# Subnet Group Name
|
61
|
+
#
|
62
|
+
# @param :subnet_group_name [String] Cache cluster aws_cache_subnet_group
|
22
63
|
attribute :subnet_group_name, kind_of: String
|
64
|
+
|
65
|
+
# Security Groups
|
66
|
+
#
|
67
|
+
# @param :security_groups [String, Array, AwsSecurityGroup, AWS::EC2::SecurityGroup] one or more VPC security groups associated with the cache cluster.
|
23
68
|
attribute :security_groups,
|
24
69
|
kind_of: [ String, Array, AwsSecurityGroup, AWS::EC2::SecurityGroup ],
|
25
70
|
required: true,
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'chef/provisioning/aws_driver/aws_resource'
|
2
2
|
require 'chef/resource/aws_security_group'
|
3
3
|
|
4
|
+
# AWS Elasticache Replication Group
|
5
|
+
# @see See http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_replication_group-instance_method
|
4
6
|
class Chef::Resource::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::AWSResource
|
5
7
|
# Note: There isn't actually an SDK class for Elasticache.
|
6
8
|
aws_sdk_type AWS::ElastiCache
|
@@ -9,18 +11,58 @@ class Chef::Resource::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::
|
|
9
11
|
# for information on possible values for each attribute. Values are passed
|
10
12
|
# straight through to AWS, with the exception of security_groups, which
|
11
13
|
# may contain a reference to a Chef aws_security_group resource.
|
14
|
+
|
15
|
+
# Group Name
|
16
|
+
#
|
17
|
+
# @param :group_name [String] Elasticache replication group name.
|
12
18
|
attribute :group_name, kind_of: String, name_attribute: true
|
19
|
+
|
20
|
+
# Replication group description
|
21
|
+
#
|
22
|
+
# @param :description [String] Elasticache replication group description.
|
13
23
|
attribute :description, kind_of: String, required: true
|
24
|
+
|
25
|
+
# Automatic failover
|
26
|
+
#
|
27
|
+
# @param :automatic_failover [Boolean] Whether a read replica will be automatically promoted to read/write primary if the existing primary encounters a failure.
|
14
28
|
attribute :automatic_failover, kind_of: [TrueClass, FalseClass], default: false
|
29
|
+
|
30
|
+
# Number of cache clusters
|
31
|
+
#
|
32
|
+
# @param :number_cache_clusters [Integer] Number of cache clusters.
|
15
33
|
attribute :number_cache_clusters, kind_of: Integer, default: 2
|
34
|
+
|
35
|
+
# Node type
|
36
|
+
#
|
37
|
+
# @param :node_type [String] AWS node type for each replication group.
|
16
38
|
attribute :node_type, kind_of: String, required: true
|
39
|
+
|
40
|
+
# Engine
|
41
|
+
#
|
42
|
+
# @param :engine [String] Valid values are `memcached` or `redis`.
|
17
43
|
attribute :engine, kind_of: String, required: true
|
44
|
+
|
45
|
+
# Engine Version
|
46
|
+
#
|
47
|
+
# @param :engine_version [String] The version number of the cache engine.
|
18
48
|
attribute :engine_version, kind_of: String, required: true
|
49
|
+
|
50
|
+
# Subnet group name
|
51
|
+
#
|
52
|
+
# @param :subnet_group_name [String] Cache cluster aws_cache_subnet_group.
|
19
53
|
attribute :subnet_group_name, kind_of: String
|
54
|
+
|
55
|
+
# Security Groups
|
56
|
+
#
|
57
|
+
# @param
|
20
58
|
attribute :security_groups,
|
21
59
|
kind_of: [ String, Array, AwsSecurityGroup, AWS::EC2::SecurityGroup ],
|
22
60
|
required: true,
|
23
61
|
coerce: proc { |v| [v].flatten }
|
62
|
+
|
63
|
+
# Group Name
|
64
|
+
#
|
65
|
+
# @param
|
24
66
|
attribute :preferred_availability_zones,
|
25
67
|
kind_of: [ String, Array ],
|
26
68
|
coerce: proc { |v| [v].flatten }
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'chef/provisioning/aws_driver/aws_resource'
|
2
2
|
require 'chef/resource/aws_subnet'
|
3
3
|
|
4
|
+
# AWS Elasticache Subnet Group
|
5
|
+
# @see http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_cache_subnet_group-instance_method
|
4
6
|
class Chef::Resource::AwsCacheSubnetGroup < Chef::Provisioning::AWSDriver::AWSResource
|
5
7
|
# Note: There isn't actually an SDK class for Elasticache.
|
6
8
|
aws_sdk_type AWS::ElastiCache, id: :group_name
|
@@ -9,8 +11,20 @@ class Chef::Resource::AwsCacheSubnetGroup < Chef::Provisioning::AWSDriver::AWSRe
|
|
9
11
|
# for information on possible values for each attribute. Values are passed
|
10
12
|
# straight through to AWS, with the exception of subnets, which
|
11
13
|
# may contain a reference to a Chef aws_subnet resource.
|
14
|
+
|
15
|
+
# Group Name
|
16
|
+
#
|
17
|
+
# @param :group_name [String] The name of the cache subnet group to be used for the replication group.
|
12
18
|
attribute :group_name, kind_of: String, name_attribute: true
|
19
|
+
|
20
|
+
# Description
|
21
|
+
#
|
22
|
+
# @param :description [String] Subnet group description.
|
13
23
|
attribute :description, kind_of: String, required: true
|
24
|
+
|
25
|
+
# Subnets
|
26
|
+
#
|
27
|
+
# @param :subnets [ String, Array, AwsSubnet, AWS::EC2::Subnet ] One or more subnets in the subnet group.
|
14
28
|
attribute :subnets,
|
15
29
|
kind_of: [ String, Array, AwsSubnet, AWS::EC2::Subnet ],
|
16
30
|
required: true,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-provisioning-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Ewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|