cheftacular 2.14.0 → 2.14.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: 691c10d8f335d581eee5c51c26d573348d1fba52
4
- data.tar.gz: 8f2ef29f362b2f9f4eeedc1da079fc7f5f68f5eb
3
+ metadata.gz: 827adc94d0f767ea316d7bcf827cfb10cd3fa2ee
4
+ data.tar.gz: f5cf035f7411a8a7ec542c836e28f5820581dbb7
5
5
  SHA512:
6
- metadata.gz: c33b2dfa6a1c1dd0feed92c44b3e14c6fb4acb2e8a5cf45f4b1d598ed0c969d630eac266b31b0abe62510d4e9bc93b9bcb29fd5bdec2e33399ab005aad26fc9e
7
- data.tar.gz: f85efd25195630c862b2dd0ab477ab7a2a049bf604360c736774be10053d52ea39954763cc9a98032b6d6ffd75c62c60a11b8a5e8961734d20f1fc86ed1cdc98
6
+ metadata.gz: 0f5e9bc8c1f3e075fa0f084857bf6ba940b2adf3434be56f903e2f6ed3ca35aad6ea1914dbdd5011e35332cec9da7a0e6bb7b2babbe092758bef1fe316f46318
7
+ data.tar.gz: b2360f856866988ff682fa1aa4f1b223fb955bbe89604f73fb9309603de1e1796367505dc31bcbc6455943e80fd55f87c1d998df5cc77491a8c4cad23cdb50ab
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Cheftacular
3
- class StatelessActionDocumentation
3
+ class ActionDocumentation
4
4
  def backups
5
5
  @config['documentation']['action'][__method__] ||= {}
6
6
  @config['documentation']['action'][__method__]['long_description'] = [
@@ -18,7 +18,8 @@ class Cheftacular
18
18
  " 4. `load` will fetch the latest backup from the production primary **if it doesn't already exist on " +
19
19
  "the server** and run the _backup loading command_ to load this backup into the env.",
20
20
 
21
- " 5. `restore` will simply just run the _backup loading command_ to load the latest backup onto the server.",
21
+ " 5. `restore` will simply just run the _backup loading command_ to load the latest backup onto the server. This " +
22
+ "command is REPOSITORY SENSITIVE, to restore a repo other than default, you must use the -R REPOSITORY flag.",
22
23
 
23
24
  " 6. `status` will display the current state of the backups",
24
25
 
@@ -30,7 +31,7 @@ class Cheftacular
30
31
  end
31
32
  end
32
33
 
33
- class StatelessAction
34
+ class Action
34
35
  def backups command=''
35
36
  command = ARGV[1] if command.blank?
36
37
 
@@ -74,8 +75,9 @@ class Cheftacular
74
75
  end
75
76
 
76
77
  target_db_primary, nodes = @config['getter'].get_db_primary_node_and_nodes
77
- applications_as_string = @config['getter'].get_repo_names_for_repositories({ database: @config['getter'].get_current_database }).keys.join(',')
78
+ applications_as_string = @config['getter'].get_repo_names_for_repositories([{ database: @config['getter'].get_current_database }, { restore_backup_file_name: 'NOT NIL' , ignore_val: true}]).keys.join(',')
78
79
  env_db_pass = @config[@options['env']]['chef_passwords_bag_hash']["#{ backup_mode }_pass"]
80
+ env_db_user = @config['getter'].get_current_repo_config['application_database_user']
79
81
  env_db_mode = @config['getter'].get_current_database
80
82
 
81
83
  options, locs, ridley, logs_bag_hash, pass_bag_hash, bundle_command, cheftacular, passwords = @config['helper'].set_local_instance_vars
@@ -87,7 +89,7 @@ class Cheftacular
87
89
 
88
90
  puts("Beginning db_backup_run for #{ n.name } (#{ n.public_ipaddress }) for env #{ options['env'] }") unless options['quiet']
89
91
 
90
- start_db_backup_restore( n.name, n.public_ipaddress, options, locs, cheftacular, passwords, applications_as_string, env_db_pass, ruby_command, env_db_mode )
92
+ start_db_backup_restore( n.name, n.public_ipaddress, options, locs, cheftacular, passwords, applications_as_string, env_db_pass, ruby_command, env_db_mode, env_db_user )
91
93
  end
92
94
  end
93
95
 
@@ -235,7 +237,7 @@ module SSHKit
235
237
  puts "Finished transferring #{ full_backup_path } to #{ name }(#{ ip_address })..."
236
238
  end
237
239
 
238
- def start_db_backup_restore name, ip_address, options, locs, cheftacular, passwords, applications_as_string, env_db_pass, ruby_command, env_db_mode, out=''
240
+ def start_db_backup_restore name, ip_address, options, locs, cheftacular, passwords, applications_as_string, env_db_pass, ruby_command, env_db_mode, env_db_user, out=''
239
241
  log_loc, timestamp = set_log_loc_and_timestamp(locs)
240
242
 
241
243
  puts "Beginning backup run on #{ name } (#{ ip_address }), this command may take a while to complete..."
@@ -244,7 +246,7 @@ module SSHKit
244
246
  when 'backup_gem'
245
247
  command = cheftacular['backup_config']['backup_load_command']
246
248
  command = command.gsub('ENVIRONMENT', options['env']).gsub('APPLICATIONS', applications_as_string).gsub('DB_PASS', env_db_pass)
247
- command = command.gsub('RUBY_COMMAND', ruby_command ).gsub('MODE', env_db_mode)
249
+ command = command.gsub('RUBY_COMMAND', ruby_command ).gsub('MODE', env_db_mode).gsub('DATABASE_USER', env_db_user)
248
250
 
249
251
  out << sudo_capture( passwords[ip_address], command )
250
252
  when 'raw'
@@ -11,7 +11,7 @@ class Cheftacular
11
11
 
12
12
  " 2. If the all argument is provided, all repositories will be checked for the current environment",
13
13
 
14
- " 3. If the verify argument is provided, cft will attempt to see if the servers are using the latest commits",
14
+ " 3. If the verify argument is provided, cft will attempt to see if the servers are using the latest commits. This is also aliased to `cft ch ve`",
15
15
 
16
16
  " 4. Aliased to `cft ch`"
17
17
  ]
