cheftacular 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46547d3aa90d80b995df07810a4675b88f3d4822
4
- data.tar.gz: 1e8ea61b705880d022271335953a9c2364b200a7
3
+ metadata.gz: d1824b19ce37e0733ceb249e6bbac87eecbb81d5
4
+ data.tar.gz: b448ce029765480b636de8ec62f4b0bd74a214a0
5
5
  SHA512:
6
- metadata.gz: b5a4f09cba60332a5d60ed2de80747b900601006132a5dbcb6e10ed9fa6f741c2b82482bcc5ac4c6689a30cbfb708b24d253f66bae9c9fdf82f8c0895170a293
7
- data.tar.gz: 5e0101b89e3f56ad978669ca89c5f0a460e0aa19dfde40d1ee73ec0f2dfb9aed5565854b497a1b2eab5b56e8bc239e5384b5a2aa5f1a0f258ba53c30ce475bbf
6
+ metadata.gz: 513496fe5d458cc5131dfad0bf573888b6a05a762b1bce7070bf2dd639eabe03bf1ccfba52a2e8a3919048cfd22ff3a2eac0217f09417c207a005d48cadbe599
7
+ data.tar.gz: 941ccd83c2d7eaf0fcdaa40512a4f7b87c96d9b8f89caa5d6df5b9c608639ed86838c70c6eee2a83056a500f2c8a20161506a3b2ff44c0c2b14e44b4dda8149b
@@ -53,7 +53,7 @@
53
53
 
54
54
  2. `-z|--unset-revision` will unset a custom revision specified in the arg below and make the codebase utilize the default.
55
55
 
56
- 3. `-Z|--revision REVISION` will force the role you're deploying to to utilize the revision specified here. This can be a specific commit or a branch name.
56
+ 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.
57
57
 
58
58
  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.
59
59
 
@@ -82,6 +82,8 @@
82
82
 
83
83
  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
84
 
85
+ 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
+
85
87
  7. `cft disk_report` will fetch useful statistics from every server for every environment and output it into your log directory.
86
88
 
87
89
  8. `cft environment boot|destroy` will boot / destroy the current environment
@@ -187,7 +189,7 @@
187
189
 
