cheftacular 2.10.2 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cheftacular/README.md +119 -77
  3. data/lib/cheftacular/actions/check.rb +58 -24
  4. data/lib/cheftacular/actions/deploy.rb +5 -3
  5. data/lib/cheftacular/auditor.rb +4 -3
  6. data/lib/cheftacular/cheftacular.rb +1 -0
  7. data/lib/cheftacular/cloud_provider.rb +17 -12
  8. data/lib/cheftacular/file_system.rb +20 -0
  9. data/lib/cheftacular/getter.rb +1 -1
  10. data/lib/cheftacular/helper.rb +41 -28
  11. data/lib/cheftacular/initializer.rb +5 -3
  12. data/lib/cheftacular/parser.rb +10 -6
  13. data/lib/cheftacular/queue_master.rb +24 -0
  14. data/lib/cheftacular/stateless_actions/backups.rb +2 -2
  15. data/lib/cheftacular/stateless_actions/bootstrappers/{centos_bootstrap.rb → centos_bootstrap_from_queue.rb} +1 -1
  16. data/lib/cheftacular/stateless_actions/bootstrappers/{coreos_bootstrap.rb → coreos_bootstrap_from_queue.rb} +1 -1
  17. data/lib/cheftacular/stateless_actions/bootstrappers/{fedora_bootstrap.rb → fedora_bootstrap_from_queue.rb} +1 -1
  18. data/lib/cheftacular/stateless_actions/bootstrappers/{redhat_bootstrap.rb → redhat_bootstrap_from_queue.rb} +1 -1
  19. data/lib/cheftacular/stateless_actions/bootstrappers/ubuntu_bootstrap_from_queue.rb +203 -0
  20. data/lib/cheftacular/stateless_actions/bootstrappers/vyatta_bootstrap_from_queue.rb +7 -0
  21. data/lib/cheftacular/stateless_actions/check_cheftacular_yml_keys.rb +30 -0
  22. data/lib/cheftacular/stateless_actions/chef_bootstrap_from_queue.rb +89 -0
  23. data/lib/cheftacular/stateless_actions/cheftacular_yml_help.rb +55 -6
  24. data/lib/cheftacular/stateless_actions/client_list.rb +1 -3
  25. data/lib/cheftacular/stateless_actions/cloud_bootstrap.rb +24 -15
  26. data/lib/cheftacular/stateless_actions/cloud_bootstrap_from_queue.rb +37 -0
  27. data/lib/cheftacular/stateless_actions/environment.rb +80 -31
  28. data/lib/cheftacular/stateless_actions/fix_known_hosts.rb +1 -22
  29. data/lib/cheftacular/stateless_actions/{full_bootstrap.rb → full_bootstrap_from_queue.rb} +8 -15
  30. data/lib/cheftacular/stateless_actions/knife_upload.rb +14 -3
  31. data/lib/cheftacular/stateless_actions/reinitialize.rb +1 -1
  32. data/lib/cheftacular/stateless_actions/remove_client.rb +3 -3
  33. data/lib/cheftacular/stateless_actions/restart_swap.rb +0 -1
  34. data/lib/cheftacular/stateless_actions/test_env.rb +24 -18
  35. data/lib/cheftacular/stateless_actions/update_thecheftacularcookbook.rb +1 -1
  36. data/lib/cheftacular/stateless_actions/upload_nodes.rb +2 -2
  37. data/lib/cheftacular/version.rb +1 -1
  38. data/lib/cloud_interactor/domain/create.rb +2 -2
  39. data/lib/cloud_interactor/domain/create_record.rb +1 -1
  40. data/lib/cloud_interactor/domain/destroy.rb +2 -2
  41. data/lib/cloud_interactor/domain/destroy_record.rb +1 -1
  42. data/lib/cloud_interactor/domain/list_records.rb +1 -1
  43. data/lib/cloud_interactor/domain/read.rb +1 -1
  44. data/lib/cloud_interactor/domain/read_record.rb +1 -1
  45. data/lib/cloud_interactor/domain/update.rb +2 -2
  46. data/lib/cloud_interactor/domain/update_record.rb +2 -2
  47. data/lib/cloud_interactor/helpers.rb +11 -6
  48. data/lib/cloud_interactor/server/attach_volume.rb +1 -1
  49. data/lib/cloud_interactor/server/create.rb +4 -4
  50. data/lib/cloud_interactor/server/detach_volume.rb +2 -2
  51. data/lib/cloud_interactor/server/list_volumes.rb +1 -1
  52. data/lib/cloud_interactor/server/poll.rb +2 -2
  53. data/lib/cloud_interactor/server/read_volume.rb +1 -1
  54. data/lib/cloud_interactor/version.rb +1 -1
  55. data/lib/cloud_interactor/volume/create.rb +1 -1
  56. data/lib/sshkit/getters.rb +9 -1
  57. metadata +25 -10
  58. data/lib/cheftacular/stateless_actions/bootstrappers/ubuntu_bootstrap.rb +0 -116
  59. data/lib/cheftacular/stateless_actions/bootstrappers/vyatta_bootstrap.rb +0 -7
  60. data/lib/cheftacular/stateless_actions/chef_bootstrap.rb +0 -63
