hashicorptools 0.1.2 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4692b4e530bde9683f94ab831155926ce8b479aa
4
- data.tar.gz: c90b5a4d1d0fd216aec3a53e83ce57b4d81184f6
2
+ SHA256:
3
+ metadata.gz: 3480aac6dcba04268d682dbd19fddb5d3fa43220e5e9b3cc0c679391749d217e
4
+ data.tar.gz: fe0b0c9a625b495dc830913a3a4b957ec7a1c68dc3aa98b41ac48888abea33e4
5
5
  SHA512:
6
- metadata.gz: 05d7b64814446f085f7f03883de44eb47b975a202d07e9154af125439e506e7783645d4aa55514210a2c0100f9bdc57a2174030888014bb9fb9743b52a5d05ea
7
- data.tar.gz: bbe1ed16b551f5123503afeb086acc5cca65499e1eb0b6a4939c0c4c1c5830ac2bedf4aa09dea714c3e311c811981c602c946c5208096400254deda9687829ef
6
+ metadata.gz: 16bdfd1e3ecf8152f230e5f145b70d8e0356cef6af22651294567a8b1eb33c66edc1e4582816610a8180ce53067873d4894203dd03a2b1699183b04007d9d5c2
7
+ data.tar.gz: e61e5e7c5418954fedf936e187d778c8f413236020cc193bd80934b95efa72135a74f4f13cef32b21553c8198978a5400501cee9de98723f5eb1c55ee4d3c9c6
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.3.4
1
+ ruby-2.5.1
data/Gemfile.lock CHANGED
@@ -1,47 +1,52 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (3.2.22.5)
5
- i18n (~> 0.6, >= 0.6.4)
6
- multi_json (~> 1.0)
7
- addressable (2.4.0)
8
- aws-sdk (2.6.30)
9
- aws-sdk-resources (= 2.6.30)
10
- aws-sdk-core (2.6.30)
4
+ activesupport (5.1.4)
5
+ concurrent-ruby (~> 1.0, >= 1.0.2)
6
+ i18n (~> 0.7)
7
+ minitest (~> 5.1)
8
+ tzinfo (~> 1.1)
9
+ addressable (2.5.2)
10
+ public_suffix (>= 2.0.2, < 4.0)
11
+ aws-sdk (2.11.86)
12
+ aws-sdk-resources (= 2.11.86)
13
+ aws-sdk-core (2.11.86)
11
14
  aws-sigv4 (~> 1.0)
12
15
  jmespath (~> 1.0)
13
- aws-sdk-resources (2.6.30)
14
- aws-sdk-core (= 2.6.30)
15
- aws-sdk-v1 (1.66.0)
16
+ aws-sdk-resources (2.11.86)
17
+ aws-sdk-core (= 2.11.86)
18
+ aws-sdk-v1 (1.67.0)
16
19
  json (~> 1.4)
17
- nokogiri (>= 1.4.4)
18
- aws-sigv4 (1.0.0)
20
+ nokogiri (~> 1)
21
+ aws-sigv4 (1.0.3)
19
22
  builder (3.2.3)
20
- byebug (9.0.6)
23
+ byebug (10.0.2)
24
+ concurrent-ruby (1.0.5)
21
25
  descendants_tracker (0.0.4)
22
26
  thread_safe (~> 0.3, >= 0.3.1)
23
27
  diff-lcs (1.3)
24
28
  docile (1.1.5)
25
- domain_name (0.5.20161129)
29
+ domain_name (0.5.20170404)
26
30
  unf (>= 0.0.5, < 1.0.0)
27
- dotenv (2.1.1)
31
+ dotenv (2.2.1)
28
32
  dynect_rest (0.4.6)
29
33
  rest-client
30
- faraday (0.9.2)
34
+ faraday (0.12.2)
31
35
  multipart-post (>= 1.2, < 3)
32
36
  git (1.3.0)
33
- github_api (0.14.5)
34
- addressable (~> 2.4.0)
37
+ github_api (0.18.2)
38
+ addressable (~> 2.4)
35
39
  descendants_tracker (~> 0.0.4)
36
- faraday (~> 0.8, < 0.10)
37
- hashie (>= 3.4)
40
+ faraday (~> 0.8)
41
+ hashie (~> 3.5, >= 3.5.2)
38
42
  oauth2 (~> 1.0)
39
43
  hashie (3.5.6)
40
- highline (1.7.8)
44
+ highline (1.7.10)
41
45
  http-cookie (1.0.3)
42
46
  domain_name (~> 0.5)
