tsudura 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/lib/tsudura/aws/launch_config.rb +18 -8
- data/lib/tsudura/provisioner/ansible/command.rb +11 -0
- data/lib/tsudura/provisioner/ansible/command_generator.rb +44 -0
- data/lib/tsudura/runners/runner_module.rb +1 -1
- data/lib/tsudura/version.rb +1 -1
- data/lib/tsudura.rb +3 -1
- metadata +5 -4
- data/lib/tsudura/provisioner/ansible.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56a4955ff27b07868427adff391a2c354728b695
|
4
|
+
data.tar.gz: 8a3fa23722dcb6c0d4c80b790db0c932b3370cc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 205d6370da4f3f30048c273cba79e9bd650b7fd73218e33704fa800af2ba6617bdbf4bcbaedaa1837b11ccd5494c3ab2e95bad56a43a8cfe433119b2b15050f7
|
7
|
+
data.tar.gz: ba6d4ab8c6e10642409ccc4b85aee214846a514e87cf4fbfaed381377f5903d1adabd1b458dc83c8d2ad070af985bc3d68d0b0dc90d2fe6e8dfc2584ea2abfd9
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -7,16 +7,15 @@ module Tsudura::Aws
|
|
7
7
|
@config = config
|
8
8
|
@timestamp = timestamp
|
9
9
|
end
|
10
|
+
|
11
|
+
def options
|
12
|
+
option = base_option
|
13
|
+
option[:iam_instance_profile] = @config[:iam_instance_profile] if @config[:iam_instance_profile]
|
14
|
+
option
|
15
|
+
end
|
10
16
|
|
11
17
|
def create
|
12
|
-
@new_launch_config = autoscaling.create_launch_configuration(
|
13
|
-
image_id: @image_id,
|
14
|
-
key_name: @config[:key_name],
|
15
|
-
user_data: Base64.encode64(@config[:user_data_script]),
|
16
|
-
instance_type: @config[:instance_type],
|
17
|
-
security_groups: [@config[:security_group_id]],
|
18
|
-
launch_configuration_name: "#{@config[:service]}-#{short_env}-#{@timestamp}",
|
19
|
-
)
|
18
|
+
@new_launch_config = autoscaling.create_launch_configuration(options)
|
20
19
|
end
|
21
20
|
|
22
21
|
def delete
|
@@ -50,5 +49,16 @@ module Tsudura::Aws
|
|
50
49
|
autoscaling.describe_launch_configurations.each_page { |i| tmp.concat i.launch_configurations }
|
51
50
|
tmp.select { |i| i[:launch_configuration_name] =~ /#{@config[:service]}-#{short_env}/ }.map(&:launch_configuration_name)
|
52
51
|
end
|
52
|
+
|
53
|
+
def base_option
|
54
|
+
{
|
55
|
+
image_id: @image_id,
|
56
|
+
key_name: @config[:key_name],
|
57
|
+
user_data: Base64.encode64(@config[:user_data_script]),
|
58
|
+
instance_type: @config[:instance_type],
|
59
|
+
security_groups: [@config[:security_group_id]],
|
60
|
+
launch_configuration_name: "#{@config[:service]}-#{short_env}-#{@timestamp}",
|
61
|
+
}
|
62
|
+
end
|
53
63
|
end
|
54
64
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Tsudura::Provisioner
|
2
|
+
module Ansible
|
3
|
+
class CommandGenerator
|
4
|
+
def initialize(config)
|
5
|
+
@config = config
|
6
|
+
end
|
7
|
+
|
8
|
+
def generate
|
9
|
+
exec_command = []
|
10
|
+
exec_command << base_command
|
11
|
+
exec_command << vault_option if use_vault_option?
|
12
|
+
exec_command.join(" ")
|
13
|
+
end
|
14
|
+
|
15
|
+
def use_vault_option?
|
16
|
+
@config[:vault_password] ? true : false
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def base_command
|
22
|
+
"ansible-playbook #{@config[:playbook_path]} -i #{@config[:inventory_file]}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def vault_option
|
26
|
+
create_vault_password_file
|
27
|
+
vault_password_file_option
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_vault_password_file
|
31
|
+
tmp_password_file << @config[:vault_password]
|
32
|
+
tmp_password_file.close
|
33
|
+
end
|
34
|
+
|
35
|
+
def vault_password_file_option
|
36
|
+
"--vault-password-file #{tmp_password_file.path}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def tmp_password_file
|
40
|
+
@tmp_password_file ||= Tempfile.new("tsudura.#{@config[:service]}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/tsudura/version.rb
CHANGED
data/lib/tsudura.rb
CHANGED
@@ -25,4 +25,6 @@ require "tsudura/aws/ami"
|
|
25
25
|
require "tsudura/aws/auto_scale"
|
26
26
|
require "tsudura/aws/launch_config"
|
27
27
|
require "tsudura/aws/launch_instance"
|
28
|
-
|
28
|
+
|
29
|
+
require "tsudura/provisioner/ansible/command"
|
30
|
+
require "tsudura/provisioner/ansible/command_generator"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tsudura
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- onigra
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -194,7 +194,8 @@ files:
|
|
194
194
|
- lib/tsudura/config_parser.rb
|
195
195
|
- lib/tsudura/env_prefix.rb
|
196
196
|
- lib/tsudura/progress_bar.rb
|
197
|
-
- lib/tsudura/provisioner/ansible.rb
|
197
|
+
- lib/tsudura/provisioner/ansible/command.rb
|
198
|
+
- lib/tsudura/provisioner/ansible/command_generator.rb
|
198
199
|
- lib/tsudura/runner.rb
|
199
200
|
- lib/tsudura/runners/normal_runner.rb
|
200
201
|
- lib/tsudura/runners/packer_plus_runner.rb
|
@@ -225,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
226
|
version: '0'
|
226
227
|
requirements: []
|
227
228
|
rubyforge_project:
|
228
|
-
rubygems_version: 2.4.5
|
229
|
+
rubygems_version: 2.4.5.1
|
229
230
|
signing_key:
|
230
231
|
specification_version: 4
|
231
232
|
summary: Update ami and launch_config and auto scaling group like packer.
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module Tsudura::Provisioner
|
2
|
-
class Ansible
|
3
|
-
def initialize(config)
|
4
|
-
@config = config
|
5
|
-
end
|
6
|
-
|
7
|
-
def provision!
|
8
|
-
command = base_command
|
9
|
-
|
10
|
-
if use_vault_option?
|
11
|
-
command << add_vault_option
|
12
|
-
end
|
13
|
-
|
14
|
-
Open3.popen3 command do |i, o, e, w|
|
15
|
-
o.each do |line| puts line end
|
16
|
-
end
|
17
|
-
ensure
|
18
|
-
remove_vault_password_file if use_vault_option?
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def base_command
|
24
|
-
"ansible-playbook #{@config[:playbook_path]} -i #{@config[:inventory_file]}"
|
25
|
-
end
|
26
|
-
|
27
|
-
def use_vault_option?
|
28
|
-
@config[:vault_password] ? true : false
|
29
|
-
end
|
30
|
-
|
31
|
-
def add_vault_option
|
32
|
-
create_vault_password_file
|
33
|
-
vault_option
|
34
|
-
end
|
35
|
-
|
36
|
-
def vault_option
|
37
|
-
" --vault-password-file tmp_password_file"
|
38
|
-
end
|
39
|
-
|
40
|
-
def create_vault_password_file
|
41
|
-
File.open("tmp_password_file", "w") { |f| f.puts @config[:vault_password] }
|
42
|
-
end
|
43
|
-
|
44
|
-
def remove_vault_password_file
|
45
|
-
FileUtils.rm "tmp_password_file"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|