@@ -12,9 +12,7 @@ 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>`.",
16
-
17
- " 3. This command is aliased to `client-list` with no arguments or cft prefix."
15
+ "This address is also the server's `local.<SERVER_DNS_NAME>`."
18
16
  ]
19
17
  ]
20
18
 
@@ -28,13 +28,22 @@ class Cheftacular
28
28
  end
29
29
 
30
30
  class StatelessAction
31
- def cloud_bootstrap
31
+ def cloud_bootstrap server_hash={}, options_to_sync=['node_name', 'flavor_name', 'descriptor', 'dns_config', 'address', 'private_address', 'client_pass']
32
32
  raise "This action can only be performed if the mode is set to devops" if !@config['helper'].running_in_mode?('devops') && !@options['in_scaling']
33
33
 
34
+ @options['node_name'] = server_hash['node_name'] if server_hash.has_key?('node_name')
35
+ @options['flavor_name'] = server_hash['flavor_name'] if server_hash.has_key?('flavor_name')
36
+ @options['descriptor'] = server_hash['descriptor'] if server_hash.has_key?('descriptor')
37
+ @options['with_dn'] = server_hash['dns_config'] if server_hash.has_key?('dns_config')
38
+
34
39
  @options['node_name'] = ARGV[1] unless @options['node_name']
35
40
  @options['flavor_name'] = ARGV[2] unless @options['flavor_name']
36
41
  @options['descriptor'] = ARGV[3] if ARGV[3] && !@options['descriptor']
37
42
 
43
+ @options['in_single_server_creation'] = true
44
+
45
+ puts "Preparing to boot #{ @options['node_name'] }(#{ @options['flavor_name'] })..."
46
+
38
47
  if `which sshpass`.empty?
39
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)"
40
49
  end
@@ -46,23 +55,18 @@ class Cheftacular
46
55
 
47
56
  status_hash = @config['stateless_action'].cloud "server", "poll:#{ real_node_name }"
48
57
 
49
- status_hash['created_servers'].each do |server_hash|
50
- next unless server_hash['name'] == "#{ real_node_name }"
58
+ status_hash['created_servers'].each do |cloud_server_hash|
59
+ next unless cloud_server_hash['name'] == "#{ real_node_name }"
51
60
 
52
- @options['address'], @options['private_address'] = @config['cloud_provider'].parse_addresses_from_server_create_hash server_hash
61
+ @options['address'], @options['private_address'] = @config['cloud_provider'].parse_addresses_from_server_create_hash cloud_server_hash
53
62
  end
54
63
 
55
64
  @options['client_pass'] = @config['cloud_provider'].parse_server_root_password_from_server_create_hash status_hash, real_node_name
56
-
57
- tld = @config[@options['env']]['config_bag_hash'][@options['sub_env']]['tld']
58
-
59
- target_serv_index = @config[@options['env']]['addresses_bag_hash']['addresses'].count
60
-
61
- compile_args = ['set_all_attributes']
62
-
63
- compile_args << "set_specific_domain:#{ @options['with_dn'] }" if @options['with_dn']
64
-
65
- address_hash = @config['DNS'].compile_address_hash_for_server_from_options(*compile_args)
65
+ tld = @config[@options['env']]['config_bag_hash'][@options['sub_env']]['tld']
66
+ target_serv_index = @config[@options['env']]['addresses_bag_hash']['addresses'].count
67
+ compile_args = ['set_all_attributes']
68
+ compile_args << "set_specific_domain:#{ @options['with_dn'] }" if @options['with_dn']
69
+ address_hash = @config['DNS'].compile_address_hash_for_server_from_options(*compile_args)
66
70
 
67
71
  @config['DNS'].create_dns_record_for_domain_from_address_hash(@options['with_dn'], address_hash, "specific_domain_mode") if @options['with_dn']
68
72
 
@@ -72,7 +76,12 @@ class Cheftacular
72
76
 
73
77
  @options['dont_remove_address_or_server'] = true #flag to make sure our entry isnt removed in addresses bag
74
78
 
75
- @config['stateless_action'].full_bootstrap #bootstrap server with ruby and attach it to the chef server
79
+ server_hash = @config['queue_master'].sync_server_hash_into_queue(server_hash.merge(@config['helper'].return_options_as_hash(options_to_sync)))
80
+
81
+ puts("Created server #{ server_hash['node_name'] } and attached additional flags:") unless @options['quiet']
82
+ ap(@config['queue_master'].return_hash_from_queue('server_creation_queue', server_hash, 'node_name').except(*options_to_sync[0..3])) unless @options['quiet']
83
+
84
+ @config['stateless_action'].full_bootstrap_from_queue unless @config['in_server_creation_queue'] #bootstrap server with ruby and attach it to the chef server
76
85
  end
77
86
  end
78
87
  end
@@ -0,0 +1,37 @@
1
+
2
+ class Cheftacular
3
+ class StatelessActionDocumentation
4
+ def cloud_bootstrap_from_queue
5
+ @config['documentation']['stateless_action'][__method__] ||= {}
6
+ @config['documentation']['stateless_action'][__method__]['long_description'] = [
7
+ "`cft cloud_bootstrap_from_queue` uses a cloud api to " +
8
+ "create several servers. It is a wrapper around the cloud_bootstrap command that tries to queue server creation.",
9
+
10
+ [
11
+ " 1. This command cannot be called directly and can only be utilized from `cft environment boot`",
12
+ ]
13
+ ]
14
+
15
+ @config['documentation']['stateless_action'][__method__]['short_description'] = '[Not Directly Callable]'
16
+ end
17
+ end
18
+
19
+ class StatelessAction
20
+ def cloud_bootstrap_from_queue
21
+ raise "This action is not meant to be called directly!" unless @options['in_scaling']
22
+
23
+ puts("Preparing to boot server #{ @options['node_name'] } for #{ @options['env'] }!") unless @options['quiet']
24
+
25
+ @config['in_server_creation_queue'] = true
26
+
27
+ @config['server_creation_queue'].each do |server_hash|
28
+ puts("Creating server #{ server_hash['node_name'] } with arguments:") unless @options['quiet']
29
+ ap(server_hash.except('node_name')) unless @options['quiet']
30
+
31
+ @config['stateless_action'].cloud_bootstrap(server_hash)
32
+ end
33
+
34
+ @config['stateless_action'].full_bootstrap_from_queue
35
+ end
36
+ end
37
+ end
@@ -4,7 +4,7 @@ class Cheftacular
4
4
  def environment
5
5
  @config['documentation']['stateless_action'][__method__] ||= {}
6
6
  @config['documentation']['stateless_action'][__method__]['long_description'] = [
7
- "`cft environment boot|destroy` will boot / destroy the current environment",
7
+ "`cft environment boot|boot_without_deploy|destroy|destroy_raw_servers [SERVER_NAMES]` will boot / destroy the current environment",
8
8
 
9
9
  [
10
10
  " 1. `boot` will spin up servers and bring them to a stable state. " +
@@ -12,7 +12,14 @@ class Cheftacular
12
12
 
13
13
  " 2. `destroy` will destroy all servers needed for the target environment",
14
14
 
15
- " 3. This command will prompt when attempting to destroy servers in staging or production"
15
+ " 3. `destroy_raw_servers` will destroy the servers without destroying the node data.",
16
+
17
+ " 4. `boot_without_deploy` will spin up servers and bring them to a state where they are ready to be deployed",
18
+
19
+ " 5. This command will prompt when attempting to destroy servers in staging or production. " +
20
+ "Additionally, only devops clients will be able to destroy servers in those environments.",
21
+
22
+ " 6. This command also accepts a *comma delimited list* of server names to boot / destroy instead of all the stored ones for an environment."
16
23
  ]
17
24
  ]
18
25
 
@@ -23,7 +30,7 @@ class Cheftacular
23
30
  end
24
31
 
25
32
  class StatelessAction
26
- def environment type="boot", ask_on_destroy=false, remove=true
33
+ def environment type="boot", ask_on_destroy=false, remove=true, servers_to_interact_with=[], threads=[]
27
34
  ask_on_destroy = case @options['env']
28
35
  when 'staging' then true
29
36
  when 'production' then true
@@ -32,7 +39,11 @@ class Cheftacular
32
39
 
33
40
  type = ARGV[1] if ARGV[1]
34
41
 
35
- raise "Unknown type: #{ type }, can only be 'boot' or 'destroy'" unless (type =~ /boot|destroy/) == 0
42
+ servers_to_interact_with = ARGV[2].split(',') if ARGV[2]
43
+
44
+ unless (type =~ /boot|destroy|destroy_raw_servers|boot_without_deploy/) == 0
45
+ raise "Unknown type: #{ type }, can only be 'boot'/'boot_without_deploy'/'destroy'/'destroy_raw_servers'"
46
+ end
36
47
 
37
48
  nodes = @config['getter'].get_true_node_objects(true)
38
49
 
@@ -43,6 +54,10 @@ class Cheftacular
43
54
 
44
55
  initial_servers = @config['cheftacular']['env_boot_nodes']["#{ @options['env'] }_nodes"]
45
56
 
57
+ unless servers_to_interact_with.empty?
58
+ initial_servers = initial_servers.delete_if {|name, config_hash| !servers_to_interact_with.include?(name)}
59
+ end
60
+
46
61
  if initial_servers.empty?
47
62
  puts "There are no servers defined for #{ @options['env'] } in the env_boot_nodes hash in your cheftacular.yml... Exiting"
48
63
 
@@ -50,44 +65,51 @@ class Cheftacular
50
65
  end
51
66
 
52
67
  case type
53
- when 'boot'
54
- initial_servers.each_pair do |name, config_hash|
55
- next if nodes.map { |n| n.name }.include?(name)
56
- config_hash ||= {}
57
-
58
- @options['node_name'] = name
59
- @options['flavor_name'] = config_hash.has_key?('flavor') ? config_hash['flavor'] : @config['cheftacular']['default_flavor_name']
60
- @options['descriptor'] = config_hash.has_key?('descriptor') ? config_hash['descriptor'] : name
61
- @options['with_dn'] = config_hash.has_key?('dns_config') ? @config['parser'].parse_to_dns(config_hash['dns_config']) : @config['parser'].parse_to_dns('NODE_NAME.ENV_TLD')
68
+ when /boot|boot_without_deploy/
69
+ begin
70
+ initial_servers.each_pair do |name, config_hash|
71
+ next if nodes.map { |n| n.name }.include?(name)
72
+ config_hash ||= {}
73
+ node_hash = {}
74
+
75
+ node_hash['node_name'] = name
76
+ node_hash['flavor_name'] = config_hash.has_key?('flavor') ? config_hash['flavor'] : @config['cheftacular']['default_flavor_name']
77
+ node_hash['descriptor'] = config_hash.has_key?('descriptor') ? config_hash['descriptor'] : name
78
+ node_hash['dns_config'] = if config_hash.has_key?('dns_config')
79
+ @config['parser'].parse_to_dns(config_hash['dns_config'], node_hash['node_name'])
80
+ else
81
+ @config['parser'].parse_to_dns('NODE_NAME.ENV_TLD', node_hash['node_name'])
82
+ end
83
+
84
+ @config['server_creation_queue'] << node_hash
85
+ end
86
+
87
+ @config['stateless_action'].cloud_bootstrap_from_queue
88
+ end
62
89
 
63
- puts("Preparing to boot server #{ @options['node_name'] } for #{ @options['env'] }!") unless @options['quiet']
90
+ @config['ChefDataBag'].save_server_passwords_bag
64
91
 
65
- @config['stateless_action'].cloud_bootstrap
92
+ if type == 'boot'
93
+ @options = @options.delete_if { |k,v| ['node_name','address', 'descriptor', 'with_dn', 'private_address', 'client_pass'].include?(k) }
66
94
 
67
- sleep 15
68
- end
95
+ @options['role'] = @config['cheftacular']['backup_config']['db_primary_role']
69
96
 
70
- @config['ChefDataBag'].save_server_passwords_bag
97
+ @options['unset_address_and_node_name'] = true
71
98
 
72
- @options['node_name'] = nil
99
+ @config['action'].deploy
73
100
 
74
- @options['role'] = 'all'
101
+ backup_pid = Process.spawn("cft backups load --env=#{ @options['env'] }")
75
102
 
76
- @config['action'].deploy
103
+ @options['role'] = 'all'
77
104
 
78
- #TODO INTEGRATE backups TO LOAD DATA INTO THE NEWLY BOOTED ENV
79
- when 'destroy'
80
- raise "This action can only be performed if the mode is set to devops" if !@config['helper'].running_in_mode?('devops')
81
-
82
- if ask_on_destroy
83
- puts "Preparing to delete nodes in #{ @options['env'] }.\nEnter Y/y to confirm."
105
+ @config['action'].deploy
84
106
 
85
- input = STDIN.gets.chomp
107
+ Process.wait backup_pid
86
108
 
87
- remove = false unless ( input =~ /y|Y|yes|Yes/ ) == 0
109
+ puts "Done loading data and setting up #{ @options['env'] }!"
88
110
  end
89
-
90
- return false unless remove
111
+ when 'destroy'
112
+ return false if ask_on_destroy && !environment_is_destroyable?
91
113
 
92
114
  @options['delete_server_on_remove'] = true
93
115
 
@@ -98,9 +120,36 @@ class Cheftacular
98
120
 
99
121
  @config['stateless_action'].remove_client
100
122
 
123
+ sleep 15
124
+ end
125
+ when 'destroy_raw_servers'
126
+ return false if ask_on_destroy && !environment_is_destroyable?
127
+
128
+ @options['delete_server_on_remove'] = true
129
+
130
+ initial_servers.each_pair do |name, config_hash|
131
+ next if nodes.map { |n| n.name }.include?(name)
132
+ @options['node_name'] = name
133
+
134
+ real_node_name = @config['getter'].get_current_real_node_name
135
+
136
+ @config['stateless_action'].cloud('servers', "destroy:#{ real_node_name }")
137
+
101
138
  sleep 15
102
139
  end
103
140
  end
104
141
  end
142
+
143
+ private
144
+
145
+ def environment_is_destroyable?
146
+ raise "This action can only be performed if the mode is set to devops" unless @config['helper'].running_in_mode?('devops')
147
+
148
+ puts "Preparing to delete nodes in #{ @options['env'] }.\nEnter Y/y to confirm."
149
+
150
+ input = STDIN.gets.chomp
151
+
152
+ ( input =~ /y|Y|yes|Yes/ ) == 0
153
+ end
105
154
  end
106
155
  end
@@ -45,29 +45,8 @@ class Cheftacular
45
45
  end
46
46
 
47
47
  targets.each do |target|
48
- puts "clearing #{ target }"
49
- case CONFIG['host_os']
50
- when /mswin|windows/i
51
- raise "#{ __method__ } does not support this operating system at this time"
52
- when /linux|arch/i
53
- puts "#{ __method__ } does not support this operating system at this time"
54
- when /sunos|solaris/i
55
- raise "#{ __method__ } does not support this operating system at this time"
56
- when /darwin/i
57
- cleanup_known_hosts_for_BSD_linux_architecture target
58
- else
59
- raise "#{ __method__ } does not support this operating system at this time"
60
- end
48
+ @config['filesystem'].scrub_from_known_hosts target
61
49
  end
62
50
  end
63
- private
64
-
65
- def cleanup_known_hosts_for_BSD_linux_architecture target
66
- #Removes the entire line containing the string
67
- `sed -i '' "s/#{ target }.*//g" ~/.ssh/known_hosts`
68
-
69
- #remove empty lines
70
- `sed -i '' "/^$/d" ~/.ssh/known_hosts`
71
- end
72
51
  end
73
52
  end
@@ -1,40 +1,33 @@
1
1
 
2
2
  class Cheftacular
3
3
  class StatelessActionDocumentation
4
- def full_bootstrap
4
+ def full_bootstrap_from_queue
5
5
  @config['documentation']['stateless_action'][__method__] ||= {}
6
6
  @config['documentation']['stateless_action'][__method__]['long_description'] = [
7
- "`cft full_bootstrap ADDRESS ROOT_PASS NODE_NAME` This command performs both " +
7
+ "`cft full_bootstrap_from_queue` This command performs both " +
8
8
  "#{ @config['cheftacular']['preferred_cloud_os'] }_bootstrap and chef_bootstrap.",
9
9
 
10
10
  [
11
- " 1. This command is run by `cft cloud_bootstrap` and should not be run on its own unless the " +
12
- "target server is already created and not initialized."
11
+ " 1. This command is run by `cft cloud_bootstrap` and should not be run on its own."
13
12
  ]
14
13
  ]
15
14
 
16
- @config['documentation']['stateless_action'][__method__]['short_description'] = 'Attempts to setup a server that has already been created'
15
+ @config['documentation']['stateless_action'][__method__]['short_description'] = '[Not Directly Callable]'
17
16
  end
18
17
  end
19
18
 
20
19
  class StatelessAction
21
- def full_bootstrap
20
+ def full_bootstrap_from_queue options_to_sync=['node_name', 'address', 'client_pass']
22
21
  raise "This action can only be performed if the mode is set to devops" if !@config['helper'].running_in_mode?('devops') && !@options['in_scaling']
23
22
 
24
- @options['address'] = ARGV[1] unless @options['address']
25
- @options['client_pass'] = ARGV[2] unless @options['client_pass']
26
- @options['node_name'] = ARGV[3] unless @options['node_name']
27
-
28
23
  case @config['cheftacular']['preferred_cloud_os']
29
- when 'ubuntu' || 'debian' then @config['stateless_action'].ubuntu_bootstrap
30
- else @config['stateless_action'].instance_eval("#{ @config['cheftacular']['preferred_cloud_os'] }_bootstrap")
24
+ when 'ubuntu' || 'debian' then @config['stateless_action'].ubuntu_bootstrap_from_queue
25
+ else @config['stateless_action'].instance_eval("#{ @config['cheftacular']['preferred_cloud_os'] }_bootstrap_from_queue")
31
26
  end
32
27
 
33
28
  @config['initializer'].initialize_passwords @options['env'] #reset the passwords var to contain the new deploy pass set in ubuntu_bootstrap
34
29
 
35
- @config['helper'].install_rvm_sh_file if @config['cheftacular']['install_rvm_on_boot']
36
-
37
- @config['stateless_action'].chef_bootstrap
30
+ @config['stateless_action'].chef_bootstrap_from_queue
38
31
  end
39
32
  end
40
33
  end
@@ -4,8 +4,12 @@ class Cheftacular
4
4
  def knife_upload
5
5
  @config['documentation']['stateless_action'][__method__] ||= {}
6
6
  @config['documentation']['stateless_action'][__method__]['long_description'] = [
7
- "`cft knife_upload` will resync the chef-server with the local chef-repo code. " +
8
- "This command is analog for `knife upload /`"
7
+ "`cft knife_upload [force]` will resync the chef-server with the local chef-repo code. " +
8
+ "This command is analog for `knife upload /`",
9
+
10
+ [
11
+ " 1. The force option will add the force option to knife upload."
12
+ ]
9
13
  ]
10
14
 
11
15
  @config['documentation']['stateless_action'][__method__]['short_description'] = 'Uploads your current cookbooks to the chef server'
@@ -16,9 +20,16 @@ class Cheftacular
16
20
  def knife_upload
17
21
  raise "This action can only be performed if the mode is set to devops" unless @config['helper'].running_in_mode?('devops')
18
22
 
23
+ arg = ARGV[1]
24
+
25
+ option = case arg
26
+ when 'force' then ' --force'
27
+ else ''
28
+ end
29
+
19
30
  puts("Starting upload...") unless @options['quiet']
20
31
 
21
- out = `knife upload / --chef-repo-path #{ @config['locs']['chef-repo'] }`
32
+ out = `knife upload / --chef-repo-path #{ @config['locs']['chef-repo'] }#{ option }`
22
33
 