@@ -25,7 +25,7 @@ class Cheftacular
25
25
  @config['filesystem'].cleanup_file_caches('current-nodes')
26
26
 
27
27
  fetch_all_repository_data = ARGV[1] == 'all'
28
- verify_state_is_latest = ARGV[1] == 'verify'
28
+ verify_state_is_latest = ARGV[1] == 'verify' || ARGV[1] == 've'
29
29
  verify_state_is_latest = mode == 'verify' if ARGV[1] != 'verify'
30
30
 
31
31
  nodes = @config['getter'].get_true_node_objects(fetch_all_repository_data)
@@ -37,6 +37,8 @@ class Cheftacular
37
37
 
38
38
  start_console_postgresql(n.public_ipaddress, private_database_host_address )
39
39
  end
40
+
41
+ @config['auditor'].notify_slack_on_completion("psql run completed on #{ nodes.first.name } (#{ nodes.first.public_ipaddress })\n") if @config['cheftacular']['auditing']
40
42
  end
41
43
 
42
44
  def db_console_mongodb private_database_host_address=nil
@@ -56,6 +58,8 @@ class Cheftacular
56
58
 
57
59
  start_console_mongodb(n.public_ipaddress, private_database_host_address)
58
60
  end
61
+
62
+ @config['auditor'].notify_slack_on_completion("mongo run completed on #{ nodes.first.name } (#{ nodes.first.public_ipaddress })\n") if @config['cheftacular']['auditing']
59
63
  end
60
64
 
61
65
  def db_console_mysql
@@ -19,9 +19,9 @@ class Cheftacular
19
19
 
20
20
  " 5. The `-v|--verbose` option will cause failed deploys to output to the terminal window and to their normal log file. Useful for debugging.",
