cheftacular 2.15.1 → 2.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cheftacular/README.md +68 -60
- data/lib/cheftacular/actions/db_console.rb +1 -1
- data/lib/cheftacular/actions/deploy.rb +1 -1
- data/lib/cheftacular/actions/migrate.rb +1 -1
- data/lib/cheftacular/actions/run.rb +1 -1
- data/lib/cheftacular/auditor.rb +5 -3
- data/lib/cheftacular/file_system.rb +1 -1
- data/lib/cheftacular/helper.rb +1 -1
- data/lib/cheftacular/parser.rb +10 -0
- data/lib/cheftacular/stateless_actions/env_ssh_exec.rb +60 -0
- data/lib/cheftacular/stateless_actions/environment.rb +2 -1
- data/lib/cheftacular/stateless_actions/pass.rb +6 -4
- data/lib/cheftacular/stateless_actions/server_update.rb +1 -1
- data/lib/cheftacular/stateless_actions/ssh.rb +12 -2
- data/lib/cheftacular/version.rb +1 -1
- data/lib/sshkit/getters.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05f90c2978ae89eb69550b45a8784c274b114fe9
|
4
|
+
data.tar.gz: 6406c670ac6daf9b05d7852f655678d001f1007d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7067830d11b95fad95e141022d575d94697bac18a72b96b2d44de035cb02808e3a38532237cccde2ac77dd77f8f6d05ff228db5819d5d73b9528db403a27d4d2
|
7
|
+
data.tar.gz: 887a72065e1ace867ed8fcb7fd6fca9fde90d282a67907f517bc98b9544ff90ee57bc4c1defd9a811a22ca5cab6a659ba979045f55dced0bc5363882b5deb382
|
data/lib/cheftacular/README.md
CHANGED
@@ -184,7 +184,11 @@
|
|
184
184
|
|
185
185
|
12. `cft disk_report` will fetch useful statistics from every server for every environment and output it into your log directory.
|
186
186
|
|
187
|
-
13. `cft
|
187
|
+
13. `cft env_ssh_exec [command]` will ssh into each server in an environment and run the command as sudo.
|
188
|
+
|
189
|
+
1. To deactivate logstash: `cft env_ssh_exec sv stop logstash_agent`
|
190
|
+
|
191
|
+
14. `cft environment boot|boot_without_deploy|destroy|destroy_raw_servers [SERVER_NAMES]` will boot / destroy the current environment
|
188
192
|
|
189
193
|
1. `boot` will spin up servers and bring them to a stable state. This includes setting up their subdomains for the target environment.
|
190
194
|
|
@@ -200,9 +204,9 @@
|
|
200
204
|
|
201
205
|
7. This command works with all the flags that `cft deploy` works with, like -Z -z -O and so on.
|
202
206
|
|
203
|
-
8. Aliased to `cft e`
|
207
|
+
8. Aliased to `cft e` and `cft env`
|
204
208
|
|
205
|
-
|
209
|
+
15. `cft file NODE_NAME LOCATION_ALIAS MODE FILE_NAME` interacts with a file on the remote server
|
206
210
|
|
207
211
|
1. `LOCATION_ALIAS` will be parsed as a path if it has backslash characters. Otherwise it will be parsed from your location_aliases hash in your cheftacular.yml
|
208
212
|
|
@@ -232,35 +236,35 @@
|
|
232
236
|
|
233
237
|
1. `--save-to-file FILE_PATH` can also be used in the `fetch` context to specify where exactly to save the file and what to name it as.
|
234
238
|
|
235
|
-
|
239
|
+
16. `cft fix_known_hosts [HOSTNAME]` this command will delete entries in your known_hosts file for all the servers that are in our system (ip addresses AND dns names)
|
236
240
|
|
237
241
|
1. Passing in a hostname will make the command only remove entries with that hostname / ip specifically
|
238
242
|
|
239
243
|
2. Aliased to `cft fkh`
|
240
244
|
|
241
|
-
|
245
|
+
17. `cft get_active_ssh_connections` will fetch the active ssh connections from every server and output it into your log directory.
|
242
246
|
|
243
247
|
1. This command runs on all servers in an environment by default
|
244
248
|
|
245
249
|
2. Packets can be examined more closely with `tcpdump src port PORT`
|
246
250
|
|
247
|
-
|
251
|
+
18. `cft get_haproxy_log` this command will generate a haproxy html file for the load balancer(s) associated with a repository in the log directory. Opening this log file in the browser will show the status of that haproxy at the time of the log.
|
248
252
|
|
249
253
|
1. In devops mode, this command will not do anything without the -R repository passed.
|
250
254
|
|
251
|
-
|
255
|
+
19. `cft get_log_from_bag <NODE_NAME-COMMAND_TYPE>` this command grabs the latest command run log from the data bags and saves it to your log directory. There are different types of logs saved per server depending on command.
|
252
256
|
|
253
|
-
|
257
|
+
20. `cft get_pg_pass ['clip']` command will output the current environment's pg_password to your terminal. Optionally you can pass in clip like `cft get_pg_pass clip` to have it also copy the pass to your clipboard.
|
254
258
|
|
255
|
-
|
259
|
+
21. `cft help COMMAND|MODE` this command returns the documentation for a specific command if COMMAND matches the name of a command. Alternatively, it can be passed `action|arguments|application|current|devops|stateless_action` to fetch the commands for a specific mode.Misspellings of commands will display near hits.
|
256
260
|
|
257
|
-
|
261
|
+
22. `cft list_toggleable_roles NODE_NAME` This command will allow you to see all toggleable roles for a node
|
258
262
|
|
259
|
-
|
263
|
+
23. `cft location_aliases` will list all location aliases listed in your cheftacular.yml. These aliases can be used in the `cft file` command.
|
260
264
|
|
261
265
|
1. This command is aliased to `cft la`
|
262
266
|
|
263
|
-
|
267
|
+
24. `cft log` this command will output the last 500 lines of logs from every server set for the repository (can be given additional args to specify) to the log directory
|
264
268
|
|
265
269
|
1. `--nginx` will fetch the nginx logs as well as the application logs
|
266
270
|
|
@@ -272,13 +276,13 @@
|
|
272
276
|
|
273
277
|
4. `--fetch-backup` If doing a pg_data log, this will fetch the latest logs from the pg_data log directory for each database.
|
274
278
|
|
275
|
-
|
279
|
+
25. `cft migrate` this command will grab the first alphabetical node for a repository and run a migration that will hit the database primary server.
|
276
280
|
|
277
281
|
1. Currently only supports rails stacks.
|
278
282
|
|
279
|
-
|
283
|
+
26. `cft pass NODE_NAME` will drop the server's sudo password into your clipboard. Useful for when you need to ssh into the server itself and try advanced linux commands
|
280
284
|
|
281
|
-
|
285
|
+
27. `cft role_toggle NODE_NAME ROLE_NAME activate|deactivate` This command will allow you to **toggle** roles on nodes without using `cft upload_nodes`
|
282
286
|
|
283
287
|
1. This command uses your *role_toggling:deactivated_role_suffix* attribute set in your cheftacular.yml to toggle the role, it checks to see if the toggled name exists then sets the node's run_list to include the toggled role
|
284
288
|
|
@@ -292,7 +296,7 @@
|
|
292
296
|
|
293
297
|
4. Aliased to `cft rt`
|
294
298
|
|
295
|
-
|
299
|
+
28. `cft run COMMAND [--all]` will trigger the command on the first server in the role. Can be used to run rake commands or anything else.
|
296
300
|
|
297
301
|
1. `--all` will make the command run against all servers in a role rather than the first server it comes across. Don't do this if you're modifying the database with the command.
|
298
302
|
|
@@ -304,15 +308,15 @@
|
|
304
308
|
|
305
309
|
5. Can also be used to run meteor commands and is aliased to `cft meteor`
|
306
310
|
|
307
|
-
|
311
|
+
29. `cft scale up|down [NUM_TO_SCALE]` will add (or remove) NUM_TO_SCALE servers from the server array. This command will not let you scale down below 1 server.
|
308
312
|
|
309
313
|
1. In the case of server creation, this command takes a great deal of time to execute. It will output what stage it is currently on to the terminal but <b>you must not kill this command while it is executing</b>.A failed build may require the server to be destroyed / examined by a DevOps engineer.
|
310
314
|
|
311
|
-
|
315
|
+
30. `cft ssh NODE_NAME [exec] [command]` ssh you into the node name you are trying to access. It will also drop the server's sudo password into your clipboard.
|
312
316
|
|
313
317
|
1. `cft ssh NODE_NAME exec COMMAND` will execute a command on the server as root
|
314
318
|
|
315
|
-
|
319
|
+
31. `cft tail [PATTERN_TO_MATCH]` will tail the logs (return continuous output) of the first node if finds that has an application matching the repository running on it. Currently only supports rails stacks
|
316
320
|
|
317
321
|
1. pass `-n NODE_NAME` to grab the output of a node other than the first.
|
318
322
|
|
@@ -320,15 +324,15 @@
|
|
320
324
|
|
321
325
|
3. if the `PATTERN_TO_MATCH` argument exists, the tail will only return entries that have that pattern rather than everything written to the file.
|
322
326
|
|
323
|
-
|
327
|
+
32. `cft update_cheftacular` this command attempts to update cheftacular to the latest version.
|
324
328
|
|
325
|
-
|
329
|
+
33. `cft verify` Checks to see if the servers for the current state are running the latest commits.
|
326
330
|
|
327
331
|
1. This command is functionally the same as `cft check verify`.
|
328
332
|
|
329
333
|
2. This command is aliased to `cft ve`
|
330
334
|
|
331
|
-
|
335
|
+
34. `cft version` this command prints out the current version of cheftacular.
|
332
336
|
|
333
337
|
1. Aliased to `cft v`
|
334
338
|
|
@@ -531,7 +535,11 @@
|
|
531
535
|
|
532
536
|
18. `cft disk_report` will fetch useful statistics from every server for every environment and output it into your log directory.
|
533
537
|
|
534
|
-
19. `cft
|
538
|
+
19. `cft env_ssh_exec [command]` will ssh into each server in an environment and run the command as sudo.
|
539
|
+
|
540
|
+
1. To deactivate logstash: `cft env_ssh_exec sv stop logstash_agent`
|
541
|
+
|
542
|
+
20. `cft environment boot|boot_without_deploy|destroy|destroy_raw_servers [SERVER_NAMES]` will boot / destroy the current environment
|
535
543
|
|
536
544
|
1. `boot` will spin up servers and bring them to a stable state. This includes setting up their subdomains for the target environment.
|
537
545
|
|
@@ -547,9 +555,9 @@
|
|
547
555
|
|
548
556
|
7. This command works with all the flags that `cft deploy` works with, like -Z -z -O and so on.
|
549
557
|
|
550
|
-
8. Aliased to `cft e`
|
558
|
+
8. Aliased to `cft e` and `cft env`
|
551
559
|
|
552
|
-
|
560
|
+
21. `cft file NODE_NAME LOCATION_ALIAS MODE FILE_NAME` interacts with a file on the remote server
|
553
561
|
|
554
562
|
1. `LOCATION_ALIAS` will be parsed as a path if it has backslash characters. Otherwise it will be parsed from your location_aliases hash in your cheftacular.yml
|
555
563
|
|
@@ -579,41 +587,41 @@
|
|
579
587
|
|
580
588
|
1. `--save-to-file FILE_PATH` can also be used in the `fetch` context to specify where exactly to save the file and what to name it as.
|
581
589
|
|
582
|
-
|
590
|
+
22. `cft fix_known_hosts [HOSTNAME]` this command will delete entries in your known_hosts file for all the servers that are in our system (ip addresses AND dns names)
|
583
591
|
|
584
592
|
1. Passing in a hostname will make the command only remove entries with that hostname / ip specifically
|
585
593
|
|
586
594
|
2. Aliased to `cft fkh`
|
587
595
|
|
588
|
-
|
596
|
+
23. `cft full_bootstrap_from_queue` This command performs both ubuntu_bootstrap and chef_bootstrap.
|
589
597
|
|
590
598
|
1. This command is run by `cft cloud_bootstrap` and should not be run on its own.
|
591
599
|
|
592
|
-
|
600
|
+
24. `cft get_active_ssh_connections` will fetch the active ssh connections from every server and output it into your log directory.
|
593
601
|
|
594
602
|
1. This command runs on all servers in an environment by default
|
595
603
|
|
596
604
|
2. Packets can be examined more closely with `tcpdump src port PORT`
|
597
605
|
|
598
|
-
|
606
|
+
25. `cft get_haproxy_log` this command will generate a haproxy html file for the load balancer(s) associated with a repository in the log directory. Opening this log file in the browser will show the status of that haproxy at the time of the log.
|
599
607
|
|
600
608
|
1. In devops mode, this command will not do anything without the -R repository passed.
|
601
609
|
|
602
|
-
|
610
|
+
26. `cft get_log_from_bag <NODE_NAME-COMMAND_TYPE>` this command grabs the latest command run log from the data bags and saves it to your log directory. There are different types of logs saved per server depending on command.
|
603
611
|
|
604
|
-
|
612
|
+
27. `cft get_pg_pass ['clip']` command will output the current environment's pg_password to your terminal. Optionally you can pass in clip like `cft get_pg_pass clip` to have it also copy the pass to your clipboard.
|
605
613
|
|
606
|
-
|
614
|
+
28. `cft help COMMAND|MODE` this command returns the documentation for a specific command if COMMAND matches the name of a command. Alternatively, it can be passed `action|arguments|application|current|devops|stateless_action` to fetch the commands for a specific mode.Misspellings of commands will display near hits.
|
607
615
|
|
608
|
-
|
616
|
+
29. `cft initialize_cheftacular_yml [application|TheCheftacularCookbook]` will create a cheftacular.yml file in your config folder (and create the config folder if it does not exist). If you already have a cheftacular.yml file in the config folder, it will create a cheftacular.example.yml file that will contain the new changes / keys in the latest cheftacular version.
|
609
617
|
|
610
618
|
1. If `TheCheftacularCookbook` is passed, the generated cheftacular.yml file will include the additional TheCheftacularCookbook keys.
|
611
619
|
|
612
620
|
2. If `application` is passed, the generated cheftacular.yml file will look like one you could use in an application directory.
|
613
621
|
|
614
|
-
|
622
|
+
30. `cft initialize_data_bag_contents ENVIRONMENT_NAME` will ensure the data bags always have the correct structure before each run. This command is run every time the gem is started and if called directly, will exit after completion.
|
615
623
|
|
616
|
-
|
624
|
+
31. `cft knife_upload [force]` will resync the chef-server with the local chef-repo code. This command is analog for `knife upload /`
|
617
625
|
|
618
626
|
1. The force option will add the force option to knife upload.
|
619
627
|
|
@@ -621,31 +629,31 @@
|
|
621
629
|
|
622
630
|
3. Aliased to `cft ku`
|
623
631
|
|
624
|
-
|
632
|
+
32. `cft list_toggleable_roles NODE_NAME` This command will allow you to see all toggleable roles for a node
|
625
633
|
|
626
|
-
|
634
|
+
33. `cft location_aliases` will list all location aliases listed in your cheftacular.yml. These aliases can be used in the `cft file` command.
|
627
635
|
|
628
636
|
1. This command is aliased to `cft la`
|
629
637
|
|
630
|
-
|
638
|
+
34. `cft pass NODE_NAME` will drop the server's sudo password into your clipboard. Useful for when you need to ssh into the server itself and try advanced linux commands
|
631
639
|
|
632
|
-
|
640
|
+
35. `cft reinitialize IP_ADDRESS NODE_NAME` will reconnect a server previously managed by chef to a new chef server. The node name MUST MATCH THE NODE'S ORIGINAL NODE NAME for the roles to be setup correctly.
|
633
641
|
|
634
|
-
|
642
|
+
36. `cft remove_client NODE_NAME [destroy]` removes a client (and its node data) from the chef-server. It also removes its dns records from the cloud service (if possible). This should not be done lightly as you will have to wipe the server and trigger another chef-client run to get it to register again. Alternatively, you can run `cft reinitialize IP_ADDRESS NODE_NAME as well.
|
635
643
|
|
636
644
|
1. `destroy` deletes the server as well as removing it from the chef environment.
|
637
645
|
|
638
646
|
2. This command is aliased to `cft remove_node` and `cft rc`
|
639
647
|
|
640
|
-
|
648
|
+
37. `cft replication_status` will check the status of the database master and slaves in every environment. Also lists how far behind the slaves are from the master in milliseconds.
|
641
649
|
|
642
|
-
|
650
|
+
38. `cft reset_bag BAG_NAME` this command allows you to reset a data bag item to an empty state. Run this on full data bags to clear them out.
|
643
651
|
|
644
|
-
|
652
|
+
39. `cft restart_swap` will restart the swap on every server that doesn't have swap currently on. Useful if you notice servers with no swap activated from `cft disk_report`
|
645
653
|
|
646
654
|
1. There is no risk in running this command. Sometimes swap doesnt reactivate if the server was rebooted and this command fixes that.
|
647
655
|
|
648
|
-
|
656
|
+
40. `cft role_toggle NODE_NAME ROLE_NAME activate|deactivate` This command will allow you to **toggle** roles on nodes without using `cft upload_nodes`
|
649
657
|
|
650
658
|
1. This command uses your *role_toggling:deactivated_role_suffix* attribute set in your cheftacular.yml to toggle the role, it checks to see if the toggled name exists then sets the node's run_list to include the toggled role
|
651
659
|
|
@@ -659,7 +667,7 @@
|
|
659
667
|
|
660
668
|
4. Aliased to `cft rt`
|
661
669
|
|
662
|
-
|
670
|
+
41. `cft rvm [COMMAND] [ADDITIONAL_COMMANDS]*` will run rvm commands on the remote servers. Output from this command for each server will go into your rvm directory under the log directory. Please refer to [the rvm help page](https://rvm.io/rvm) for more information on rvm commands.
|
663
671
|
|
664
672
|
1. When no commands are passed, rvm will just run `rvm list` on each server on all servers in the current environment.
|
665
673
|
|
@@ -675,11 +683,11 @@
|
|
675
683
|
|
676
684
|
7. `upgrade_rvm` will run `rvm get stable --auth-dotfiles` on all servers for the current environment. It will also check and attempt to upgrade pre 1.25 installations of RVM to 1.26+ (which requires a GPG key).
|
677
685
|
|
678
|
-
|
686
|
+
42. `cft server_update [restart]` allows you to force update all nodes' packages for a specific environment. This should be done with caution as this *might* break something.
|
679
687
|
|
680
688
|
1. `cft server_update restart` will prompt to ask if you also want to restart all servers in a rolling restart. This should be done with extreme caution and only in a worst-case scenario.
|
681
689
|
|
682
|
-
|
690
|
+
43. `cft service [COMMAND] [SERVICE]` will run service commands on remote servers. This command only runs on the first server it comes across. Specify others with -n NODE_NAME.
|
683
691
|
|
684
692
|
1. When no commands are passed, the command will list all the services in the /etc/init directory
|
685
693
|
|
@@ -687,17 +695,17 @@
|
|
687
695
|
|
688
696
|
3. When `restart|stop|start SERVICE` is passed, the command will attempt to restart|stop|start the service if it has a .conf file on the remote server in the /etc/init directory.
|
689
697
|
|
690
|
-
|
698
|
+
44. `cft slack "MESSAGE" [CHANNEL]` will attempt to post the message to the webhook set in your cheftacular.yml. Slack posts to your default channel by default but if the CHANNEL argument is supplied the message will post there.
|
691
699
|
|
692
700
|
1. NOTE: To prevent confusing spam from many possible sources, the username posted to slack will always be *Cheftacular*. This can be overloaded in the StatelessAction method "slack" but this is not recommended.
|
693
701
|
|
694
702
|
2. Remember, if you have auditing turned on in your cheftacular.yml, you can track who sends what to slack.
|
695
703
|
|
696
|
-
|
704
|
+
45. `cft ssh NODE_NAME [exec] [command]` ssh you into the node name you are trying to access. It will also drop the server's sudo password into your clipboard.
|
697
705
|
|
698
706
|
1. `cft ssh NODE_NAME exec COMMAND` will execute a command on the server as root
|
699
707
|
|
700
|
-
|
708
|
+
46. `cft test_env [TARGET_ENV] boot|destroy` will create (or destroy) the test nodes for a particular environment (defaults to staging, prod split-envs can be set with `-p`). Please read below for how TARGET_ENV works
|
701
709
|
|
702
710
|
1. TARGET_ENV changes functionality depending on the overall (like staging / production) environment
|
703
711
|
|
@@ -707,11 +715,11 @@
|
|
707
715
|
|
708
716
|
3. The default tld used should change depending on which environment you are booting / destroying. This is set in the environment's config data bag under the tld key
|
709
717
|
|
710
|
-
|
718
|
+
47. `cft ubuntu_bootstrap_from_queue` This command will bring a fresh server to a state where chef-client can be run on it via `cft chef-bootstrap`. It should be noted that it is in this step where a server's randomized deploy_user sudo password is generated.
|
711
719
|
|
712
|
-
|
720
|
+
48. `cft update_cheftacular` this command attempts to update cheftacular to the latest version.
|
713
721
|
|
714
|
-
|
722
|
+
49. `cft update_cloudflare_dns_from_cloud [skip_update_tld]` command will force a full dns update for cloudflare.
|
715
723
|
|
716
724
|
1. It will ensure all the subdomain entries are correct (based on the contents of the addresses data bag) and update them if they are not. It will also create the local subdomain for the entry as well if it does exist and point it to the correct private address for an environment.
|
717
725
|
|
@@ -719,7 +727,7 @@
|
|
719
727
|
|
720
728
|
3. The argument `skip_update_tld` will stop the long process of checking and updating all the server domains _before_ cloudflare is updated. Only skip if you believe your domain info on your cloud is accurate.
|
721
729
|
|
722
|
-
|
730
|
+
50. `cft update_cookbook [COOKBOOK_NAME] [INSTALL_VERSION|local]` allows you to specifically update a single cookbook
|
723
731
|
|
724
732
|
1. This command passed with no arguments will update TheCheftacularCookbook
|
725
733
|
|
@@ -727,7 +735,7 @@
|
|
727
735
|
|
728
736
|
3. Aliased to `cft uc`
|
729
737
|
|
730
|
-
|
738
|
+
51. `cft update_split_branches` will perform a series of git commands that will merge all the split branches for your split_branch enabled repositories with what is currently on master and push them.
|
731
739
|
|
732
740
|
1. Repository must be set with `-R REPOSITORY_NAME` for this command to work.
|
733
741
|
|
@@ -737,13 +745,13 @@
|
|
737
745
|
|
738
746
|
4. This command will return a helpful error statement if you attempt to run the command with changes to your current working directory. You must commit these changes before running this command.
|
739
747
|
|
740
|
-
|
748
|
+
52. `cft update_the_cheftacular_cookbook_and_knife_upload` update your local cheftacular cookbook with your local (out of chef-repo) cheftacular cookbook and knife_upload afterwards.
|
741
749
|
|
742
750
|
1. This method is aliased to `cft utccaku` and `cft utcc`.
|
743
751
|
|
744
|
-
|
752
|
+
53. `cft update_tld TLD` command will force a full dns update for a tld in the preferred cloud. It will ensure all the subdomain entries are correct (based on the contents of the addresses data bag) and update them if they are not. It will also create the local subdomain for the entry as well if it does exist and point it to the correct private address.
|
745
753
|
|
746
|
-
|
754
|
+
54. `cft upload_nodes` This command will resync the chef server's nodes with the data in our chef-repo/node_roles.
|
747
755
|
|
748
756
|
1. This command changes behavior depending on several factors about both your mode and the state of your environment
|
749
757
|
|
@@ -757,10 +765,10 @@
|
|
757
765
|
|
758
766
|
4. Aliased to `cft un`
|
759
767
|
|
760
|
-
|
768
|
+
55. `cft upload_roles` This command will resync the chef server's roles with the data in the chef-repo/roles.
|
761
769
|
|
762
770
|
1. Aliased to `cft ur`
|
763
771
|
|
764
|
-
|
772
|
+
56. `cft version` this command prints out the current version of cheftacular.
|
765
773
|
|
766
774
|
1. Aliased to `cft v`
|
@@ -59,7 +59,7 @@ class Cheftacular
|
|
59
59
|
start_console_mongodb(n.public_ipaddress, private_database_host_address)
|
60
60
|
end
|
61
61
|
|
62
|
-
@config['auditor'].notify_slack_on_completion("mongo run completed on #{
|
62
|
+
@config['auditor'].notify_slack_on_completion("mongo run completed on #{ mongoable_nodes.first.name } (#{ mongoable_nodes.first.public_ipaddress })\n") if @config['cheftacular']['auditing']
|
63
63
|
end
|
64
64
|
|
65
65
|
def db_console_mysql
|
@@ -57,7 +57,7 @@ class Cheftacular
|
|
57
57
|
|
58
58
|
log_data, timestamp, exit_status = start_deploy( n.name, n.public_ipaddress, options, locs, passwords)
|
59
59
|
|
60
|
-
logs_bag_hash["#{ n.name }-#{ __method__ }"] = { "text" => log_data.scrub_pretty_text, "timestamp" => timestamp, "exit_status" => exit_status }
|
60
|
+
logs_bag_hash["#{ n.name }-#{ __method__ }"] = { "text" => log_data.scrub_pretty_text.force_encoding('UTF-8'), "timestamp" => timestamp, "exit_status" => exit_status }
|
61
61
|
end
|
62
62
|
|
63
63
|
@config['helper'].send_log_bag_hash_slack_notification(logs_bag_hash, __method__)
|
@@ -38,7 +38,7 @@ class Cheftacular
|
|
38
38
|
|
39
39
|
log_data, timestamp, exit_status = start_task( n.name, n.public_ipaddress, n.run_list, "#{ bundle_command } exec rake db:migrate", options, locs, cheftacular, passwords)
|
40
40
|
|
41
|
-
logs_bag_hash["#{ n.name }-#{ __method__ }"] = { "text" => log_data.scrub_pretty_text, "timestamp" => timestamp, "exit_status" => exit_status }
|
41
|
+
logs_bag_hash["#{ n.name }-#{ __method__ }"] = { "text" => log_data.scrub_pretty_text.force_encoding('UTF-8'), "timestamp" => timestamp, "exit_status" => exit_status }
|
42
42
|
end
|
43
43
|
|
44
44
|
@config['ChefDataBag'].save_logs_bag
|
@@ -78,7 +78,7 @@ class Cheftacular
|
|
78
78
|
|
79
79
|
log_data, timestamp, exit_status = start_task( n.name, n.public_ipaddress, n.run_list, "#{ executable } #{ command }", options, locs, cheftacular, passwords, sudo)
|
80
80
|
|
81
|
-
logs_bag_hash["#{ n.name }-#{ descriptor }"] = { "text" => log_data.scrub_pretty_text, "timestamp" => timestamp, "exit_status" => exit_status }
|
81
|
+
logs_bag_hash["#{ n.name }-#{ descriptor }"] = { "text" => log_data.scrub_pretty_text.force_encoding('UTF-8'), "timestamp" => timestamp, "exit_status" => exit_status }
|
82
82
|
end
|
83
83
|
|
84
84
|
@config['ChefDataBag'].save_logs_bag
|
data/lib/cheftacular/auditor.rb
CHANGED
@@ -74,9 +74,11 @@ class Cheftacular
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
msg << "deploy run succeeded on #{ node_name_array.join(', ') }
|
77
|
+
msg << "deploy run succeeded on #{ node_name_array.join(', ') }" unless node_name_array.empty?
|
78
78
|
|
79
|
-
msg << "#{ 'and ' unless msg.blank? }deploy run FAILED on #{ failed_node_names.join(', ') }
|
79
|
+
msg << "#{ 'and ' unless msg.blank? }deploy run FAILED on #{ failed_node_names.join(', ') }" unless failed_node_names.empty?
|
80
|
+
|
81
|
+
msg << "\n"
|
80
82
|
|
81
83
|
audit_command_to_slack_queue(audit_run_as_hash, 'short', msg)
|
82
84
|
end
|
@@ -111,7 +113,7 @@ class Cheftacular
|
|
111
113
|
cheftacular_yml_help: ['yml_help'],
|
112
114
|
client_list: ['cl'],
|
113
115
|
cloud_bootstrap: ['cb'],
|
114
|
-
environment: ['e'],
|
116
|
+
environment: ['e', 'env'],
|
115
117
|
fix_known_hosts: ['fkh'],
|
116
118
|
knife_upload: ['ku'],
|
117
119
|
location_aliases: ['la'],
|
@@ -5,7 +5,7 @@ class Cheftacular
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def log_directories
|
8
|
-
['applog', 'deploy', 'failed-deploy', 'rolelog', 'rvm', 'server-setup', 'stashedlog', 'server-update']
|
8
|
+
['applog', 'deploy', 'failed-deploy', 'rolelog', 'rvm', 'server-setup', 'stashedlog', 'server-update', 'ssh-exec']
|
9
9
|
end
|
10
10
|
|
11
11
|
def write_version_file version
|
data/lib/cheftacular/helper.rb
CHANGED
data/lib/cheftacular/parser.rb
CHANGED
@@ -13,6 +13,8 @@ class Cheftacular
|
|
13
13
|
|
14
14
|
parse_role(@options['role']) unless @options['role'].nil?
|
15
15
|
|
16
|
+
@options['repository'] = reverse_parse_role_to_repository(@options['role']) unless @options['role'].nil?
|
17
|
+
|
16
18
|
parse_repository(@options['repository'])
|
17
19
|
|
18
20
|
parse_node_name(@options['node_name']) if @options['node_name']
|
@@ -253,5 +255,13 @@ class Cheftacular
|
|
253
255
|
|
254
256
|
repo_state_hash
|
255
257
|
end
|
258
|
+
|
259
|
+
def reverse_parse_role_to_repository role
|
260
|
+
@config['cheftacular']['repositories'].each_pair do |repo_role_name, repo_hash|
|
261
|
+
return repo_hash['repo_name'] if role == repo_role_name
|
262
|
+
end if @config['cheftacular']['repositories'].keys.include?(role)
|
263
|
+
|
264
|
+
''
|
265
|
+
end
|
256
266
|
end
|
257
267
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
class Cheftacular
|
3
|
+
class StatelessActionDocumentation
|
4
|
+
def env_ssh_exec
|
5
|
+
@config['documentation']['stateless_action'][__method__] ||= {}
|
6
|
+
@config['documentation']['stateless_action'][__method__]['long_description'] = [
|
7
|
+
"`cft env_ssh_exec [command]` will ssh into each server in an environment and run the command as sudo. ",
|
8
|
+
|
9
|
+
[
|
10
|
+
" 1. To deactivate logstash: `cft env_ssh_exec sv stop logstash_agent`"
|
11
|
+
]
|
12
|
+
]
|
13
|
+
|
14
|
+
@config['documentation']['stateless_action'][__method__]['short_description'] = 'Runs a command on all servers in an environment'
|
15
|
+
|
16
|
+
@config['documentation']['application'][__method__] = @config['documentation']['stateless_action'][__method__]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class StatelessAction
|
21
|
+
def env_ssh_exec command='', nodes=[]
|
22
|
+
raise "This action can only be performed if the mode is set to devops" unless @config['helper'].running_in_mode?('devops')
|
23
|
+
|
24
|
+
command = ARGV[1] if command.blank?
|
25
|
+
|
26
|
+
nodes = @config['parser'].exclude_nodes( @config['getter'].get_true_node_objects(true), [{ unless: { env: @options['env'] }}] ) if nodes.empty?
|
27
|
+
|
28
|
+
#this must always precede on () calls so they have the instance variables they need
|
29
|
+
options, locs, ridley, logs_bag_hash, pass_bag_hash, bundle_command, cheftacular, passwords = @config['helper'].set_local_instance_vars
|
30
|
+
|
31
|
+
on ( nodes.map { |n| @config['cheftacular']['deploy_user'] + "@" + n.public_ipaddress } ), in: :groups, limit: 5, wait: 5 do |host|
|
32
|
+
n = get_node_from_address(nodes, host.hostname)
|
33
|
+
|
34
|
+
log_data, timestamp = start_env_exec( n.name, n.public_ipaddress, command, options, locs, passwords)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
module SSHKit
|
41
|
+
module Backend
|
42
|
+
class Netssh
|
43
|
+
def start_env_exec name, ip_address, command, options, locs, passwords, out=""
|
44
|
+
log_loc, timestamp = set_log_loc_and_timestamp(locs)
|
45
|
+
|
46
|
+
puts("Generating a log file for #{ command } at #{ name } (#{ ip_address }) at #{ log_loc }/ssh-exec/#{ name }-exec-#{ timestamp }.txt") unless options['quiet']
|
47
|
+
|
48
|
+
out << sudo_capture( passwords[ip_address], command )
|
49
|
+
|
50
|
+
puts(out) if options['output'] || options['verbose']
|
51
|
+
|
52
|
+
::File.open("#{ log_loc }/ssh-exec/#{ name }-exec-#{ timestamp }.txt", "w") { |f| f.write(out.scrub_pretty_text) } unless options['no_logs']
|
53
|
+
|
54
|
+
puts "Succeeded run of #{ command } on #{ name } (#{ ip_address })"
|
55
|
+
|
56
|
+
#[out, timestamp] #return out to send to logs_bag
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -23,7 +23,7 @@ class Cheftacular
|
|
23
23
|
|
24
24
|
" 7. This command works with all the flags that `cft deploy` works with, like -Z -z -O and so on.",
|
25
25
|
|
26
|
-
" 8. Aliased to `cft e`"
|
26
|
+
" 8. Aliased to `cft e` and `cft env`"
|
27
27
|
]
|
28
28
|
]
|
29
29
|
|
@@ -153,6 +153,7 @@ class Cheftacular
|
|
153
153
|
end
|
154
154
|
|
155
155
|
alias_method :e, :environment
|
156
|
+
alias_method :env, :environment
|
156
157
|
|
157
158
|
private
|
158
159
|
|
@@ -15,7 +15,7 @@ class Cheftacular
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class StatelessAction
|
18
|
-
def pass node_name=''
|
18
|
+
def pass node_name='', mode='normal'
|
19
19
|
@options['node_name'] = ARGV[1] if !@options['node_name'] && node_name.blank?
|
20
20
|
@options['node_name'] = node_name if !@options['node_name'] && !node_name.blank?
|
21
21
|
|
@@ -25,8 +25,10 @@ class Cheftacular
|
|
25
25
|
@config['initializer'].initialize_data_bags_for_environment nodes.first.chef_environment, false, ['server_passwords']
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
if mode =~ /normal/
|
29
|
+
puts "The password for #{ nodes.first.name }(#{ nodes.first.public_ipaddress }) for env #{ nodes.first.chef_environment }" +
|
30
|
+
" is #{ @config[nodes.first.chef_environment]['server_passwords_bag_hash']["#{ nodes.first.public_ipaddress }-deploy-pass"] }"
|
31
|
+
end
|
30
32
|
|
31
33
|
case CONFIG['host_os']
|
32
34
|
when /mswin|windows/i
|
@@ -41,7 +43,7 @@ class Cheftacular
|
|
41
43
|
`echo '#{ @config[nodes.first.chef_environment]['server_passwords_bag_hash']["#{ nodes.first.public_ipaddress }-deploy-pass"] }' | pbcopy`
|
42
44
|
else
|
43
45
|
#raise "#{ __method__ } does not support this operating system at this time"
|
44
|
-
end
|
46
|
+
end if mode =~ /normal/
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -70,7 +70,7 @@ module SSHKit
|
|
70
70
|
def start_apt_updater name, ip_address, options, locs, passwords, out=""
|
71
71
|
log_loc, timestamp = set_log_loc_and_timestamp(locs)
|
72
72
|
|
73
|
-
puts("Generating apt-get log file for #{ name } (#{ ip_address }) at #{ log_loc }/#{ name }-upgrade-#{ timestamp }.txt") unless options['quiet']
|
73
|
+
puts("Generating apt-get log file for #{ name } (#{ ip_address }) at #{ log_loc }/server-update/#{ name }-upgrade-#{ timestamp }.txt") unless options['quiet']
|
74
74
|
|
75
75
|
out << sudo_capture( passwords[ip_address], 'apt-get', 'update' )
|
76
76
|
out << sudo_capture( passwords[ip_address], 'apt-get', 'upgrade', '-y', '-o' 'Dpkg::Options::="--force-confnew"' )
|
@@ -28,6 +28,12 @@ class Cheftacular
|
|
28
28
|
|
29
29
|
nodes = @config['error'].is_valid_node_name_option?
|
30
30
|
|
31
|
+
if !command.blank? && nodes.first.chef_environment != @options['env']
|
32
|
+
@config['initializer'].initialize_data_bags_for_environment nodes.first.chef_environment, false, ['addresses', 'server_passwords']
|
33
|
+
|
34
|
+
@config['initializer'].initialize_passwords nodes.first.chef_environment
|
35
|
+
end
|
36
|
+
|
31
37
|
nodes.each do |n|
|
32
38
|
puts("Beginning ssh run for #{ n.name } (#{ n.public_ipaddress })") unless @options['quiet']
|
33
39
|
|
@@ -39,8 +45,12 @@ class Cheftacular
|
|
39
45
|
|
40
46
|
private
|
41
47
|
|
42
|
-
def start_ssh_session ip_address, command
|
43
|
-
|
48
|
+
def start_ssh_session ip_address, command, out=""
|
49
|
+
unless command.blank?
|
50
|
+
out << (`ssh #{ Cheftacular::SSH_INLINE_VARS } -tt #{ @config['cheftacular']['deploy_user'] }@#{ ip_address } "#{ @config['helper'].sudo(ip_address) } #{ command }" > /dev/tty`)
|
51
|
+
|
52
|
+
puts out
|
53
|
+
end
|
44
54
|
|
45
55
|
`ssh #{ Cheftacular::SSH_INLINE_VARS } -t #{ @config['cheftacular']['deploy_user'] }@#{ ip_address } > /dev/tty` if command.blank?
|
46
56
|
end
|
data/lib/cheftacular/version.rb
CHANGED
data/lib/sshkit/getters.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheftacular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.15.
|
4
|
+
version: 2.15.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis Alridge
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -306,6 +306,7 @@ files:
|
|
306
306
|
- lib/cheftacular/stateless_actions/compile_readme.rb
|
307
307
|
- lib/cheftacular/stateless_actions/create_git_key.rb
|
308
308
|
- lib/cheftacular/stateless_actions/disk_report.rb
|
309
|
+
- lib/cheftacular/stateless_actions/env_ssh_exec.rb
|
309
310
|
- lib/cheftacular/stateless_actions/environment.rb
|
310
311
|
- lib/cheftacular/stateless_actions/file.rb
|
311
312
|
- lib/cheftacular/stateless_actions/fix_known_hosts.rb
|