itamae-mitsurin 0.9 → 0.10
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 +4 -4
- data/README.md +9 -2
- data/Rakefile +5 -5
- data/lib/itamae-mitsurin/logger.rb +16 -1
- data/lib/itamae-mitsurin/mitsurin.rb +0 -4
- data/lib/itamae-mitsurin/mitsurin/creators/templates/project/Rakefile +1 -0
- data/lib/itamae-mitsurin/mitsurin/itamae_task.rb +101 -164
- data/lib/itamae-mitsurin/mitsurin/itamae_with_git_task.rb +114 -176
- data/lib/itamae-mitsurin/mitsurin/serverspec_task.rb +61 -96
- data/lib/itamae-mitsurin/mitsurin/task_base.rb +72 -0
- data/lib/itamae-mitsurin/resource.rb +1 -0
- data/lib/itamae-mitsurin/resource/aws_ebs_volume.rb +65 -72
- data/lib/itamae-mitsurin/resource/aws_ec2_instance.rb +5 -5
- data/lib/itamae-mitsurin/resource/aws_route53_rrset.rb +13 -17
- data/lib/itamae-mitsurin/resource/aws_route53_rrset_alias.rb +13 -17
- data/lib/itamae-mitsurin/resource/file.rb +17 -12
- data/lib/itamae-mitsurin/version.txt +1 -1
- metadata +3 -2
@@ -5,11 +5,11 @@ module ItamaeMitsurin
|
|
5
5
|
module Resource
|
6
6
|
class AwsRoute53Rrset < Base
|
7
7
|
|
8
|
-
define_attribute :region, type: String
|
8
|
+
define_attribute :region, type: String, required: true
|
9
9
|
define_attribute :action, default: :create
|
10
10
|
define_attribute :name, type: String, default_name: true
|
11
11
|
define_attribute :hosted_zone_id, type: String, required: true
|
12
|
-
define_attribute :type, type: String, required: true
|
12
|
+
define_attribute :type, type: String, required: true
|
13
13
|
define_attribute :weight, type: Integer
|
14
14
|
define_attribute :failover, type: String
|
15
15
|
define_attribute :ttl, type: Integer
|
@@ -18,10 +18,9 @@ module ItamaeMitsurin
|
|
18
18
|
define_attribute :traffic_policy_instance_id, type: String
|
19
19
|
|
20
20
|
def pre_action
|
21
|
-
Aws.
|
22
|
-
route53 = ::Aws::Route53::Client.new
|
21
|
+
@route53 = ::Aws::Route53::Client.new(region: attributes.region)
|
23
22
|
|
24
|
-
@record = route53.list_resource_record_sets({
|
23
|
+
@record = @route53.list_resource_record_sets({
|
25
24
|
hosted_zone_id: attributes.hosted_zone_id,
|
26
25
|
start_record_name: attributes.name,
|
27
26
|
start_record_type: attributes.type,
|
@@ -66,29 +65,26 @@ module ItamaeMitsurin
|
|
66
65
|
end
|
67
66
|
|
68
67
|
def action_create(options)
|
69
|
-
Aws.config[:region] = attributes.region
|
70
|
-
route53 = ::Aws::Route53::Client.new
|
71
|
-
|
72
68
|
unless @record[0][0][0] == attributes.name
|
73
|
-
resp = route53.change_resource_record_sets(@rrset_hash)
|
69
|
+
resp = @route53.change_resource_record_sets(@rrset_hash)
|
70
|
+
ItamaeMitsurin.logger.debug "#{resp}"
|
71
|
+
ItamaeMitsurin.logger.info "created record #{attributes.name}"
|
74
72
|
updated!
|
75
73
|
end
|
76
74
|
end
|
77
75
|
|
78
76
|
def action_upsert(options)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
resp = route53.change_resource_record_sets(@rrset_hash)
|
77
|
+
resp = @route53.change_resource_record_sets(@rrset_hash)
|
78
|
+
ItamaeMitsurin.logger.debug "#{resp}"
|
79
|
+
ItamaeMitsurin.logger.info "upserted record #{attributes.name}"
|
83
80
|
updated!
|
84
81
|
end
|
85
82
|
|
86
83
|
def action_delete(options)
|
87
|
-
Aws.config[:region] = attributes.region
|
88
|
-
route53 = ::Aws::Route53::Client.new
|
89
|
-
|
90
84
|
if @record[0][0][0] == attributes.name
|
91
|
-
resp = route53.change_resource_record_sets(@rrset_hash)
|
85
|
+
resp = @route53.change_resource_record_sets(@rrset_hash)
|
86
|
+
ItamaeMitsurin.logger.debug "#{resp}"
|
87
|
+
ItamaeMitsurin.logger.info "deleted record #{attributes.name}"
|
92
88
|
updated!
|
93
89
|
end
|
94
90
|
end
|
@@ -5,10 +5,10 @@ module ItamaeMitsurin
|
|
5
5
|
module Resource
|
6
6
|
class AwsRoute53RrsetAlias < Base
|
7
7
|
|
8
|
-
define_attribute :region, type: String
|
8
|
+
define_attribute :region, type: String, required: true
|
9
9
|
define_attribute :action, default: :create
|
10
10
|
define_attribute :name, type: String, default_name: true
|
11
|
-
define_attribute :type, type: String, required: true
|
11
|
+
define_attribute :type, type: String, required: true
|
12
12
|
define_attribute :hosted_zone_id, type: String, required: true
|
13
13
|
define_attribute :weight, type: Integer
|
14
14
|
define_attribute :failover, type: String
|
@@ -20,10 +20,9 @@ module ItamaeMitsurin
|
|
20
20
|
define_attribute :traffic_policy_instance_id, type: String
|
21
21
|
|
22
22
|
def pre_action
|
23
|
-
Aws.
|
24
|
-
route53 = ::Aws::Route53::Client.new
|
23
|
+
@route53 = ::Aws::Route53::Client.new(region: attributes.region)
|
25
24
|
|
26
|
-
@record = route53.list_resource_record_sets({
|
25
|
+
@record = @route53.list_resource_record_sets({
|
27
26
|
hosted_zone_id: attributes.hosted_zone_id,
|
28
27
|
start_record_name: attributes.name,
|
29
28
|
start_record_type: attributes.type,
|
@@ -67,29 +66,26 @@ module ItamaeMitsurin
|
|
67
66
|
end
|
68
67
|
|
69
68
|
def action_create(options)
|
70
|
-
Aws.config[:region] = attributes.region
|
71
|
-
route53 = ::Aws::Route53::Client.new
|
72
|
-
|
73
69
|
unless @record[0][0][0] == attributes.name
|
74
|
-
resp = route53.change_resource_record_sets(@rrset_hash)
|
70
|
+
resp = @route53.change_resource_record_sets(@rrset_hash)
|
71
|
+
ItamaeMitsurin.logger.debug "#{resp}"
|
72
|
+
ItamaeMitsurin.logger.info "created record #{attributes.name}"
|
75
73
|
updated!
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
79
77
|
def action_upsert(options)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
resp = route53.change_resource_record_sets(@rrset_hash)
|
78
|
+
resp = @route53.change_resource_record_sets(@rrset_hash)
|
79
|
+
ItamaeMitsurin.logger.debug "#{resp}"
|
80
|
+
ItamaeMitsurin.logger.info "upserted record #{attributes.name}"
|
84
81
|
updated!
|
85
82
|
end
|
86
83
|
|
87
84
|
def action_delete(options)
|
88
|
-
Aws.config[:region] = attributes.region
|
89
|
-
route53 = ::Aws::Route53::Client.new
|
90
|
-
|
91
85
|
if @record[0][0][0] == attributes.name
|
92
|
-
resp = route53.change_resource_record_sets(@rrset_hash)
|
86
|
+
resp = @route53.change_resource_record_sets(@rrset_hash)
|
87
|
+
ItamaeMitsurin.logger.debug "#{resp}"
|
88
|
+
ItamaeMitsurin.logger.info "deleted record #{attributes.name}"
|
93
89
|
updated!
|
94
90
|
end
|
95
91
|
end
|
@@ -60,15 +60,6 @@ module ItamaeMitsurin
|
|
60
60
|
run_command(["touch", attributes.path])
|
61
61
|
end
|
62
62
|
|
63
|
-
change_target = @temppath || attributes.path
|
64
|
-
|
65
|
-
if attributes.mode
|
66
|
-
run_specinfra(:change_file_mode, change_target, attributes.mode)
|
67
|
-
end
|
68
|
-
if attributes.owner || attributes.group
|
69
|
-
run_specinfra(:change_file_owner, change_target, attributes.owner, attributes.group)
|
70
|
-
end
|
71
|
-
|
72
63
|
if @temppath
|
73
64
|
if run_specinfra(:check_file_is_file, attributes.path)
|
74
65
|
unless check_command(["diff", "-q", @temppath, attributes.path])
|
@@ -79,10 +70,20 @@ module ItamaeMitsurin
|
|
79
70
|
# new file
|
80
71
|
updated!
|
81
72
|
end
|
73
|
+
end
|
82
74
|
|
83
|
-
|
84
|
-
|
85
|
-
|
75
|
+
change_target = @temppath && updated? ? @temppath : attributes.path
|
76
|
+
|
77
|
+
if attributes.mode
|
78
|
+
run_specinfra(:change_file_mode, change_target, attributes.mode)
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.owner || attributes.group
|
82
|
+
run_specinfra(:change_file_owner, change_target, attributes.owner, attributes.group)
|
83
|
+
end
|
84
|
+
|
85
|
+
if @temppath && updated?
|
86
|
+
run_specinfra(:move_file, @temppath, attributes.path)
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
@@ -170,7 +171,11 @@ module ItamaeMitsurin
|
|
170
171
|
end
|
171
172
|
|
172
173
|
@temppath = ::File.join(runner.tmpdir, Time.now.to_f.to_s)
|
174
|
+
|
175
|
+
run_command(["touch", @temppath])
|
176
|
+
run_specinfra(:change_file_mode, @temppath, '0600')
|
173
177
|
backend.send_file(src, @temppath)
|
178
|
+
run_specinfra(:change_file_mode, @temppath, '0600')
|
174
179
|
ensure
|
175
180
|
f.unlink if f
|
176
181
|
end
|
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.10
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae-mitsurin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.10'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akihiro Kamiyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -274,6 +274,7 @@ files:
|
|
274
274
|
- lib/itamae-mitsurin/mitsurin/itamae_task.rb
|
275
275
|
- lib/itamae-mitsurin/mitsurin/itamae_with_git_task.rb
|
276
276
|
- lib/itamae-mitsurin/mitsurin/serverspec_task.rb
|
277
|
+
- lib/itamae-mitsurin/mitsurin/task_base.rb
|
277
278
|
- lib/itamae-mitsurin/node.rb
|
278
279
|
- lib/itamae-mitsurin/notification.rb
|
279
280
|
- lib/itamae-mitsurin/recipe.rb
|