21
21
 
22
- " 6. The `cft deploy check` argument will force a check run under the same environment as the initial deploy.",
22
+ " 6. The `cft deploy check` argument will force a check run under the same environment as the initial deploy. This is also aliased to `cft d ch`",
23
23
 
24
- " 7. The `cft deploy verify` argument will force a check AND verify run under the same environment as the initial deploy",
24
+ " 7. The `cft deploy verify` argument will force a check AND verify run under the same environment as the initial deploy. This is also aliased to `cft d ve`",
25
25
 
26
26
  " 8. Aliased to `cft d`"
27
27
  ]
@@ -33,8 +33,8 @@ class Cheftacular
33
33
 
34
34
  class Action
35
35
  def deploy deployment_args={ in: :groups, limit: 6, wait: 5 }
36
- run_check = ARGV[1] == 'check'
37
- run_verify = ARGV[1] == 'verify'
36
+ run_check = ARGV[1] == 'check' || ARGV[1] == 'ch'
37
+ run_verify = ARGV[1] == 'verify' || ARGV[1] == 've'
38
38
 
39
39
  nodes = @config['getter'].get_true_node_objects(false) #when this is run in scaling we'll need to make sure we deploy to new nodes
40
40
 
@@ -66,6 +66,8 @@ class Cheftacular
66
66
 
67
67
  @config['action'].check('verify') if run_verify && !@options['run_migration_already']
68
68
 
69
+ @config['auditor'].notify_slack_on_completion("deploy run completed on #{ nodes.map {|n| n.name }.join(', ') }\n") if @config['cheftacular']['auditing'] && !@options['run_migration_already']
70
+
69
71
  @config['action'].migrate(nodes) if @config['getter'].get_current_repo_config['database'] != 'none' && !@options['run_migration_already']
70
72
 
71
73
  split_nodes_hash = {}
@@ -5,7 +5,9 @@ class Cheftacular
5
5
  @config['documentation']['action'][__method__]['long_description'] = [
6
6
  "`cft verify` Checks to see if the servers for the current state are running the latest commits. ",
7
7
  [
8
- " 1. This command is functionally the same as `cft check verify`."
8
+ " 1. This command is functionally the same as `cft check verify`.",
9
+
10
+ " 2. This command is aliased to `cft ve`"
9
11
  ]
10
12
  ]
11
13
  @config['documentation']['action'][__method__]['short_description'] = "Checks the commits currently deployed to an env for your repo"
@@ -16,5 +18,7 @@ class Cheftacular
16
18
  def verify
17
19
  @config['action'].check('verify')
18
20
  end
21
+
22
+ alias_method :ve, :verify
19
23
  end
20
24
  end
@@ -85,22 +85,25 @@ class Cheftacular
85
85
 
86
86
  def aliased_command_hash
87
87
  {
88
- check: ['ch'],
89
- console: ['co'],
90
- deploy: ['d'],
91
- cheftacular_config: ['cc'],
92
- cheftacular_yml_help: ['yml_help'],
93
- client_list: ['cl'],
94
- environment: ['e'],
95
- fix_known_hosts: ['fkh'],
96
- knife_upload: ['ku'],
97
- location_aliases: ['la'],
98
- remove_client: ['rc'],
99
- role_toggle: ['rt'],
100
- update_cookbook: ['uc'],
101
- upload_nodes: ['un'],
102
- upload_roles: ['ur'],
103
- version: ['v']
88
+ check: ['ch'],
89
+ console: ['co'],
90
+ deploy: ['d'],
91
+ cheftacular_config: ['cc'],
92
+ cheftacular_yml_help: ['yml_help'],
93
+ client_list: ['cl'],
94
+ cloud_bootstrap: ['cb'],
95
+ environment: ['e'],
96
+ fix_known_hosts: ['fkh'],
97
+ knife_upload: ['ku'],
98
+ location_aliases: ['la'],
99
+ remove_client: ['rc'],
100
+ role_toggle: ['rt'],
101
+ update_cookbook: ['uc'],
102
+ update_the_cheftacular_cookbook_and_knife_upload: ['utcc', 'utccaku'],
103
+ upload_nodes: ['un'],
104
+ upload_roles: ['ur'],
105
+ verify: ['ve'],
106
+ version: ['v']
104
107
  }