188
190
  9. `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.
189
191
 
190
- 1. `domain` 1st level argument for interacting with cloud domains
192
+ 1. `domain` first level argument for interacting with cloud domains
191
193
 
192
194
  1. `list` default behavior
193
195
 
@@ -207,7 +209,7 @@
207
209
 
208
210
  9. `update_record:TOP_LEVEL_DOMAIN:SUBDOMAIN_NAME:IP_ADDRESS[:RECORD_TYPE[:TTL]]` similar to `create_record`.
209
211
 
210
- 2. `server` 1st level argument for interacting with cloud servers, if no additional args are passed the command will return a list of all servers on the preferred cloud.
212
+ 2. `server` first level argument for interacting with cloud servers, if no additional args are passed the command will return a list of all servers on the preferred cloud.
211
213
 
212
214
  1. `list` default behavior
213
215
 
@@ -220,7 +222,7 @@
220
222
  2. NOTE! Most flavors have spaces in them, you must use quotes at the command line to utilize them!
221
223
 
222
224
  4. `destroy:SERVER_NAME` destroys the server on the cloud. This must be an exact match of the server's actual name or the script will error.
223
-
225
+
224
226
  5. `poll:SERVER_NAME` polls the cloud's server for the status of the SERVER_NAME. This command will stop polling if / when the status of the server is ACTIVE and its build progress is 100%.
225
227
 
226
228
  6. `attach_volume:SERVER_NAME:VOLUME_NAME[:VOLUME_SIZE[:DEVICE_LOCATION]]` If VOLUME_NAME exists it will attach it if it is unattached otherwise it will create it
@@ -239,7 +241,7 @@
239
241
 
240
242
  9. `read_volume:SERVER_NAME:VOLUME_NAME` returns the data of VOLUME_NAME if it is attached to the server.
241
243
 
242
- 3. `volume` 1st level argument for interacting with cloud storage volumes, if no additional args are passed the command will return a list of all cloud storage containers.
244
+ 3. `volume` first level argument for interacting with cloud storage volumes, if no additional args are passed the command will return a list of all cloud storage containers.
243
245
 
244
246
  1. `list` default behavior
245
247
 
@@ -249,7 +251,7 @@
249
251
 
250
252
  4. `destroy:VOLUME_NAME` destroys the volume. This operation will not work if the volume is attached to a server.
251
253
 
252
- 4. `flavor` 1st level argument for listing the flavors available on the cloud service
254
+ 4. `flavor` first level argument for listing the flavors available on the cloud service
253
255
 
254
256
  1. `list` default behavior
255
257
 
@@ -31,12 +31,19 @@ class Cheftacular
31
31
 
32
32
  puts("Beginning chef client run for #{ n.name } (#{ n.public_ipaddress }) on role #{ options['role'] }") unless options['quiet']
33
33
 
34
- log_data, timestamp = start_deploy( n.name, n.public_ipaddress, options, locs, passwords)
34
+ log_data, timestamp, exit_status = start_deploy( n.name, n.public_ipaddress, options, locs, passwords)
35
35
 
36
- logs_bag_hash["#{ n.name }-deploy"] = { text: log_data.scrub_pretty_text, timestamp: timestamp }
36
+ logs_bag_hash["#{ n.name }-deploy"] = { "text" => log_data.scrub_pretty_text, "timestamp" => timestamp, "exit_status" => exit_status }
37
+ end
38
+
39
+ #Yes, you will get pinged on EVERY deploy until you fix the problem
40
+ if @config['cheftacular']['slack']['webhook']
41
+ logs_bag_hash.each_pair do |key, hash|
42
+ @config['stateless_action'].slack(hash['text'].prepend('```').insert(-1, '```')) if hash['exit_status'] && hash['exit_status'] == 1
43
+ end
37
44
  end
38
45
 
39
- #@config['ChefDataBag'].save_logs_bag unless @options['debug'] #We don't really need to store entire chef runs in the logs bag
46
+ @config['ChefDataBag'].save_logs_bag unless @options['debug'] #We don't really need to store entire chef runs in the logs bag
40
47
 
41
48
  migrate(nodes) if @config['getter'].get_current_repo_config['database'] != 'none' && !@options['run_migration_already']
42
49
 
@@ -83,7 +90,15 @@ module SSHKit
83
90
 
84
91
  puts "Succeeded deploy of #{ name } (#{ ip_address }) on role #{ options['role'] }"
85
92
 
86
- [out, timestamp] #return out to send to logs_bag
93
+ ['Successful Deploy', timestamp, 0] #return out to send to logs_bag
94
+ rescue SSHKit::Command::Failed => e
95
+ puts "@@@@@CRITICAL! Deploy failed for #{ name } (#{ ip_address })! Please check your #{ log_loc }/failed-deploy for the logs!@@@@@"
96
+
97
+ lines = e.message.split("\n").last(100).join("\n")
98
+
99
+ ::File.open("#{ log_loc }/failed-deploy/#{ name }-deploy-#{ timestamp }.txt", "w") { |f| f.write(lines.scrub_pretty_text) }
100
+
101
+ [lines, timestamp, 1]
87
102
  end
88
103
  end
89
104
  end
@@ -23,6 +23,8 @@ class Cheftacular
23
23
  end
24
24
 
25
25
  def save_logs_bag bag_env="options"
26
+ return true if @config['helper'].running_on_chef_node?
27
+
26
28
  env = bag_env == 'options' ? @options['env'] : bag_env
27
29
 
28
30
  item = @config[env]['logs_bag'].reload
@@ -62,7 +62,7 @@ class Cheftacular
62
62
  record_hash['SRV_weight'],
63
63
  record_hash['SRV_port'],
64
64
  record_hash['SRV_target'],
65
- (record_hash['activate_cloudflare'] ? 1 : 0) #service_mode
65
+ (record_hash['activate_cloudflare'] ? 0 : 1) #service_mode
66
66
  )
67
67
 
68
68
  print 'create'.ljust(20, '_')
@@ -417,7 +417,7 @@ class Cheftacular
417
417
  end
418
418
 
419
419
  def initialize_directories
420
- ['applog', 'deploy', 'rolelog', 'rvm', 'stashedlog'].each do |sub_log_directory|
420
+ ['applog', 'deploy', 'failed-deploy', 'rolelog', 'rvm', 'stashedlog'].each do |sub_log_directory|
421
421
  FileUtils.mkdir_p File.join( @config['locs']['chef-log'], sub_log_directory )
422
422
  end
423
423
 
@@ -44,7 +44,7 @@ class Cheftacular
44
44
  berkshelf_cookbooks.keys.each do |processed_berkshelf_cookbook|
45
45
  if processed_berkshelf_cookbook.rpartition('-').first == berkshelf_cookbook.rpartition('-').first
46
46
  cookbook_mtime = File.mtime(File.expand_path("#{ @config['locs']['berks'] }/#{ berkshelf_cookbook }"))
47
- pcookbook_mtime = File.mtime(File.expand_path("#{ @locs['locs']['berks'] }/#{ processed_berkshelf_cookbook }"))
47
+ pcookbook_mtime = File.mtime(File.expand_path("#{ @config['locs']['berks'] }/#{ processed_berkshelf_cookbook }"))
48
48
 
49
49
  skip = true if cookbook_mtime < pcookbook_mtime #get only the latest version, berkshelf pulls in multiple commits from git repos for SOME REASON
50
50
  end
@@ -62,7 +62,7 @@ class Cheftacular
62
62
  chef_repo_cookbooks = {}
63
63
 
64
64
  Dir.foreach(@config['locs']['cookbooks']) do |chef_repo_cookbook|
65
- next if @config['helper'].is_junk_filename?(berkshelf_cookbook)
65
+ next if @config['helper'].is_junk_filename?(chef_repo_cookbook)
66
66
 
67
67
  new_name = chef_repo_cookbook.rpartition('-').first
68
68
 
@@ -16,11 +16,14 @@ class Cheftacular
16
16
  end
17
17
 
18
18
  class StatelessAction
19
- def slack
20
- notifier = Slack::Notifier.new @config['cheftacular']['slack_webhook'], username: 'Cheftacular'
19
+ def slack message='', channel=''
20
+ @slack_notifier ||= Slack::Notifier.new @config['cheftacular']['slack']['webhook'], username: 'Cheftacular'
21
+
22
+ message = ARGV[1] if message.blank?
23
+ channel = ARGV[2] if channel.blank?
21
24
 
22
- notifier.channel = ARGV[2] ? ARGV[2] : '#default'
23
- notifier.ping ARGV[1]
25
+ @slack_notifier.channel = channel.nil? ? @config['cheftacular']['slack']['default_channel'] : channel
26
+ @slack_notifier.ping message
24
27
  end
25
28
  end
26
29
  end
@@ -1,5 +1,5 @@
1
1
  class Cheftacular
2
2
  #major_version.minor_version.bugfixes
3
- VERSION = "2.4.0"
3
+ VERSION = "2.4.1"
4
4
  RUBY_VERSION = "2.2.2"
5
5
  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.0
4
+ version: 2.4.1
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-06-12 00:00:00.000000000 Z
11
+ date: 2015-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- type: :development
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: pry
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: awesome_print
113
99
  requirement: !ruby/object:Gem::Requirement