cheftacular 2.5.0 → 2.6.0
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 +155 -63
- data/lib/cheftacular/actions/db_console.rb +3 -3
- data/lib/cheftacular/actions/deploy.rb +18 -12
- data/lib/cheftacular/actions/migrate.rb +1 -1
- data/lib/cheftacular/actions/tail.rb +1 -1
- data/lib/cheftacular/auditor.rb +14 -6
- data/lib/cheftacular/chef/data_bag.rb +1 -4
- data/lib/cheftacular/cheftacular.rb +19 -15
- data/lib/cheftacular/cloud_provider.rb +32 -0
- data/lib/cheftacular/dns.rb +1 -1
- data/lib/cheftacular/error.rb +13 -2
- data/lib/cheftacular/file_system.rb +122 -0
- data/lib/cheftacular/files/rvm.sh +55 -0
- data/lib/cheftacular/getter.rb +10 -3
- data/lib/cheftacular/helper.rb +31 -127
- data/lib/cheftacular/initialization_action.rb +8 -0
- data/lib/cheftacular/initializer.rb +104 -44
- data/lib/cheftacular/parser.rb +6 -0
- data/lib/cheftacular/stateless_actions/add_ssh_key_to_bag.rb +2 -2
- data/lib/cheftacular/stateless_actions/arguments.rb +9 -2
- data/lib/cheftacular/stateless_actions/backups.rb +1 -1
- data/lib/cheftacular/stateless_actions/bootstrappers/ubuntu_bootstrap.rb +16 -5
- data/lib/cheftacular/stateless_actions/check_cheftacular_yml_keys.rb +79 -0
- data/lib/cheftacular/stateless_actions/chef_bootstrap.rb +20 -4
- data/lib/cheftacular/stateless_actions/chef_server.rb +78 -0
- data/lib/cheftacular/stateless_actions/clean_cookbooks.rb +3 -3
- data/lib/cheftacular/stateless_actions/clean_server_passwords.rb +3 -1
- data/lib/cheftacular/stateless_actions/cleanup_log_files.rb +1 -0
- data/lib/cheftacular/stateless_actions/client_list.rb +2 -2
- data/lib/cheftacular/stateless_actions/cloud.rb +30 -2
- data/lib/cheftacular/stateless_actions/cloud_bootstrap.rb +7 -13
- data/lib/cheftacular/stateless_actions/compile_audit_log.rb +1 -1
- data/lib/cheftacular/stateless_actions/create_git_key.rb +3 -1
- data/lib/cheftacular/stateless_actions/environment.rb +2 -0
- data/lib/cheftacular/stateless_actions/file.rb +4 -2
- data/lib/cheftacular/stateless_actions/fix_known_hosts.rb +2 -1
- data/lib/cheftacular/stateless_actions/full_bootstrap.rb +2 -0
- data/lib/cheftacular/stateless_actions/get_active_ssh_connections.rb +1 -1
- data/lib/cheftacular/stateless_actions/help.rb +9 -7
- data/lib/cheftacular/stateless_actions/initialize_cheftacular_yml.rb +29 -0
- data/lib/cheftacular/stateless_actions/initialize_data_bag_contents.rb +5 -36
- data/lib/cheftacular/stateless_actions/list_toggleable_roles.rb +45 -0
- data/lib/cheftacular/stateless_actions/location_aliases.rb +24 -0
- data/lib/cheftacular/stateless_actions/pass.rb +4 -4
- data/lib/cheftacular/stateless_actions/reinitialize.rb +0 -6
- data/lib/cheftacular/stateless_actions/remove_client.rb +12 -7
- data/lib/cheftacular/stateless_actions/role_toggle.rb +141 -0
- data/lib/cheftacular/stateless_actions/server_update.rb +2 -2
- data/lib/cheftacular/stateless_actions/update_chef_client.rb +18 -0
- data/lib/cheftacular/stateless_actions/upload_nodes.rb +5 -3
- data/lib/cheftacular/stateless_actions/upload_roles.rb +1 -1
- data/lib/cheftacular/version.rb +1 -1
- data/lib/cloud_interactor/authentication.rb +78 -40
- data/lib/cloud_interactor/cloud_interactor.rb +4 -1
- data/lib/cloud_interactor/cloud_provider.rb +19 -0
- data/lib/cloud_interactor/domain/create.rb +1 -1
- data/lib/cloud_interactor/domain/create_record.rb +1 -1
- data/lib/cloud_interactor/domain/destroy_record.rb +1 -1
- data/lib/cloud_interactor/domain/list_records.rb +1 -1
- data/lib/cloud_interactor/domain/update.rb +1 -1
- data/lib/cloud_interactor/domain/update_record.rb +6 -6
- data/lib/cloud_interactor/helpers.rb +1 -1
- data/lib/cloud_interactor/parser.rb +3 -2
- data/lib/cloud_interactor/region.rb +27 -0
- data/lib/cloud_interactor/server/create.rb +9 -0
- data/lib/cloud_interactor/sshkey.rb +59 -0
- data/lib/ridley/monkeypatches.rb +12 -0
- data/lib/sshkit/actions/start_task.rb +8 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5bcc816f796287851b09a9aae84f8c0c870d0a5
|
4
|
+
data.tar.gz: b88ae2e25f2732f9204f5d1fe425290472cfb0a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cea832a9a9c55ab8bd3f20a3b8ea76cedc7fcb7227d55437eb510ae8047912bab1f04d46f79492058d1af2c85f415c611d8fd9bba8d1a92d939de61dc6950eaa
|
7
|
+
data.tar.gz: 197bfb84446358b86921378c0777fec8b8542988df3e0b0fe78d361517105db64e61832cb1fc44a3c19e068739a31ecb11d9f467788b77405f4d6240ceb29e52
|
data/lib/cheftacular/README.md
CHANGED
@@ -60,11 +60,25 @@
|
|
60
60
|
|
61
61
|
## Commands that can be run in the application context
|
62
62
|
|
63
|
-
1. `cft
|
63
|
+
1. [NYI]`cft get_active_ssh_connections` will fetch the active ssh connections from every server and output it into your log directory.
|
64
64
|
|
65
|
-
2. `cft
|
65
|
+
2. `cft backup [activate|deactivate]` this command sets the fetch_backups and restore_backups flags in your config data bag for an environment. These can be used to give application developers a way to trigger / untrigger restores in an environment
|
66
66
|
|
67
|
-
3. `cft
|
67
|
+
3. `cft check` Checks the commits for all servers for a repository (for an environment) and returns them in a simple chart. Also shows when these commits were deployed to the server.
|
68
|
+
|
69
|
+
4. `cft chef_server [restart|processes|memory]` this command can be used to query the chef server for stats if the cheftacular.yml has the chef_server key filled out. Useful for low resource chef-servers.
|
70
|
+
|
71
|
+
1. `restart` restarts all chef processes on the chef server which may alleviate slow cheftacular load times for some users. (NOTE) do not run this command while the chef-server is performing actions or instability may result! Not tested for high volume chef servers.
|
72
|
+
|
73
|
+
2. `processes` runs `ps aux` on the server to return the running processes and their stats.
|
74
|
+
|
75
|
+
3. `memory` runs `free -m` on the server to return the current memory usage.
|
76
|
+
|
77
|
+
4. NOTE! This command (and all arguments to it) bypass the normal environment loading like the help command.
|
78
|
+
|
79
|
+
5. NOTE 2! Cheftacular does not (and will not) support accessing your chef server over ssh with password auth. If you have done this, you should feel bad and immediately switch ssh access to key authentication...
|
80
|
+
|
81
|
+
5. `cft client_list` Allows you check the basic information for all the servers setup via chef. Shows the server's short name, its public ip address and roles (run_list) by default.
|
68
82
|
|
69
83
|
1. `-v` option will make this command display the server's domain name, whether its password is stored on the chef server and what that password is.
|
70
84
|
|
@@ -72,21 +86,23 @@
|
|
72
86
|
|
73
87
|
3. This command is aliased to `client-list` with no arguments or cft prefix.
|
74
88
|
|
75
|
-
|
89
|
+
6. `cft console` will create a pry session on the first node found for a codebase.
|
76
90
|
|
77
|
-
|
91
|
+
7. `cft db_console` will create a database console session on the first node found for a database stack in the current environment.
|
78
92
|
|
79
93
|
1. This command is aliased to psql, typing `cft psql` will drop you into a rails stack database psql session.
|
80
94
|
|
81
|
-
|
95
|
+
8. `cft deploy` will do a simple chef-client run on the servers for a role. Logs of the run itself will be sent to the local log directory in the application (or chef-repo) where the run was conducted.
|
82
96
|
|
83
97
|
1. This command also restarts services on the server and updates the code. Changes behavior slightly with the `-z|-Z` args but only if your cookbooks support switching revisions based on tags / branch names.
|
84
98
|
|
85
99
|
2. This command will also run migrations on both an role's normal servers and its split servers if certain conditions are met (such as the role having a database, etc).
|
86
100
|
|
87
|
-
|
101
|
+
3. The `-v|--verbose` option will cause failed deploys to output to the terminal window and to their normal log file. Useful for debugging.
|
88
102
|
|
89
|
-
|
103
|
+
9. `cft disk_report` will fetch useful statistics from every server for every environment and output it into your log directory.
|
104
|
+
|
105
|
+
10. `cft environment boot|destroy` will boot / destroy the current environment
|
90
106
|
|
91
107
|
1. `boot` will spin up servers and bring them to a stable state. This includes setting up their subdomains for the target environment.
|
92
108
|
|
@@ -94,7 +110,7 @@
|
|
94
110
|
|
95
111
|
3. This command will prompt when attempting to destroy servers in staging or production
|
96
112
|
|
97
|
-
|
113
|
+
11. `cft file NODE_NAME LOCATION_ALIAS MODE FILE_NAME` interacts with a file on the remote server
|
98
114
|
|
99
115
|
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
|
100
116
|
|
@@ -124,23 +140,25 @@
|
|
124
140
|
|
125
141
|
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.
|
126
142
|
|
127
|
-
|
143
|
+
12. `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)
|
128
144
|
|
129
145
|
1. Passing in a hostname will make the command only remove entries with that hostname / ip specifically
|
130
146
|
|
131
|
-
|
132
|
-
|
133
|
-
12. `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.
|
147
|
+
13. `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.
|
134
148
|
|
135
149
|
1. In devops mode, this command will not do anything without the -R repository passed.
|
136
150
|
|
137
|
-
|
151
|
+
14. `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.
|
152
|
+
|
153
|
+
15. `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.
|
154
|
+
|
155
|
+
16. `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.
|
138
156
|
|
139
|
-
|
157
|
+
17. `cft list_toggleable_roles NODE_NAME` This command will allow you to see all toggleable roles for a node
|
140
158
|
|
141
|
-
|
159
|
+
18. `cft location_aliases` will list all location aliases listed in your cheftacular.yml. These aliases can be used in the `cft file` command.
|
142
160
|
|
143
|
-
|
161
|
+
19. `cft log` this command will output the last 500 lines of logs from every server set for CODEBASE (can be given additional args to specify) to the log directory
|
144
162
|
|
145
163
|
1. `--nginx` will fetch the nginx logs as well as the application logs
|
146
164
|
|
@@ -152,13 +170,25 @@
|
|
152
170
|
|
153
171
|
4. `--fetch-backup` If doing a pg_data log, this will fetch the latest logs from the pg_data log directory for each database.
|
154
172
|
|
155
|
-
|
173
|
+
20. `cft migrate` this command will grab the first alphabetical node for a repository and run a migration that will hit the database primary server.
|
174
|
+
|
175
|
+
21. `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
|
176
|
+
|
177
|
+
22. `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.
|
178
|
+
|
179
|
+
23. `cft role_toggle NODE_NAME ROLE_NAME activate|deactivate` This command will allow you to **toggle** roles on nodes without using `cft upload_nodes`
|
156
180
|
|
157
|
-
|
181
|
+
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
|
158
182
|
|
159
|
-
|
183
|
+
2. EX: `cft role_toggle apisc01 worker activate` will find the node apisc01 and attempt to toggle the worker role to on. If the node does NOT have the worker_deactivate role, then it will add it if *role_toggling:strict_roles* is set to **false**
|
160
184
|
|
161
|
-
|
185
|
+
1. If *role_toggling:strict_roles* is set to true, then cheftacular would raise an error saying this role is unsettable on the node. On the other hand, if the node already has the worker_deactivaterole, then this command will succeed even if *strict_roles* is set.
|
186
|
+
|
187
|
+
3. In case it isn't obvious, this command ONLY supports deactivation suffix roles like worker_deactivate or worker_off, with theiron counterpart just being the role itself, like "worker".
|
188
|
+
|
189
|
+
1. Please run `cft list_toggleable_roles NODE_NAME` to get a list of your org's toggleable roles for a node.
|
190
|
+
|
191
|
+
24. `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.
|
162
192
|
|
163
193
|
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.
|
164
194
|
|
@@ -168,11 +198,11 @@
|
|
168
198
|
|
169
199
|
4. IMPORTANT NOTE: You cannot run `cft run rake -T` as is, you have to enclose any command that uses command line dash arguments in quotes like `cft run "rake -T"`
|
170
200
|
|
171
|
-
|
201
|
+
25. `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.
|
172
202
|
|
173
203
|
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.
|
174
204
|
|
175
|
-
|
205
|
+
26. `cft tail` 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
|
176
206
|
|
177
207
|
1. pass `-n NODE_NAME` to grab the output of a node other than the first.
|
178
208
|
|
@@ -183,21 +213,39 @@
|
|
183
213
|
|
184
214
|
1. [NYI]`cft clean_sensu_plugins` will checkout / update the sensu community plugins github repo on your local machine and sync any sensu plugin files in your wrapper cookbook directory with what is in the repo.
|
185
215
|
|
186
|
-
2. `cft
|
216
|
+
2. [NYI]`cft get_active_ssh_connections` will fetch the active ssh connections from every server and output it into your log directory.
|
217
|
+
|
218
|
+
3. [NYI]`cft update_chef_client` attempts to update the chef-client of all nodes to the latest version. Should be done with caution and with the chef_server's version in mind.
|
219
|
+
|
220
|
+
4. `cft add_ssh_key_to_bag "<NEW SSH PUB KEY>" [SPECIFIC_REPOSITORY]` this command will add the given ssh key to the default authentication data bag. After this your server recipes should read the contents of the 'default' 'authentication' bag for the authorized_keys array.
|
187
221
|
|
188
222
|
1. `SPECIFIC_REPOSITORY` is a special argument, if left blank the key will be placed in the authorized_keys array in the bag, otherwise it will be placed in the specific_authorized_keys hash under a key named for the repository that is passed. The script will error if SPECIFIC_REPOSITORY does not exist in the cheftacular.yml respositories hash. You can then use this data to give users selective ssh access to certain servers.
|
189
223
|
|
190
|
-
|
224
|
+
5. `cft backup [activate|deactivate]` this command sets the fetch_backups and restore_backups flags in your config data bag for an environment. These can be used to give application developers a way to trigger / untrigger restores in an environment
|
225
|
+
|
226
|
+
6. `cft check_cheftacular_yml_keys` allows you to check to see if your cheftacular yml keys are valid to the current version of cheftacular. It will also set your missing keys to their likely default and let you know to update the cheftacular.yml file.
|
227
|
+
|
228
|
+
7. `cft chef_bootstrap ADDRESS NODE_NAME` allows you to register a node in the chef system, remove any lingering data that may be associated with it and update the node's runlist if it has an entry in nodes_dir for its NODE_NAME.
|
191
229
|
|
192
|
-
|
230
|
+
8. `cft chef_server [restart|processes|memory]` this command can be used to query the chef server for stats if the cheftacular.yml has the chef_server key filled out. Useful for low resource chef-servers.
|
193
231
|
|
194
|
-
|
232
|
+
1. `restart` restarts all chef processes on the chef server which may alleviate slow cheftacular load times for some users. (NOTE) do not run this command while the chef-server is performing actions or instability may result! Not tested for high volume chef servers.
|
233
|
+
|
234
|
+
2. `processes` runs `ps aux` on the server to return the running processes and their stats.
|
235
|
+
|
236
|
+
3. `memory` runs `free -m` on the server to return the current memory usage.
|
237
|
+
|
238
|
+
4. NOTE! This command (and all arguments to it) bypass the normal environment loading like the help command.
|
239
|
+
|
240
|
+
5. NOTE 2! Cheftacular does not (and will not) support accessing your chef server over ssh with password auth. If you have done this, you should feel bad and immediately switch ssh access to key authentication...
|
241
|
+
|
242
|
+
9. `cft clean_cookbooks [force] [remove_cookbooks]` allows you to update the internal chef-repo's cookbooks easily. By default this script will force you to decide what to do with each cookbook individually (shows version numbers and whether to overwrite it to cookbooks or not).
|
195
243
|
|
196
244
|
1. `force` argument will cause the downloaded cookbooks to *always* overwrite the chef-repo's cookbooks as long as the downloaded cookbook has a higher version number.
|
197
245
|
|
198
246
|
2. If you would like to remove all the cookbooks on the chef server, run `knife cookbook bulk delete '.*' -p -c ~/.chef/knife.rb`
|
199
247
|
|
200
|
-
|
248
|
+
10. `cft client_list` Allows you check the basic information for all the servers setup via chef. Shows the server's short name, its public ip address and roles (run_list) by default.
|
201
249
|
|
202
250
|
1. `-v` option will make this command display the server's domain name, whether its password is stored on the chef server and what that password is.
|
203
251
|
|
@@ -205,7 +253,7 @@
|
|
205
253
|
|
206
254
|
3. This command is aliased to `client-list` with no arguments or cft prefix.
|
207
255
|
|
208
|
-
|
256
|
+
11. `cft cloud <FIRST_LEVEL_ARG> [<SECOND_LEVEL_ARG>[:<SECOND_LEVEL_ARG_QUERY>]*] ` this command handles talking to various cloud APIs. If no args are passed nothing will happen.
|
209
257
|
|
210
258
|
1. `domain` first level argument for interacting with cloud domains
|
211
259
|
|
@@ -277,7 +325,31 @@
|
|
277
325
|
|
278
326
|
1. Standard servers are listed as XGB with no spaces in their size, performance servers are listed as X GB with a space in their size. If you are about to create a server and are unsure, query flavors first.
|
279
327
|
|
280
|
-
|
328
|
+
5. `image` first level argument for listing the images available on the cloud service
|
329
|
+
|
330
|
+
1. `list` default behavior
|
331
|
+
|
332
|
+
2. `read:NAME` behaves the same as list unless a specific image name is supplied
|
333
|
+
|
334
|
+
6. `region` first level argument for listing the regions available on the cloud service (only supported by DigitalOcean)
|
335
|
+
|
336
|
+
1. `list` default behavior
|
337
|
+
|
338
|
+
2. `read:REGION` behaves the same as list unless a specific region name is supplied
|
339
|
+
|
340
|
+
7. `sshkey` first level argument for listing the sshkeys added to the cloud service (only supported by DigitalOcean)
|
341
|
+
|
342
|
+
1. `list` default behavior
|
343
|
+
|
344
|
+
2. `read:KEY_NAME` behaves the same as list unless a specific sshkey name is supplied
|
345
|
+
|
346
|
+
3. `"create:KEY_NAME:KEY_STRING"` creates an sshkey object. KEY_STRING must contain the entire value of the ssh public key file. The command must be enclosed in quotes.
|
347
|
+
|
348
|
+
4. `destroy:KEY_NAME` destroys the sshkey object
|
349
|
+
|
350
|
+
5. `bootstrap` captures the current computer's hostname and checks to see if a key matching this hostname exists on the cloud service. If the key does not exist, the command attempts to read the contents of the ~/.ssh/id_rsa.pub file and create a new key with that data and the hostname of the current computer. Run automatically when creating DigitalOcean servers. It's worth noting that if the computer's key already exists on DigitalOcean under a different name, this specific command will fail with a generic error. Please check your keys.
|
351
|
+
|
352
|
+
12. `cft cloud_bootstrap NODE_NAME FLAVOR_NAME [DESCRIPTOR] [--with-dn DOMAIN]` uses a cloud api to create a server and attaches its DOMAIN_NAME to the TLD specified for that environment (IE: example-staging.com for staging)
|
281
353
|
|
282
354
|
1. If no DOMAIN_NAME is supplied it will use the node's NODE_NAME (IE: api01.example-staging.com)
|
283
355
|
|
@@ -287,19 +359,21 @@
|
|
287
359
|
|
288
360
|
4. DESCRIPTOR is used as an internal tag for the node, if left blank it will become the name of the node. It is recommended to enter a custom repository-dependent tag here to make nodes easier to load-balance like "lb:[CODEBASE_NAME]"
|
289
361
|
|
290
|
-
|
362
|
+
13. `cft compile_audit_log [clean]` compiles the audit logs in each environment's audit data bag a audit-log-CURRENTDAY.md file in the log folder of the application. Bear in mind that the bag can only hold 100K bytes and will need to have that data removed to store more than that.
|
291
363
|
|
292
|
-
|
364
|
+
14. `cft compile_readme` compiles all documentation methods and creates a README.md file in the log folder of the application.
|
293
365
|
|
294
|
-
|
366
|
+
15. `cft create_git_key ID_RSA_FILE [OAUTH_TOKEN]` This command will update the default/authentication data bag with new credentials. The [ID_RSA_FILE](https://help.github.com/articles/generating-ssh-keys) needs to exist beforehand.
|
295
367
|
|
296
368
|
1. This command will upload both the private and public key to the data bag. The public key should be the one that matches the github user for your deployment github user.
|
297
369
|
|
298
370
|
2. `OAUTH_TOKEN` *must* be generated by logging into github and generating an access token in the account settings -> applications -> personal access tokens
|
299
371
|
|
300
|
-
|
372
|
+
3. NOTE! The ID_RSA_FILE should be in your .chef folder in the root of your home directory!
|
373
|
+
|
374
|
+
16. `cft disk_report` will fetch useful statistics from every server for every environment and output it into your log directory.
|
301
375
|
|
302
|
-
|
376
|
+
17. `cft environment boot|destroy` will boot / destroy the current environment
|
303
377
|
|
304
378
|
1. `boot` will spin up servers and bring them to a stable state. This includes setting up their subdomains for the target environment.
|
305
379
|
|
@@ -307,7 +381,7 @@
|
|
307
381
|
|
308
382
|
3. This command will prompt when attempting to destroy servers in staging or production
|
309
383
|
|
310
|
-
|
384
|
+
18. `cft file NODE_NAME LOCATION_ALIAS MODE FILE_NAME` interacts with a file on the remote server
|
311
385
|
|
312
386
|
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
|
313
387
|
|
@@ -337,23 +411,21 @@
|
|
337
411
|
|
338
412
|
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.
|
339
413
|
|
340
|
-
|
414
|
+
19. `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)
|
341
415
|
|
342
416
|
1. Passing in a hostname will make the command only remove entries with that hostname / ip specifically
|
343
417
|
|
344
|
-
|
418
|
+
20. `cft full_bootstrap ADDRESS ROOT_PASS NODE_NAME` This command performs both ubuntu_bootstrap and chef_bootstrap.
|
345
419
|
|
346
|
-
|
347
|
-
|
348
|
-
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.
|
420
|
+
21. `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.
|
349
421
|
|
350
422
|
1. In devops mode, this command will not do anything without the -R repository passed.
|
351
423
|
|
352
|
-
|
424
|
+
22. `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.
|
353
425
|
|
354
|
-
|
426
|
+
23. `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.
|
355
427
|
|
356
|
-
|
428
|
+
24. `cft get_shorewall_allowed_connections [PATH_TO_LOCAL_FILE] -n NODE_NAME` command will query a single server and return all of its ACCEPT connections from shorewall in it's syslog and return the results in a CSV format. Useful for tracking IP activity.
|
357
429
|
|
358
430
|
1. You must pass in a node name to query with `-n NODE_NAME`
|
359
431
|
|
@@ -361,23 +433,43 @@
|
|
361
433
|
|
362
434
|
3. If `PATH_TO_LOCAL_FILE` is not blank, the command will use that file instead of building a file on the remote server
|
363
435
|
|
364
|
-
|
436
|
+
25. `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.
|
437
|
+
|
438
|
+
26. `cft initialize_cheftacular_yml` will create a cheftacular.yml file in your config folder (and create theconfig 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.
|
439
|
+
|
440
|
+
27. `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.
|
441
|
+
|
442
|
+
28. `cft knife_upload` will resync the chef-server with the local chef-repo code. This command is analog for `knife upload /`
|
443
|
+
|
444
|
+
29. `cft list_toggleable_roles NODE_NAME` This command will allow you to see all toggleable roles for a node
|
365
445
|
|
366
|
-
|
446
|
+
30. `cft location_aliases` will list all location aliases listed in your cheftacular.yml. These aliases can be used in the `cft file` command.
|
367
447
|
|
368
|
-
|
448
|
+
31. `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
|
369
449
|
|
370
|
-
|
450
|
+
32. `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.
|
371
451
|
|
372
|
-
|
452
|
+
1. `destroy` deletes the server as well as removing it from the chef environment.
|
373
453
|
|
374
|
-
|
454
|
+
33. `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.
|
375
455
|
|
376
|
-
|
456
|
+
34. `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`
|
377
457
|
|
378
458
|
1. There is no risk in running this command. Sometimes swap doesnt reactivate if the server was rebooted and this command fixes that.
|
379
459
|
|
380
|
-
|
460
|
+
35. `cft role_toggle NODE_NAME ROLE_NAME activate|deactivate` This command will allow you to **toggle** roles on nodes without using `cft upload_nodes`
|
461
|
+
|
462
|
+
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
|
463
|
+
|
464
|
+
2. EX: `cft role_toggle apisc01 worker activate` will find the node apisc01 and attempt to toggle the worker role to on. If the node does NOT have the worker_deactivate role, then it will add it if *role_toggling:strict_roles* is set to **false**
|
465
|
+
|
466
|
+
1. If *role_toggling:strict_roles* is set to true, then cheftacular would raise an error saying this role is unsettable on the node. On the other hand, if the node already has the worker_deactivaterole, then this command will succeed even if *strict_roles* is set.
|
467
|
+
|
468
|
+
3. In case it isn't obvious, this command ONLY supports deactivation suffix roles like worker_deactivate or worker_off, with theiron counterpart just being the role itself, like "worker".
|
469
|
+
|
470
|
+
1. Please run `cft list_toggleable_roles NODE_NAME` to get a list of your org's toggleable roles for a node.
|
471
|
+
|
472
|
+
36. `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.
|
381
473
|
|
382
474
|
1. When no commands are passed, rvm will just run `rvm list` on each server on all servers in the current environment.
|
383
475
|
|
@@ -393,11 +485,11 @@
|
|
393
485
|
|
394
486
|
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).
|
395
487
|
|
396
|
-
|
488
|
+
37. `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.
|
397
489
|
|
398
|
-
1. `
|
490
|
+
1. `cft apt_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.
|
399
491
|
|
400
|
-
|
492
|
+
38. `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.
|
401
493
|
|
402
494
|
1. When no commands are passed, the command will list all the services in the /etc/init directory
|
403
495
|
|
@@ -405,13 +497,13 @@
|
|
405
497
|
|
406
498
|
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.
|
407
499
|
|
408
|
-
|
500
|
+
39. `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.
|
409
501
|
|
410
502
|
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.
|
411
503
|
|
412
504
|
2. Remember, if you have auditing turned on in your cheftacular.yml, you can track who sends what to slack.
|
413
505
|
|
414
|
-
|
506
|
+
40. `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
|
415
507
|
|
416
508
|
1. TARGET_ENV changes functionality depending on the overall (like staging / production) environment
|
417
509
|
|
@@ -421,9 +513,9 @@
|
|
421
513
|
|
422
514
|
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
|
423
515
|
|
424
|
-
|
516
|
+
41. `cft ubuntu_bootstrap ADDRESS ROOT_PASS` 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.
|
425
517
|
|
426
|
-
|
518
|
+
42. `cft update_cloudflare_dns_from_cloud [skip_update_tld]` command will force a full dns update for cloudflare.
|
427
519
|
|
428
520
|
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.
|
429
521
|
|
@@ -431,7 +523,7 @@
|
|
431
523
|
|
432
524
|
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.
|
433
525
|
|
434
|
-
|
526
|
+
43. `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.
|
435
527
|
|
436
528
|
1. Repository must be set with `-R REPOSITORY_NAME` for this command to work.
|
437
529
|
|
@@ -441,9 +533,9 @@
|
|
441
533
|
|
442
534
|
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.
|
443
535
|
|
444
|
-
|
536
|
+
44. `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.
|
445
537
|
|
446
|
-
|
538
|
+
45. `cft upload_nodes` This command will resync the chef server's nodes with the data in our chef-repo/node_roles.
|
447
539
|
|
448
540
|
1. This command changes behavior depending on several factors about both your mode and the state of your environment
|
449
541
|
|
@@ -455,4 +547,4 @@
|
|
455
547
|
|
456
548
|
1. Due to this, only users running this against their chef-repo need to worry about having a nodes_dir, the way it should be.
|
457
549
|
|
458
|
-
|
550
|
+
46. `cft upload_roles` This command will resync the chef server's roles with the data in the chef-repo/roles.
|
@@ -18,12 +18,12 @@ class Cheftacular
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def db_console_postgresql
|
21
|
-
nodes = @config['getter'].get_true_node_objects
|
21
|
+
nodes = @config['getter'].get_true_node_objects(true)
|
22
22
|
|
23
23
|
#must have rails stack to run migrations and not be a db, only want ONE node
|
24
|
-
psqlable_nodes = @config['parser'].exclude_nodes( nodes, [{ unless: "role[#{ @options['role'] }]" }, { unless: 'role[rails]' }], true )
|
24
|
+
psqlable_nodes = @config['parser'].exclude_nodes( nodes, [{ unless: "role[#{ @options['role'] }]" }, { unless: 'role[rails]' }, { if: { not_env: @options['env'] } }], true )
|
25
25
|
|
26
|
-
database_host = @config['parser'].exclude_nodes( nodes, [{ unless: "role[#{ @config['getter'].get_current_repo_config['db_primary_host_role'] }]"}], true).first
|
26
|
+
database_host = @config['parser'].exclude_nodes( nodes, [{ unless: "role[#{ @config['getter'].get_current_repo_config['db_primary_host_role'] }]"}, { if: { not_env: @options['env'] } }], true).first
|
27
27
|
|
28
28
|
private_database_host_address = @config['getter'].get_address_hash(database_host.name)[database_host.name]['priv']
|
29
29
|
|
@@ -10,7 +10,9 @@ class Cheftacular
|
|
10
10
|
"but only if your cookbooks support switching revisions based on tags / branch names.",
|
11
11
|
|
12
12
|
" 2. This command will also run migrations on both an role's normal servers and its split servers if certain " +
|
13
|
-
"conditions are met (such as the role having a database, etc)."
|
13
|
+
"conditions are met (such as the role having a database, etc).",
|
14
|
+
|
15
|
+
" 3. The `-v|--verbose` option will cause failed deploys to output to the terminal window and to their normal log file. Useful for debugging."
|
14
16
|
]
|
15
17
|
]
|
16
18
|
end
|
@@ -49,20 +51,22 @@ class Cheftacular
|
|
49
51
|
|
50
52
|
split_nodes_hash = {}
|
51
53
|
|
52
|
-
@config['cheftacular']['run_list_environments']
|
53
|
-
|
54
|
-
|
54
|
+
if @config['cheftacular']['run_list_environments'].has_key?(@options['env'])
|
55
|
+
@config['cheftacular']['run_list_environments'][@options['env']].each_key do |role_name|
|
56
|
+
split_nodes_hash[role_name] = @config['parser'].exclude_nodes( nodes, [{ unless: "role[#{ role_name }]" }])
|
57
|
+
end
|
55
58
|
|
56
|
-
|
57
|
-
|
59
|
+
split_nodes_hash.each_pair do |role, split_nodes|
|
60
|
+
next if split_nodes.empty?
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
if @config['getter'].get_current_repo_config['database'] != 'none'
|
63
|
-
puts("Running migration on split environment #{ role }...") if !@options['quiet']
|
62
|
+
unless @options["run_#{ role }_migrations_already"]
|
63
|
+
@options["run_#{ role }_migrations_already"] = true
|
64
64
|
|
65
|
-
|
65
|
+
if @config['getter'].get_current_repo_config['database'] != 'none'
|
66
|
+
puts("Running migration on split environment #{ role }...") if !@options['quiet']
|
67
|
+
|
68
|
+
migrate(split_nodes)
|
69
|
+
end
|
66
70
|
end
|
67
71
|
end
|
68
72
|
end
|
@@ -94,6 +98,8 @@ module SSHKit
|
|
94
98
|
rescue SSHKit::Command::Failed => e
|
95
99
|
puts "@@@@@CRITICAL! Deploy failed for #{ name } (#{ ip_address })! Please check your #{ log_loc }/failed-deploy for the logs!@@@@@"
|
96
100
|
|
101
|
+
puts(e.message) if options['verbose']
|
102
|
+
|
97
103
|
lines = e.message.split("\n").last(100).join("\n")
|
98
104
|
|
99
105
|
::File.open("#{ log_loc }/failed-deploy/#{ name }-deploy-#{ timestamp }.txt", "w") { |f| f.write(e.message.scrub_pretty_text) }
|
data/lib/cheftacular/auditor.rb
CHANGED
@@ -17,13 +17,21 @@ class Cheftacular
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def write_audit_cache_file
|
20
|
-
File.open( @config['
|
20
|
+
File.open( @config['filesystem'].current_audit_file_path, "w") { |f| f.write( fetch_audit_data_hash ) }
|
21
21
|
end
|
22
22
|
|
23
|
-
def read_audit_cache_file_to_hash ret_hash={}
|
24
|
-
ret_hash = Hash.class_eval( File.read( @config['
|
23
|
+
def read_audit_cache_file_to_hash ret_hash={}, options_to_ignore=[]
|
24
|
+
ret_hash = Hash.class_eval( File.read( @config['filesystem'].current_audit_file_path ))
|
25
25
|
ret_hash['command'] = @options['command']
|
26
|
-
|
26
|
+
|
27
|
+
options_to_ignore << :preferred_cloud if @options['preferred_cloud'] == @config['cheftacular']['preferred_cloud']
|
28
|
+
options_to_ignore << :preferred_cloud_image if @options['preferred_cloud_image'] == @config['cheftacular']['preferred_cloud_image']
|
29
|
+
options_to_ignore << :preferred_cloud_region if @options['preferred_cloud_region'] == @config['cheftacular']['preferred_cloud_region']
|
30
|
+
options_to_ignore << :virtualization_mode if @options['virtualization_mode'] == @config['cheftacular']['virtualization_mode']
|
31
|
+
options_to_ignore << :route_dns_changes_via if @options['route_dns_changes_via'] == @config['cheftacular']['route_dns_changes_via']
|
32
|
+
|
33
|
+
ret_hash['options'] = @options.dup.delete_if { |key, value| options_to_ignore.include?(key.to_sym) }
|
34
|
+
|
27
35
|
ret_hash['arguments'] = ARGV[1..ARGV.length]
|
28
36
|
|
29
37
|
ret_hash
|
@@ -34,9 +42,9 @@ class Cheftacular
|
|
34
42
|
|
35
43
|
ret_hash
|
36
44
|
rescue StandardError => exception
|
37
|
-
@config['
|
45
|
+
@config['filesystem'].cleanup_file_caches('current-audit-only')
|
38
46
|
|
39
|
-
@config['
|
47
|
+
@config['error'].exception_output "Unable to finish parsing auditing hash", exception
|
40
48
|
end
|
41
49
|
end
|
42
50
|
end
|
@@ -29,9 +29,6 @@ class Cheftacular
|
|
29
29
|
|
30
30
|
item = @config[env]['logs_bag'].reload
|
31
31
|
|
32
|
-
#TODO use zlib gem to store and display logs https://stackoverflow.com/questions/17882463/compressing-large-string-in-ruby
|
33
|
-
#Zlib::Deflate.deflate(data_to_compress)
|
34
|
-
#Zlib::Inflate.inflate(data_compressed)
|
35
32
|
item.attributes = item.attributes.deep_merge(@config[env]['logs_bag_hash'].dup)
|
36
33
|
|
37
34
|
begin
|
@@ -106,7 +103,7 @@ class Cheftacular
|
|
106
103
|
rescue Ridley::Errors::HTTPRequestEntityTooLarge => e
|
107
104
|
msg = "FATAL! Bag #{ bag_name } in environment bag #{ bag_env } was not able to be saved because it has grown too large! This bag must cleaned up ASAP!"
|
108
105
|
|
109
|
-
@config['
|
106
|
+
@config['error'].exception_output msg, e
|
110
107
|
end
|
111
108
|
end
|
112
109
|
end
|