43
- i18n (0.8.1)
44
- jmespath (1.3.1)
47
+ i18n (0.9.1)
48
+ concurrent-ruby (~> 1.0)
49
+ jmespath (1.4.0)
45
50
  json (1.8.6)
46
51
  juwelier (2.4.7)
47
52
  builder
@@ -61,13 +66,14 @@ GEM
61
66
  mime-types (3.1)
62
67
  mime-types-data (~> 3.2015)
63
68
  mime-types-data (3.2016.0521)
64
- mini_portile2 (2.1.0)
65
- multi_json (1.12.1)
69
+ mini_portile2 (2.3.0)
70
+ minitest (5.10.3)
71
+ multi_json (1.12.2)
66
72
  multi_xml (0.6.0)
67
73
  multipart-post (2.0.0)
68
74
  netrc (0.11.0)
69
- nokogiri (1.7.2)
70
- mini_portile2 (~> 2.1.0)
75
+ nokogiri (1.8.4)
76
+ mini_portile2 (~> 2.3.0)
71
77
  oauth2 (1.4.0)
72
78
  faraday (>= 0.8, < 0.13)
73
79
  jwt (~> 1.0)
@@ -75,38 +81,41 @@ GEM
75
81
  multi_xml (~> 0.5)
76
82
  rack (>= 1.2, < 3)
77
83
  psych (2.2.4)
84
+ public_suffix (3.0.1)
78
85
  rack (2.0.3)
79
- rake (12.0.0)
86
+ rake (12.3.0)
80
87
  rdoc (3.12.2)
81
88
  json (~> 1.4)
82
- rest-client (2.0.0)
89
+ rest-client (2.0.2)
83
90
  http-cookie (>= 1.0.2, < 2.0)
84
91
  mime-types (>= 1.16, < 4.0)
85
92
  netrc (~> 0.8)
86
- rspec (3.5.0)
87
- rspec-core (~> 3.5.0)
88
- rspec-expectations (~> 3.5.0)
89
- rspec-mocks (~> 3.5.0)
90
- rspec-core (3.5.4)
91
- rspec-support (~> 3.5.0)
92
- rspec-expectations (3.5.0)
93
+ rspec (3.7.0)
94
+ rspec-core (~> 3.7.0)
95
+ rspec-expectations (~> 3.7.0)
96
+ rspec-mocks (~> 3.7.0)
97
+ rspec-core (3.7.0)
98
+ rspec-support (~> 3.7.0)
99
+ rspec-expectations (3.7.0)
93
100
  diff-lcs (>= 1.2.0, < 2.0)
94
- rspec-support (~> 3.5.0)
95
- rspec-mocks (3.5.0)
101
+ rspec-support (~> 3.7.0)
102
+ rspec-mocks (3.7.0)
96
103
  diff-lcs (>= 1.2.0, < 2.0)
97
- rspec-support (~> 3.5.0)
98
- rspec-support (3.5.0)
104
+ rspec-support (~> 3.7.0)
105
+ rspec-support (3.7.0)
99
106
  semver2 (3.4.2)
100
- simplecov (0.14.1)
107
+ simplecov (0.15.1)
101
108
  docile (~> 1.1.0)
102
109
  json (>= 1.8, < 3)
103
110
  simplecov-html (~> 0.10.0)
104
- simplecov-html (0.10.0)
105
- thor (0.19.4)
111
+ simplecov-html (0.10.2)
112
+ thor (0.20.0)
106
113
  thread_safe (0.3.6)
114
+ tzinfo (1.2.4)
115
+ thread_safe (~> 0.1)
107
116
  unf (0.1.4)
108
117
  unf_ext
109
- unf_ext (0.0.7.2)
118
+ unf_ext (0.0.7.4)
110
119
 
111
120
  PLATFORMS
112
121
  ruby
@@ -127,4 +136,4 @@ DEPENDENCIES
127
136
  thor
128
137
 
129
138
  BUNDLED WITH
130
- 1.14.6
139
+ 1.16.2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.2
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: hashicorptools 0.1.2 ruby lib
5
+ # stub: hashicorptools 0.2.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "hashicorptools".freeze
9
- s.version = "0.1.2"
9
+ s.version = "0.2.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Nathan Woodhull".freeze]
14
- s.date = "2017-08-21"
14
+ s.date = "2018-07-20"
15
15
  s.description = "Wrappers for terraform and packer".freeze
16
16
  s.email = "systems@controlshiftlabs.com".freeze
