sonic-screwdriver 1.4.0 → 2.2.1

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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/bin/commit_docs.sh +26 -0
  3. data/.circleci/config.yml +72 -0
  4. data/.gitignore +2 -1
  5. data/CHANGELOG.md +29 -3
  6. data/Gemfile +3 -3
  7. data/Guardfile +17 -10
  8. data/LICENSE.txt +2 -2
  9. data/README.md +25 -28
  10. data/Rakefile +9 -2
  11. data/docs/_config.yml +3 -0
  12. data/docs/_docs/help.md +1 -1
  13. data/docs/_docs/install-bastion.md +5 -15
  14. data/docs/_docs/install.md +3 -13
  15. data/docs/_docs/next-steps.md +1 -1
  16. data/docs/_docs/settings.md +42 -56
  17. data/docs/_docs/tutorial-ecs-exec.md +16 -20
  18. data/docs/_docs/tutorial-ecs-sh.md +73 -0
  19. data/docs/_docs/tutorial-execute.md +106 -38
  20. data/docs/_docs/tutorial-ssh.md +15 -19
  21. data/docs/_docs/why-ec2-run-command.md +1 -1
  22. data/docs/_includes/commands.html +5 -5
  23. data/docs/_includes/content.html +5 -0
  24. data/docs/_includes/css/main.css +15 -9
  25. data/docs/_includes/css/sonic.css +7 -5
  26. data/docs/_includes/example.html +4 -4
  27. data/docs/_includes/footer.html +6 -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 +85 -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/bin/web +1 -1
  41. data/docs/img/tutorials/ec2-console-run-command.png +0 -0
  42. data/docs/quick-start.md +17 -22
  43. data/docs/reference.md +12 -0
  44. data/{bin → exe}/sonic +3 -3
  45. data/lib/bash_scripts/docker-exec.sh +1 -0
  46. data/lib/bash_scripts/docker-run.sh +8 -1
  47. data/lib/sonic.rb +11 -3
  48. data/lib/sonic/{aws_services.rb → aws_service.rb} +6 -1
  49. data/lib/sonic/base_command.rb +82 -0
  50. data/lib/sonic/checks.rb +2 -2
  51. data/lib/sonic/cli.rb +41 -29
  52. data/lib/sonic/command.rb +8 -22
  53. data/lib/sonic/completer.rb +161 -0
  54. data/lib/sonic/completer/script.rb +6 -0
  55. data/lib/sonic/completer/script.sh +10 -0
  56. data/lib/sonic/core.rb +15 -0
  57. data/lib/sonic/default/settings.yml +9 -16
  58. data/lib/sonic/docker.rb +30 -2
  59. data/lib/sonic/ecs.rb +22 -0
  60. data/lib/sonic/execute.rb +203 -51
  61. data/lib/sonic/help.rb +9 -0
  62. data/lib/sonic/help/command/send.md +10 -0
  63. data/lib/sonic/help/completion.md +22 -0
  64. data/lib/sonic/help/completion_script.md +3 -0
  65. data/lib/sonic/help/ecs/exec.md +8 -0
  66. data/lib/sonic/help/ecs/sh.md +13 -0
  67. data/lib/sonic/help/execute.md +59 -0
  68. data/lib/sonic/help/list.md +17 -0
  69. data/lib/sonic/help/ssh.md +60 -0
  70. data/lib/sonic/list.rb +5 -2
  71. data/lib/sonic/setting.rb +47 -0
  72. data/lib/sonic/ssh.rb +42 -23
  73. data/lib/sonic/ssh/identifier_detector.rb +7 -3
  74. data/lib/sonic/ui.rb +2 -2
  75. data/lib/sonic/version.rb +1 -1
  76. data/sonic.gemspec +14 -9
  77. data/spec/lib/cli_spec.rb +11 -11
  78. data/spec/lib/sonic/execute_spec.rb +1 -2
  79. data/spec/spec_helper.rb +18 -10
  80. metadata +115 -19
  81. data/Gemfile.lock +0 -134
  82. data/docs/_docs/tutorial-ecs-run.md +0 -100
  83. data/lib/sonic/cli/help.rb +0 -152
  84. data/lib/sonic/settings.rb +0 -115
@@ -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>
@@ -6,10 +6,12 @@
6
6
  <div class="footer-col col-md-4">
7
7
  <h3>More Tools</h3>
8
8
  <ul class="list-unstyled tools">
