simplygenius-atmos 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/exe/atmos +2 -2
- data/lib/{atmos.rb → simplygenius/atmos.rb} +9 -7
- data/lib/simplygenius/atmos/cli.rb +116 -0
- data/lib/simplygenius/atmos/commands/account.rb +69 -0
- data/lib/simplygenius/atmos/commands/apply.rb +24 -0
- data/lib/simplygenius/atmos/commands/auth_exec.rb +34 -0
- data/lib/simplygenius/atmos/commands/base_command.rb +16 -0
- data/lib/simplygenius/atmos/commands/bootstrap.rb +76 -0
- data/lib/simplygenius/atmos/commands/container.rb +62 -0
- data/lib/simplygenius/atmos/commands/destroy.rb +22 -0
- data/lib/simplygenius/atmos/commands/generate.rb +187 -0
- data/lib/simplygenius/atmos/commands/init.rb +22 -0
- data/lib/simplygenius/atmos/commands/new.rb +22 -0
- data/lib/simplygenius/atmos/commands/otp.rb +58 -0
- data/lib/simplygenius/atmos/commands/plan.rb +24 -0
- data/lib/simplygenius/atmos/commands/secret.rb +91 -0
- data/lib/simplygenius/atmos/commands/terraform.rb +56 -0
- data/lib/simplygenius/atmos/commands/user.rb +78 -0
- data/lib/simplygenius/atmos/config.rb +279 -0
- data/lib/simplygenius/atmos/exceptions.rb +13 -0
- data/lib/simplygenius/atmos/generator.rb +232 -0
- data/lib/simplygenius/atmos/ipc.rb +136 -0
- data/lib/simplygenius/atmos/ipc_actions/notify.rb +31 -0
- data/lib/simplygenius/atmos/ipc_actions/ping.rb +23 -0
- data/lib/simplygenius/atmos/logging.rb +164 -0
- data/lib/simplygenius/atmos/otp.rb +62 -0
- data/lib/simplygenius/atmos/plugin.rb +27 -0
- data/lib/simplygenius/atmos/plugin_manager.rb +120 -0
- data/lib/simplygenius/atmos/plugins/output_filter.rb +29 -0
- data/lib/simplygenius/atmos/plugins/prompt_notify.rb +21 -0
- data/lib/simplygenius/atmos/provider_factory.rb +23 -0
- data/lib/simplygenius/atmos/providers/aws/account_manager.rb +83 -0
- data/lib/simplygenius/atmos/providers/aws/auth_manager.rb +220 -0
- data/lib/simplygenius/atmos/providers/aws/container_manager.rb +118 -0
- data/lib/simplygenius/atmos/providers/aws/provider.rb +53 -0
- data/lib/simplygenius/atmos/providers/aws/s3_secret_manager.rb +51 -0
- data/lib/simplygenius/atmos/providers/aws/user_manager.rb +213 -0
- data/lib/simplygenius/atmos/settings_hash.rb +93 -0
- data/lib/simplygenius/atmos/source_path.rb +186 -0
- data/lib/simplygenius/atmos/template.rb +117 -0
- data/lib/simplygenius/atmos/terraform_executor.rb +297 -0
- data/lib/simplygenius/atmos/ui.rb +173 -0
- data/lib/simplygenius/atmos/utils.rb +54 -0
- data/lib/simplygenius/atmos/version.rb +5 -0
- data/templates/new/config/atmos.yml +21 -13
- data/templates/new/config/atmos/recipes.yml +16 -0
- data/templates/new/config/atmos/runtime.yml +9 -0
- metadata +46 -40
- data/lib/atmos/cli.rb +0 -105
- data/lib/atmos/commands/account.rb +0 -65
- data/lib/atmos/commands/apply.rb +0 -20
- data/lib/atmos/commands/auth_exec.rb +0 -29
- data/lib/atmos/commands/base_command.rb +0 -12
- data/lib/atmos/commands/bootstrap.rb +0 -72
- data/lib/atmos/commands/container.rb +0 -58
- data/lib/atmos/commands/destroy.rb +0 -18
- data/lib/atmos/commands/generate.rb +0 -90
- data/lib/atmos/commands/init.rb +0 -18
- data/lib/atmos/commands/new.rb +0 -18
- data/lib/atmos/commands/otp.rb +0 -54
- data/lib/atmos/commands/plan.rb +0 -20
- data/lib/atmos/commands/secret.rb +0 -87
- data/lib/atmos/commands/terraform.rb +0 -52
- data/lib/atmos/commands/user.rb +0 -74
- data/lib/atmos/config.rb +0 -208
- data/lib/atmos/exceptions.rb +0 -9
- data/lib/atmos/generator.rb +0 -199
- data/lib/atmos/generator_factory.rb +0 -93
- data/lib/atmos/ipc.rb +0 -132
- data/lib/atmos/ipc_actions/notify.rb +0 -27
- data/lib/atmos/ipc_actions/ping.rb +0 -19
- data/lib/atmos/logging.rb +0 -160
- data/lib/atmos/otp.rb +0 -61
- data/lib/atmos/provider_factory.rb +0 -19
- data/lib/atmos/providers/aws/account_manager.rb +0 -82
- data/lib/atmos/providers/aws/auth_manager.rb +0 -208
- data/lib/atmos/providers/aws/container_manager.rb +0 -116
- data/lib/atmos/providers/aws/provider.rb +0 -51
- data/lib/atmos/providers/aws/s3_secret_manager.rb +0 -49
- data/lib/atmos/providers/aws/user_manager.rb +0 -211
- data/lib/atmos/settings_hash.rb +0 -90
- data/lib/atmos/terraform_executor.rb +0 -267
- data/lib/atmos/ui.rb +0 -159
- data/lib/atmos/utils.rb +0 -50
- data/lib/atmos/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5761d35141b55d13b0e372081647d0a898aa0dda202d12c02f4c6728d671600f
|
4
|
+
data.tar.gz: b2b0650b44c07c757f106b7f8f4c55ac3a0b44457f337c06620adb934340db16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 889d94f2c5743bccab0a8e53d76a936585f4410bd1a18ee9df46036da8a3b718833a73f8aaed475ae1278708532f113f4f96b7dc43833bef8b5bab7fac0520d6
|
7
|
+
data.tar.gz: 87c5c8896b562ed95898584284a741bb0d7dc903e0365e197054f73e00c795eaf4200a6c0ec4cfccc8a66f4aa5f15c0ede4e8e7c16b628ce83cdf6eb96deb2ef
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
Atmos(phere) - Breathe easier with terraform
|
8
8
|
|
9
|
-
Atmos provides a layer of organization on top of terraform for creating cloud system architectures with Amazon Web Services. It handles the plumbing so you can focus on your application. The core atmos runtime is free and open-source, with a business friendly license (Apache). It provides some basic recipes to help get you going with a service oriented architecture implemented with AWS Elastic Container Services. For more in-depth recipes, please check out the Atmos Pro offering.
|
9
|
+
Atmos provides a layer of organization on top of terraform for creating cloud system architectures with Amazon Web Services. It handles the plumbing so you can focus on your application. The core atmos runtime is free and open-source, with a business friendly license (Apache). It provides some basic recipes to help get you going with a service oriented architecture implemented with AWS Elastic Container Services. For more in-depth recipes, please check out the [Atmos Pro](https://simplygenius.com/atmos-pro) offering.
|
10
10
|
|
11
11
|
In a nutshell, you provide the green, atmos delivers the rest:
|
12
12
|
|
@@ -18,7 +18,7 @@ In a nutshell, you provide the green, atmos delivers the rest:
|
|
18
18
|
|
19
19
|
* The command line is king. Using a CLI to iterate on and manage core infrastructure has always been more effective for me, so I aim to make things as convenient and usable as possible from there.
|
20
20
|
|
21
|
-
* No lock-in. Since atmos just provides you convenience on top of using terraform, and the templates for defining your infrastructure are
|
21
|
+
* No lock-in. Since atmos just provides you convenience on top of using terraform, and the templates for defining your infrastructure are entirely in terraform, its possible to migrate away (albeit giving up all the convenience atmos provides) if your goals ever diverge from those of atmos.
|
22
22
|
|
23
23
|
* Your infrastructure is an important product. It should have its own repo and be tracked under configuration management, not just clickety-click-clicked on in a UI and promptly forgotten what it is you actually did to get there. The only guarantee you have, is that things are going to need to change, and you'll be much better off with a system that allows you to iterate easily. Atmos gets you started with minimal up-front knowledge, but provides a path for your infrastructure to evolve.
|
24
24
|
|
@@ -48,7 +48,7 @@ To install as a gem:
|
|
48
48
|
* gem install simplygenius-atmos
|
49
49
|
* verify: `atmos --help`
|
50
50
|
|
51
|
-
To install/run as a docker image:
|
51
|
+
To install/run as a docker image (experimental):
|
52
52
|
* curl -sL https://raw.githubusercontent.com/simplygenius/atmos/master/exe/atmos-docker > /usr/local/bin/atmos
|
53
53
|
* chmod +x /usr/local/bin/atmos
|
54
54
|
* verify: `atmos --help`
|
@@ -216,4 +216,4 @@ The gem is available as open source under the terms of the [Apache 2.0 License](
|
|
216
216
|
|
217
217
|
# About Us
|
218
218
|
|
219
|
-
Simply Genius LLC is an independently run organization in Boston, MA USA. Its Chief Everything is Matt Conway, a software engineer and executive with more than 20 years of experience in the Boston Tech Startup scene. Atmos is his attempt at providing the world with the same tools, techniques, mindset and philosophy that he strives for when building a system architecture for a new startup.
|
219
|
+
[Simply Genius LLC](https://simplygenius.com) is an independently run organization in Boston, MA USA. Its Chief Everything is Matt Conway, a software engineer and executive with more than 20 years of experience in the Boston Tech Startup scene. Atmos is his attempt at providing the world with the same tools, techniques, mindset and philosophy that he strives for when building a system architecture for a new startup.
|
data/exe/atmos
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require_relative 'atmos/version'
|
2
|
-
|
3
|
-
require_relative 'atmos/logging'
|
4
|
-
Atmos::Logging.setup_logging(false, false, nil)
|
5
|
-
|
6
|
-
require_relative 'atmos/config'
|
7
2
|
require 'active_support/core_ext/string'
|
8
3
|
require 'active_support/concern'
|
9
4
|
|
10
|
-
module
|
11
|
-
|
5
|
+
module SimplyGenius
|
6
|
+
module Atmos
|
7
|
+
mattr_accessor :config
|
8
|
+
end
|
12
9
|
end
|
10
|
+
|
11
|
+
require_relative 'atmos/logging'
|
12
|
+
# SimplyGenius::Atmos::Logging.setup_logging(false, false, nil)
|
13
|
+
|
14
|
+
require_relative 'atmos/config'
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require_relative '../atmos'
|
2
|
+
require_relative '../atmos/ui'
|
3
|
+
require_relative '../atmos/plugins/prompt_notify'
|
4
|
+
require 'clamp'
|
5
|
+
require 'sigdump/setup'
|
6
|
+
|
7
|
+
Dir.glob(File.join(File.join(__dir__, 'commands'), '*.rb')) do |f|
|
8
|
+
require_relative "commands/#{File.basename(f).sub(/\.rb$/, "")}"
|
9
|
+
end
|
10
|
+
|
11
|
+
module SimplyGenius
|
12
|
+
module Atmos
|
13
|
+
|
14
|
+
# The command line interface to atmos
|
15
|
+
class CLI < Clamp::Command
|
16
|
+
|
17
|
+
include GemLogger::LoggerSupport
|
18
|
+
|
19
|
+
def self.description
|
20
|
+
desc = <<-DESC
|
21
|
+
Atmos version #{VERSION}
|
22
|
+
|
23
|
+
Runs The atmos command line application
|
24
|
+
|
25
|
+
e.g.
|
26
|
+
|
27
|
+
atmos --help
|
28
|
+
DESC
|
29
|
+
desc.split("\n").collect(&:strip).join("\n")
|
30
|
+
end
|
31
|
+
|
32
|
+
option ["-d", "--debug"],
|
33
|
+
:flag, "debug output\n",
|
34
|
+
default: false
|
35
|
+
|
36
|
+
option ["-c", "--[no-]color"],
|
37
|
+
:flag, "colorize output (or not)\n (default: $stdout.tty?)"
|
38
|
+
|
39
|
+
option ["-e", "--atmos-env"],
|
40
|
+
'ENV', "The atmos environment\n",
|
41
|
+
environment_variable: 'ATMOS_ENV', default: 'ops'
|
42
|
+
|
43
|
+
option ["-l", "--load-path"],
|
44
|
+
"PATH", "adds additional paths to ruby load path",
|
45
|
+
multivalued: true
|
46
|
+
|
47
|
+
def default_color?
|
48
|
+
$stdout.tty?
|
49
|
+
end
|
50
|
+
|
51
|
+
option ["-l", "--[no-]log"],
|
52
|
+
:flag, "log to file in addition to terminal (or not)\n",
|
53
|
+
default: true
|
54
|
+
|
55
|
+
|
56
|
+
subcommand "new", "Sets up a new atmos project",
|
57
|
+
Commands::New
|
58
|
+
subcommand "generate", "Generate recipes for the repository",
|
59
|
+
Commands::Generate
|
60
|
+
subcommand "bootstrap", "Init cloud provider for use with atmos",
|
61
|
+
Commands::Bootstrap
|
62
|
+
subcommand "init", "Run terraform init",
|
63
|
+
Commands::Init
|
64
|
+
subcommand "plan", "Run terraform plan",
|
65
|
+
Commands::Plan
|
66
|
+
subcommand "apply", "Run terraform apply",
|
67
|
+
Commands::Apply
|
68
|
+
subcommand "destroy", "Run terraform destroy",
|
69
|
+
Commands::Destroy
|
70
|
+
subcommand "terraform", "Run all other terraform commands",
|
71
|
+
Commands::Terraform
|
72
|
+
subcommand "account", "Account management commands",
|
73
|
+
Commands::Account
|
74
|
+
subcommand "user", "User management commands",
|
75
|
+
Commands::User
|
76
|
+
subcommand "otp", "Otp tools",
|
77
|
+
Commands::Otp
|
78
|
+
subcommand "secret", "Secret management commands",
|
79
|
+
Commands::Secret
|
80
|
+
subcommand "auth_exec", "Authenticated exec",
|
81
|
+
Commands::AuthExec
|
82
|
+
subcommand "container", "Container tools",
|
83
|
+
Commands::Container
|
84
|
+
|
85
|
+
subcommand "version", "Display version" do
|
86
|
+
def execute
|
87
|
+
logger.info "Atmos Version #{VERSION}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
subcommand "config", "Display expanded config for atmos_env" do
|
92
|
+
def execute
|
93
|
+
logger.info YAML.dump(Atmos.config.to_h)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# hook into clamp lifecycle to force logging setup even when we are calling
|
98
|
+
# a subcommand
|
99
|
+
def parse(arguments)
|
100
|
+
super
|
101
|
+
if Atmos.config.nil?
|
102
|
+
Atmos.config = Config.new(atmos_env)
|
103
|
+
log = Atmos.config.is_atmos_repo? && log? ? "atmos.log" : nil
|
104
|
+
Logging.setup_logging(debug?, color?, log)
|
105
|
+
UI.color_enabled = color?
|
106
|
+
|
107
|
+
Atmos.config.add_user_load_path(*load_path_list)
|
108
|
+
Atmos.config.plugin_manager.register_output_filter(:stdout, Plugins::PromptNotify)
|
109
|
+
Atmos.config.plugin_manager.load_plugins
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative 'base_command'
|
2
|
+
require_relative '../../atmos/settings_hash'
|
3
|
+
require 'climate_control'
|
4
|
+
|
5
|
+
module SimplyGenius
|
6
|
+
module Atmos
|
7
|
+
module Commands
|
8
|
+
|
9
|
+
class Account < BaseCommand
|
10
|
+
|
11
|
+
def self.description
|
12
|
+
"Manages accounts/envs in the cloud provider"
|
13
|
+
end
|
14
|
+
|
15
|
+
subcommand "create", "Create a new account" do
|
16
|
+
|
17
|
+
option ["-s", "--source-env"],
|
18
|
+
"SOURCE_ENV", "Base the new env on a clone of the given one\n"
|
19
|
+
|
20
|
+
option ["-e", "--email"],
|
21
|
+
"EMAIL", "override default email used for new account\n"
|
22
|
+
|
23
|
+
option ["-n", "--name"],
|
24
|
+
"NAME", "override default name used for new account\n"
|
25
|
+
|
26
|
+
parameter "ENV",
|
27
|
+
"The name of the new env to create"
|
28
|
+
|
29
|
+
def execute
|
30
|
+
|
31
|
+
Atmos.config.provider.auth_manager.authenticate(ENV) do |auth_env|
|
32
|
+
ClimateControl.modify(auth_env) do
|
33
|
+
|
34
|
+
config = YAML.load_file(Atmos.config.config_file)
|
35
|
+
|
36
|
+
if config['environments'][env]
|
37
|
+
signal_usage_error "Env '#{env}' is already present in atmos config"
|
38
|
+
end
|
39
|
+
|
40
|
+
source = {}
|
41
|
+
if source_env.present?
|
42
|
+
source = config['environments'][source_env]
|
43
|
+
if source.blank?
|
44
|
+
signal_usage_error "Source env '#{source_env}' does not exist"
|
45
|
+
end
|
46
|
+
source = source.clone
|
47
|
+
end
|
48
|
+
|
49
|
+
account = Atmos.config.provider.account_manager.create_account(env, name: name, email: email)
|
50
|
+
logger.info "Account created: #{display account}"
|
51
|
+
|
52
|
+
source['account_id'] = account[:account_id].to_s
|
53
|
+
|
54
|
+
new_yml = SettingsHash.add_config(
|
55
|
+
Atmos.config.config_file,
|
56
|
+
"environments.#{env}", source
|
57
|
+
)
|
58
|
+
logger.info("Writing out new atmos.yml containing new account")
|
59
|
+
File.write(Atmos.config.config_file, new_yml)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'terraform'
|
2
|
+
|
3
|
+
module SimplyGenius
|
4
|
+
module Atmos
|
5
|
+
module Commands
|
6
|
+
|
7
|
+
class Apply < Terraform
|
8
|
+
|
9
|
+
def self.description
|
10
|
+
"Runs terraform apply"
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute
|
14
|
+
args = ["apply"]
|
15
|
+
args << "--get-modules" unless Atmos.config["disable_auto_modules"].to_s == "true"
|
16
|
+
@terraform_arguments.insert(0, *args)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative 'base_command'
|
2
|
+
require 'climate_control'
|
3
|
+
|
4
|
+
module SimplyGenius
|
5
|
+
module Atmos
|
6
|
+
module Commands
|
7
|
+
|
8
|
+
class AuthExec < BaseCommand
|
9
|
+
|
10
|
+
def self.description
|
11
|
+
"Exec subprocess with an authenticated environment"
|
12
|
+
end
|
13
|
+
|
14
|
+
option ["-r", "--role"],
|
15
|
+
'ROLE', "overrides assume role name\n"
|
16
|
+
|
17
|
+
parameter "COMMAND ...", "command to exec", :attribute_name => :command
|
18
|
+
|
19
|
+
def execute
|
20
|
+
Atmos.config.provider.auth_manager.authenticate(ENV, role: role) do |auth_env|
|
21
|
+
result = system(auth_env, *command)
|
22
|
+
if ! result
|
23
|
+
logger.error("Process failed: #{command}")
|
24
|
+
exit(1)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative '../../atmos'
|
2
|
+
require_relative '../../atmos/ui'
|
3
|
+
require 'clamp'
|
4
|
+
|
5
|
+
module SimplyGenius
|
6
|
+
module Atmos
|
7
|
+
module Commands
|
8
|
+
|
9
|
+
class BaseCommand < Clamp::Command
|
10
|
+
include GemLogger::LoggerSupport
|
11
|
+
include UI
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require_relative 'base_command'
|
2
|
+
|
3
|
+
module SimplyGenius
|
4
|
+
module Atmos
|
5
|
+
module Commands
|
6
|
+
|
7
|
+
class Bootstrap < BaseCommand
|
8
|
+
|
9
|
+
def self.description
|
10
|
+
"Sets up the initial aws account for use by atmos"
|
11
|
+
end
|
12
|
+
|
13
|
+
option ["-f", "--force"],
|
14
|
+
:flag, "forces bootstrap\n"
|
15
|
+
|
16
|
+
def execute
|
17
|
+
|
18
|
+
tf_init_dir = File.join(Atmos.config.tf_working_dir('bootstrap'), '.terraform')
|
19
|
+
tf_initialized = File.exist?(tf_init_dir)
|
20
|
+
backend_initialized = File.exist?(File.join(tf_init_dir, 'terraform.tfstate'))
|
21
|
+
|
22
|
+
rebootstrap_msg = <<~EOF
|
23
|
+
Bootstrap should only be performed when provisioning an account for the first
|
24
|
+
time. Try 'atmos terraform init'
|
25
|
+
EOF
|
26
|
+
|
27
|
+
if !force? && tf_initialized
|
28
|
+
signal_usage_error(rebootstrap_msg)
|
29
|
+
end
|
30
|
+
|
31
|
+
Atmos.config.provider.auth_manager.authenticate(ENV, bootstrap: true) do |auth_env|
|
32
|
+
begin
|
33
|
+
exe = TerraformExecutor.new(process_env: auth_env, working_group: 'bootstrap')
|
34
|
+
|
35
|
+
skip_backend = true
|
36
|
+
skip_secrets = true
|
37
|
+
if backend_initialized
|
38
|
+
skip_backend = false
|
39
|
+
skip_secrets = false
|
40
|
+
end
|
41
|
+
|
42
|
+
# Cases
|
43
|
+
# 1) bootstrap of new account - success
|
44
|
+
# 2) repeating bootstrap of new account due to failure partway - success
|
45
|
+
# 3) try to rebootstrap existing account on fresh checkout - should fail trying to create resources of same name, check output for this?
|
46
|
+
# 4) bootstrap new account with no-default secrets
|
47
|
+
|
48
|
+
# Need to init before we can create the resources to store state in bootstrap
|
49
|
+
exe.run("init", "-input=false", "-lock=false",
|
50
|
+
skip_backend: true, skip_secrets: true)
|
51
|
+
|
52
|
+
# Bootstrap to create the resources needed to store state
|
53
|
+
exe.run("apply", "-input=false",
|
54
|
+
skip_backend: true, skip_secrets: true)
|
55
|
+
|
56
|
+
# Need to init to setup the backend state after we create the resources
|
57
|
+
# to store state in bootstrap
|
58
|
+
exe.run("init", "-input=false", "-force-copy", skip_secrets: true)
|
59
|
+
|
60
|
+
# Might as well init the non-bootstrap case as well once the state
|
61
|
+
# storage has been setup in bootstrap
|
62
|
+
exe = TerraformExecutor.new(process_env: auth_env)
|
63
|
+
exe.run("init", "-input=false", skip_secrets: true)
|
64
|
+
|
65
|
+
rescue TerraformExecutor::ProcessFailed => e
|
66
|
+
logger.error(e.message)
|
67
|
+
logger.error(rebootstrap_msg)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative 'base_command'
|
2
|
+
require_relative '../../atmos/settings_hash'
|
3
|
+
require 'climate_control'
|
4
|
+
|
5
|
+
module SimplyGenius
|
6
|
+
module Atmos
|
7
|
+
module Commands
|
8
|
+
|
9
|
+
class Container < BaseCommand
|
10
|
+
|
11
|
+
def self.description
|
12
|
+
"Manages containers in the cloud provider"
|
13
|
+
end
|
14
|
+
|
15
|
+
subcommand "deploy", "Deploy a container" do
|
16
|
+
|
17
|
+
option ["-c", "--cluster"],
|
18
|
+
"CLUSTER", "The cluster name\n",
|
19
|
+
required: true
|
20
|
+
|
21
|
+
option ["-r", "--role"],
|
22
|
+
"ROLE", "The role to assume when deploying\n"
|
23
|
+
|
24
|
+
option ["-i", "--image"],
|
25
|
+
"IMAGE", "The local container image to deploy\nDefaults to service/task name"
|
26
|
+
|
27
|
+
option ["-t", "--task"],
|
28
|
+
:flag, "Deploy as a task, not a service\n"
|
29
|
+
|
30
|
+
option ["-v", "--revision"],
|
31
|
+
"REVISION", "Use as the remote image revision\n"
|
32
|
+
|
33
|
+
parameter "NAME",
|
34
|
+
"The name of the service (or task) to deploy"
|
35
|
+
|
36
|
+
def default_image
|
37
|
+
name
|
38
|
+
end
|
39
|
+
|
40
|
+
def execute
|
41
|
+
Atmos.config.provider.auth_manager.authenticate(ENV, role: role) do |auth_env|
|
42
|
+
ClimateControl.modify(auth_env) do
|
43
|
+
mgr = Atmos.config.provider.container_manager
|
44
|
+
|
45
|
+
result = mgr.push(name, image, revision: revision)
|
46
|
+
if task?
|
47
|
+
result = result.merge(mgr.deploy_task(name, result[:remote_image]))
|
48
|
+
else
|
49
|
+
result = result.merge(mgr.deploy_service(cluster, name, result[:remote_image]))
|
50
|
+
end
|
51
|
+
|
52
|
+
logger.info "Container deployed:\n #{display result}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|