17
17
  s.executables = ["ec2_host".freeze]
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
46
46
  ]
47
47
  s.homepage = "http://github.com/woodhull/hashicorptools".freeze
48
48
  s.licenses = ["MIT".freeze]
49
- s.rubygems_version = "2.5.2".freeze
49
+ s.rubygems_version = "2.7.6".freeze
50
50
  s.summary = "Wrappers for terraform and packer".freeze
51
51
 
52
52
  if s.respond_to? :specification_version then
@@ -1,47 +1,59 @@
1
1
  {
2
- "variables": {
3
- "aws_access_key": "",
4
- "aws_secret_key": "",
5
- "source_ami": "",
6
- "ami_tag": "",
7
- "cookbook_name": ""
8
- },
9
-
10
2
  "builders": [
11
3
  {
12
- "type": "amazon-ebs",
13
4
  "access_key": "{{user `aws_access_key`}}",
14
- "secret_key": "{{user `aws_secret_key`}}",
5
+ "ami_name": "{{user `ami_tag`}} {{timestamp}}",
6
+ "associate_public_ip_address": true,
7
+ "ena_support": true,
8
+ "instance_type": "c5.large",
9
+ "launch_block_device_mappings": [
10
+ {
11
+ "delete_on_termination": true,
12
+ "device_name": "/dev/sda1",
13
+ "volume_size": 8,
14
+ "volume_type": "gp2"
15
+ }
16
+ ],
15
17
  "region": "us-east-1",
18
+ "run_tags": {
19
+ "kind": "packer",
20
+ "role": "AMI builder"
21
+ },
22
+ "secret_key": "{{user `aws_secret_key`}}",
16
23
  "source_ami": "{{user `source_ami`}}",
17
- "instance_type": "c4.large",
24
+ "ssh_interface": "public_ip",
18
25
  "ssh_username": "ubuntu",
19
- "ami_name": "{{user `ami_tag`}} {{timestamp}}",
26
+ "subnet_id": "{{user `subnet_id`}}",
20
27
  "tags": {
21
28
  "Name": "{{user `ami_tag`}}",
22
29
  "created_at": "{{isotime}}",
23
30
  "parent_ami": "{{user `source_ami`}}"
24
31
  },
25
- "run_tags": {
26
- "kind": "packer",
27
- "role": "AMI builder"
28
- },
29
- "launch_block_device_mappings": [{
30
- "device_name": "/dev/sda1",
31
- "volume_size": 8,
32
- "volume_type": "gp2",
33
- "delete_on_termination": true
34
- }]
32
+ "type": "amazon-ebs",
33
+ "vpc_id": "{{user `vpc_id`}}"
35
34
  }
36
35
  ],
36
+ "post-processors": [],
37
37
  "provisioners": [
38
38
  {
39
- "type": "chef-solo",
40
- "cookbook_paths": ["cookbooks", "site-cookbooks"],
41
- "run_list": ["{{user `cookbook_name`}}"],
39
+ "cookbook_paths": [
40
+ "cookbooks",
41
+ "site-cookbooks"
42
+ ],
43
+ "run_list": [
44
+ "{{user `cookbook_name`}}"
45
+ ],
42
46
  "skip_install": true,
43
- "data_bags_path": "data_bags",
44
- "encrypted_data_bag_secret_path": "/etc/chef/encrypted_data_bag_secret"
47
+ "type": "chef-solo"
45
48
  }
46
- ]
49
+ ],
50
+ "variables": {
51
+ "ami_tag": "",
52
+ "aws_access_key": "",
53
+ "aws_secret_key": "",
54
+ "cookbook_name": "",
55
+ "source_ami": "",
56
+ "subnet_id": "",
57
+ "vpc_id": ""
58
+ }
47
59
  }
@@ -24,12 +24,13 @@ module Hashicorptools
24
24
  end
25
25
 
26
26
  puts "waiting for scaling events to finish"
27
- groups.each do |group|
28
- wait_for_activities_to_complete(group)
27
+ wait_for_activities_to_complete(group)
28
+ puts "all scaling activities finished."
29
+
30
+ if desired_instances > 0
31
+ wait_until_instances_ready
32
+ puts "all #{desired_instances} instances ready."
29
33
  end
30
- puts "all #{desired_instances} scaling activities successful."
31
- wait_until_instances_ready
32
- puts "all #{desired_instances} instances ready."
33
34
  end
34
35
 
35
36
  def wait_until_instances_ready
@@ -89,6 +90,15 @@ module Hashicorptools
89
90
  end
90
91
  end
