cheftacular 2.11.1 → 2.12.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 +94 -10
- data/lib/cheftacular/actions/migrate.rb +1 -1
- data/lib/cheftacular/actions/run.rb +1 -1
- data/lib/cheftacular/cheftacular.rb +1 -0
- data/lib/cheftacular/file_system.rb +8 -3
- data/lib/cheftacular/helper.rb +40 -1
- data/lib/cheftacular/initializer.rb +24 -2
- data/lib/cheftacular/queue_master.rb +4 -0
- data/lib/cheftacular/stateless_actions/arguments.rb +7 -1
- data/lib/cheftacular/stateless_actions/backups.rb +65 -38
- data/lib/cheftacular/stateless_actions/bootstrappers/ubuntu_bootstrap_from_queue.rb +2 -6
- data/lib/cheftacular/stateless_actions/chef_bootstrap_from_queue.rb +1 -1
- data/lib/cheftacular/stateless_actions/cheftacular_config.rb +1 -23
- data/lib/cheftacular/stateless_actions/clean_cookbooks.rb +9 -11
- data/lib/cheftacular/stateless_actions/client_list.rb +14 -4
- data/lib/cheftacular/stateless_actions/cloud_bootstrap.rb +0 -4
- data/lib/cheftacular/stateless_actions/knife_upload.rb +3 -1
- data/lib/cheftacular/stateless_actions/update_cookbook.rb +45 -0
- data/lib/cheftacular/version.rb +1 -1
- data/lib/sshkit/actions/start_task.rb +2 -2
- data/lib/sshkit/monkeypatches.rb +0 -2
- metadata +19 -5
- data/lib/cheftacular/stateless_actions/update_thecheftacularcookbook.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2f0c0d7f232e7617f6c0f511806a71d37f7b7fa
|
4
|
+
data.tar.gz: 43aeba1d59eec85f9c5fc7d5f20b168cb8283cf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b2567debc1835e4079e46486301ce31ee675efcc24cb1e89c739178d29a97f33fb237c28800733a6466fd5b8b55dbfb1d1cc821b456e0ef547a802ae59b295e
|
7
|
+
data.tar.gz: f8a09335967bd9bc172e77a00a710708bde5cc1c24a34c99bbcde186aea7d89865b96f796ceeff463af8af8e882207c362702e506bceb8c9075d8dce88a407de
|
data/lib/cheftacular/README.md
CHANGED
@@ -41,7 +41,73 @@
|
|
41
41
|
|
42
42
|
7. `-R|--repository NAME` will make the command run against a specific repository or context (automatically set for application mode)
|
43
43
|
|
44
|
-
8. `-
|
44
|
+
8. `-s|--search-node-name NODE_NAME` option will make this command return results that INCLUDE the NODE_NAME.
|
45
|
+
|
46
|
+
9. `-S|--search-role-name ROLE_NAME` option will make this command return results that INCLUDE the ROLE_NAME.
|
47
|
+
|
48
|
+
10. `-E|--search-env-name ENV_NAME` option will make this command return results that have this environment.
|
49
|
+
|
50
|
+
11. `-v|--verbose` toggles on verbose logging. All commands that write logs will also output to terminal AND write the logs.
|
51
|
+
|
52
|
+
### Help Related
|
53
|
+
|
54
|
+
1. `-h|--help` Displays the full readme and exits.
|
55
|
+
|
56
|
+
### Action Flags
|
57
|
+
|
58
|
+
1. `-e|--except-role ROLE_NAME` will *prevent* any server with this role from being *deployed to* for the deploy command. Other commands will ignore this argument.
|
59
|
+
|
60
|
+
2. `-z|--unset-github-deploy-args` will unset a custom revision specified in the arg below and make the codebase utilize the default.
|
61
|
+
|
62
|
+
3. `-Z|--revision REVISION` will force the role you're deploying to to utilize the revision specified here. This can be a specific commit, a branch name or even a tag.
|
63
|
+
|
64
|
+
1. Note: The system does not check if the revision exists, if you pass a non-existent revision no one will be able to deploy to that role until -Z with a correction revision or -z is passed.
|
65
|
+
|
66
|
+
4. The `-O ORGANIZATION` flag can be used with TheCheftacularCookbook to set an *organization* your app can try deploying from, your git user needs access to these forks / organization(s).
|
67
|
+
|
68
|
+
3. The `-z|--unset-github-deploy-args` option will clear your current `-Z` and `-O` flags.
|
69
|
+
|
70
|
+
## Arguments and flags for cheftacular
|
71
|
+
|
72
|
+
### Environment flags
|
73
|
+
|
74
|
+
1. `-d|--dev-remote` toggles on dev-remote mode. Commands passed to cft will hit the devremote server(s) instead of the default server(s)
|
75
|
+
|
76
|
+
2. `--env ENV` sets the environment commands hit to one you specify instead of the default one.
|
77
|
+
|
78
|
+
3. `-p|--prod` toggles on production mode. Commands passed to cft will hit the production server(s) instead of the default server(s)
|
79
|
+
|
80
|
+
4. `-Q|--qa` toggles on QA mode. Commands passed to cft will hit the QA server(s) instead of the default server(s)
|
81
|
+
|
82
|
+
5. `-s|--staging` toggles on staging mode. Commands passed to cft will hit the staging server(s) instead of the default server(s)
|
83
|
+
|
84
|
+
6. `--split-env SPLIT_ENV_NAME` sets the sub-environment to SPLIT_ENV_NAME. This only slightly affects certain commands.
|
85
|
+
|
86
|
+
7. `-t|--test` toggles on test mode. Commands passed to cft will hit the test server(s) instead of the default server(s)
|
87
|
+
|
88
|
+
### General Flags
|
89
|
+
|
90
|
+
1. `-a|--address ADDRESS` will force the command to only run against the specified address if it belongs to a node
|
91
|
+
|
92
|
+
2. `-D|--debug` toggles on extremely verbose logging. Chef-client runs will generate ~10 times the amounts of logs including any additional effects that the `-v` flag will activate
|
93
|
+
|
94
|
+
3. `--no-logs` will make the cft commands not generate log files, you must still specify `-v` if you want output of most verbose commands to your terminal.
|
95
|
+
|
96
|
+
4. `-n|--node-name NODE_NAME` will force the command to only run against the specified name if it belongs to a node
|
97
|
+
|
98
|
+
5. `-q|--quiet` will make the cft commands only output information that is a direct result of the command being run
|
99
|
+
|
100
|
+
6. `-r|--role-name ROLE_NAME` will force the command to only run against the specified role if it exists (this argument is generally not needed though it can be used to deploy a codebase for an application you're not currently cd'd into when running this as a gem)
|
101
|
+
|
102
|
+
7. `-R|--repository NAME` will make the command run against a specific repository or context (automatically set for application mode)
|
103
|
+
|
104
|
+
8. `-s|--search-node-name NODE_NAME` option will make this command return results that INCLUDE the NODE_NAME.
|
105
|
+
|
106
|
+
9. `-S|--search-role-name ROLE_NAME` option will make this command return results that INCLUDE the ROLE_NAME.
|
107
|
+
|
108
|
+
10. `-E|--search-env-name ENV_NAME` option will make this command return results that have this environment.
|
109
|
+
|
110
|
+
11. `-v|--verbose` toggles on verbose logging. All commands that write logs will also output to terminal AND write the logs.
|
45
111
|
|
46
112
|
### Help Related
|
47
113
|
|
@@ -64,15 +130,17 @@
|
|
64
130
|
|
65
131
|
## Commands that can be run in the application context
|
66
132
|
|
67
|
-
1. `cft backups [activate|deactivate|load|restore]` 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
|
133
|
+
1. `cft backups [activate|deactivate|fetch|load|restore]` 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
|
68
134
|
|
69
135
|
1. `activate` will turn on automated backup running (turns on the flag for the env in the config bag).
|
70
136
|
|
71
137
|
2. `deactivate` will turn off automated backup running.
|
72
138
|
|
73
|
-
3. `
|
139
|
+
3. `fetch` will fetch the latest backup and drop it onto your machine. This argument accepts the --save-to-file LOCATION flag.
|
140
|
+
|
141
|
+
4. `load` will fetch the latest backup from the production primary **if it doesn't already exist on the server** and run the _backup loading command_ to load this backup into the env.
|
74
142
|
|
75
|
-
|
143
|
+
5. `restore` will simply just run the _backup loading command_ to load the latest backup onto the server.
|
76
144
|
|
77
145
|
2. `cft check [all]` 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.
|
78
146
|
|
@@ -116,6 +184,12 @@
|
|
116
184
|
|
117
185
|
2. `-W|--with-priv` option will make this command display the server's local (private) ip address. This address is also the server's `local.<SERVER_DNS_NAME>`.
|
118
186
|
|
187
|
+
3. `-s|--search-node-name NODE_NAME` option will make this command return results that INCLUDE the NODE_NAME.
|
188
|
+
|
189
|
+
4. `-S|--search-role-name ROLE_NAME` option will make this command return results that INCLUDE the ROLE_NAME.
|
190
|
+
|
191
|
+
5. `-E|--search-env-name ENV_NAME` option will make this command return results that have this environment.
|
192
|
+
|
119
193
|
8. `cft console` will create a console session on the first node found for a repository.
|
120
194
|
|
121
195
|
1. Attempts to setup a console for the unique stack, stacks currently supported for console is only Rails.
|
@@ -269,15 +343,17 @@
|
|
269
343
|
|
270
344
|
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.
|
271
345
|
|
272
|
-
4. `cft backups [activate|deactivate|load|restore]` 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
|
346
|
+
4. `cft backups [activate|deactivate|fetch|load|restore]` 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
|
273
347
|
|
274
348
|
1. `activate` will turn on automated backup running (turns on the flag for the env in the config bag).
|
275
349
|
|
276
350
|
2. `deactivate` will turn off automated backup running.
|
277
351
|
|
278
|
-
3. `
|
352
|
+
3. `fetch` will fetch the latest backup and drop it onto your machine. This argument accepts the --save-to-file LOCATION flag.
|
353
|
+
|
354
|
+
4. `load` will fetch the latest backup from the production primary **if it doesn't already exist on the server** and run the _backup loading command_ to load this backup into the env.
|
279
355
|
|
280
|
-
|
356
|
+
5. `restore` will simply just run the _backup loading command_ to load the latest backup onto the server.
|
281
357
|
|
282
358
|
5. `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.
|
283
359
|
|
@@ -327,6 +403,12 @@
|
|
327
403
|
|
328
404
|
2. `-W|--with-priv` option will make this command display the server's local (private) ip address. This address is also the server's `local.<SERVER_DNS_NAME>`.
|
329
405
|
|
406
|
+
3. `-s|--search-node-name NODE_NAME` option will make this command return results that INCLUDE the NODE_NAME.
|
407
|
+
|
408
|
+
4. `-S|--search-role-name ROLE_NAME` option will make this command return results that INCLUDE the ROLE_NAME.
|
409
|
+
|
410
|
+
5. `-E|--search-env-name ENV_NAME` option will make this command return results that have this environment.
|
411
|
+
|
330
412
|
13. `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.
|
331
413
|
|
332
414
|
1. `domain` first level argument for interacting with cloud domains
|
@@ -623,7 +705,11 @@
|
|
623
705
|
|
624
706
|
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.
|
625
707
|
|
626
|
-
49. `cft
|
708
|
+
49. `cft update_cookbook [COOKBOOK_NAME]` allows you to specifically update a single cookbook
|
709
|
+
|
710
|
+
1. This command passed with no arguments will update TheCheftacularCookbook
|
711
|
+
|
712
|
+
50. `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.
|
627
713
|
|
628
714
|
1. Repository must be set with `-R REPOSITORY_NAME` for this command to work.
|
629
715
|
|
@@ -633,8 +719,6 @@
|
|
633
719
|
|
634
720
|
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.
|
635
721
|
|
636
|
-
50. `cft update_thecheftacularcookbook` allows you to update ONLY the internal chef-repo's TheCheftacularCookbook.
|
637
|
-
|
638
722
|
51. `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.
|
639
723
|
|
640
724
|
52. `cft upload_nodes` This command will resync the chef server's nodes with the data in our chef-repo/node_roles.
|
@@ -36,7 +36,7 @@ class Cheftacular
|
|
36
36
|
|
37
37
|
puts("Beginning migration run for #{ n.name } (#{ n.public_ipaddress }) on role #{ options['role'] }") unless options['quiet']
|
38
38
|
|
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)
|
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
41
|
logs_bag_hash["#{ n.name }-#{ __method__ }"] = { "text" => log_data.scrub_pretty_text, "timestamp" => timestamp, "exit_status" => exit_status }
|
42
42
|
end
|
@@ -46,7 +46,7 @@ class Cheftacular
|
|
46
46
|
|
47
47
|
puts("Beginning task run for #{ n.name } (#{ n.public_ipaddress }) on role #{ options['role'] }") unless options['quiet']
|
48
48
|
|
49
|
-
log_data, timestamp, exit_status = start_task( n.name, n.public_ipaddress, n.run_list, "#{ bundle_command } exec #{ command }", options, locs, cheftacular)
|
49
|
+
log_data, timestamp, exit_status = start_task( n.name, n.public_ipaddress, n.run_list, "#{ bundle_command } exec #{ command }", options, locs, cheftacular, passwords)
|
50
50
|
|
51
51
|
logs_bag_hash["#{ n.name }-#{ __method__ }"] = { "text" => log_data.scrub_pretty_text, "timestamp" => timestamp, "exit_status" => exit_status }
|
52
52
|
end
|
@@ -30,6 +30,7 @@ class Cheftacular
|
|
30
30
|
def initialize options={'env'=>'staging'}, config={}
|
31
31
|
@options, @config = options, config
|
32
32
|
SSHKit.config.format = :blackhole
|
33
|
+
Excon.defaults[:ssl_verify_peer] = false #https://github.com/excon/excon/issues/479 # issues with cert bundle chains
|
33
34
|
#Fog::Logger[:warning] = nil
|
34
35
|
@config['start_time'] = Time.now
|
35
36
|
@config['helper'] = Helper.new(@options, @config)
|
@@ -137,7 +137,7 @@ class Cheftacular
|
|
137
137
|
File.open( File.join(@config['locs']['chef-repo'], "config", to_be_created_filename), "w") { |f| f.write(File.read(File.join(@config['locs']['examples'], example_filename))) }
|
138
138
|
end
|
139
139
|
|
140
|
-
def
|
140
|
+
def parse_berkshelf_cookbook_versions version='latest', berkshelf_cookbooks={}
|
141
141
|
|
142
142
|
Dir.foreach(@config['locs']['berks']) do |berkshelf_cookbook|
|
143
143
|
next if is_junk_filename?(berkshelf_cookbook)
|
@@ -148,7 +148,12 @@ class Cheftacular
|
|
148
148
|
|
149
149
|
#get only the latest version, berkshelf pulls in multiple commits from git repos for SOME REASON
|
150
150
|
use_current_cookbook = !berkshelf_cookbooks.has_key?(true_cookbook_name)
|
151
|
-
|
151
|
+
|
152
|
+
if version == 'latest'
|
153
|
+
use_current_cookbook = @config['helper'].is_higher_version?(cookbook_version, berkshelf_cookbooks[true_cookbook_name]['version']) if berkshelf_cookbooks.has_key?(true_cookbook_name)
|
154
|
+
else
|
155
|
+
use_current_cookbook = true if berkshelf_cookbooks.has_key?(true_cookbook_name) && cookbook_version == version
|
156
|
+
end
|
152
157
|
|
153
158
|
if use_current_cookbook
|
154
159
|
berkshelf_cookbooks[true_cookbook_name] ||= {}
|
@@ -191,7 +196,7 @@ class Cheftacular
|
|
191
196
|
|
192
197
|
def scrub_from_known_hosts target
|
193
198
|
puts "Clearing #{ target } from known_hosts file."
|
194
|
-
case CONFIG['host_os']
|
199
|
+
case RbConfig::CONFIG['host_os']
|
195
200
|
when /mswin|windows/i
|
196
201
|
puts "#{ __method__ } does not support this operating system at this time"
|
197
202
|
when /linux|arch/i
|
data/lib/cheftacular/helper.rb
CHANGED
@@ -248,7 +248,11 @@ class Cheftacular
|
|
248
248
|
if hash['exit_status'] && hash['exit_status'] == 1
|
249
249
|
@config['slack_queue'] << { message: hash['text'].prepend('```').insert(-1, '```') }
|
250
250
|
|
251
|
-
|
251
|
+
if !on_failing_exit_status_message.blank?
|
252
|
+
@config['queue_master'].work_off_slack_queue
|
253
|
+
|
254
|
+
@config['error'].exception_output(on_failing_exit_status_message)
|
255
|
+
end
|
252
256
|
end
|
253
257
|
end
|
254
258
|
end
|
@@ -316,6 +320,41 @@ class Cheftacular
|
|
316
320
|
exit
|
317
321
|
end
|
318
322
|
end
|
323
|
+
|
324
|
+
def display_cheftacular_config_diff
|
325
|
+
diff_hash = @config['initial_cheftacular_yml'].deep_diff(@config['default']['cheftacular_bag_hash'], true).except('mode', 'default_repository').compact
|
326
|
+
|
327
|
+
recursive_hash_scrub(diff_hash)
|
328
|
+
recursive_hash_scrub(diff_hash) #scrub out any leftover empty hashes
|
329
|
+
|
330
|
+
if diff_hash.empty?
|
331
|
+
puts "No difference detected between your cheftacular.yml and the global environment."
|
332
|
+
else
|
333
|
+
puts "Difference detected between local cheftacular.yml and data bag cheftacular.yml! Displaying...\n\n"
|
334
|
+
|
335
|
+
ap diff_hash
|
336
|
+
|
337
|
+
if @config['helper'].running_in_mode?('application') && @config['default']['cheftacular_bag_hash']['slack']['webhook'] && !diff_hash.empty?
|
338
|
+
@config['slack_queue'] << { message: diff_hash.awesome_inspect({plain: true, indent: 2}).prepend('```').insert(-1, '```'), channel: @config['cheftacular']['slack']['notify_on_yaml_sync'] }
|
339
|
+
end
|
340
|
+
|
341
|
+
puts("If these are your intended changes you want to sync into the environment, you should run `cft cheftacular_config sync`\n\n") if ARGV[0] != 'cheftacular_config' && ARGV[1] != 'sync'
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
def recursive_hash_scrub hash
|
346
|
+
hash.each_pair do |key, value|
|
347
|
+
if value.nil?
|
348
|
+
hash.delete(key)
|
349
|
+
elsif value.class == Hash && value.empty?
|
350
|
+
hash.delete(key)
|
351
|
+
elsif value.class == Hash && value[value.keys.first].empty?
|
352
|
+
hash.delete(key)
|
353
|
+
elsif value.class == Hash
|
354
|
+
recursive_hash_scrub(hash[key])
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
319
358
|
end
|
320
359
|
end
|
321
360
|
|
@@ -12,6 +12,8 @@ class Cheftacular
|
|
12
12
|
|
13
13
|
initialize_locations
|
14
14
|
|
15
|
+
initialize_directories
|
16
|
+
|
15
17
|
initialize_data_bag_cheftacular_hash if !@config['helper'].is_initialization_command?(ARGV[0]) && !@config['helper'].running_on_chef_node?
|
16
18
|
|
17
19
|
initialize_monkeypatches unless @config['helper'].running_on_chef_node?
|
@@ -30,8 +32,6 @@ class Cheftacular
|
|
30
32
|
|
31
33
|
initialize_classes
|
32
34
|
|
33
|
-
initialize_directories
|
34
|
-
|
35
35
|
unless @config['helper'].is_initialization_command?(ARGV[0])
|
36
36
|
initialize_cloud_checks
|
37
37
|
|
@@ -111,6 +111,10 @@ class Cheftacular
|
|
111
111
|
@options['verbose'] = true
|
112
112
|
end
|
113
113
|
|
114
|
+
opts.on('-E', '--search-env-name ENV_NAME', 'For commands that support searching, return results with this environment in them') do |name|
|
115
|
+
@options['search_env_name'] = name
|
116
|
+
end
|
117
|
+
|
114
118
|
opts.on('-n', '--node-name NAME', "Run your command against this node_name") do |name|
|
115
119
|
@options['node_name'] = name
|
116
120
|
end
|
@@ -127,6 +131,14 @@ class Cheftacular
|
|
127
131
|
@options['repository'] = name
|
128
132
|
end
|
129
133
|
|
134
|
+
opts.on('-s', '--search-node-name NODE_NAME', 'For commands that support searching, return results with NODE_NAME in them') do |name|
|
135
|
+
@options['search_node_name'] = name
|
136
|
+
end
|
137
|
+
|
138
|
+
opts.on('-S', '--search-role-name ROLE_NAME', 'For commands that support searching, return results with ROLE_NAME in them') do |name|
|
139
|
+
@options['search_role_name'] = name
|
140
|
+
end
|
141
|
+
|
130
142
|
opts.on('-v', '--verbose', "Activates slightly more verbose logging, also causes commands to output to terminal and logs") do
|
131
143
|
@options['verbose'] = true
|
132
144
|
end
|
@@ -261,6 +273,16 @@ class Cheftacular
|
|
261
273
|
@config['initial_cheftacular_yml'] = @config['cheftacular'].deep_dup
|
262
274
|
|
263
275
|
@config['cheftacular'] = @config['default']['cheftacular_bag_hash'].deep_merge(@config['cheftacular'])
|
276
|
+
|
277
|
+
parsed_cheftacular = Digest::SHA2.hexdigest(@config['helper'].get_cheftacular_yml_as_hash.to_s)
|
278
|
+
|
279
|
+
return true if File.exist?(@config['filesystem'].local_cheftacular_file_cache_path) && File.read(@config['filesystem'].local_cheftacular_file_cache_path) == parsed_cheftacular
|
280
|
+
|
281
|
+
@config['helper'].display_cheftacular_config_diff
|
282
|
+
|
283
|
+
puts "Creating file cache for #{ Time.now.strftime("%Y%m%d") }'s local cheftacular.yml."
|
284
|
+
|
285
|
+
@config['filesystem'].write_local_cheftacular_cache_file parsed_cheftacular
|
264
286
|
end
|
265
287
|
|
266
288
|
def initialize_default_cheftacular_options
|
@@ -36,7 +36,13 @@ class Cheftacular
|
|
36
36
|
|
37
37
|
'7. `-R|--repository NAME` will make the command run against a specific repository or context (automatically set for application mode)',
|
38
38
|
|
39
|
-
'8. `-
|
39
|
+
'8. `-s|--search-node-name NODE_NAME` option will make this command return results that INCLUDE the NODE_NAME.',
|
40
|
+
|
41
|
+
'9. `-S|--search-role-name ROLE_NAME` option will make this command return results that INCLUDE the ROLE_NAME.',
|
42
|
+
|
43
|
+
'10. `-E|--search-env-name ENV_NAME` option will make this command return results that have this environment.',
|
44
|
+
|
45
|
+
'11. `-v|--verbose` toggles on verbose logging. All commands that write logs will also output to terminal AND write the logs.',
|
40
46
|
|
41
47
|
'### Help Related',
|
42
48
|
|
@@ -4,7 +4,7 @@ class Cheftacular
|
|
4
4
|
def backups
|
5
5
|
@config['documentation']['stateless_action'][__method__] ||= {}
|
6
6
|
@config['documentation']['stateless_action'][__method__]['long_description'] = [
|
7
|
-
"`cft backups [activate|deactivate|load|restore]` this command " +
|
7
|
+
"`cft backups [activate|deactivate|fetch|load|restore]` this command " +
|
8
8
|
"sets the fetch_backups and restore_backups flags in your config data bag for an environment. " +
|
9
9
|
"These can be used to give application developers a way to trigger / untrigger restores in an environment",
|
10
10
|
|
@@ -13,10 +13,12 @@ class Cheftacular
|
|
13
13
|
|
14
14
|
" 2. `deactivate` will turn off automated backup running.",
|
15
15
|
|
16
|
-
" 3. `
|
16
|
+
" 3. `fetch` will fetch the latest backup and drop it onto your machine. This argument accepts the --save-to-file LOCATION flag.",
|
17
|
+
|
18
|
+
" 4. `load` will fetch the latest backup from the production primary **if it doesn't already exist on " +
|
17
19
|
"the server** and run the _backup loading command_ to load this backup into the env.",
|
18
20
|
|
19
|
-
"
|
21
|
+
" 5. `restore` will simply just run the _backup loading command_ to load the latest backup onto the server."
|
20
22
|
]
|
21
23
|
]
|
22
24
|
|
@@ -30,7 +32,7 @@ class Cheftacular
|
|
30
32
|
def backups command=''
|
31
33
|
command = ARGV[1] if command.blank?
|
32
34
|
|
33
|
-
raise "Unsupported command (#{ command }) for cft backups" unless command =~ /activate|deactivate|load|restore/
|
35
|
+
raise "Unsupported command (#{ command }) for cft backups" unless command =~ /activate|deactivate|fetch|load|restore/
|
34
36
|
|
35
37
|
self.send("backups_#{ command }")
|
36
38
|
end
|
@@ -46,44 +48,12 @@ class Cheftacular
|
|
46
48
|
end
|
47
49
|
|
48
50
|
def backups_load status_hash={}
|
49
|
-
|
50
|
-
|
51
|
-
if backup_env != @options['env']
|
52
|
-
@config['initializer'].initialize_data_bags_for_environment(backup_env, false, ['addresses', 'server_passwords', 'logs'])
|
53
|
-
@config['initializer'].initialize_passwords backup_env
|
54
|
-
end
|
55
|
-
|
56
|
-
@options['role'] = @config['cheftacular']['backup_config']['global_backup_role_name']
|
57
|
-
@options['env'] = backup_env
|
58
|
-
|
59
|
-
puts "Deploying to backup master to force refresh of the ssh keys..."
|
60
|
-
@config['action'].deploy
|
51
|
+
target_db_primary, nodes, status_hash, backup_master_local_ip = backups_get_status_hash_from_backupmaster
|
61
52
|
|
62
|
-
|
63
|
-
@options['env'] = old_env
|
64
|
-
|
65
|
-
target_db_primary, nodes = @config['getter'].get_db_primary_node_and_nodes
|
66
|
-
|
67
|
-
args_config = [
|
68
|
-
{ unless: "role[#{ @config['cheftacular']['backup_config']['global_backup_role_name'] }]" },
|
69
|
-
{ if: { not_env: backup_env } }
|
70
|
-
]
|
71
|
-
|
72
|
-
backup_master = @config['parser'].exclude_nodes( nodes, args_config, true)
|
73
|
-
backup_master_local_ip = @config['getter'].get_address_hash(backup_master.first.name, true)[backup_master.first.name]['priv']
|
53
|
+
return false unless status_hash['latest_backup']['file_check']
|
74
54
|
|
75
55
|
options, locs, ridley, logs_bag_hash, pass_bag_hash, bundle_command, cheftacular, passwords = @config['helper'].set_local_instance_vars
|
76
56
|
|
77
|
-
on ( backup_master.map { |n| @config['cheftacular']['deploy_user'] + "@" + n.public_ipaddress } ) do |host|
|
78
|
-
n = get_node_from_address(nodes, host.hostname)
|
79
|
-
|
80
|
-
puts("Beginning latest db_fetch_and_check for #{ n.name } (#{ n.public_ipaddress }) for env #{ backup_env }") unless options['quiet']
|
81
|
-
|
82
|
-
status_hash['latest_backup'] = start_db_check_and_fetch( n.name, n.public_ipaddress, options, locs, cheftacular, passwords)
|
83
|
-
end
|
84
|
-
|
85
|
-
return false unless status_hash['latest_backup']['file_check']
|
86
|
-
|
87
57
|
on ( target_db_primary.map { |n| @config['cheftacular']['deploy_user'] + "@" + n.public_ipaddress } ) do |host|
|
88
58
|
n = get_node_from_address(nodes, host.hostname)
|
89
59
|
|
@@ -113,6 +83,17 @@ class Cheftacular
|
|
113
83
|
end
|
114
84
|
end
|
115
85
|
|
86
|
+
def backups_fetch
|
87
|
+
target_db_primary, nodes, status_hash, backup_master_local_ip = backups_get_status_hash_from_backupmaster(__method__.to_s)
|
88
|
+
|
89
|
+
full_backup_dir = File.join(@config['cheftacular']['backup_config']['db_primary_backup_path'], status_hash['latest_backup']['file_dir'])
|
90
|
+
full_backup_path = File.join(full_backup_dir, status_hash['latest_backup']['filename'])
|
91
|
+
|
92
|
+
file_scp_execute(target_db_primary, 'scp', full_backup_dir, status_hash['latest_backup']['filename'])
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
116
97
|
def backups_toggle_setting restore_backup, fetch_backup
|
117
98
|
initial_fetch_backup = @config[@options['env']]['config_bag_hash'][@options['sub_env']]['fetch_backups']
|
118
99
|
initial_restore_backup = @config[@options['env']]['config_bag_hash'][@options['sub_env']]['restore_backups']
|
@@ -134,6 +115,52 @@ class Cheftacular
|
|
134
115
|
|
135
116
|
@config['action'].deploy
|
136
117
|
end
|
118
|
+
|
119
|
+
def backups_get_status_hash_from_backupmaster mode='backups_load', status_hash={}
|
120
|
+
backup_env = @config['cheftacular']['backup_config']['global_backup_environ']
|
121
|
+
|
122
|
+
if backup_env != @options['env']
|
123
|
+
@config['initializer'].initialize_data_bags_for_environment(backup_env, false, ['addresses', 'server_passwords', 'logs'])
|
124
|
+
@config['initializer'].initialize_passwords backup_env
|
125
|
+
end
|
126
|
+
|
127
|
+
if mode == 'backups_load'
|
128
|
+
old_role, old_env = @options['role'], @options['env']
|
129
|
+
|
130
|
+
@options['role'] = @config['cheftacular']['backup_config']['global_backup_role_name']
|
131
|
+
@options['env'] = backup_env
|
132
|
+
|
133
|
+
puts "Deploying to backup master to force refresh of the ssh keys..."
|
134
|
+
@config['action'].deploy
|
135
|
+
|
136
|
+
@options['role'] = old_role
|
137
|
+
@options['env'] = old_env
|
138
|
+
end
|
139
|
+
|
140
|
+
target_db_primary, nodes = @config['getter'].get_db_primary_node_and_nodes
|
141
|
+
|
142
|
+
args_config = [
|
143
|
+
{ unless: "role[#{ @config['cheftacular']['backup_config']['global_backup_role_name'] }]" },
|
144
|
+
{ if: { not_env: backup_env } }
|
145
|
+
]
|
146
|
+
|
147
|
+
backup_master = @config['parser'].exclude_nodes( nodes, args_config, true)
|
148
|
+
backup_master_local_ip = @config['getter'].get_address_hash(backup_master.first.name, true)[backup_master.first.name]['priv']
|
149
|
+
|
150
|
+
options, locs, ridley, logs_bag_hash, pass_bag_hash, bundle_command, cheftacular, passwords = @config['helper'].set_local_instance_vars
|
151
|
+
|
152
|
+
on ( backup_master.map { |n| @config['cheftacular']['deploy_user'] + "@" + n.public_ipaddress } ) do |host|
|
153
|
+
n = get_node_from_address(nodes, host.hostname)
|
154
|
+
|
155
|
+
puts("Beginning latest db_fetch_and_check for #{ n.name } (#{ n.public_ipaddress }) for env #{ backup_env }") unless options['quiet']
|
156
|
+
|
157
|
+
status_hash['latest_backup'] = start_db_check_and_fetch( n.name, n.public_ipaddress, options, locs, cheftacular, passwords)
|
158
|
+
end
|
159
|
+
|
160
|
+
return [nil, nil, {}] unless status_hash['latest_backup']['file_check']
|
161
|
+
|
162
|
+
[target_db_primary, nodes, status_hash, backup_master_local_ip]
|
163
|
+
end
|
137
164
|
end
|
138
165
|
end
|
139
166
|
|
@@ -16,10 +16,6 @@ class Cheftacular
|
|
16
16
|
def ubuntu_bootstrap_from_queue threads=[], execution_hash_array=[]
|
17
17
|
raise "This action is not meant to be called directly!" if !@options['in_scaling'] && !@options['in_single_server_creation']
|
18
18
|
|
19
|
-
if `which sshpass`.empty?
|
20
|
-
raise "sshpass not installed! Please run brew install https://raw.github.com/eugeneoden/homebrew/eca9de1/Library/Formula/sshpass.rb (or get it from your repo for linux)"
|
21
|
-
end
|
22
|
-
|
23
19
|
@config['bootstrap_timestamp'] ||= Time.now.strftime("%Y%m%d%H%M%S")
|
24
20
|
|
25
21
|
@config['queue_master'].generate_passwords_for_each_server_hash_in_queue
|
@@ -31,7 +27,7 @@ class Cheftacular
|
|
31
27
|
execution_hash_array = execution_hash_array.flatten(1)
|
32
28
|
|
33
29
|
@config['server_creation_queue'].each do |server_hash|
|
34
|
-
puts("#{ server_name_output(server_hash) }_Starting initial setup for server...")
|
30
|
+
puts("#{ server_name_output(server_hash) }_Starting initial setup for server...")
|
35
31
|
|
36
32
|
threads << Thread.new { execute_execution_hash_array(server_hash, execution_hash_array) }
|
37
33
|
end
|
@@ -83,7 +79,7 @@ class Cheftacular
|
|
83
79
|
deploy_commands = [
|
84
80
|
"#{ sudo } apt-get update",
|
85
81
|
"#{ sudo } apt-get install curl #{ @config['cheftacular']['pre_install_packages'] } -y",
|
86
|
-
"#{ sudo } apt-get upgrade -y"
|
82
|
+
"#{ sudo } DEBIAN_FRONTEND=noninteractive apt-get upgrade -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
|
87
83
|
]
|
88
84
|
|
89
85
|
if @config['cheftacular']['install_rvm_on_boot']
|
@@ -27,7 +27,7 @@ class Cheftacular
|
|
27
27
|
@config['bootstrap_timestamp'] ||= Time.now.strftime("%Y%m%d%H%M%S")
|
28
28
|
|
29
29
|
@config['server_creation_queue'].each do |server_hash|
|
30
|
-
puts("
|
30
|
+
puts("#{ server_name_output(server_hash) } Starting chef-client installation...") unless @options['quiet']
|
31
31
|
|
32
32
|
threads << Thread.new { execute_execution_hash_array(server_hash, execution_hash_array) }
|
33
33
|
end
|
@@ -39,35 +39,13 @@ class Cheftacular
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def cheftacular_config_diff
|
42
|
-
|
43
|
-
|
44
|
-
diff_hash.each_pair do |key, value|
|
45
|
-
diff_hash.delete(key) if value.empty? || value.nil?
|
46
|
-
end
|
47
|
-
|
48
|
-
if @config['helper'].running_in_mode?('devops') && !diff_hash.empty?
|
49
|
-
puts "Difference detected between local cheftacular.yml and data bag cheftacular.yml! Displaying..."
|
50
|
-
|
51
|
-
ap diff_hash
|
52
|
-
elsif @config['helper'].running_in_mode?('application') && @config['default']['cheftacular_bag_hash']['slack']['webhook'] && !diff_hash.empty?
|
53
|
-
@config['slack_queue'] << diff_hash.awesome_inspect({plain: true, indent: 2}).prepend('```').insert(-1, '```')
|
54
|
-
end
|
42
|
+
@config['helper'].display_cheftacular_config_diff
|
55
43
|
end
|
56
44
|
|
57
45
|
def cheftacular_config_sync
|
58
|
-
cheftacular_config_diff
|
59
|
-
|
60
|
-
parsed_cheftacular = Digest::SHA2.hexdigest(@config['helper'].get_cheftacular_yml_as_hash.to_s)
|
61
|
-
|
62
|
-
return true if File.exist?(@config['filesystem'].local_cheftacular_file_cache_path) && File.read(@config['filesystem'].local_cheftacular_file_cache_path) == parsed_cheftacular
|
63
|
-
|
64
46
|
@config['default']['cheftacular_bag_hash'] = @config['cheftacular'].deep_dup.except('default_repository', 'mode') #the values have already been merged
|
65
47
|
|
66
48
|
@config['ChefDataBag'].save_cheftacular_bag
|
67
|
-
|
68
|
-
puts "Creating file cache for #{ Time.now.strftime("%Y%m%d") }'s local cheftacular.yml."
|
69
|
-
|
70
|
-
@config['filesystem'].write_local_cheftacular_cache_file parsed_cheftacular
|
71
49
|
end
|
72
50
|
end
|
73
51
|
end
|
@@ -38,17 +38,15 @@ class Cheftacular
|
|
38
38
|
out = `berks install`
|
39
39
|
puts "#{out}\nFinished... Beginning directory scanning and conflict resolution..."
|
40
40
|
|
41
|
-
berkshelf_cookbooks = @config['filesystem'].
|
41
|
+
berkshelf_cookbooks = @config['filesystem'].parse_berkshelf_cookbook_versions
|
42
42
|
|
43
43
|
chef_repo_cookbooks = @config['filesystem'].parse_chef_repo_cookbook_versions
|
44
44
|
|
45
|
-
berkshelf_cookbooks.each_pair do |berkshelf_cookbook,
|
46
|
-
|
47
|
-
|
48
|
-
if chef_repo_cookbooks.has_key?(new_name) || chef_repo_cookbooks.has_key?(berkshelf_cookbook) #don't overwrite cookbooks without user input
|
45
|
+
berkshelf_cookbooks.each_pair do |berkshelf_cookbook, cookbook_hash|
|
46
|
+
if chef_repo_cookbooks.has_key?(berkshelf_cookbook) || chef_repo_cookbooks.has_key?(cookbook_hash['location']) #don't overwrite cookbooks without user input
|
49
47
|
if local_options['interactive']
|
50
|
-
puts "COOKBOOK::~~~~#{
|
51
|
-
puts "\nEnter O | o | overwrite to overwrite ~~~~#{
|
48
|
+
puts "COOKBOOK::~~~~#{ berkshelf_cookbook }~~~~::VERSION::~~~~~~~~#{ cookbook_hash['version'] } VS #{ chef_repo_cookbooks[berkshelf_cookbook] }"
|
49
|
+
puts "\nEnter O | o | overwrite to overwrite ~~~~#{ berkshelf_cookbook }~~~~ in the chef-repo (THIS SHOULD NOT BE DONE LIGHTLY)"
|
52
50
|
puts "Enter N | n | no to skip to the next conflict"
|
53
51
|
puts "If you pass force to this script, it will always overwrite."
|
54
52
|
#puts "If you pass a STRING of comma delimited cookbooks, it will skip these cookbooks automatically and overwrite others"
|
@@ -59,12 +57,12 @@ class Cheftacular
|
|
59
57
|
next if (input =~ /N|n|no/) == 0
|
60
58
|
end
|
61
59
|
|
62
|
-
next if @config['helper'].is_higher_version?(chef_repo_cookbooks[
|
60
|
+
next if @config['helper'].is_higher_version?(chef_repo_cookbooks[berkshelf_cookbook], cookbook_hash['version'])
|
63
61
|
end
|
64
62
|
|
65
|
-
cmnd = "#{ @config['locs']['berks'] }/#{
|
66
|
-
puts "Moving #{ cmnd } (#{ version }:#{ chef_repo_cookbooks[
|
67
|
-
`rm -Rf #{ @config['locs']['cookbooks'] }/#{
|
63
|
+
cmnd = "#{ @config['locs']['berks'] }/#{ cookbook_hash['location'] } #{ @config['locs']['cookbooks'] }/#{ berkshelf_cookbook }"
|
64
|
+
puts "Moving #{ cmnd } (#{ cookbook_hash['version'] }:#{ chef_repo_cookbooks[berkshelf_cookbook] })" if @options['verbose']
|
65
|
+
`rm -Rf #{ @config['locs']['cookbooks'] }/#{ berkshelf_cookbook }`
|
68
66
|
`cp -Rf #{ cmnd }`
|
69
67
|
end
|
70
68
|
end
|
@@ -12,7 +12,13 @@ class Cheftacular
|
|
12
12
|
"whether its password is stored on the chef server and what that password is.",
|
13
13
|
|
14
14
|
" 2. `-W|--with-priv` option will make this command display the server's local (private) ip address. " +
|
15
|
-
"This address is also the server's `local.<SERVER_DNS_NAME>`."
|
15
|
+
"This address is also the server's `local.<SERVER_DNS_NAME>`.",
|
16
|
+
|
17
|
+
" 3. `-s|--search-node-name NODE_NAME` option will make this command return results that INCLUDE the NODE_NAME.",
|
18
|
+
|
19
|
+
" 4. `-S|--search-role-name ROLE_NAME` option will make this command return results that INCLUDE the ROLE_NAME.",
|
20
|
+
|
21
|
+
" 5. `-E|--search-env-name ENV_NAME` option will make this command return results that have this environment."
|
16
22
|
]
|
17
23
|
]
|
18
24
|
|
@@ -36,9 +42,11 @@ class Cheftacular
|
|
36
42
|
|
37
43
|
environments.uniq.each do |env|
|
38
44
|
next if env == '_default'
|
45
|
+
next if @options['env'] != @config['cheftacular']['default_environment'] && env != @options['env']
|
46
|
+
next if @options['search_env_name'] && env != @options['search_env_name']
|
39
47
|
|
40
48
|
env_nodes = @config['parser'].exclude_nodes(nodes, [{ if: { not_env: env } }])
|
41
|
-
puts "\nFound #{ env_nodes.count } #{ env } nodes:"
|
49
|
+
puts "\nFound #{ env_nodes.count } #{ env } total nodes: (If you input search arguments the number returned will be smaller)"
|
42
50
|
out = " #{ 'name'.ljust(22) } #{ 'ip_address'.ljust(21) }"
|
43
51
|
out << "#{ 'private_address'.ljust(21) }" if @options['with_private']
|
44
52
|
out << "#{ 'pass?'.ljust(5) } #{ 'domain'.ljust(41) }" if @options['verbose']
|
@@ -52,7 +60,9 @@ class Cheftacular
|
|
52
60
|
addresses_hash = @config['getter'].get_addresses_hash env
|
53
61
|
|
54
62
|
env_nodes.each do |node|
|
55
|
-
|
63
|
+
next if @options['search_node_name'] && !node.name.include?(@options['search_node_name'])
|
64
|
+
next if @options['search_role_name'] && !node.run_list.join(', ').gsub('role[','').gsub(']','').include?(@options['search_role_name'])
|
65
|
+
|
56
66
|
out = " #{ node.chef_id.ljust(22,'_') }_#{ node.public_ipaddress.ljust(20,'_') }"
|
57
67
|
|
58
68
|
if @options['with_private']
|
@@ -80,7 +90,7 @@ class Cheftacular
|
|
80
90
|
end
|
81
91
|
end
|
82
92
|
|
83
|
-
out << "_#{ node.run_list.join(', ') }"
|
93
|
+
out << "_#{ node.run_list.join(', ').gsub('role[','').gsub(']','') }"
|
84
94
|
|
85
95
|
puts out
|
86
96
|
end
|
@@ -44,10 +44,6 @@ class Cheftacular
|
|
44
44
|
|
45
45
|
puts "Preparing to boot #{ @options['node_name'] }(#{ @options['flavor_name'] })..."
|
46
46
|
|
47
|
-
if `which sshpass`.empty?
|
48
|
-
raise "sshpass not installed! Please run brew install https://raw.github.com/eugeneoden/homebrew/eca9de1/Library/Formula/sshpass.rb (or get it from your repo for linux)"
|
49
|
-
end
|
50
|
-
|
51
47
|
real_node_name = @config['getter'].get_current_real_node_name
|
52
48
|
|
53
49
|
#the output of the cloud command is a hash, this hash is UPDATED every time a rax command is run so you only need to grab it when you need it
|
@@ -8,7 +8,9 @@ class Cheftacular
|
|
8
8
|
"This command is analog for `knife upload /`",
|
9
9
|
|
10
10
|
[
|
11
|
-
" 1. The force option will add the force option to knife upload."
|
11
|
+
" 1. The force option will add the force option to knife upload.",
|
12
|
+
|
13
|
+
" 2. Utilize `knife cookbook upload -a -V --cookbook-path ./cookbooks` if this command gives you trouble"
|
12
14
|
]
|
13
15
|
]
|
14
16
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
class Cheftacular
|
3
|
+
class StatelessActionDocumentation
|
4
|
+
def update_cookbook
|
5
|
+
@config['documentation']['stateless_action'][__method__] ||= {}
|
6
|
+
@config['documentation']['stateless_action'][__method__]['long_description'] = [
|
7
|
+
"`cft update_cookbook [COOKBOOK_NAME] [INSTALL_VERSION]` allows you to specifically update a single cookbook",
|
8
|
+
|
9
|
+
[
|
10
|
+
" 1. This command passed with no arguments will update TheCheftacularCookbook"
|
11
|
+
]
|
12
|
+
]
|
13
|
+
|
14
|
+
@config['documentation']['stateless_action'][__method__]['short_description'] = 'Useful for updating specific cookbooks'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class StatelessAction
|
19
|
+
def update_cookbook cookbook='TheCheftacularCookbook', version='latest'
|
20
|
+
raise "This action can only be performed if the mode is set to devops" unless @config['helper'].running_in_mode?('devops')
|
21
|
+
|
22
|
+
cookbook = ARGV[1] if ARGV[1]
|
23
|
+
version = ARGV[2] if ARGV[2]
|
24
|
+
|
25
|
+
@config['cheftacular']['wrapper_cookbooks'].split(',').each do |wrapper_cookbook|
|
26
|
+
wrapper_cookbook_loc = "#{ @config['locs']['cookbooks'] }/#{ wrapper_cookbook }"
|
27
|
+
FileUtils.rm_rf(File.expand_path("#{ @config['locs']['berks'] }/cookbooks")) if File.exists?(File.expand_path("#{ @config['locs']['berks'] }/cookbooks"))
|
28
|
+
|
29
|
+
Dir.chdir wrapper_cookbook_loc
|
30
|
+
puts "Installing new cookbooks..."
|
31
|
+
out = `berks install`
|
32
|
+
puts "#{out}\nFinished fetching cookbooks, moving #{ cookbook } into local chef repo"
|
33
|
+
|
34
|
+
specific_cookbook = @config['filesystem'].parse_berkshelf_cookbook_versions(version).select {|key| key.include?(cookbook)}[cookbook]
|
35
|
+
|
36
|
+
puts "Moving #{ cookbook } (#{ specific_cookbook['version'] })[#{ specific_cookbook['mtime'] }] to your chef-repo!"
|
37
|
+
|
38
|
+
`rm -Rf #{ @config['locs']['cookbooks'] }/#{ cookbook }` if File.exists?(File.expand_path("#{ @config['locs']['cookbooks'] }/#{ cookbook }"))
|
39
|
+
`cp -Rf #{ @config['locs']['berks'] }/#{ specific_cookbook['location'] } #{ @config['locs']['cookbooks'] }/#{ cookbook }`
|
40
|
+
|
41
|
+
break
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/cheftacular/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module SSHKit
|
2
2
|
module Backend
|
3
3
|
class Netssh
|
4
|
-
def start_task name, ip_address, run_list, command, options, locs, cheftacular, out=""
|
4
|
+
def start_task name, ip_address, run_list, command, options, locs, cheftacular, passwords, out=""
|
5
5
|
log_loc, timestamp = set_log_loc_and_timestamp(locs)
|
6
6
|
true_env = get_true_environment run_list, cheftacular['run_list_environments'][options['env']], options['env']
|
7
7
|
|
@@ -9,7 +9,7 @@ module SSHKit
|
|
9
9
|
|
10
10
|
target_loc = "#{ cheftacular['base_file_path'] }/#{ options['repository'] }/current"
|
11
11
|
|
12
|
-
if
|
12
|
+
if !sudo_test( passwords[ip_address], target_loc )
|
13
13
|
puts "#{ name } (#{ ip_address }) cannot run #{ command } as there is no directory at #{ target_loc }!"
|
14
14
|
|
15
15
|
return ['', timestamp]
|
data/lib/sshkit/monkeypatches.rb
CHANGED
@@ -9,8 +9,6 @@ module SSHKit
|
|
9
9
|
message = ""
|
10
10
|
message += "#{command} exit status: " + exit_status.to_s + "\n"
|
11
11
|
message += "#{command} stdout: " + (full_stdout.strip || "Nothing written") + "\n"
|
12
|
-
|
13
|
-
stderr_message = [stderr.strip, full_stderr.strip].delete_if(&:empty?).first
|
14
12
|
message += "#{command} stderr: " + (full_stderr.strip || 'Nothing written') + "\n\n"
|
15
13
|
raise Failed, message
|
16
14
|
end
|
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.
|
4
|
+
version: 2.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis Alridge
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -72,14 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
75
|
+
version: '4.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
82
|
+
version: '4.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: berkshelf-api-client
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: highline
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -320,8 +334,8 @@ files:
|
|
320
334
|
- lib/cheftacular/stateless_actions/update_chef_client.rb
|
321
335
|
- lib/cheftacular/stateless_actions/update_cheftacular.rb
|
322
336
|
- lib/cheftacular/stateless_actions/update_cloudflare_dns_from_cloud.rb
|
337
|
+
- lib/cheftacular/stateless_actions/update_cookbook.rb
|
323
338
|
- lib/cheftacular/stateless_actions/update_split_branches.rb
|
324
|
-
- lib/cheftacular/stateless_actions/update_thecheftacularcookbook.rb
|
325
339
|
- lib/cheftacular/stateless_actions/update_tld.rb
|
326
340
|
- lib/cheftacular/stateless_actions/upload_nodes.rb
|
327
341
|
- lib/cheftacular/stateless_actions/upload_roles.rb
|
@@ -1,38 +0,0 @@
|
|
1
|
-
|
2
|
-
class Cheftacular
|
3
|
-
class StatelessActionDocumentation
|
4
|
-
def update_thecheftacularcookbook
|
5
|
-
@config['documentation']['stateless_action'][__method__] ||= {}
|
6
|
-
@config['documentation']['stateless_action'][__method__]['long_description'] = [
|
7
|
-
"`cft update_thecheftacularcookbook` allows you to update ONLY the internal chef-repo's TheCheftacularCookbook."
|
8
|
-
]
|
9
|
-
|
10
|
-
@config['documentation']['stateless_action'][__method__]['short_description'] = 'Useful for ONLY updating TheCheftacularCookbook'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class StatelessAction
|
15
|
-
def update_thecheftacularcookbook local_options={'interactive' => true}
|
16
|
-
raise "This action can only be performed if the mode is set to devops" unless @config['helper'].running_in_mode?('devops')
|
17
|
-
|
18
|
-
@config['cheftacular']['wrapper_cookbooks'].split(',').each do |wrapper_cookbook|
|
19
|
-
wrapper_cookbook_loc = "#{ @config['locs']['cookbooks'] }/#{ wrapper_cookbook }"
|
20
|
-
FileUtils.rm_rf(File.expand_path("#{ @config['locs']['berks'] }/cookbooks")) if File.exists?(File.expand_path("#{ @config['locs']['berks'] }/cookbooks"))
|
21
|
-
|
22
|
-
Dir.chdir wrapper_cookbook_loc
|
23
|
-
puts "Installing new cookbooks..."
|
24
|
-
out = `berks install`
|
25
|
-
puts "#{out}\nFinished fetching cookbooks, moving TheCheftacularCookbook into local chef repo"
|
26
|
-
|
27
|
-
cheftacular_cookbook = @config['filesystem'].parse_latest_berkshelf_cookbook_versions.select {|key| key.include?('TheCheftacularCookbook')}['TheCheftacularCookbook']
|
28
|
-
|
29
|
-
puts "Moving TheCheftacularCookbook (#{ cheftacular_cookbook['version'] })[#{ cheftacular_cookbook['mtime'] }] to your chef-repo!"
|
30
|
-
|
31
|
-
`rm -Rf #{ @config['locs']['cookbooks'] }/TheCheftacularCookbook` if File.exists?(File.expand_path("#{ @config['locs']['cookbooks'] }/TheCheftacularCookbook"))
|
32
|
-
`cp -Rf #{ @config['locs']['berks'] }/#{ cheftacular_cookbook['location'] } #{ @config['locs']['cookbooks'] }/TheCheftacularCookbook`
|
33
|
-
|
34
|
-
break
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|