105
108
  end
106
109
  end
@@ -161,12 +161,17 @@ class Cheftacular
161
161
  ret
162
162
  end
163
163
 
164
- def get_repo_names_for_repositories restrict_to={}, ret={}
164
+ def get_repo_names_for_repositories restrict_to=[{}], ret={}
165
165
  @config['cheftacular']['repositories'].each_pair do |name, repo_hash|
166
166
  unless restrict_to.empty?
167
167
  skip = false
168
- restrict_to.each_pair do |key, val|
169
- skip = true if repo_hash[key.to_s] == val
168
+ restrict_to.each do |restrict_hash|
169
+ restrict_hash.each_pair do |key, val|
170
+ skip = true if repo_hash[key.to_s] != val && restrict_hash.has_key?(:ignore_value)
171
+ skip = true if val == 'NOT NIL' && repo_hash[key.to_s].nil?
172
+ skip = true if val == 'NIL' && !repo_hash[key.to_s].nil?
173
+ puts "#{ name } => k:#{ key }::v:#{ val }:::#{ skip }:[#{ repo_hash[key.to_s] }]"
174
+ end
170
175
  end
171
176
 
172
177
  next if skip
@@ -303,6 +303,12 @@ class Cheftacular
303
303
  if git_output.blank?
304
304
  puts "! The remote organization #{ org_name_to_check } does not have the repository: #{ @options['repository'] }! Please verify your repositories and try again"
305
305
 
306
+ exit
307
+ elsif !git_output.include?(revision_to_check) && output_mode == 'display_for_check'
308
+ puts "WARNING! The commit #{ repo_state_hash['revision'] } is NOT the latest for the branch #{ repo_state_hash['branch'] } in organization #{ repo_state_hash['deploy_organization'] }!"
309
+
310
+ puts "Please re-run your deploy again and if this continues to not work, check with your DevOps personel!"
311
+
306
312
  exit
307
313
  elsif !git_output.include?(revision_to_check)
308
314
  puts "! The remote organization #{ org_name_to_check } does not have a revision / branch #{ revision_to_check } for repository: #{ @options['repository'] } !"
@@ -330,6 +330,7 @@ class Cheftacular
330
330
  end
331
331
 
332
332
  locs['chef-repo'] = Dir.getwd
333
+ locs['true-root'] = File.expand_path("#{ locs['chef-repo'] }/..")
333
334
  locs['roles'] = File.expand_path("#{ locs['chef-repo'] }/roles")
334
335
  locs['nodes'] = File.expand_path("#{ locs['chef-repo'] }/nodes_dir") #DO NOT RENAME THIS TO NODES
335
336
  locs['root'] = locs['chef-repo'] unless locs['root']
@@ -48,7 +48,7 @@ class Cheftacular
48
48
 
49
49
  log_data, timestamp = start_apt_updater( n.name, n.public_ipaddress, options, locs, passwords)
50
50
 
51
- logs_bag_hash["#{ n.name }-upgrade"] = { text: log_data.scrub_pretty_text, timestamp: timestamp }
51
+ #logs_bag_hash["#{ n.name }-upgrade"] = { text: log_data.scrub_pretty_text, timestamp: timestamp }
52
52
  end
53
53
 
54
54
  on ( nodes.map { |n| @config['cheftacular']['deploy_user'] + "@" + n.public_ipaddress } ), in: :groups, limit: 5, wait: 120 do |host|
@@ -59,7 +59,7 @@ class Cheftacular
59
59
  start_sys_restarter( n.name, n.public_ipaddress, options, locs, passwords)
60
60
  end if @options['rolling_restart']
61
61
 