23
34
  puts out
24
35
  end
@@ -35,7 +35,7 @@ class Cheftacular
35
35
 
36
36
  puts("Starting reinitialization...") unless @options['quiet']
37
37
 
38
- out << `#{ @config['helper'].knife_bootstrap_command }`
38
+ out << `#{ knife_bootstrap_command }`
39
39
 
40
40
  puts(out.last) unless @options['quiet']
41
41
  end
@@ -32,7 +32,7 @@ class Cheftacular
32
32
 
33
33
  raise "Invalid arguments! Node name is blank. Please call this script as cft remove_client <node_name>" unless @options['node_name']
34
34
 
35
- nodes = @config['getter'].get_true_node_objects(false, true)
35
+ nodes = @config['getter'].get_true_node_objects
36
36
 
37
37
  nodes.each do |n|
38
38
  begin
@@ -68,9 +68,9 @@ class Cheftacular
68
68
  end
69
69
  end
70
70
 
71
- puts("Done. Please verify that the output of the next line(s) match your expectations (running client-list)") if @options['verbose']
71
+ puts("Done. Please verify that the output of the next line(s) match your expectations (running cft client_list)") if @options['verbose']
72
72
 
73
- puts(`client-list`) if @options['verbose']
73
+ @config['stateless_actions'].client_list if @options['verbose']
74
74
  end
