awstool 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa7519114222d1de674841c22bee82fc62444d4e
4
- data.tar.gz: 57ac99fc9beb9fbb41e576771d3ce9eba096addd
3
+ metadata.gz: 7abfa0e64a3d9a28a994d7e6acc548e57ec86b80
4
+ data.tar.gz: fd0f4220f55996073e533398435713a52410610f
5
5
  SHA512:
6
- metadata.gz: 47e913f259f1c39c6ab791e1fa795e49f0c7cbb03c42e03dec5a58b2097d52616b3b3d2681b7448481681805550a1f15a9482561907c20486b79107ce5b41bc7
7
- data.tar.gz: db8eaa00d531d0b330a32f894f00ec2aca07e74b274c1197e08d233eb274248ee3cae14d47a4e254a3dc5251376907e04af6842080112e3d701372c08e7e0c13
6
+ metadata.gz: 7d25c0da9e49ab33136a5c23b331d8003c949289b37140c8d493c327bdbefed73bfd9c8017f402fa491a84c7aaebbe600a62614d1de5dd3bf9557d302720ba17
7
+ data.tar.gz: f00ed640eac0e9c2afde436636b7972bac82454e26aa48770610b0a520b831f3dbe3dc7cc98373f9cbd5377bed439f206948e854bc77bf17cb45cd55ad3e0022
@@ -4,7 +4,6 @@ require 'awstool'
4
4
  require 'pp'
5
5
 
6
6
  options = Awstool::Settings.get_options
7
- pp options
8
7
 
9
8
  options['hostnames'].each do |hostname|
10
9
  if options['subnet_balance']
@@ -2,5 +2,5 @@ require "awstool/version"
2
2
  require 'awstool/settings'
3
3
  require 'awstool/instance'
4
4
 
5
- class Awstools
5
+ module Awstools
6
6
  end
@@ -10,6 +10,12 @@ class Awstool::Instance
10
10
  aws_access_key_id: @options['access_key_id'],
11
11
  aws_secret_access_key: @options['access_key'],
12
12
  )
13
+ @dns = Fog::DNS.new(
14
+ provider: 'AWS',
15
+ aws_access_key_id: @options['access_key_id'],
16
+ aws_secret_access_key: @options['access_key'],
17
+ )
18
+
13
19
  end
14
20
 
15
21
  def launch
@@ -20,20 +26,22 @@ class Awstool::Instance
20
26
  subnet_id: @options['subnet-ids'][@options['subnet-id-index']],
21
27
  key_name: @options['key-name'],
22
28
  tags: @options['tags'],
23
- user_data: ERB.new(File.read(@options['userdata'])).result
29
+ user_data: ERB.new(File.read(@options['userdata'])).result,
30
+ block_device_mapping: [
31
+ {
32
+ 'DeviceName' => '/dev/sda1',
33
+ 'Ebs.VolumeType' => "gp2",
34
+ 'Ebs.VolumeSize' => @options['rootvol_size'],
35
+ 'Ebs.DeleteOnTermination' => 'true'
36
+ },
37
+ ],
24
38
  )
25
39
  @instance.wait_for { ready? }
26
40
  pp @instance.reload
27
41
  end
28
42
 
29
43
  def set_dns
30
- dns = Fog::DNS.new(
31
- provider: 'AWS',
32
- aws_access_key_id: @options['access_key_id'],
33
- aws_secret_access_key: @options['access_key'],
34
- )
35
-
36
- zone = dns.zones.get(@options['dns-zone-id'])
44
+ zone = @dns.zones.get(@options['dns-zone-id'])
37
45
 
38
46
  if @options['purge_dns']
39
47
  record = zone.records.find { |r| r.name == "#{@options['hostname']}." }
@@ -42,7 +50,7 @@ class Awstool::Instance
42
50
  end
43
51
  end
44
52
 
45
- @record = zone.records.create(
53
+ record = zone.records.create(
46
54
  value: @instance.private_ip_address,
47
55
  name: @options['hostname'],
48
56
  type: 'A'
@@ -31,14 +31,14 @@ class Awstool::Settings
31
31
  opts.on('-f', '--facts FACT1,FACT2', Array, 'Seed new instance with puppet facts') do |facts|
32
32
  facts.each do |fact|
33
33
  split_fact = fact.split('=')
34
- @options['facts'][split_fact[0]] = split_fact[1]
34
+ @options['facts'][split_fact.first] = split_fact[1]
35
35
  end
36
36
  end
37
37
 
38
38
  opts.on('-t', '--tags TAG1,TAG2', Array, 'Set EC2 instance tags') do |tags|
39
39
  tags.each do |tag|
40
40
  split_tag = tag.split('=')
41
- @options['tags'][split_tag[0]] = split_tag[1]
41
+ @options['tags'][split_tag.first] = split_tag[1]
42
42
  end
43
43
  end
44
44
 
@@ -79,9 +79,10 @@ class Awstool::Settings
79
79
  end
80
80
 
81
81
  def self.set_default
82
- @options['userdata'] = File.expand_path('../userdata/default.erb')
82
+ @options['userdata'] = File.expand_path(File.dirname(__FILE__)) + '/../../userdata/default.erb'
83
83
  @options['facts'] = {}
84
84
  @options['tags']= {}
85
85
  @options['hostnames'] = []
86
+ @options['rootvol_size'] = 8
86
87
  end
87
88
  end
@@ -1,3 +1,3 @@
1
- class Awstool
2
- VERSION = '0.1.0'
1
+ module Awstool
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awstool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Burgess
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-29 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler