sonic-screwdriver 1.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/bin/commit_docs.sh +26 -0
  3. data/.circleci/config.yml +70 -0
  4. data/.gitignore +1 -1
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +13 -2
  7. data/Gemfile +3 -3
  8. data/Gemfile.lock +43 -14
  9. data/Guardfile +17 -10
  10. data/LICENSE.txt +2 -2
  11. data/README.md +10 -10
  12. data/Rakefile +9 -2
  13. data/docs/_config.yml +3 -0
  14. data/docs/_docs/help.md +1 -1
  15. data/docs/_docs/install-bastion.md +5 -15
  16. data/docs/_docs/install.md +3 -3
  17. data/docs/_docs/settings.md +40 -56
  18. data/docs/_docs/tutorial-ecs-exec.md +16 -20
  19. data/docs/_docs/tutorial-ecs-sh.md +73 -0
  20. data/docs/_docs/tutorial-execute.md +93 -17
  21. data/docs/_docs/tutorial-ssh.md +13 -18
  22. data/docs/_docs/why-ec2-run-command.md +1 -1
  23. data/docs/_includes/commands.html +5 -5
  24. data/docs/_includes/content.html +5 -0
  25. data/docs/_includes/css/main.css +15 -9
  26. data/docs/_includes/css/sonic.css +7 -5
  27. data/docs/_includes/example.html +4 -4
  28. data/docs/_includes/reference.md +1 -0
  29. data/docs/_includes/subnav.html +2 -1
  30. data/docs/_reference/sonic-completion.md +44 -0
  31. data/docs/_reference/sonic-completion_script.md +25 -0
  32. data/docs/_reference/sonic-ecs-exec.md +30 -0
  33. data/docs/_reference/sonic-ecs-help.md +21 -0
  34. data/docs/_reference/sonic-ecs-sh.md +35 -0
  35. data/docs/_reference/sonic-ecs.md +25 -0
  36. data/docs/_reference/sonic-execute.md +84 -0
  37. data/docs/_reference/sonic-list.md +40 -0
  38. data/docs/_reference/sonic-ssh.md +86 -0
  39. data/docs/_reference/sonic-version.md +21 -0
  40. data/docs/img/tutorials/ec2-console-run-command.png +0 -0
  41. data/docs/quick-start.md +9 -10
  42. data/docs/reference.md +12 -0
  43. data/{bin → exe}/sonic +3 -3
  44. data/lib/bash_scripts/docker-exec.sh +1 -0
  45. data/lib/bash_scripts/docker-run.sh +8 -1
  46. data/lib/sonic.rb +10 -2
  47. data/lib/sonic/{aws_services.rb → aws_service.rb} +6 -1
  48. data/lib/sonic/base_command.rb +82 -0
  49. data/lib/sonic/cli.rb +37 -27
  50. data/lib/sonic/command.rb +8 -22
  51. data/lib/sonic/completer.rb +161 -0
  52. data/lib/sonic/completer/script.rb +6 -0
  53. data/lib/sonic/completer/script.sh +10 -0
  54. data/lib/sonic/core.rb +15 -0
  55. data/lib/sonic/default/settings.yml +6 -16
  56. data/lib/sonic/docker.rb +29 -1
  57. data/lib/sonic/ecs.rb +22 -0
  58. data/lib/sonic/execute.rb +153 -18
  59. data/lib/sonic/help.rb +9 -0
  60. data/lib/sonic/help/command/send.md +10 -0
  61. data/lib/sonic/help/completion.md +22 -0
  62. data/lib/sonic/help/completion_script.md +3 -0
  63. data/lib/sonic/help/ecs/exec.md +8 -0
  64. data/lib/sonic/help/ecs/sh.md +13 -0
  65. data/lib/sonic/help/execute.md +60 -0
  66. data/lib/sonic/help/list.md +17 -0
  67. data/lib/sonic/help/ssh.md +60 -0
  68. data/lib/sonic/list.rb +4 -1
  69. data/lib/sonic/setting.rb +47 -0
  70. data/lib/sonic/ssh.rb +41 -20
  71. data/lib/sonic/ssh/identifier_detector.rb +6 -2
  72. data/lib/sonic/version.rb +1 -1
  73. data/sonic.gemspec +14 -9
  74. data/spec/lib/cli_spec.rb +5 -10
  75. data/spec/lib/sonic/execute_spec.rb +0 -1
  76. data/spec/spec_helper.rb +18 -10
  77. metadata +115 -16
  78. data/docs/_docs/tutorial-ecs-run.md +0 -100
  79. data/lib/sonic/cli/help.rb +0 -152
  80. data/lib/sonic/settings.rb +0 -115
