sonic-screwdriver 1.4.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/bin/commit_docs.sh +26 -0
- data/.circleci/config.yml +72 -0
- data/.gitignore +2 -1
- data/CHANGELOG.md +29 -3
- data/Gemfile +3 -3
- data/Guardfile +17 -10
- data/LICENSE.txt +2 -2
- data/README.md +25 -28
- data/Rakefile +9 -2
- data/docs/_config.yml +3 -0
- data/docs/_docs/help.md +1 -1
- data/docs/_docs/install-bastion.md +5 -15
- data/docs/_docs/install.md +3 -13
- data/docs/_docs/next-steps.md +1 -1
- data/docs/_docs/settings.md +42 -56
- data/docs/_docs/tutorial-ecs-exec.md +16 -20
- data/docs/_docs/tutorial-ecs-sh.md +73 -0
- data/docs/_docs/tutorial-execute.md +106 -38
- data/docs/_docs/tutorial-ssh.md +15 -19
- data/docs/_docs/why-ec2-run-command.md +1 -1
- data/docs/_includes/commands.html +5 -5
- data/docs/_includes/content.html +5 -0
- data/docs/_includes/css/main.css +15 -9
- data/docs/_includes/css/sonic.css +7 -5
- data/docs/_includes/example.html +4 -4
- data/docs/_includes/footer.html +6 -4
- data/docs/_includes/reference.md +1 -0
- data/docs/_includes/subnav.html +2 -1
- data/docs/_reference/sonic-completion.md +44 -0
- data/docs/_reference/sonic-completion_script.md +25 -0
- data/docs/_reference/sonic-ecs-exec.md +30 -0
- data/docs/_reference/sonic-ecs-help.md +21 -0
- data/docs/_reference/sonic-ecs-sh.md +35 -0
- data/docs/_reference/sonic-ecs.md +25 -0
- data/docs/_reference/sonic-execute.md +85 -0
- data/docs/_reference/sonic-list.md +40 -0
- data/docs/_reference/sonic-ssh.md +86 -0
- data/docs/_reference/sonic-version.md +21 -0
- data/docs/bin/web +1 -1
- data/docs/img/tutorials/ec2-console-run-command.png +0 -0
- data/docs/quick-start.md +17 -22
- data/docs/reference.md +12 -0
- data/{bin → exe}/sonic +3 -3
- data/lib/bash_scripts/docker-exec.sh +1 -0
- data/lib/bash_scripts/docker-run.sh +8 -1
- data/lib/sonic.rb +11 -3
- data/lib/sonic/{aws_services.rb → aws_service.rb} +6 -1
- data/lib/sonic/base_command.rb +82 -0
- data/lib/sonic/checks.rb +2 -2
- data/lib/sonic/cli.rb +41 -29
- data/lib/sonic/command.rb +8 -22
- data/lib/sonic/completer.rb +161 -0
- data/lib/sonic/completer/script.rb +6 -0
- data/lib/sonic/completer/script.sh +10 -0
- data/lib/sonic/core.rb +15 -0
- data/lib/sonic/default/settings.yml +9 -16
- data/lib/sonic/docker.rb +30 -2
- data/lib/sonic/ecs.rb +22 -0
- data/lib/sonic/execute.rb +203 -51
- data/lib/sonic/help.rb +9 -0
- data/lib/sonic/help/command/send.md +10 -0
- data/lib/sonic/help/completion.md +22 -0
- data/lib/sonic/help/completion_script.md +3 -0
- data/lib/sonic/help/ecs/exec.md +8 -0
- data/lib/sonic/help/ecs/sh.md +13 -0
- data/lib/sonic/help/execute.md +59 -0
- data/lib/sonic/help/list.md +17 -0
- data/lib/sonic/help/ssh.md +60 -0
- data/lib/sonic/list.rb +5 -2
- data/lib/sonic/setting.rb +47 -0
- data/lib/sonic/ssh.rb +42 -23
- data/lib/sonic/ssh/identifier_detector.rb +7 -3
- data/lib/sonic/ui.rb +2 -2
- data/lib/sonic/version.rb +1 -1
- data/sonic.gemspec +14 -9
- data/spec/lib/cli_spec.rb +11 -11
- data/spec/lib/sonic/execute_spec.rb +1 -2
- data/spec/spec_helper.rb +18 -10
- metadata +115 -19
- data/Gemfile.lock +0 -134
- data/docs/_docs/tutorial-ecs-run.md +0 -100
- data/lib/sonic/cli/help.rb +0 -152
- data/lib/sonic/settings.rb +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca0ee2f6b882f119c6e607c3de2c38391c8c17236f9ef892211cb55e887c7c95
|
4
|
+
data.tar.gz: a4592ac7afc7d3c875be3f02b26f5a884d2bd09423f518cf53fc5b027c963436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4c02076435af8641128a6487769362b4a3cb4f428a88fe07f14cb0455f8a5ab3bf80ea1950748b9ea0690307e7c38f4f779165e01a3e5279801ad798e4b279f
|
7
|
+
data.tar.gz: f0a7a5cea95e05190b5cf2fe767cc212d49e4063b9cfd4e04c18fb95ed20f2ae4b59b7bfe5a245b1616750aba6eb562ab53cddc196034af98977f8c25af56845
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/bin/bash -eux
|
2
|
+
|
3
|
+
# Even though specs also generate docs, lets run again to ensure clean slate
|
4
|
+
bundle exec rake docs
|
5
|
+
|
6
|
+
out=$(git status docs)
|
7
|
+
if [[ "$out" = *"nothing to commit"* ]]; then
|
8
|
+
exit
|
9
|
+
fi
|
10
|
+
|
11
|
+
COMMIT_MESSAGE="docs updated by circleci"
|
12
|
+
|
13
|
+
# If the last commit already updated the docs, then exit.
|
14
|
+
# Preventable measure to avoid infinite loop.
|
15
|
+
if git log -1 --pretty=oneline | grep "$COMMIT_MESSAGE" ; then
|
16
|
+
exit
|
17
|
+
fi
|
18
|
+
|
19
|
+
# If reach here, we have some changes on docs that we should commit.
|
20
|
+
# Even though s
|
21
|
+
git add docs
|
22
|
+
git commit -m "$COMMIT_MESSAGE"
|
23
|
+
|
24
|
+
# https://makandracards.com/makandra/12107-git-show-current-branch-name-only
|
25
|
+
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
26
|
+
git push origin "$current_branch"
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
docker:
|
9
|
+
# specify the version you desire here
|
10
|
+
- image: circleci/ruby:2.6.5-node-browsers
|
11
|
+
|
12
|
+
# Specify service dependencies here if necessary
|
13
|
+
# CircleCI maintains a library of pre-built images
|
14
|
+
# documented at https://circleci.com/docs/2.0/circleci-images/
|
15
|
+
# - image: circleci/postgres:9.4
|
16
|
+
|
17
|
+
working_directory: ~/repo
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- checkout
|
21
|
+
|
22
|
+
- run:
|
23
|
+
name: submodule sync
|
24
|
+
command: |
|
25
|
+
git submodule sync
|
26
|
+
git submodule update --init
|
27
|
+
|
28
|
+
# Download and cache dependencies
|
29
|
+
- restore_cache:
|
30
|
+
keys:
|
31
|
+
- v1-dependencies-{{ checksum "Gemfile" }}
|
32
|
+
# fallback to using the latest cache if no exact match is found
|
33
|
+
- v1-dependencies-
|
34
|
+
|
35
|
+
- run:
|
36
|
+
name: install dependencies
|
37
|
+
command: |
|
38
|
+
gem install bundler
|
39
|
+
gem update --system
|
40
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
41
|
+
|
42
|
+
- save_cache:
|
43
|
+
paths:
|
44
|
+
- ./vendor/bundle
|
45
|
+
key: v1-dependencies-{{ checksum "Gemfile" }}
|
46
|
+
|
47
|
+
# specs need git configured ad commit_docs.sh required it also
|
48
|
+
- run:
|
49
|
+
name: configure git
|
50
|
+
command: |
|
51
|
+
git config --global user.email "tongueroo@gmail.com"
|
52
|
+
git config --global user.name "Tung Nguyen"
|
53
|
+
|
54
|
+
# run tests!
|
55
|
+
- run:
|
56
|
+
name: run tests
|
57
|
+
command: |
|
58
|
+
mkdir /tmp/test-results
|
59
|
+
bundle exec rspec
|
60
|
+
|
61
|
+
- run:
|
62
|
+
name: commit cli reference docs
|
63
|
+
command: |
|
64
|
+
chmod a+x -R .circleci/bin
|
65
|
+
.circleci/bin/commit_docs.sh
|
66
|
+
|
67
|
+
# collect reports
|
68
|
+
- store_test_results:
|
69
|
+
path: /tmp/test-results
|
70
|
+
- store_artifacts:
|
71
|
+
path: /tmp/test-results
|
72
|
+
destination: test-results
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,33 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
|
-
This project *
|
4
|
+
This project *loosely* adheres to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
|
+
|
6
|
+
## [2.2.1] - 2021-04-12
|
7
|
+
- [#9](https://github.com/boltops-tools/sonic/pull/9) improve command array handling
|
8
|
+
|
9
|
+
## [2.2.0]
|
10
|
+
- #7 sonic execute command: `--tags` and `--instance-id` options instead of polymorphic list. Breaking behavior.
|
11
|
+
- display output even if tags used
|
12
|
+
- configure default log group
|
13
|
+
- correct exit status
|
14
|
+
|
15
|
+
## [2.1.1]
|
16
|
+
- use rainbow gem for terminal colors
|
17
|
+
|
18
|
+
## [2.1.0]
|
19
|
+
- change the setting format to ssh.user instead of bastion.user
|
20
|
+
|
21
|
+
## [2.0.0]
|
22
|
+
- Merge pull request #5 from boltopslabs/cli-template-upgrade
|
23
|
+
- improve css for docs site
|
24
|
+
- add CLI reference docs
|
25
|
+
- use JumpProxy option for bastion
|
26
|
+
- change the way settings work, usage of SONIC_PROFILE and AWS_PROFILE and separate files
|
27
|
+
- Big restructuring of sonic commands:
|
28
|
+
- sonic ecs exec
|
29
|
+
- sonic ecs run
|
30
|
+
- sonic execute # much improved and added conveniences
|
5
31
|
|
6
32
|
## [1.4.0]
|
7
33
|
- only use required aws-sdk modules
|
@@ -29,8 +55,8 @@ This project *tries* to adhere to [Semantic Versioning](http://semver.org/), eve
|
|
29
55
|
- standardize filter to be first argument
|
30
56
|
|
31
57
|
## [1.0.0]
|
32
|
-
- sonic ecs
|
33
|
-
- sonic ecs
|
58
|
+
- sonic ecs exec
|
59
|
+
- sonic ecs sh
|
34
60
|
- sonic execute
|
35
61
|
- sonic list
|
36
62
|
- sonic ssh
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
# Specify your gem
|
3
|
+
# Specify your gem dependencies in sonic.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem "codeclimate-test-reporter", group: :test, require: nil
|
6
|
+
gem "codeclimate-test-reporter", group: :test, require: nil
|
data/Guardfile
CHANGED
@@ -1,12 +1,19 @@
|
|
1
|
-
guard
|
2
|
-
watch(
|
3
|
-
watch(
|
4
|
-
watch(%r{^lib/sonic/(.+)\.rb$}) { "spec/sonic_spec.rb" }
|
5
|
-
watch('spec/spec_helper.rb') { "spec/sonic_spec.rb" }
|
6
|
-
watch(%r{^lib/sonic/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
1
|
+
guard "bundler", cmd: "bundle" do
|
2
|
+
watch("Gemfile")
|
3
|
+
watch(/^.+\.gemspec/)
|
7
4
|
end
|
8
5
|
|
9
|
-
guard
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
7
|
+
require "guard/rspec/dsl"
|
8
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
9
|
+
|
10
|
+
# RSpec files
|
11
|
+
rspec = dsl.rspec
|
12
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
13
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
14
|
+
watch(rspec.spec_files)
|
15
|
+
|
16
|
+
# Ruby files
|
17
|
+
ruby = dsl.ruby
|
18
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
19
|
+
end
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2018 Tung Nguyen
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
[![Gitter](https://badges.gitter.im/boltopslabs/sonic.svg)](https://gitter.im/boltopslabs/sonic?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
5
5
|
[![Support](https://img.shields.io/badge/get-support-blue.svg)](https://boltops.com?utm_source=badge&utm_medium=badge&utm_campaign=sonic)
|
6
6
|
|
7
|
+
[![BoltOps Badge](https://img.boltops.com/boltops/badges/boltops-badge.png)](https://www.boltops.com)
|
8
|
+
|
7
9
|
Sonic is a multi-functional tool that helps you manage AWS resources. Sonic contains a group of commands that help debug EC2 instances and ECS containers quickly.
|
8
10
|
|
9
11
|
See [sonic-screwdriver.cloud](http://sonic-screwdriver.cloud) for full documentation.
|
@@ -32,15 +34,7 @@ By the time I get into the container, I need to remind my brain of what the orig
|
|
32
34
|
|
33
35
|
You can install sonic with RubyGems
|
34
36
|
|
35
|
-
|
36
|
-
gem install sonic
|
37
|
-
```
|
38
|
-
|
39
|
-
If you want to quickly install sonic without having to worry about sonic's dependencies you can also install the Bolts Toolbelt which has sonic included.
|
40
|
-
|
41
|
-
```sh
|
42
|
-
brew cask install boltopslabs/software/bolts
|
43
|
-
```
|
37
|
+
gem install sonic
|
44
38
|
|
45
39
|
Full installation instructions are at [Install Sonic Screwdriver](http://sonic-screwdriver.cloud/docs/install/). There are some server side dependencies for some of the sonic commands, so it is important to read through the full installation guide.
|
46
40
|
|
@@ -48,30 +42,33 @@ Full installation instructions are at [Install Sonic Screwdriver](http://sonic-s
|
|
48
42
|
|
49
43
|
Here is a quick overview of sonic abilities:
|
50
44
|
|
51
|
-
|
52
|
-
|
53
|
-
sonic ssh
|
54
|
-
sonic ssh
|
55
|
-
sonic ssh
|
56
|
-
sonic ssh
|
57
|
-
sonic ssh
|
58
|
-
|
45
|
+
# ssh into an instance
|
46
|
+
sonic ssh i-0f7f833131a51ce35
|
47
|
+
sonic ssh demo-web # ec2 tag
|
48
|
+
sonic ssh demo-web --cluster staging # ecs service name
|
49
|
+
sonic ssh demo-web --cluster staging # ecs service name
|
50
|
+
sonic ssh 7fbc8c75-4675-4d39-a5a4-0395ff8cd474 --cluster staging # ECS container id
|
51
|
+
sonic ssh 1ed12abd-645c-4a05-9acf-739b9d790170 --cluster staging # ECS task id
|
52
|
+
|
53
|
+
# docker exec to a running ECS docker container
|
54
|
+
sonic ecs exec demo-web
|
59
55
|
|
60
|
-
# docker
|
61
|
-
sonic ecs
|
56
|
+
# docker run with the same environment as the ECS docker running containers
|
57
|
+
sonic ecs sh demo-web
|
62
58
|
|
63
|
-
#
|
64
|
-
sonic
|
59
|
+
# run command with instance ids
|
60
|
+
sonic execute --instance-ids i-111 uptime
|
61
|
+
sonic execute --instance-ids i-111,i-222 uptime
|
65
62
|
|
66
|
-
# run command on
|
67
|
-
sonic execute
|
63
|
+
# run command on all instances tagged with Name demo-web and worker
|
64
|
+
sonic execute --tags Name=demo-web,demo-worker uptime
|
68
65
|
|
69
|
-
# run command on all instances
|
70
|
-
|
66
|
+
# run command on all instances with multiple tags
|
67
|
+
# Quotes are important due to semi-colon
|
68
|
+
sonic execute --tags "Name=demo-web,demo-worker;Owner=test" uptime
|
71
69
|
|
72
|
-
# list ec2 instances
|
73
|
-
sonic list
|
74
|
-
```
|
70
|
+
# list ec2 instances
|
71
|
+
sonic list demo-web
|
75
72
|
|
76
73
|
## Contributing
|
77
74
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
3
|
|
4
|
-
task :
|
4
|
+
task default: :spec
|
5
5
|
|
6
|
-
RSpec::Core::RakeTask.new
|
6
|
+
RSpec::Core::RakeTask.new
|
7
|
+
|
8
|
+
require_relative "lib/sonic"
|
9
|
+
require "cli_markdown"
|
10
|
+
desc "Generates cli reference docs as markdown"
|
11
|
+
task :docs do
|
12
|
+
CliMarkdown::Creator.create_all(cli_class: Sonic::CLI, cli_name: "sonic")
|
13
|
+
end
|
data/docs/_config.yml
CHANGED
data/docs/_docs/help.md
CHANGED
@@ -7,21 +7,13 @@ It is common to secure your network setup by restricting access to your servers
|
|
7
7
|
You can configure the [settings.yml]({% link _docs/settings.md %}) file to use a bastion host. Here's an example:
|
8
8
|
|
9
9
|
```yaml
|
10
|
-
bastion:
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
bastion:
|
11
|
+
host: ec2-user@34.211.223.3
|
12
|
+
host_key_check: false
|
13
|
+
user: ec2-user # user for 2nd level servers
|
14
14
|
```
|
15
15
|
|
16
|
-
The
|
17
|
-
|
18
|
-
```sh
|
19
|
-
sonic ssh --cluster prod [IDENTIFER] # ec2-user@bastion.mydomain.com used as the bastion host
|
20
|
-
sonic ssh --cluster stag [IDENTIFER] # ubuntu@bastion-stag.mydomain.com used as the bastion host
|
21
|
-
sonic ssh --cluster whatever [IDENTIFER] # ec2-user@bastion.mydomain.com used as the bastion host
|
22
|
-
```
|
23
|
-
|
24
|
-
The settting directs the `sonic ssh` to jump through the bastion host. This works completely transparently. The sonic commands are exactly the same as if there is no bastion host. Examples:
|
16
|
+
The settting directs the `sonic ssh` to jump through the bastion host. This works transparently. The sonic commands are exactly the same as if there is no bastion host. Examples:
|
25
17
|
|
26
18
|
```
|
27
19
|
sonic ssh i-0f7f833131a51ce35
|
@@ -32,8 +24,6 @@ You should notice that the built up command now includes the bastion jump host.
|
|
32
24
|
```
|
33
25
|
$ sonic ssh i-0f7f833131a51ce35 uptime
|
34
26
|
=> ssh -At ec2-user@34.211.223.3 ssh ec2-user@10.10.110.135 uptime
|
35
|
-
Warning: Permanently added '34.211.223.3' (ECDSA) to the list of known hosts.
|
36
|
-
Warning: Permanently added '10.10.110.135' (ECDSA) to the list of known hosts.
|
37
27
|
18:35:18 up 1:14, 0 users, load average: 0.24, 0.07, 0.02
|
38
28
|
Connection to 34.211.223.3 closed.
|
39
29
|
$
|
data/docs/_docs/install.md
CHANGED
@@ -16,28 +16,18 @@ You can also add sonic to your Gemfile in your project if you are working with a
|
|
16
16
|
gem "sonic-screwdriver"
|
17
17
|
```
|
18
18
|
|
19
|
-
### Install with Bolts Toolbelt
|
20
|
-
|
21
|
-
If you want to install sonic without having to worry about sonic's ruby dependency you can simply install the Bolts Toolbelt which has sonic included.
|
22
|
-
|
23
|
-
```sh
|
24
|
-
brew cask install boltopslabs/software/bolts
|
25
|
-
```
|
26
|
-
|
27
|
-
For more information about the Bolts Toolbelt or to get an installer for another operating system visit: [https://boltops.com/toolbelt](https://boltops.com/toolbelt)
|
28
|
-
|
29
19
|
### Server Side Dependencies
|
30
20
|
|
31
21
|
For a small set of the commands there are server side dependencies.
|
32
22
|
|
33
|
-
#### sonic ecs
|
23
|
+
#### sonic ecs dependencies
|
34
24
|
|
35
|
-
For the `sonic ecs
|
25
|
+
For the `sonic ecs` commands to work `jq` is required on the server side. This is covered in the [How It Works]({% link _docs/how-it-works.md %}) section.
|
36
26
|
|
37
27
|
One way to install `jq` quickly is by using the `sonic execute` command. For example:
|
38
28
|
|
39
29
|
```sh
|
40
|
-
sonic execute hi-web
|
30
|
+
sonic execute hi-web yum install -y jq
|
41
31
|
```
|
42
32
|
|
43
33
|
It is recommended that you install `jq` with the UserData script or bake it into the AMI though.
|
data/docs/_docs/next-steps.md
CHANGED
@@ -14,6 +14,6 @@ From here, there are a few resources that can help you continue along:
|
|
14
14
|
Everyone can contribute to make sonic better, including the documentation. These docs are of the same sonic repo in the [docs folder](https://github.com/boltopslabs/sonic/tree/master/docs). Please fork the project and open a pull request! We love your pull requests. Contributions are encouraged and welcomed!
|
15
15
|
|
16
16
|
<a id="prev" class="btn btn-basic" href="{% link _docs/how-it-works.md %}">Back</a>
|
17
|
-
|
17
|
+
<a id="next" class="btn btn-primary" href="{% link reference.md %}">Next Step</a>
|
18
18
|
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
|
19
19
|
|
data/docs/_docs/settings.md
CHANGED
@@ -2,92 +2,78 @@
|
|
2
2
|
title: Settings
|
3
3
|
---
|
4
4
|
|
5
|
-
You can adjust the behavior of sonic and set some handy default values with
|
5
|
+
You can adjust the behavior of sonic and set some handy default values with settings files. The settings files used are determined by the value of environment variable `SONIC_PROFILE` or `AWS_PROFILE`. The value determines the settings profile to use. There can exist multiple settings files which all get loaded and merged. The options from the files follow the following precedence rules:
|
6
6
|
|
7
|
-
1. current folder - The current folder's `.sonic/
|
8
|
-
2. user - The user's `~/.sonic/
|
7
|
+
1. current folder - The current folder's `.sonic/[AWS_PROFILE].yml` values take the highest precedence. The current folder is typically the project folder.
|
8
|
+
2. user - The user's `~/.sonic/[AWS_PROFILE].yml` values take the second highest precedence.
|
9
9
|
3. default - The [default settings](https://github.com/boltopslabs/sonic/blob/master/lib/sonic/default/settings.yml) bundled with the tool takes the lowest precedence.
|
10
10
|
|
11
|
-
|
11
|
+
A concrete example helps explain it. Let's say `AWS_PROFILE=prod-profile` with the following files:
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
default: # default is nil - which means a bastion host wont be used
|
16
|
-
# Examples:
|
17
|
-
# prod: bastion.mydomain.com
|
18
|
-
# stag: ubuntu@bastion-stag.mydomain.com
|
19
|
-
host_key_check: false
|
20
|
-
service_cluster:
|
21
|
-
default: # defaults to nil
|
22
|
-
hi-web-prod: prod
|
23
|
-
hi-clock-prod: prod
|
24
|
-
hi-worker-prod: prod
|
25
|
-
hi-web-stag: stag
|
26
|
-
hi-clock-stag: stag
|
27
|
-
hi-worker-stag: stag
|
28
|
-
user: ec2-user
|
29
|
-
```
|
13
|
+
* in current folder: `.sonic/prod-profile.yml`
|
14
|
+
* in user home folder: `~/.sonic/prod-profile.yml`
|
30
15
|
|
31
|
-
|
32
|
-
|
33
|
-
Setting | Description | Default
|
34
|
-
------------- | ------------- | -------------
|
35
|
-
bastion | Bastion mapping allows you to set a bastion host on a per ECS cluster basis. The bastion host is used as the jump host. Examples: bastion.mydomain.com, myuser@bastion.myuser.com or 123.123.123.123. | (no value)
|
36
|
-
host_key_check | Controls whether or not use the strict host checking ssh option. Since EC2 server host changes often the default value is false. | false
|
37
|
-
service_cluster | Service to cluster mapping. This is a Hash structure that maps the service name to cluster names. | (no value)
|
38
|
-
user | User to ssh into the server with. This can be overriden at the CLI with the user@host notation but can be set in the settings.yml file also. | ec2-user
|
16
|
+
Then the `.sonic/prod-profile.yml` gets merged into `~/.sonic/prod-profile.yml` and that in turn gets merged into sonic's [default settings](https://github.com/boltopslabs/sonic/blob/master/lib/sonic/default/settings.yml).
|
39
17
|
|
40
|
-
|
18
|
+
You can also use the `SONIC_PROFILE=prod-profile` environment variable instead of the `AWS_PROFILE` environment variable. The `SONIC_PROFILE` wins over the `AWS_PROFILE` value.
|
41
19
|
|
42
|
-
|
20
|
+
## Full Example
|
43
21
|
|
44
|
-
|
22
|
+
Here is an `prod-profile.yml` example:
|
45
23
|
|
46
24
|
```yaml
|
47
25
|
bastion: # cluster_host mapping
|
48
|
-
|
49
|
-
|
50
|
-
|
26
|
+
host: # default is nil - which means a bastion host wont be used
|
27
|
+
host_key_check: false
|
28
|
+
|
29
|
+
ssh:
|
30
|
+
user: ec2-user
|
31
|
+
|
32
|
+
# used with `sonic ecs ssh` command
|
33
|
+
ecs_service_cluster_map:
|
34
|
+
default: default # default cluster
|
35
|
+
hi-web: production
|
36
|
+
hi-clock: production
|
37
|
+
hi-worker: production
|
51
38
|
```
|
52
39
|
|
53
|
-
|
40
|
+
The following table covers the different setting options:
|
54
41
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
42
|
+
Setting | Description | Default
|
43
|
+
------------- | ------------- | -------------
|
44
|
+
bastion.host | Bastion mapping allows you to set a bastion host on a per ECS cluster basis. The bastion host is used as the jump host. Examples: bastion.mydomain.com, myuser@bastion.myuser.com or 123.123.123.123. | (no value)
|
45
|
+
bastion.host_key_check | Controls whether or not use the strict host checking ssh option. Since EC2 server host changes often the default value is false. | false
|
46
|
+
ecs_service_cluster_map | Service to cluster mapping. This is a Hash structure that maps the service name to cluster names. | (no value)
|
47
|
+
ssh.user | User to ssh into the server with. This can be overriden at the CLI with the user@host notation but can be set in the settings.yml file also. | ec2-user
|
48
|
+
|
49
|
+
The default settings are located tool source code at [lib/sonic/default/settings.yml](https://github.com/boltopslabs/sonic/blob/master/lib/sonic/default/settings.yml).
|
60
50
|
|
61
51
|
### Service to Cluster Mapping
|
62
52
|
|
63
|
-
|
53
|
+
A useful option is the `ecs_service_cluster_map`. This option maps ecs service names to cluster names. This saves you from typing the `--cluster` option repeatedly. Here is an example `~/.sonic/settings.yml`:
|
64
54
|
|
65
55
|
```yaml
|
66
|
-
|
67
|
-
service_cluster:
|
56
|
+
ecs_service_cluster_map:
|
68
57
|
default: my-default-cluster
|
69
|
-
hi-web
|
70
|
-
hi-clock
|
71
|
-
hi-worker
|
72
|
-
hi-web-stag: stag
|
73
|
-
hi-clock-stag: stag
|
74
|
-
hi-worker-stag: stag
|
58
|
+
hi-web: production
|
59
|
+
hi-clock: production
|
60
|
+
hi-worker: production
|
75
61
|
```
|
76
62
|
|
77
63
|
This results in shorter commands:
|
78
64
|
|
79
65
|
```
|
80
|
-
sonic ssh hi-web
|
81
|
-
sonic ssh hi-clock
|
82
|
-
sonic ssh hi-worker
|
66
|
+
sonic ecs ssh hi-web
|
67
|
+
sonic ecs ssh hi-clock
|
68
|
+
sonic ecs ssh hi-worker
|
83
69
|
```
|
84
70
|
|
85
71
|
Instead of what you normally would have to type:
|
86
72
|
|
87
73
|
```
|
88
|
-
sonic ssh hi-web
|
89
|
-
sonic ssh hi-clock
|
90
|
-
sonic ssh hi-worker
|
74
|
+
sonic ecs ssh hi-web --cluster production
|
75
|
+
sonic ecs ssh hi-clock --cluster production
|
76
|
+
sonic ecs ssh hi-worker --cluster production
|
91
77
|
```
|
92
78
|
|
93
79
|
|