itamae-mitsurin 0.7 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/lib/itamae-mitsurin/resource.rb +2 -0
- data/lib/itamae-mitsurin/resource/aws_ebs_volume.rb +64 -62
- data/lib/itamae-mitsurin/resource/aws_route53_rrset.rb +96 -0
- data/lib/itamae-mitsurin/resource/aws_route53_rrset_alias.rb +97 -0
- data/lib/itamae-mitsurin/version.txt +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e97c933691d17f91c2c1c4264349bb262cfbb18b
|
4
|
+
data.tar.gz: 029195b19075695902c96f3542d87fa381fb6db1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d987dd2f60c4d83910b537c1a4494814ed8178ccdc90b9c60cae176988aef7ad28cb0ed30cc4df06c130975b5bea502e2edcb827570eee91171a85c5ebde439
|
7
|
+
data.tar.gz: d6aa204d123181354c6cf027c10dee0e94c29d1e6d90537326891e07345f9484ecfe3e2d0e022e38e713f5c9cd9cea757f5f08db2187ee46a70a77132254cc95
|
data/README.md
CHANGED
@@ -23,10 +23,9 @@ $ manaita init
|
|
23
23
|
```ruby
|
24
24
|
# recipe
|
25
25
|
|
26
|
-
Aws.config[:region] = 'ap-northeast-1'
|
27
|
-
|
28
26
|
aws_ebs_volume "ebs_name" do
|
29
27
|
action [:create, :attach]
|
28
|
+
region "ap-northeast-1"
|
30
29
|
availability_zone "ap-northeast-1a"
|
31
30
|
device '/dev/xvdb'
|
32
31
|
volume_type 'standard'
|
@@ -17,6 +17,8 @@ require 'itamae-mitsurin/resource/user'
|
|
17
17
|
require 'itamae-mitsurin/resource/group'
|
18
18
|
require 'itamae-mitsurin/resource/gem_package'
|
19
19
|
require 'itamae-mitsurin/resource/aws_ebs_volume'
|
20
|
+
require 'itamae-mitsurin/resource/aws_route53_rrset'
|
21
|
+
require 'itamae-mitsurin/resource/aws_route53_rrset_alias'
|
20
22
|
|
21
23
|
module ItamaeMitsurin
|
22
24
|
module Resource
|
@@ -2,83 +2,85 @@ require 'itamae-mitsurin'
|
|
2
2
|
require 'itamae-mitsurin/mitsurin'
|
3
3
|
|
4
4
|
module ItamaeMitsurin
|
5
|
-
|
6
|
-
|
7
|
-
define_attribute :action, default: :create
|
8
|
-
define_attribute :name, type: String, default_name: true
|
9
|
-
define_attribute :availability_zone, type: String
|
10
|
-
define_attribute :device, type: String
|
11
|
-
define_attribute :instance_id, type: String
|
12
|
-
define_attribute :volume_type, type: String
|
13
|
-
define_attribute :size, type: Integer
|
5
|
+
module Resource
|
6
|
+
class AwsEbsVolume < Base
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
},
|
24
|
-
],
|
25
|
-
}
|
26
|
-
).volumes
|
27
|
-
|
28
|
-
if volumes.empty?
|
29
|
-
@volume = ec2.create_volume(
|
30
|
-
size: attributes[:size], # attributes.size returns the size of attributes hash
|
31
|
-
availability_zone: attributes.availability_zone,
|
32
|
-
volume_type: attributes.volume_type,
|
33
|
-
)
|
8
|
+
define_attribute :region, type: String
|
9
|
+
define_attribute :action, default: :create
|
10
|
+
define_attribute :name, type: String, default_name: true
|
11
|
+
define_attribute :availability_zone, type: String
|
12
|
+
define_attribute :device, type: String
|
13
|
+
define_attribute :instance_id, type: String
|
14
|
+
define_attribute :volume_type, type: String
|
15
|
+
define_attribute :size, type: Integer
|
34
16
|
|
35
|
-
|
17
|
+
def action_create(options)
|
18
|
+
Aws.config[:region] = attributes.region
|
19
|
+
ec2 = ::Aws::EC2::Client.new
|
20
|
+
volumes = ec2.describe_volumes(
|
21
|
+
{
|
22
|
+
filters: [
|
36
23
|
{
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
],
|
44
|
-
}
|
45
|
-
)
|
24
|
+
name: 'tag:Name',
|
25
|
+
values: [ attributes.name ],
|
26
|
+
},
|
27
|
+
],
|
28
|
+
}
|
29
|
+
).volumes
|
46
30
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
31
|
+
if volumes.empty?
|
32
|
+
@volume = ec2.create_volume(
|
33
|
+
size: attributes[:size], # attributes.size returns the size of attributes hash
|
34
|
+
availability_zone: attributes.availability_zone,
|
35
|
+
volume_type: attributes.volume_type,
|
36
|
+
)
|
52
37
|
|
53
|
-
|
54
|
-
|
55
|
-
def action_attach(options)
|
56
|
-
ec2 = ::Aws::EC2::Client.new
|
57
|
-
volumes = ec2.describe_volumes(
|
38
|
+
ec2.create_tags(
|
58
39
|
{
|
59
|
-
|
40
|
+
resources: [ @volume.volume_id ],
|
41
|
+
tags: [
|
60
42
|
{
|
61
|
-
|
62
|
-
|
43
|
+
key: 'Name',
|
44
|
+
value: attributes.name,
|
63
45
|
},
|
64
46
|
],
|
65
47
|
}
|
66
|
-
)
|
48
|
+
)
|
49
|
+
|
50
|
+
updated!
|
51
|
+
sleep(3)
|
52
|
+
else
|
53
|
+
@volume = volumes[0]
|
54
|
+
end
|
55
|
+
end
|
67
56
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
57
|
+
def action_attach(options)
|
58
|
+
Aws.config[:region] = attributes.region
|
59
|
+
ec2 = ::Aws::EC2::Client.new
|
60
|
+
volumes = ec2.describe_volumes(
|
61
|
+
{
|
62
|
+
filters: [
|
63
|
+
{
|
64
|
+
name: 'tag:Name',
|
65
|
+
values: [ attributes.name ],
|
66
|
+
},
|
67
|
+
],
|
68
|
+
}
|
69
|
+
).volumes
|
74
70
|
|
75
|
-
|
76
|
-
|
77
|
-
@volume
|
78
|
-
|
71
|
+
unless volumes.empty?
|
72
|
+
@volume = ec2.attach_volume({
|
73
|
+
volume_id: @volume.volume_id,
|
74
|
+
instance_id: attributes.instance_id,
|
75
|
+
device: attributes.device
|
76
|
+
})
|
79
77
|
|
78
|
+
updated!
|
79
|
+
else
|
80
|
+
@volume = volumes[0]
|
80
81
|
end
|
81
82
|
end
|
82
83
|
end
|
84
|
+
end
|
83
85
|
end
|
84
86
|
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'itamae-mitsurin'
|
2
|
+
require 'itamae-mitsurin/mitsurin'
|
3
|
+
|
4
|
+
module ItamaeMitsurin
|
5
|
+
module Resource
|
6
|
+
class AwsRoute53Rrset < Base
|
7
|
+
|
8
|
+
define_attribute :region, type: String
|
9
|
+
define_attribute :action, default: :create
|
10
|
+
define_attribute :name, type: String, default_name: true
|
11
|
+
define_attribute :hosted_zone_id, type: String, required: true
|
12
|
+
define_attribute :type, type: String, required: true
|
13
|
+
define_attribute :weight, type: Integer
|
14
|
+
define_attribute :failover, type: String
|
15
|
+
define_attribute :ttl, type: Integer
|
16
|
+
define_attribute :value, type: String, required: true
|
17
|
+
define_attribute :health_check_id, type: String
|
18
|
+
define_attribute :traffic_policy_instance_id, type: String
|
19
|
+
|
20
|
+
def pre_action
|
21
|
+
Aws.config[:region] = attributes.region
|
22
|
+
route53 = ::Aws::Route53::Client.new
|
23
|
+
|
24
|
+
@record = route53.list_resource_record_sets({
|
25
|
+
hosted_zone_id: attributes.hosted_zone_id,
|
26
|
+
start_record_name: attributes.name,
|
27
|
+
start_record_type: attributes.type,
|
28
|
+
max_items: 1,
|
29
|
+
})
|
30
|
+
|
31
|
+
if attributes.failover == "PRIMARY"
|
32
|
+
set_identifier = "PRIMARY-" + attributes.name.split(".")[0]
|
33
|
+
elsif attributes.failover == "SECONDARY"
|
34
|
+
set_identifier = "SECONDARY-" + attributes.name.split(".")[0]
|
35
|
+
else
|
36
|
+
set_identifier = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
@rrset_hash = {
|
40
|
+
hosted_zone_id: attributes.hosted_zone_id,
|
41
|
+
change_batch: {
|
42
|
+
comment: nil,
|
43
|
+
changes: [
|
44
|
+
{
|
45
|
+
action: attributes.action.to_s.upcase,
|
46
|
+
resource_record_set: {
|
47
|
+
name: attributes.name,
|
48
|
+
type: attributes.type,
|
49
|
+
set_identifier: set_identifier,
|
50
|
+
weight: attributes.weight,
|
51
|
+
failover: attributes.failover,
|
52
|
+
ttl: attributes.ttl,
|
53
|
+
resource_records: [
|
54
|
+
{
|
55
|
+
value: attributes.value,
|
56
|
+
},
|
57
|
+
],
|
58
|
+
health_check_id: attributes.health_check_id,
|
59
|
+
traffic_policy_instance_id: attributes.traffic_policy_instance_id,
|
60
|
+
},
|
61
|
+
},
|
62
|
+
],
|
63
|
+
},
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
def action_create(options)
|
68
|
+
Aws.config[:region] = attributes.region
|
69
|
+
route53 = ::Aws::Route53::Client.new
|
70
|
+
|
71
|
+
unless @record[0][0][0] == attributes.name
|
72
|
+
resp = route53.change_resource_record_sets(@rrset_hash)
|
73
|
+
updated!
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def action_upsert(options)
|
78
|
+
Aws.config[:region] = attributes.region
|
79
|
+
route53 = ::Aws::Route53::Client.new
|
80
|
+
|
81
|
+
resp = route53.change_resource_record_sets(@rrset_hash)
|
82
|
+
updated!
|
83
|
+
end
|
84
|
+
|
85
|
+
def action_delete(options)
|
86
|
+
Aws.config[:region] = attributes.region
|
87
|
+
route53 = ::Aws::Route53::Client.new
|
88
|
+
|
89
|
+
if @record[0][0][0] == attributes.name
|
90
|
+
resp = route53.change_resource_record_sets(@rrset_hash)
|
91
|
+
updated!
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'itamae-mitsurin'
|
2
|
+
require 'itamae-mitsurin/mitsurin'
|
3
|
+
|
4
|
+
module ItamaeMitsurin
|
5
|
+
module Resource
|
6
|
+
class AwsRoute53RrsetAlias < Base
|
7
|
+
|
8
|
+
define_attribute :region, type: String
|
9
|
+
define_attribute :action, default: :create
|
10
|
+
define_attribute :name, type: String, default_name: true
|
11
|
+
define_attribute :type, type: String, required: true
|
12
|
+
define_attribute :hosted_zone_id, type: String, required: true
|
13
|
+
define_attribute :weight, type: Integer
|
14
|
+
define_attribute :failover, type: String
|
15
|
+
define_attribute :alias_target, type: [TrueClass, FalseClass], default: false, required: true
|
16
|
+
define_attribute :alias_hosted_zone_id, type: String, required: true
|
17
|
+
define_attribute :dns_name, type: String, required: true
|
18
|
+
define_attribute :evaluate_target_health, type: [TrueClass, FalseClass], default: false
|
19
|
+
define_attribute :health_check_id, type: String
|
20
|
+
define_attribute :traffic_policy_instance_id, type: String
|
21
|
+
|
22
|
+
def pre_action
|
23
|
+
Aws.config[:region] = attributes.region
|
24
|
+
route53 = ::Aws::Route53::Client.new
|
25
|
+
|
26
|
+
@record = route53.list_resource_record_sets({
|
27
|
+
hosted_zone_id: attributes.hosted_zone_id,
|
28
|
+
start_record_name: attributes.name,
|
29
|
+
start_record_type: attributes.type,
|
30
|
+
max_items: 1,
|
31
|
+
})
|
32
|
+
|
33
|
+
if attributes.failover == "PRIMARY"
|
34
|
+
set_identifier = "PRIMARY-" + attributes.name.split(".")[0]
|
35
|
+
elsif attributes.failover == "SECONDARY"
|
36
|
+
set_identifier = "SECONDARY-" + attributes.name.split(".")[0]
|
37
|
+
else
|
38
|
+
set_identifier = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
@rrset_hash = {
|
42
|
+
hosted_zone_id: attributes.hosted_zone_id,
|
43
|
+
change_batch: {
|
44
|
+
comment: nil,
|
45
|
+
changes: [
|
46
|
+
{
|
47
|
+
action: attributes.action.to_s.upcase,
|
48
|
+
resource_record_set: {
|
49
|
+
name: attributes.name,
|
50
|
+
type: attributes.type,
|
51
|
+
set_identifier: set_identifier,
|
52
|
+
weight: attributes.weight,
|
53
|
+
failover: attributes.failover,
|
54
|
+
alias_target: {
|
55
|
+
hosted_zone_id: attributes.alias_hosted_zone_id,
|
56
|
+
dns_name: attributes.dns_name,
|
57
|
+
evaluate_target_health: attributes.evaluate_target_health,
|
58
|
+
},
|
59
|
+
health_check_id: attributes.health_check_id,
|
60
|
+
traffic_policy_instance_id: attributes.traffic_policy_instance_id,
|
61
|
+
},
|
62
|
+
},
|
63
|
+
],
|
64
|
+
},
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
def action_create(options)
|
69
|
+
Aws.config[:region] = attributes.region
|
70
|
+
route53 = ::Aws::Route53::Client.new
|
71
|
+
|
72
|
+
unless @record[0][0][0] == attributes.name
|
73
|
+
resp = route53.change_resource_record_sets(@rrset_hash)
|
74
|
+
updated!
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def action_upsert(options)
|
79
|
+
Aws.config[:region] = attributes.region
|
80
|
+
route53 = ::Aws::Route53::Client.new
|
81
|
+
|
82
|
+
resp = route53.change_resource_record_sets(@rrset_hash)
|
83
|
+
updated!
|
84
|
+
end
|
85
|
+
|
86
|
+
def action_delete(options)
|
87
|
+
Aws.config[:region] = attributes.region
|
88
|
+
route53 = ::Aws::Route53::Client.new
|
89
|
+
|
90
|
+
if @record[0][0][0] == attributes.name
|
91
|
+
resp = route53.change_resource_record_sets(@rrset_hash)
|
92
|
+
updated!
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae-mitsurin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akihiro Kamiyama
|
@@ -280,6 +280,8 @@ files:
|
|
280
280
|
- lib/itamae-mitsurin/recipe_children.rb
|
281
281
|
- lib/itamae-mitsurin/resource.rb
|
282
282
|
- lib/itamae-mitsurin/resource/aws_ebs_volume.rb
|
283
|
+
- lib/itamae-mitsurin/resource/aws_route53_rrset.rb
|
284
|
+
- lib/itamae-mitsurin/resource/aws_route53_rrset_alias.rb
|
283
285
|
- lib/itamae-mitsurin/resource/base.rb
|
284
286
|
- lib/itamae-mitsurin/resource/directory.rb
|
285
287
|
- lib/itamae-mitsurin/resource/execute.rb
|