91
92
 
93
+ def verify_all_instances_using_correct_ami
94
+ launch_configuration = Aws::AutoScaling::LaunchConfiguration.new(name: group.launch_configuration_name, client: autoscaling)
95
+ image_id = launch_configuration.image_id
96
+ group.instances.each do |i|
97
+ instance = Aws::EC2::Instance.new(i.instance_id, client: ec2)
98
+ raise "#{i.instance_id} has the incorrect AMI, not #{image_id} from current LaunchConfig" if instance.image_id != image_id
99
+ end
100
+ end
101
+
92
102
  private
93
103
 
94
104
  def wait_for_activities_to_complete(group)
@@ -5,6 +5,10 @@ module Hashicorptools
5
5
  include Ec2Utilities
6
6
  include Variables
7
7
 
8
+ def self.exit_on_failure?
9
+ true
10
+ end
11
+
8
12
  desc "build", "creates an AMI from the current config"
9
13
  option :debug, :required => false
10
14
  def build
@@ -16,6 +20,11 @@ module Hashicorptools
16
20
  system "packer validate #{ami_config_path}"
17
21
  end
18
22
 
23
+ desc "fix", "runs the packer fix cmd"
24
+ def fix
25
+ system "packer fix #{ami_config_path}"
26
+ end
27
+
19
28
  desc "console", "interactive session"
20
29
  def console
21
30
  require 'byebug'
@@ -70,17 +79,17 @@ module Hashicorptools
70
79
  protected
71
80
 
72
81
  def _build(settings_overrides={})
73
- settings_overrides.merge!({source_ami: source_ami_id, ami_tag: tag_name, cookbook_name: cookbook_name})
82
+ settings_overrides.merge!({source_ami: source_ami_id, vpc_id: ami_building_vpc_id, subnet_id: ami_building_subnet_id, ami_tag: tag_name, cookbook_name: cookbook_name})
74
83
 
75
84
  if options[:debug]
76
85
  puts "[DEBUG] Executing 'packer build -debug #{variables(settings_overrides)} #{ami_config_path}'"
77
86
  system "packer build -debug \
78
87
  #{variables(settings_overrides)} \
79
- #{ami_config_path}"
88
+ #{ami_config_path}" or exit(1)
80
89
  else
81
90
  system "packer build \
82
91
  #{variables(settings_overrides)} \
83
- #{ami_config_path}"
92
+ #{ami_config_path}" or exit(1)
84
93
  end
85
94
 
86
95
  clean_amis
@@ -90,6 +99,14 @@ module Hashicorptools
90
99
  current_ami('base-image').image_id
91
100
  end
92
101
 
102
+ def ami_building_vpc_id
103
+ vpc_with_name('ami-building').vpc_id
104
+ end
105
+
106
+ def ami_building_subnet_id
107
+ ec2.client.describe_subnets({filters: [{name: "vpc-id", values: [ami_building_vpc_id]}]}).subnet_set.first.subnet_id
108
+ end
109
+
93
110
  def format_variable(key, value)
94
111
  "-var '#{key}=#{value}'"
95
112
  end
@@ -1,6 +1,6 @@
1
1
  module Hashicorptools
2
2
  class Terraform < Thor
3
- TERRAFORM_VERSION = '0.9.1'
3
+ TERRAFORM_VERSION = '0.11.0'
4
4
 
5
5
  include Ec2Utilities
6
6
  include Variables
@@ -11,6 +11,12 @@ module Hashicorptools
11
11
  apply
12
12
  end
13
13
 
14
+ desc 'init', 'install providers into local terraform'
15
+ option :environment, :required => true
16
+ def init
17
+
18
+ end
19
+
14
20
  [:apply, :plan, :destroy, :pull, :refresh].each do |cmd|
15
21
  desc cmd, "terraform #{cmd}"
16
22
  option :environment, :required => true
@@ -16,6 +16,8 @@ module Hashicorptools
16
16
 
17
17
  # then bring the instance count back down again.
18
18
  asg.set_desired_instances(current_count)
19
+
20
+ asg.verify_all_instances_using_correct_ami
19
21
  end
20
22
  end
21
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashicorptools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-21 00:00:00.000000000 Z
11
+ date: 2018-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -244,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  version: '0'
245
245
  requirements: []
246
246
  rubyforge_project:
247
- rubygems_version: 2.5.2
247
+ rubygems_version: 2.7.6
248
248
  signing_key:
249
249
  specification_version: 4
250
250
  summary: Wrappers for terraform and packer