@@ -2,8 +2,6 @@
2
2
  title: SSH
3
3
  ---
4
4
 
5
- ### SSH
6
-
7
5
  Sonic allows you to ssh into an instance quickly.
8
6
 
9
7
  Often when working with AWS EC2 it is helpful to ssh into an instance to debug. To ssh into an instance, the first thing you do is go to the EC2 Console and grab the public IP address.
@@ -32,7 +30,7 @@ The above command effectively translates to:
32
30
  ssh ec2-user@52.24.216.170
33
31
  ```
34
32
 
35
- By default the user that sonic uses to log in to the server is `ec2-user`. You can override the user easily like so:
33
+ By default the user that sonic uses to log in to the server is `ec2-user`. You can override the user as part of the sonic command like so:
36
34
 
37
35
  ```sh
38
36
  sonic ssh ubuntu@i-0f7f833131a51ce35
@@ -48,15 +46,15 @@ More information about sonic settings in available in the docs: [Settings]({% li
48
46
 
49
47
  ### Polymorphic Identifiers
50
48
 
51
- The `sonic ssh` command can auto-detect the proper IP address with a variety of different identifiers. The identifier is not just limited to the instance id. The identifier can also be an EC2 tag-value filter, ECS service name, ECS container id or ECS task id.
49
+ The `sonic ssh` command can auto-detect the proper IP address with a variety of different identifiers. The identifier is not limited to the instance id. The identifier can be an EC2 tag-value filter, ECS service name, ECS container id or ECS task id.
52
50
 
53
51
  Polymorphic identifiers are convenient in case you happen to be on a dashboard with another identifier close by and handy. Here are examples of identifiers that `sonic ssh` understands.
54
52
 
55
53
  ```
56
54
  sonic ssh EC2_TAG_FILTER
57
- sonic ssh ECS_SERVICE --cluster stag
58
- sonic ssh ECS_CONTAINER_ID --cluster stag
59
- sonic ssh ECS_TASK_ID --cluster stag
55
+ sonic ssh ECS_SERVICE --cluster staging
56
+ sonic ssh ECS_CONTAINER_ID --cluster staging
57
+ sonic ssh ECS_TASK_ID --cluster staging
60
58
  ```
61
59
 
62
60
  The EC2 tag filter uses the 'tag-value' filter as described in the [AWS describe-instances](http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html) filter docs. This filter is independent of the tag-key filter, which means any EC2 tag value will match, regardless of the tag key name. Sonic does not support spaces in the EC2 tag filter.
@@ -64,14 +62,11 @@ The EC2 tag filter uses the 'tag-value' filter as described in the [AWS describe
64
62
  Notice, that when the `sonic ssh` is passed an ECS identifier then it also requires the ECS cluster name. The commands above with the ECS identifier are normally shorten further by configuring the a [settings]({% link _docs/settings.md %}) file. Here's an example:
65
63
 
66
64
  ```yaml
67
- service_cluster:
65
+ ecs_service_cluster_map:
68
66
  default: my-default-cluster
69
- hi-web-prod: prod
70
- hi-clock-prod: prod
71
- hi-worker-prod: prod
72
- hi-web-stag: stag
73
- hi-clock-stag: stag
74
- hi-worker-stag: stag
67
+ hi-web: production
68
+ hi-clock: production
69
+ hi-worker: production
75
70
  ```
76
71
 
77
72
  With these settings in place, the ECS identifier commands get shortened to become:
@@ -82,16 +77,16 @@ sonic ssh ECS_SERVICE
82
77
  sonic ssh ECS_TASK_ID
83
78
  ```
84
79
 
85
- It then becomes effortless to ssh into an EC2 Container Instance with the ECS service name. For example, if the ECS service name is `hi-web-stag` then the command becomes.
80
+ It then becomes effortless to ssh into an EC2 Container Instance with the ECS service name. For example, if the ECS service name is `hi-web` then the command becomes.
86
81
 
87
82
  ```sh
88
- $ sonic ssh hi-web-stag
83
+ $ sonic ssh hi-web
89
84
  # now you are on the container instance
90
85
  $ docker ps
91
86
  $ curl -s http://localhost:51678/v1/meta | jq .
92
87
  ```
93
88
 
94
- The `hi-web-stag` can be running on multiple container instances. The `sonic ssh` command chooses the first container instance that it finds. If you need to ssh into a specific container instance, then use the `sonic ssh` command with an instance id instead.
89
+ The `hi-web` can be running on multiple container instances. The `sonic ssh` command chooses the first container instance that it finds. If you need to ssh into a specific container instance, then use the `sonic ssh` command with an instance id instead.
95
90
 
96
91
  You can also use the ECS container instance arn or task id to ssh into the machine. Examples:
97
92
 
@@ -120,7 +115,7 @@ Can't ssh into the server yet. Retrying until success.
120
115
 
121
116
  ### Specifying Custom Pem or Private Keys
122
117
 
123
- It is recommended that you use ssh-agent to specify a custom private key, covered here [3 SSH tips: Ssh-agent, Tunnel, and Escaping from the Dead](https://blog.boltops.com/2017/09/21/3-ssh-tips-ssh-agent-tunnel-and-escaping-from-the-dead). You can specify the private key if you prefer with the `-i` option though. Example:
118
+ It is recommended that you use ssh-agent to specify a custom private key, covered here [3 SSH tips: Ssh-agent, Tunnel, and Escaping from the Dead](https://blog.boltops.com/2017/09/21/3-ssh-tips-ssh-agent-tunnel-and-escaping-from-the-dead). But you can specify the private key if you prefer with the `-i` option though. Example:
124
119
 
125
120
  ```sh
126
121
  $ sonic ssh -i ~/.ssh/id_rsa-custom i-0b21da68fff89937b
@@ -9,7 +9,7 @@ Why use Amazon EC2 Run Command vs just using a multi-ssh session?
9
9
  * The EC2 Run Manager has the ability to run the command in "blue/green" fashion with concurrency controls. Say you have 100 servers, you can tell EC2 Run Manager to run the command on one server first and the expodentially roll it out to the rest of the servers until the command has successfully ran on all servers. If it the command errors on one server then it halts execution and does not run on the rest of the servers.
10
10
  * This is all provided for free by using EC2 Run Manager.
11
11
 
12
- The iniitial ertia of setting up EC2 Run Manager is actually very little. The [installation instructions]({% link _docs/install.md %}) demonstrate that installing EC2 Run Manager is literally one command.
12
+ The initial ertia of setting up EC2 Run Manager is actually very little. The [installation instructions]({% link _docs/install.md %}) demonstrate that installing EC2 Run Manager is literally one command.
13
13
 
14
14
  <a id="prev" class="btn btn-basic" href="{% link _docs/why.md %}">Back</a>
15
15
  <a id="next" class="btn btn-primary" href="{% link _docs/how-it-works.md %}">Next Step</a>
@@ -11,15 +11,15 @@
11
11
  <div class="col-lg-8 col-lg-offset-2">
12
12
  <div class="commands">
13
13
  {% highlight sh %}
14
- sonic ssh
14
+ sonic ssh # ssh onto instance
15
15
 
16
- sonic ecs-run
16
+ sonic ecs sh # docker run on ECS
17
17
 
18
- sonic ecs-exec
18
+ sonic ecs exec # docker exec on ECS
19
19
 
20
- sonic list
20
+ sonic list # list servers
21
21
 
22
- sonic execute
22
+ sonic execute # run command with SSM
23
23
  {% endhighlight %}
24
24
  </div>
25
25
  </div>
@@ -8,6 +8,11 @@
8
8
  <section id="main">
9
9
  <div class="container">
10
10
  <div class="row">
11
+ {% if page.reference %}
12
+ <div class="col-md-9 reference-nav">
13
+ <a href="/reference">Back to Reference Index</a>
14
+ </div>
15
+ {% endif %}
11
16
  <div class="col-md-9 content-body">
12
17
  <h2>{{ page.title }}</h2>
13
18
  {{ content }}
@@ -9,11 +9,13 @@ body {
9
9
  }
10
10
 
11
11
  p {
12
- font-size: 20px;
12
+ /*font-size: 20px;*/
13
+ font-size: 1.2em;
13
14
  }
14
15
 
15
16
  p.small {
16
- font-size: 16px;
17
+ font-size: 1em;
18
+ /*font-size: 16px;*/
17
19
  }
18
20
 
19
21
  a,
@@ -31,16 +33,21 @@ h3,
31
33
  h4,
32
34
  h5,
33
35
  h6 {
34
- text-transform: uppercase;
35
36
  font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
36
37
  font-weight: 700;
37
38
  }
38
39
 
39
- h3,
40
- h4,
41
- h5,
42
- h6 {
43
- text-transform: none;
40
+ h1 {
41
+ font-size: 1.6em;
42
+ }
43
+ h2 {
44
+ font-size: 1.5em;
45
+ }
46
+ h3 {
47
+ font-size: 1.4em;
48
+ }
49
+ h4 {
50
+ font-size: 1.3em;
44
51
  }
45
52
 
46
53
  hr.star-light,
@@ -201,7 +208,6 @@ section {
201
208
  section h2 {
202
209
  margin: 0;
203
210
  margin-bottom: 15px;
204
- font-size: 2em;
205
211
  }
206
212
 
207
213
  section.success {
@@ -28,7 +28,7 @@ section#main .intro-text .name {
28
28
  display: block;
29
29
  text-transform: uppercase;
30
30
  font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
31
- font-size: 2em;
31
+ font-size: 1.5em;
32
32
  font-weight: 700;
33
33
  }
34
34
 
@@ -58,22 +58,23 @@ section#main .intro-text .skills {
58
58
 
59
59
  .content-body {
60
60
  text-align: left;
61
- font-size: 1.2em;
61
+ font-size: 1em;
62
62
  }
63
63
 
64
64
  .content-body h2 {
65
- text-align: center;
65
+ text-align: left;
66
66
  }
67
67
 
68
68
  .content-body ul,
69
69
  .content-body ol {
70
70
  margin-top: 0;
71
+ font-size: 17px;
71
72
  }
72
73
 
73
74
  .content-nav {
74
75
  /*background-color: green;*/
75
76
  margin-top: 40px;
76
- font-size: 1.25em;
77
+ font-size: 1.15em;
77
78
  }
78
79
 
79
80
  .content-nav ul, .content-nav ol {
@@ -95,6 +96,7 @@ section#main .intro-text .skills {
95
96
  code {
96
97
  color: #443e40;
97
98
  background-color: #cdcbd4;
99
+ font-size: 0.72em;
98
100
  }
99
101
 
100
102
  footer h3 {
@@ -140,7 +142,7 @@ ul.tools li {
140
142
  .edit-on-github h2,
141
143
  .edit-on-github p,
142
144
  .edit-on-github li {
143
- font-size: 1.5em;
145
+ /*font-size: 1.5em;*/
144
146
  }
145
147
 
146
148
  .use-cases {
@@ -10,10 +10,10 @@
10
10
  <div class='col-md-offset-1 col-md-10'>
11
11
  <p>With one command you can go from your local machine into a live ECS running docker container. Boom!</p>
12
12
  {% highlight sh %}
13
- $ sonic ecs-exec hi-web-prod --cluster stag
14
- Running: scp -r /tmp/sonic ec2-user@ec2-52-24-216-170.us-west-2.compute.amazonaws.com:/tmp/sonic > /dev/null
15
- => ssh -t ec2-user@ec2-52-24-216-170.us-west-2.compute.amazonaws.com bash /tmp/sonic/bash_scripts/docker-exec.sh
16
- root@b371924fce50:/app#
13
+ $ sonic ecs exec boltops-web
14
+ ...
15
+ + exec docker exec -ti 385b643c7a895231d2b193574368b0c6c6bebce487267c3c175d0acea3082d4c bash
16
+ root@385b643c7a89:/app#
17
17
  {% endhighlight %}
18
18
  </div>
19
19
  </div>
@@ -0,0 +1 @@
1
+ Multi-functional tool to manage AWS infrastructure. A swiss army knife with a variety of uses.
@@ -11,7 +11,7 @@
11
11
  <ul class="tutorial">
12
12
  <li><a href="{% link _docs/tutorial-ssh.md %}">SSH</a></li>
13
13
  <li><a href="{% link _docs/tutorial-ecs-exec.md %}">ECS Exec</a></li>
14
- <li><a href="{% link _docs/tutorial-ecs-run.md %}">ECS Run</a></li>
14
+ <li><a href="{% link _docs/tutorial-ecs-sh.md %}">ECS Run</a></li>
15
15
  <li><a href="{% link _docs/tutorial-execute.md %}">Execute</a></li>
16
16
  <li><a href="{% link _docs/tutorial-list.md %}">List</a></li>
17
17
  </ul>
@@ -25,5 +25,6 @@
25
25
  </li>
26
26
  <li><a href="{% link _docs/how-it-works.md %}">How It Works</a></li>
27
27
  <li><a href="{% link _docs/next-steps.md %}">Next Steps</a></li>
28
+ <li><a href="{% link reference.md %}">CLI Reference</a></li>
28
29
  </ul>
29
30
  </div>
@@ -0,0 +1,44 @@
1
+ ---
2
+ title: sonic completion
3
+ reference: true
4
+ ---
5
+
6
+ ## Usage
7
+
8
+ sonic completion *PARAMS
9
+
10
+ ## Description
11
+
12
+ Prints words for auto-completion.
13
+
14
+ Example:
15
+
16
+ sonic completion
17
+
18
+ Prints words for TAB auto-completion.
19
+
20
+ Examples:
21
+
22
+ sonic completion
23
+ sonic completion execute
24
+ sonic completion list
25
+
26
+ To enable, TAB auto-completion add the following to your profile:
27
+
28
+ eval $(sonic completion_script)
29
+
30
+ Auto-completion example usage:
31
+
32
+ sonic [TAB]
33
+ sonic exe[TAB]
34
+ sonic execute [TAB]
35
+ sonic list [TAB]
36
+
37
+
38
+ ## Options
39
+
40
+ ```
41
+ [--verbose], [--no-verbose]
42
+ [--noop], [--no-noop]
43
+ ```
44
+
@@ -0,0 +1,25 @@
1
+ ---
2
+ title: sonic completion_script
3
+ reference: true
4
+ ---
5
+
6
+ ## Usage
7
+
8
+ sonic completion_script
9
+
10
+ ## Description
11
+
12
+ Generates a script that can be eval to setup auto-completion.
13
+
14
+ To use, add the following to your `~/.bashrc` or `~/.profile`
15
+
16
+ eval $(sonic completion_script)
17
+
18
+
19
+ ## Options
20
+
21
+ ```
22
+ [--verbose], [--no-verbose]
23
+ [--noop], [--no-noop]
24
+ ```
25
+
@@ -0,0 +1,30 @@
1
+ ---
2
+ title: sonic ecs exec
3
+ reference: true
4
+ ---
5
+
6
+ ## Usage
7
+
8
+ sonic ecs exec [ECS_SERVICE]
9
+
10
+ ## Description
11
+
12
+ docker exec into running docker container associated with the service on a container instance
13
+
14
+ Ssh into an ECS container instance, finds a running docker container associated
15
+ with the service and docker exec's into it.
16
+
17
+ Examples:
18
+
19
+ $ sonic ecs exec my-service --cluster my-cluster
20
+
21
+ You can use a variety of identifiers. These include the ECS service name and task id.
22
+
23
+
24
+ ## Options
25
+
26
+ ```
27
+ [--bastion=BASTION] # Bastion jump host to use. Defaults to no bastion server.
28
+ [--cluster=CLUSTER] # ECS Cluster to use. Default cluster is default
29
+ ```
30
+
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: sonic ecs help
3
+ reference: true
4
+ ---
5
+
6
+ ## Usage
7
+
8
+ sonic ecs help [COMMAND]
9
+
10
+ ## Description
11
+
12
+ Describe subcommands or one specific subcommand
13
+
14
+
15
+ ## Options
16
+
17
+ ```
18
+ [--bastion=BASTION] # Bastion jump host to use. Defaults to no bastion server.
19
+ [--cluster=CLUSTER] # ECS Cluster to use. Default cluster is default
20
+ ```
21
+
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: sonic ecs sh
3
+ reference: true
4
+ ---
5
+
6
+ ## Usage
7
+
8
+ sonic ecs sh [ECS_SERVICE]
9
+
10
+ ## Description
11
+
12
+ docker run with the service on a container instance
13
+
14
+ Ssh into an ECS container instance and runs a docker container using the same
15
+ environment and image as the specified running service.
16
+
17
+ Examples:
18
+
19
+ $ sonic ecs sh --cluster my-cluster my-service
20
+ $ sonic ecs sh --cluster my-cluster my-service
21
+
22
+ # If there are flags in the command that you want to pass down to the docker
23
+ run command you will need to put the command in single quotes. This is due to
24
+ the way Thor (what this tool uses) parses options.
25
+
26
+ $ sonic ecs sh --cluster production-hi hi-web 'rake -T'
27
+
28
+
29
+ ## Options
30
+
31
+ ```
32
+ [--bastion=BASTION] # Bastion jump host to use. Defaults to no bastion server.
33
+ [--cluster=CLUSTER] # ECS Cluster to use. Default cluster is default
34
+ ```
35
+
@@ -0,0 +1,25 @@
1
+ ---
2
+ title: sonic ecs
3
+ reference: true
4
+ ---
5
+
6
+ ## Usage
7
+
8
+ sonic ecs SUBCOMMAND
9
+
10
+ ## Description
11
+
12
+ ecs subcommands
13
+
14
+ ## Subcommands
15
+
16
+ * [sonic ecs exec]({% link _reference/sonic-ecs-exec.md %}) - docker exec into running docker container associated with the service on a container instance
17
+ * [sonic ecs sh]({% link _reference/sonic-ecs-sh.md %}) - docker run with the service on a container instance
18
+
19
+ ## Options
20
+
21
+ ```
22
+ [--verbose], [--no-verbose]
23
+ [--noop], [--no-noop]
24
+ ```
25
+