9
- <li><a href="http://jack-eb.com">Jack</a></li>
10
- <li><a href="http://lono.cloud">Lono</a></li>
11
- <li><a href="http://ufoships.com">Ufo</a></li>
12
- <li><a href="https://boltops.com/toolbelt">Toolbelt</a></li>
9
+ <li><a href="https://terraspace.cloud">Terraspace</a></li>
10
+ <li><a href="https://kubes.guru">Kubes</a></li>
11
+ <li><a href="https://rubyonjets.com">Jets</a></li>
12
+ <li><a href="https://ufoships.com">Ufo</a></li>
13
+ <li><a href="https://lono.cloud">Lono</a></li>
14
+ <li><a href="https://jack-eb.com">Jack</a></li>
13
15
  </ul>
14
16
  </div>
15
17
  <div class="footer-col col-md-4">
@@ -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
+
@@ -0,0 +1,85 @@
1
+ ---
2
+ title: sonic execute
3
+ reference: true
4
+ ---
5
+
6
+ ## Usage
7
+
8
+ sonic execute [FILTER] [COMMAND]
9
+
10
+ ## Description
11
+
12
+ Runs command across fleet of servers via AWS Run Command.
13
+
14
+ * A filter must be provided. The filter can be a mix of instance ids and ec2 tags.
15
+ * The command can be provided inline or as a file. To a file use `file://` at the beginning of your file.
16
+
17
+ ## Examples Summary
18
+
19
+ sonic execute --tags Name=demo-web uptime
20
+ sonic execute --tags Name=demo-web,demo-worker uptime # multiple values
21
+ sonic execute --instance-ids i-030033c20c54bf149,i-030033c20c54bf150 uname -a
22
+ sonic execute --instance-ids i-030033c20c54bf149 file://hello.sh # script from file
23
+
24
+ You cannot mix instance ids and tag names in the filter.
25
+
26
+ ## Example Detailed
27
+
28
+ Here's a command example output in detailed:
29
+
30
+ $ sonic execute --instance-ids i-0bf51a000ab4e73a8 uptime
31
+ Sending command to SSM with options:
32
+ ---
33
+ instance_ids:
34
+ - i-0bf51a000ab4e73a8
35
+ document_name: AWS-RunShellScript
36
+ comment: sonic execute --instance-ids i-0bf51a000ab4e73a8 uptime
37
+ parameters:
38
+ commands:
39
+ - uptime
40
+ output_s3_region: us-east-1
41
+ output_s3_bucket_name: [reacted]
42
+ output_s3_key_prefix: ssm/commands/sonic
43
+
44
+ Command sent to AWS SSM. To check the details of the command:
45
+ aws ssm list-commands --command-id 0bb18d58-6436-49fd-9bfd-0c4b6c51c7a2
46
+ aws ssm get-command-invocation --command-id 0bb18d58-6436-49fd-9bfd-0c4b6c51c7a2 --instance-id i-0bf51a000ab4e73a8
47
+
48
+ Waiting for ssm command to finish.....
49
+ Command finished.
50
+
51
+ Displaying output for i-0bf51a000ab4e73a8.
52
+ Command status: Success
53
+ Command standard output:
54
+ 01:08:10 up 8 days, 6:41, 0 users, load average: 0.00, 0.00, 0.00
55
+
56
+ To see the more output details visit:
57
+ https://us-west-2.console.aws.amazon.com/systems-manager/run-command/0bb18d58-6436-49fd-9bfd-0c4b6c51c7a2
58
+
59
+ Pro tip: the console url is already in your copy/paste clipboard.
60
+ $
61
+
62
+ Notice the conveniences of `sonic execute`, it:
63
+
64
+ 1. Showed the parameters that will be sent as part of the send_command call to SSM.
65
+ 2. Sent the command to SSM.
66
+ 3. Waited for the command to finish.
67
+ 4. Displayed the output of the command.
68
+ 5. Provided the console url that visit to view more details about the SSM command.
69
+
70
+ The AWS SSM console looks like this:
71
+
72
+ <img src="/img/tutorials/ec2-console-run-command.png" class="doc-photo" />
73
+
74
+
75
+ ## Options
76
+
77
+ ```
78
+ [--zero-warn], [--no-zero-warn] # Warns user when no instances found
79
+ # Default: true
80
+ [--instance-ids=INSTANCE_IDS] # Instance ids to execute command on. Format: --instance-ids "i-111,i-222"
81
+ [--tags=TAGS] # Tags used to determine what instances to execute command on. Format: --tags "Key1=v1,v2;Key2=v3"
82
+ [--verbose], [--no-verbose]
83
+ [--noop], [--no-noop]
84
+ ```
85
+