62
- @config['ChefDataBag'].save_logs_bag
62
+ #@config['ChefDataBag'].save_logs_bag
63
63
  end
64
64
  end
65
65
  end
@@ -4,12 +4,14 @@ class Cheftacular
4
4
  def update_cookbook
5
5
  @config['documentation']['stateless_action'][__method__] ||= {}
6
6
  @config['documentation']['stateless_action'][__method__]['long_description'] = [
7
- "`cft update_cookbook [COOKBOOK_NAME] [INSTALL_VERSION]` allows you to specifically update a single cookbook",
7
+ "`cft update_cookbook [COOKBOOK_NAME] [INSTALL_VERSION|local]` allows you to specifically update a single cookbook",
8
8
 
9
9
  [
10
10
  " 1. This command passed with no arguments will update TheCheftacularCookbook",
11
11
 
12
- " 2. Aliased to `cft uc`"
12
+ " 2. If the 2nd argument is local, the command will drop a local version of the cookbook onto your chef-repo",
13
+
14
+ " 3. Aliased to `cft uc`"
13
15
  ]
14
16
  ]
15
17
 
@@ -17,6 +19,12 @@ class Cheftacular
17
19
  end
18
20
  end
19
21
 
22
+ class InitializationAction
23
+ def update_cookbook
24
+
25
+ end
26
+ end
27
+
20
28
  class StatelessAction
21
29
  def update_cookbook cookbook='TheCheftacularCookbook', version='latest'
22
30
  raise "This action can only be performed if the mode is set to devops" unless @config['helper'].running_in_mode?('devops')
@@ -24,23 +32,34 @@ class Cheftacular
24
32
  cookbook = ARGV[1] if ARGV[1]
25
33
  version = ARGV[2] if ARGV[2]
26
34
 
27
- @config['cheftacular']['wrapper_cookbooks'].split(',').each do |wrapper_cookbook|
28
- wrapper_cookbook_loc = "#{ @config['locs']['cookbooks'] }/#{ wrapper_cookbook }"
29
- FileUtils.rm_rf(File.expand_path("#{ @config['locs']['berks'] }/cookbooks")) if File.exists?(File.expand_path("#{ @config['locs']['berks'] }/cookbooks"))
30
-
31
- Dir.chdir wrapper_cookbook_loc
32
- puts "Installing new cookbooks..."
33
- out = `berks install`
34
- puts "#{out}\nFinished fetching cookbooks, moving #{ cookbook } into local chef repo"
35
+ if version == 'local'
36
+ if File.exists?(File.expand_path("#{ @config['locs']['true-root'] }/#{ cookbook }"))
37
+ `rm -Rf #{ @config['locs']['cookbooks'] }/#{ cookbook }` if File.exists?(File.expand_path("#{ @config['locs']['cookbooks'] }/#{ cookbook }"))
38
+ `cp -Rf #{ @config['locs']['true-root'] }/#{ cookbook } #{ @config['locs']['cookbooks'] }/#{ cookbook }`
39
+
40
+ `rm -Rf #{ @config['locs']['true-root'] }/#{ cookbook }/.git`
41
+ else
42
+ puts "You do not have #{ cookbook } under the #{ @config['locs']['true-root'] } directory!"
43
+ end
44
+ else
45
+ @config['cheftacular']['wrapper_cookbooks'].split(',').each do |wrapper_cookbook|
46
+ wrapper_cookbook_loc = "#{ @config['locs']['cookbooks'] }/#{ wrapper_cookbook }"
47
+ FileUtils.rm_rf(File.expand_path("#{ @config['locs']['berks'] }/cookbooks")) if File.exists?(File.expand_path("#{ @config['locs']['berks'] }/cookbooks"))
48
+
49
+ Dir.chdir wrapper_cookbook_loc
50
+ puts "Installing new cookbooks..."
51
+ out = `berks install`
52
+ puts "#{out}\nFinished fetching cookbooks, moving #{ cookbook } into local chef repo"
35
53
 