75
75
 
76
76
  alias_method :remove_node, :remove_client
@@ -18,7 +18,6 @@ class Cheftacular
18
18
 
19
19
  class StatelessAction
20
20
  def restart_swap
21
-
22
21
  nodes = @config['getter'].get_true_node_objects(true)
23
22
 
24
23
  nodes = @config['parser'].exclude_nodes( nodes, [{ if: { env: '_default' }}] )
@@ -48,25 +48,31 @@ class Cheftacular
48
48
 
49
49
  case type
50
50
  when 'boot'
51
- @config['cheftacular']['split_env_nodes'].each_pair do |name, config_hash|
52
- config_hash ||= {}
53
- true_name = name.gsub('SPLITENV', split_env)
54
- @options['sub_env'] = split_env
55
- @options['node_name'] = "#{ true_name }#{ 'p' if @options['env'] == 'production' }"
56
- @options['flavor_name'] = config_hash.has_key?('flavor') ? config_hash['flavor'] : @config['cheftacular']['default_flavor_name']
57
- @options['descriptor'] = config_hash.has_key?('descriptor') ? "#{ config_hash['descriptor'] }-#{ split_env }" : name
58
- @options['with_dn'] = config_hash.has_key?('dns_config') ? @config['parser'].parse_to_dns(config_hash['dns_config']) : @config['parser'].parse_to_dns('NODE_NAME.ENV_TLD')
59
-
60
- next if nodes.map { |n| n.name }.include?(@options['node_name'])
61
-
62
- puts("Preparing to boot server #{ @options['node_name'] } for #{ @options['env'] }'s #{ split_env } environment!") unless @options['quiet']
63
-
64
- @config['stateless_action'].cloud_bootstrap
65
-
66
- sleep 15
51
+ begin
52
+ @config['cheftacular']['split_env_nodes'].each_pair do |name, config_hash|
53
+ next if nodes.map { |n| n.name }.include?(@options['node_name'])
54
+ config_hash ||= {}
55
+ node_hash = {}
56
+ true_name = name.gsub('SPLITENV', split_env)
57
+ @options['sub_env'] = split_env
58
+ node_hash['node_name'] = name
59
+ node_hash['flavor_name'] = config_hash.has_key?('flavor') ? config_hash['flavor'] : @config['cheftacular']['default_flavor_name']
60
+ node_hash['descriptor'] = config_hash.has_key?('descriptor') ? "#{ config_hash['descriptor'] }-#{ split_env }" : name
61
+ node_hash['dns_config'] = if config_hash.has_key?('dns_config')
62
+ @config['parser'].parse_to_dns(config_hash['dns_config'], node_hash['node_name'])
63
+ else
64
+ @config['parser'].parse_to_dns('NODE_NAME.ENV_TLD', node_hash['node_name'])
65
+ end
66
+
67
+ puts("Preparing to boot server #{ @options['node_name'] } for #{ @options['env'] }'s #{ split_env } environment!") unless @options['quiet']
68
+
69
+ @config['stateless_action'].cloud_bootstrap_from_queue
70
+
71
+ sleep 15
72
+ end
73
+ ensure
74
+ @config['ChefDataBag'].save_server_passwords_bag
67
75
  end
68
-
69
- @config['ChefDataBag'].save_server_passwords_bag
70
76
  when 'destroy'
71
77
  @options['delete_server_on_remove'] = true
72
78