cheftacular 2.6.0 → 2.7.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 +104 -64
- data/lib/cheftacular/actions/tail.rb +17 -10
- data/lib/cheftacular/chef/data_bag.rb +49 -9
- data/lib/cheftacular/cheftacular.rb +6 -2
- data/lib/cheftacular/file_system.rb +26 -5
- data/lib/cheftacular/getter.rb +7 -0
- data/lib/cheftacular/helper.rb +29 -0
- data/lib/cheftacular/initializer.rb +43 -2
- data/lib/cheftacular/parser.rb +4 -8
- data/lib/cheftacular/queue_master.rb +16 -0
- data/lib/cheftacular/stateless_actions/backups.rb +169 -58
- data/lib/cheftacular/stateless_actions/check_cheftacular_yml_keys.rb +9 -0
- data/lib/cheftacular/stateless_actions/cheftacular_config.rb +51 -0
- data/lib/cheftacular/stateless_actions/clear_caches.rb +24 -0
- data/lib/cheftacular/stateless_actions/client_list.rb +1 -1
- data/lib/cheftacular/stateless_actions/create_git_key.rb +2 -1
- data/lib/cheftacular/stateless_actions/fix_known_hosts.rb +1 -1
- data/lib/cheftacular/stateless_actions/initialize_cheftacular_yml.rb +16 -6
- data/lib/cheftacular/stateless_actions/initialize_data_bag_contents.rb +43 -0
- data/lib/cheftacular/stateless_actions/reset_bag.rb +30 -0
- data/lib/cheftacular/stateless_actions/role_toggle.rb +1 -1
- data/lib/cheftacular/stateless_actions/update_tld.rb +1 -3
- data/lib/cheftacular/version.rb +1 -1
- metadata +6 -2
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
class Cheftacular
|
3
|
+
class StatelessActionDocumentation
|
4
|
+
def cheftacular_config
|
5
|
+
@config['documentation']['stateless_action'] << [
|
6
|
+
"`cft cheftacular_config [display|sync|overwrite]` this command " +
|
7
|
+
"Allows you to interact with your complete cheftacular configuration, the union of all repository's cheftacular.ymls. ",
|
8
|
+
|
9
|
+
[
|
10
|
+
" 1. `display` will show the current overall configuration for cheftacular.",
|
11
|
+
|
12
|
+
" 2. `sync` will sync your local cheftacular yaml keys ONTO the server's keys. This happens automatically whenever a " +
|
13
|
+
"difference is detected between the local keys and the remote keys but can be run manually. Will send a slack notification " +
|
14
|
+
"if slack is configured (the slack notification contains the diffed keys). The sync only occurs if there are CHANGES to the file."
|
15
|
+
]
|
16
|
+
]
|
17
|
+
|
18
|
+
@config['documentation']['application'] << @config['documentation']['stateless_action'].last
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class StatelessAction
|
23
|
+
def cheftacular_config command=''
|
24
|
+
command = ARGV[1] if command.blank?
|
25
|
+
|
26
|
+
raise "Unsupported command (#{ command }) for cft cheftacular_config" unless command =~ /display|sync|overwrite/
|
27
|
+
|
28
|
+
self.send("cheftacular_config_#{ command }")
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def cheftacular_config_display
|
34
|
+
ap(@config['cheftacular'], {indent: 2})
|
35
|
+
end
|
36
|
+
|
37
|
+
def cheftacular_config_sync
|
38
|
+
parsed_cheftacular = Digest::SHA2.hexdigest(@config['helper'].get_cheftacular_yml_as_hash.to_s)
|
39
|
+
|
40
|
+
return true if File.exist?(@config['filesystem'].local_cheftacular_file_cache_path) && File.read(@config['filesystem'].local_cheftacular_file_cache_path) == parsed_cheftacular
|
41
|
+
|
42
|
+
@config['default']['cheftacular_bag_hash'] = @config['cheftacular'].deep_dup.except('default_repository', 'mode') #the values have already been merged
|
43
|
+
|
44
|
+
@config['ChefDataBag'].save_cheftacular_bag
|
45
|
+
|
46
|
+
puts "Creating file cache for #{ Time.now.strftime("%Y%m%d") }'s local cheftacular.yml."
|
47
|
+
|
48
|
+
@config['filesystem'].write_local_cheftacular_cache_file parsed_cheftacular
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
class Cheftacular
|
3
|
+
class StatelessActionDocumentation
|
4
|
+
def clear_caches
|
5
|
+
@config['documentation']['stateless_action'] << [
|
6
|
+
"`cft clear_caches` this command allows you to clear all of your local caches.",
|
7
|
+
]
|
8
|
+
|
9
|
+
@config['documentation']['application'] << @config['documentation']['stateless_action'].last
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class InitializationAction
|
14
|
+
def clear_caches
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class StatelessAction
|
20
|
+
def clear_caches
|
21
|
+
@config['filesystem'].cleanup_file_caches('all')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -19,7 +19,8 @@ class Cheftacular
|
|
19
19
|
|
20
20
|
class StatelessAction
|
21
21
|
def create_git_key oauth_key=""
|
22
|
-
|
22
|
+
raise "This action can only be performed if the mode is set to devops" unless @config['helper'].running_in_mode?('devops')
|
23
|
+
|
23
24
|
case ARGV[1]
|
24
25
|
when nil then raise "Too few arguments, please enter the filename of the id_rsa file you want to use"
|
25
26
|
when 'id_rsa' then raise "Sorry, you can't use your default id_rsa"
|
@@ -33,7 +33,7 @@ class Cheftacular
|
|
33
33
|
@config['initializer'].initialize_addresses_bag_contents env
|
34
34
|
|
35
35
|
@config[env]['addresses_bag_hash']['addresses'].each do |serv_hash|
|
36
|
-
arr << serv_hash['dn']
|
36
|
+
arr << serv_hash['dn']
|
37
37
|
arr << serv_hash['public']
|
38
38
|
end
|
39
39
|
end
|
@@ -2,9 +2,16 @@ class Cheftacular
|
|
2
2
|
class StatelessActionDocumentation
|
3
3
|
def initialize_cheftacular_yml
|
4
4
|
@config['documentation']['stateless_action'] << [
|
5
|
-
"`cft initialize_cheftacular_yml` will create a cheftacular.yml
|
6
|
-
"config folder if it does not exist). If you already have a cheftacular.yml file
|
7
|
-
"create a cheftacular.example.yml file that will contain the new changes / keys in the latest
|
5
|
+
"`cft initialize_cheftacular_yml [application|TheCheftacularCookbook]` will create a cheftacular.yml " +
|
6
|
+
"file in your config folder (and create the config folder if it does not exist). If you already have a cheftacular.yml file " +
|
7
|
+
"in the config folder, it will create a cheftacular.example.yml file that will contain the new changes / keys in the latest " +
|
8
|
+
"cheftacular version.",
|
9
|
+
|
10
|
+
[
|
11
|
+
" 1. If `TheCheftacularCookbook` is passed, the generated cheftacular.yml file will include the additional TheCheftacularCookbook keys.",
|
12
|
+
|
13
|
+
" 2. If `application` is passed, the generated cheftacular.yml file will look like one you could use in an application directory."
|
14
|
+
]
|
8
15
|
]
|
9
16
|
end
|
10
17
|
end
|
@@ -16,13 +23,16 @@ class Cheftacular
|
|
16
23
|
end
|
17
24
|
|
18
25
|
class StatelessAction
|
19
|
-
def initialize_cheftacular_yml
|
26
|
+
def initialize_cheftacular_yml example_file_to_load='cheftacular.yml'
|
27
|
+
example_file_to_load = 'thecheftacularcookbook.cheftacular.yml' if ARGV[1] == 'TheCheftacularCookbook'
|
28
|
+
example_file_to_load = 'application.cheftacular.yml' if ARGV[1] == 'application'
|
29
|
+
|
20
30
|
FileUtils.mkdir_p(File.join(@config['locs']['chef-repo'], "config"))
|
21
31
|
|
22
32
|
if File.exist?(File.join(@config['locs']['chef-repo'], "config", "cheftacular.yml"))
|
23
|
-
@config['helper'].write_config_cheftacular_yml_file('cheftacular.example.yml')
|
33
|
+
@config['helper'].write_config_cheftacular_yml_file('cheftacular.example.yml', example_file_to_load )
|
24
34
|
else
|
25
|
-
@config['helper'].write_config_cheftacular_yml_file
|
35
|
+
@config['helper'].write_config_cheftacular_yml_file('cheftacular.yml', example_file_to_load)
|
26
36
|
end
|
27
37
|
end
|
28
38
|
end
|
@@ -30,6 +30,8 @@ class Cheftacular
|
|
30
30
|
|
31
31
|
#@config['ChefDataBag'].initialize_node_roles_bag_contents env
|
32
32
|
|
33
|
+
@config['initializer'].initialize_environment_config_bag_contents if @config['helper'].running_in_mode?('devops')
|
34
|
+
|
33
35
|
exit if @options['command'] == __method__
|
34
36
|
end
|
35
37
|
end
|
@@ -201,5 +203,46 @@ class Cheftacular
|
|
201
203
|
|
202
204
|
@config['ChefDataBag'].save_audit_bag(env) if save_on_finish
|
203
205
|
end
|
206
|
+
|
207
|
+
def initialize_cheftacular_data_bag_contents
|
208
|
+
@config['default']['cheftacular_bag_hash'] = @config['cheftacular']
|
209
|
+
|
210
|
+
@config['ChefDataBag'].save_cheftacular_bag
|
211
|
+
end
|
212
|
+
|
213
|
+
def initialize_environment_config_bag_contents
|
214
|
+
return true if File.exist?(@config['filesystem'].current_environment_config_cache_file_path)
|
215
|
+
|
216
|
+
hash = @config['default']['environment_config_bag_hash']
|
217
|
+
|
218
|
+
current_env_bag_names = []
|
219
|
+
|
220
|
+
@config[@options['env']].keys.each do |bag_name|
|
221
|
+
next if bag_name.include?('_bag_hash')
|
222
|
+
|
223
|
+
current_env_bag_names << bag_name.gsub('_bag','')
|
224
|
+
end
|
225
|
+
|
226
|
+
@config['chef_environments'].each do |env|
|
227
|
+
next if @config['ridley'].data_bag.find(env).nil?
|
228
|
+
|
229
|
+
hash[env] ||= {}
|
230
|
+
bags = []
|
231
|
+
|
232
|
+
current_env_bag_names.each do |bag_name|
|
233
|
+
next if @config['ridley'].data_bag.find(env).item.find(bag_name).nil?
|
234
|
+
|
235
|
+
bags << bag_name
|
236
|
+
end
|
237
|
+
|
238
|
+
hash[env]['bags'] = bags
|
239
|
+
end
|
240
|
+
|
241
|
+
@config['ChefDataBag'].save_environment_config_bag
|
242
|
+
|
243
|
+
puts "Creating file cache for #{ Time.now.strftime("%Y%m%d") }'s environment_config bag cache."
|
244
|
+
|
245
|
+
@config['filesystem'].write_environment_config_cache
|
246
|
+
end
|
204
247
|
end
|
205
248
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
class Cheftacular
|
3
|
+
class StatelessActionDocumentation
|
4
|
+
def reset_bag
|
5
|
+
@config['documentation']['stateless_action'] << [
|
6
|
+
"`cft reset_bag BAG_NAME` this command allows you to reset a data bag item to an empty state. " +
|
7
|
+
"Run this on full data bags to clear them out. "
|
8
|
+
]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class StatelessAction
|
13
|
+
def reset_bag bag_name='', bag_env=''
|
14
|
+
raise "This action can only be performed if the mode is set to devops" unless @config['helper'].running_in_mode?('devops')
|
15
|
+
|
16
|
+
bag_name = ARGV[1] if bag_name.blank?
|
17
|
+
bag_env = @options['env'] if bag_env.blank?
|
18
|
+
|
19
|
+
begin
|
20
|
+
@config['ChefDataBag'].send("reset_#{ bag_name }_bag")
|
21
|
+
|
22
|
+
puts "Successfully reset bag #{ bag_name }."
|
23
|
+
rescue NoMethodError => e
|
24
|
+
puts "You are not able to reset the bag \"#{ bag_name }\" via reset_bag, please use knife to edit the contents.\n #{ e }"
|
25
|
+
end
|
26
|
+
|
27
|
+
@config['stateless_action'].clear_caches
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -9,7 +9,7 @@ class Cheftacular
|
|
9
9
|
" 1. This command uses your *role_toggling:deactivated_role_suffix* attribute set in your cheftacular.yml to toggle the role, " +
|
10
10
|
"it checks to see if the toggled name exists then sets the node's run_list to include the toggled role",
|
11
11
|
|
12
|
-
" 2. EX: `cft role_toggle
|
12
|
+
" 2. EX: `cft role_toggle api01 worker activate` will find the node api01 and attempt to toggle the worker role to on. " +
|
13
13
|
"If the node does NOT have the worker#{ @config['cheftacular']['role_toggling']['deactivated_role_suffix'] } role, then it will " +
|
14
14
|
"add it if *role_toggling:strict_roles* is set to **false**",
|
15
15
|
|
data/lib/cheftacular/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheftacular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.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-
|
11
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -250,6 +250,7 @@ files:
|
|
250
250
|
- lib/cheftacular/initialization_action.rb
|
251
251
|
- lib/cheftacular/initializer.rb
|
252
252
|
- lib/cheftacular/parser.rb
|
253
|
+
- lib/cheftacular/queue_master.rb
|
253
254
|
- lib/cheftacular/stateless_action.rb
|
254
255
|
- lib/cheftacular/stateless_actions/add_ssh_key_to_bag.rb
|
255
256
|
- lib/cheftacular/stateless_actions/arguments.rb
|
@@ -263,10 +264,12 @@ files:
|
|
263
264
|
- lib/cheftacular/stateless_actions/check_cheftacular_yml_keys.rb
|
264
265
|
- lib/cheftacular/stateless_actions/chef_bootstrap.rb
|
265
266
|
- lib/cheftacular/stateless_actions/chef_server.rb
|
267
|
+
- lib/cheftacular/stateless_actions/cheftacular_config.rb
|
266
268
|
- lib/cheftacular/stateless_actions/clean_cookbooks.rb
|
267
269
|
- lib/cheftacular/stateless_actions/clean_sensu_plugins.rb
|
268
270
|
- lib/cheftacular/stateless_actions/clean_server_passwords.rb
|
269
271
|
- lib/cheftacular/stateless_actions/cleanup_log_files.rb
|
272
|
+
- lib/cheftacular/stateless_actions/clear_caches.rb
|
270
273
|
- lib/cheftacular/stateless_actions/client_list.rb
|
271
274
|
- lib/cheftacular/stateless_actions/cloud.rb
|
272
275
|
- lib/cheftacular/stateless_actions/cloud_bootstrap.rb
|
@@ -293,6 +296,7 @@ files:
|
|
293
296
|
- lib/cheftacular/stateless_actions/reinitialize.rb
|
294
297
|
- lib/cheftacular/stateless_actions/remove_client.rb
|
295
298
|
- lib/cheftacular/stateless_actions/replication_status.rb
|
299
|
+
- lib/cheftacular/stateless_actions/reset_bag.rb
|
296
300
|
- lib/cheftacular/stateless_actions/restart_swap.rb
|
297
301
|
- lib/cheftacular/stateless_actions/role_toggle.rb
|
298
302
|
- lib/cheftacular/stateless_actions/rvm.rb
|