36
- specific_cookbook = @config['filesystem'].parse_berkshelf_cookbook_versions(version).select {|key| key.include?(cookbook)}[cookbook]
54
+ specific_cookbook = @config['filesystem'].parse_berkshelf_cookbook_versions(version).select {|key| key.include?(cookbook)}[cookbook]
37
55
 
38
- puts "Moving #{ cookbook } (#{ specific_cookbook['version'] })[#{ specific_cookbook['mtime'] }] to your chef-repo!"
56
+ puts "Moving #{ cookbook } (#{ specific_cookbook['version'] })[#{ specific_cookbook['mtime'] }] to your chef-repo!"
39
57
 
40
- `rm -Rf #{ @config['locs']['cookbooks'] }/#{ cookbook }` if File.exists?(File.expand_path("#{ @config['locs']['cookbooks'] }/#{ cookbook }"))
41
- `cp -Rf #{ @config['locs']['berks'] }/#{ specific_cookbook['location'] } #{ @config['locs']['cookbooks'] }/#{ cookbook }`
42
-
43
- break
58
+ `rm -Rf #{ @config['locs']['cookbooks'] }/#{ cookbook }` if File.exists?(File.expand_path("#{ @config['locs']['cookbooks'] }/#{ cookbook }"))
59
+ `cp -Rf #{ @config['locs']['berks'] }/#{ specific_cookbook['location'] } #{ @config['locs']['cookbooks'] }/#{ cookbook }`
60
+
61
+ break
62
+ end
44
63
  end
45
64
  end
46
65
 
@@ -0,0 +1,31 @@
1
+
2
+ class Cheftacular
3
+ class StatelessActionDocumentation
4
+ def update_the_cheftacular_cookbook_and_knife_upload
5
+ @config['documentation']['stateless_action'][__method__] ||= {}
6
+ @config['documentation']['stateless_action'][__method__]['long_description'] = [
7
+ "`cft update_the_cheftacular_cookbook_and_knife_upload` update your local cheftacular cookbook with your local (out of chef-repo) cheftacular " +
8
+ "cookbook and knife_upload afterwards.",
9
+
10
+ [
11
+ " 1. This method is aliased to `cft utccaku` and `cft utcc`."
12
+ ]
13
+ ]
14
+
15
+ @config['documentation']['stateless_action']['utccaku']['short_description'] = 'Runs `update_cookbook` and `knife_upload` for the cheftacular cookbook'
16
+ end
17
+ end
18
+
19
+ class StatelessAction
20
+ def update_the_cheftacular_cookbook_and_knife_upload
21
+ raise "This action can only be performed if the mode is set to devops" unless @config['helper'].running_in_mode?('devops')
22
+
23
+ @config['stateless_action'].update_cookbook('TheCheftacularCookbook', 'local')
24
+
25
+ @config['stateless_action'].knife_upload
26
+ end
27
+
28
+ alias_method :utccaku, :update_the_cheftacular_cookbook_and_knife_upload
29
+ alias_method :utcc, :update_the_cheftacular_cookbook_and_knife_upload
30
+ end
31
+ end
@@ -1,5 +1,5 @@
1
1
  class Cheftacular
2
2
  #major_version.minor_version.bugfixes
3
- VERSION = "2.14.0"
3
+ VERSION = "2.14.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.14.0
4
+ version: 2.14.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: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -338,6 +338,7 @@ files:
338
338
  - lib/cheftacular/stateless_actions/update_cloudflare_dns_from_cloud.rb
339
339
  - lib/cheftacular/stateless_actions/update_cookbook.rb
340
340
  - lib/cheftacular/stateless_actions/update_split_branches.rb
341
+ - lib/cheftacular/stateless_actions/update_the_cheftacular_cookbook_and_knife_upload.rb
341
342
  - lib/cheftacular/stateless_actions/update_tld.rb
342
343
  - lib/cheftacular/stateless_actions/upload_nodes.rb
343
344
  - lib/cheftacular/stateless_actions/upload_roles.rb