forger 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/forger.gemspec +1 -2
- data/lib/forger/config.rb +6 -1
- data/lib/forger/core.rb +2 -2
- data/lib/forger/create.rb +13 -8
- data/lib/forger/dotenv.rb +1 -1
- data/lib/forger/script.rb +2 -1
- data/lib/forger/script/templates/extract_forger_scripts.sh +4 -4
- data/lib/forger/template/context.rb +2 -2
- data/lib/forger/template/helper/core_helper.rb +2 -2
- data/lib/forger/version.rb +1 -1
- data/spec/fixtures/demo_project/.env.test +2 -0
- data/spec/fixtures/demo_project/app/user-data/bootstrap.sh +4 -0
- data/spec/fixtures/demo_project/config/test.yml +1 -0
- data/spec/fixtures/demo_project/profiles/default.yml +2 -2
- data/spec/lib/cli_spec.rb +7 -0
- data/spec/spec_helper.rb +2 -2
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76857772ac7cbd2c550b7506d1a2521abd062fa81db597cb3bb7668f4748d4e8
|
4
|
+
data.tar.gz: 1629ca2594868f7613be0cedfa8d0365f7be0c2944d22d6beb91f3723eccaa9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 607c651c3253855fbaec49322962a49108c0c9861d2e84cc61c2a6dc611d21c3bd39b35ab132206b1713762982d5801a893ccaa091a8ea80d176e664bdfa7836
|
7
|
+
data.tar.gz: b1a1b5922611f071985aecaab00b56c0b36dcf1368b220056439a403d389006bece6cc17351b79a449b5d12c225a4583a126b3709463bb3356715990669c2c10
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [1.5.3]
|
7
|
+
- Merge pull request #9 from tongueroo/erb-support-for-config-env-files
|
8
|
+
- ERB support for config env files
|
9
|
+
- rename AWS_EC2 to FORGER
|
10
|
+
|
6
11
|
## [1.5.2]
|
7
12
|
- add back user-data.txt script to cloudwatch
|
8
13
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -57,7 +57,7 @@ app/partials | Your partials that can to be included in other scripts. This is
|
|
57
57
|
app/scripts | Where you define common scripts that can be used to configure the server. These scripts can be automatically uploaded to an s3 bucket for later downloading in your user-data script by setting the `s3_folder` settings option.
|
58
58
|
app/user-data | Your user-data scripts that are used to bootstrap EC2 instance.
|
59
59
|
app/user-data/layouts | user-data scripts support layouts. You user-data layouts go in here.
|
60
|
-
config/[
|
60
|
+
config/[FORGER_ENV].yml | The config file where you set configs that you want available in your templating logic. Examples are: `config/development.yml` and `config/production.yml`. You access the config variables with the `<%= config["var"] %>` helper.
|
61
61
|
profiles | Your profile files. These files mainly contain parameters that are passed to the aws-sdk run_instances API method.
|
62
62
|
tmp | Where the generated scripts get compiled to. You can manually invoke the compilation via `forger compile` to inspect what is generated. This is automatically done as part of the `forger` create command.
|
63
63
|
|
data/forger.gemspec
CHANGED
@@ -8,8 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Forger::VERSION
|
9
9
|
spec.authors = ["Tung Nguyen"]
|
10
10
|
spec.email = ["tongueroo@gmail.com"]
|
11
|
-
spec.
|
12
|
-
spec.summary = %q{Simple tool to create AWS ec2 instances}
|
11
|
+
spec.summary = "Tool to create AWS ec2 instances"
|
13
12
|
spec.homepage = "https://github.com/tongueroo/forger"
|
14
13
|
spec.license = "MIT"
|
15
14
|
|
data/lib/forger/config.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'render_me_pretty'
|
2
3
|
|
3
4
|
module Forger
|
4
5
|
class Config < Base
|
6
|
+
include Forger::Template
|
7
|
+
|
5
8
|
def initialize(options={})
|
6
9
|
super
|
7
10
|
@path = options[:path] || "#{Forger.root}/config/#{Forger.env}.yml"
|
@@ -10,7 +13,9 @@ module Forger
|
|
10
13
|
@@data = nil
|
11
14
|
def data
|
12
15
|
return @@data if @@data
|
13
|
-
|
16
|
+
|
17
|
+
text = RenderMePretty.result(@path, context: context)
|
18
|
+
@@data = YAML.load(text)
|
14
19
|
rescue Errno::ENOENT => e
|
15
20
|
puts e.message
|
16
21
|
puts "The #{@path} does not exist. Please double check that it exists."
|
data/lib/forger/core.rb
CHANGED
@@ -13,7 +13,7 @@ module Forger
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def root
|
16
|
-
path = ENV['
|
16
|
+
path = ENV['FORGER_ROOT'] || '.'
|
17
17
|
Pathname.new(path)
|
18
18
|
end
|
19
19
|
|
@@ -28,7 +28,7 @@ module Forger
|
|
28
28
|
def env
|
29
29
|
return @@env if @@env
|
30
30
|
env = env_from_profile(ENV['AWS_PROFILE']) || 'development'
|
31
|
-
env = ENV['
|
31
|
+
env = ENV['FORGER_ENV'] if ENV['FORGER_ENV'] # highest precedence
|
32
32
|
@@env = env
|
33
33
|
end
|
34
34
|
|
data/lib/forger/create.rb
CHANGED
@@ -90,22 +90,22 @@ module Forger
|
|
90
90
|
def display_cloudwatch_info(instance_id)
|
91
91
|
return unless @options[:cloudwatch]
|
92
92
|
|
93
|
-
region =
|
93
|
+
region = cloudwatch_log_region
|
94
94
|
stream = "#{instance_id}/var/log/cloud-init-output.log"
|
95
95
|
url = "https://#{region}.console.aws.amazon.com/cloudwatch/home?region=#{region}#logEventViewer:group=ec2;stream=#{stream}"
|
96
96
|
cw_init_log = "cw tail -f ec2 #{stream}"
|
97
97
|
puts "To view instance's cloudwatch logs visit:"
|
98
98
|
puts " #{url}"
|
99
99
|
|
100
|
-
puts " #{cw_init_log}" if ENV['
|
101
|
-
if ENV['
|
100
|
+
puts " #{cw_init_log}" if ENV['FORGER_CW']
|
101
|
+
if ENV['FORGER_CW'] && @options[:auto_terminate]
|
102
102
|
cw_terminate_log = "cw tail -f ec2 #{instance_id}/var/log/auto-terminate.log"
|
103
103
|
puts " #{cw_terminate_log}"
|
104
104
|
end
|
105
105
|
|
106
106
|
puts "Note: It takes a little time for the instance to launch and report logs."
|
107
107
|
|
108
|
-
paste_command = ENV['
|
108
|
+
paste_command = ENV['FORGER_CW'] ? cw_init_log : url
|
109
109
|
add_to_clipboard(paste_command)
|
110
110
|
end
|
111
111
|
|
@@ -117,10 +117,15 @@ module Forger
|
|
117
117
|
puts "Pro tip: The CloudWatch Console Link has been added to your copy-and-paste clipboard."
|
118
118
|
end
|
119
119
|
|
120
|
-
def
|
121
|
-
# Highest precedence:
|
122
|
-
|
123
|
-
|
120
|
+
def cloudwatch_log_region
|
121
|
+
# Highest precedence: FORGER_REGION env variable. Only really used here.
|
122
|
+
# This is useful to be able to override when running tool in codebuild.
|
123
|
+
# Codebuild can be running in different region then the region which the
|
124
|
+
# instance is launched in.
|
125
|
+
# Getting the region from the the profile and metadata doesnt work in
|
126
|
+
# this case.
|
127
|
+
if ENV['FORGER_REGION']
|
128
|
+
return ENV['FORGER_REGION']
|
124
129
|
end
|
125
130
|
|
126
131
|
# Pretty high in precedence: AWS_PROFILE and ~/.aws/config and
|
data/lib/forger/dotenv.rb
CHANGED
data/lib/forger/script.rb
CHANGED
@@ -29,7 +29,8 @@ module Forger
|
|
29
29
|
def create_ami
|
30
30
|
# set variables for the template
|
31
31
|
@ami_name = @options[:ami_name]
|
32
|
-
@region =
|
32
|
+
@region = 'us-east-1' if ENV['TEST']
|
33
|
+
@region ||= `aws configure get region`.strip rescue 'us-east-1'
|
33
34
|
load_template("ami_creation.sh")
|
34
35
|
end
|
35
36
|
|
@@ -21,13 +21,13 @@ function extract_forger_scripts() {
|
|
21
21
|
|
22
22
|
<%
|
23
23
|
# Examples:
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
24
|
+
# FORGER_CODE=v1.0.0
|
25
|
+
# FORGER_CODE=master
|
26
|
+
# FORGER_CODE=branch-name
|
27
27
|
#
|
28
28
|
# https://github.com/tongueroo/forger/archive/v1.0.0.tar.gz
|
29
29
|
# https://github.com/tongueroo/forger/archive/master.tar.gz
|
30
|
-
code_version = ENV['
|
30
|
+
code_version = ENV['FORGER_CODE']
|
31
31
|
code_version ||= "v#{Forger::VERSION}"
|
32
32
|
%>
|
33
33
|
url="https://github.com/tongueroo/forger/archive/<%= code_version %>.tar.gz"
|
@@ -18,10 +18,10 @@ module Forger::Template
|
|
18
18
|
filename = path.sub(%r{.*/},'').sub('.rb','')
|
19
19
|
module_name = filename.classify
|
20
20
|
|
21
|
-
# Prepend a period so require works
|
21
|
+
# Prepend a period so require works FORGER_ROOT is set to a relative path
|
22
22
|
# without a period.
|
23
23
|
#
|
24
|
-
# Example:
|
24
|
+
# Example: FORGER_ROOT=tmp/project
|
25
25
|
first_char = path[0..0]
|
26
26
|
path = "./#{path}" unless %w[. /].include?(first_char)
|
27
27
|
require path
|
@@ -58,8 +58,8 @@ module Forger::Template::Helper::CoreHelper
|
|
58
58
|
end
|
59
59
|
|
60
60
|
# provides access to config/* settings as variables
|
61
|
-
#
|
62
|
-
#
|
61
|
+
# FORGER_ENV=development => config/development.yml
|
62
|
+
# FORGER_ENV=production => config/production.yml
|
63
63
|
def config
|
64
64
|
Forger.config
|
65
65
|
end
|
data/lib/forger/version.rb
CHANGED
@@ -6,9 +6,9 @@ instance_type: t2.medium
|
|
6
6
|
key_name: default
|
7
7
|
max_count: 1
|
8
8
|
min_count: 1
|
9
|
-
user_data:
|
9
|
+
user_data: "<%= user_data("bootstrap.sh") %>"
|
10
10
|
iam_instance_profile:
|
11
|
-
name:
|
11
|
+
name: <%= ENV['IAM_INSTANCE_PROFILE'] %>
|
12
12
|
# public network settings
|
13
13
|
security_group_ids: <%= config["security_group_ids"].inspect %>
|
14
14
|
subnet_id: <%= config["subnets"].shuffle.first %>
|
data/spec/lib/cli_spec.rb
CHANGED
@@ -9,6 +9,13 @@ describe Forger::CLI do
|
|
9
9
|
expect(out).to include("Creating EC2 instance")
|
10
10
|
end
|
11
11
|
|
12
|
+
it "ERB evaluates dotenv files" do
|
13
|
+
out = execute("exe/forger create server #{@args}")
|
14
|
+
user_data = IO.readlines("spec/fixtures/demo_project/tmp/user-data.txt")
|
15
|
+
found = !user_data.select { |l| l =~ /test_key: test-key-value/ }.empty?
|
16
|
+
expect(found).to be true
|
17
|
+
end
|
18
|
+
|
12
19
|
it "ami" do
|
13
20
|
out = execute("exe/forger ami myimage #{@args}")
|
14
21
|
expect(out).to include("Creating EC2 instance")
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
ENV["TEST"] = "1"
|
2
|
-
ENV["
|
3
|
-
ENV["
|
2
|
+
ENV["FORGER_ENV"] = "test"
|
3
|
+
ENV["FORGER_ROOT"] = "spec/fixtures/demo_project"
|
4
4
|
# Ensures aws api never called. Fixture home folder does not contain ~/.aws/credentails
|
5
5
|
ENV['HOME'] = "spec/fixtures/home"
|
6
6
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
@@ -220,8 +220,7 @@ dependencies:
|
|
220
220
|
- - ">="
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
|
-
description:
|
224
|
-
settings
|
223
|
+
description:
|
225
224
|
email:
|
226
225
|
- tongueroo@gmail.com
|
227
226
|
executables:
|
@@ -315,6 +314,8 @@ files:
|
|
315
314
|
- lib/forger/wait.rb
|
316
315
|
- lib/forger/waiter.rb
|
317
316
|
- lib/forger/waiter/ami.rb
|
317
|
+
- spec/fixtures/demo_project/.env.test
|
318
|
+
- spec/fixtures/demo_project/app/user-data/bootstrap.sh
|
318
319
|
- spec/fixtures/demo_project/config/settings.yml
|
319
320
|
- spec/fixtures/demo_project/config/test.yml
|
320
321
|
- spec/fixtures/demo_project/profiles/default.yml
|
@@ -344,8 +345,10 @@ rubyforge_project:
|
|
344
345
|
rubygems_version: 2.7.3
|
345
346
|
signing_key:
|
346
347
|
specification_version: 4
|
347
|
-
summary:
|
348
|
+
summary: Tool to create AWS ec2 instances
|
348
349
|
test_files:
|
350
|
+
- spec/fixtures/demo_project/.env.test
|
351
|
+
- spec/fixtures/demo_project/app/user-data/bootstrap.sh
|
349
352
|
- spec/fixtures/demo_project/config/settings.yml
|
350
353
|
- spec/fixtures/demo_project/config/test.yml
|
351
354
|
- spec/fixtures/demo_project/profiles/default.yml
|