cheftacular 2.10.2 → 2.11.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 +119 -77
- data/lib/cheftacular/actions/check.rb +58 -24
- data/lib/cheftacular/actions/deploy.rb +5 -3
- data/lib/cheftacular/auditor.rb +4 -3
- data/lib/cheftacular/cheftacular.rb +1 -0
- data/lib/cheftacular/cloud_provider.rb +17 -12
- data/lib/cheftacular/file_system.rb +20 -0
- data/lib/cheftacular/getter.rb +1 -1
- data/lib/cheftacular/helper.rb +41 -28
- data/lib/cheftacular/initializer.rb +5 -3
- data/lib/cheftacular/parser.rb +10 -6
- data/lib/cheftacular/queue_master.rb +24 -0
- data/lib/cheftacular/stateless_actions/backups.rb +2 -2
- data/lib/cheftacular/stateless_actions/bootstrappers/{centos_bootstrap.rb → centos_bootstrap_from_queue.rb} +1 -1
- data/lib/cheftacular/stateless_actions/bootstrappers/{coreos_bootstrap.rb → coreos_bootstrap_from_queue.rb} +1 -1
- data/lib/cheftacular/stateless_actions/bootstrappers/{fedora_bootstrap.rb → fedora_bootstrap_from_queue.rb} +1 -1
- data/lib/cheftacular/stateless_actions/bootstrappers/{redhat_bootstrap.rb → redhat_bootstrap_from_queue.rb} +1 -1
- data/lib/cheftacular/stateless_actions/bootstrappers/ubuntu_bootstrap_from_queue.rb +203 -0
- data/lib/cheftacular/stateless_actions/bootstrappers/vyatta_bootstrap_from_queue.rb +7 -0
- data/lib/cheftacular/stateless_actions/check_cheftacular_yml_keys.rb +30 -0
- data/lib/cheftacular/stateless_actions/chef_bootstrap_from_queue.rb +89 -0
- data/lib/cheftacular/stateless_actions/cheftacular_yml_help.rb +55 -6
- data/lib/cheftacular/stateless_actions/client_list.rb +1 -3
- data/lib/cheftacular/stateless_actions/cloud_bootstrap.rb +24 -15
- data/lib/cheftacular/stateless_actions/cloud_bootstrap_from_queue.rb +37 -0
- data/lib/cheftacular/stateless_actions/environment.rb +80 -31
- data/lib/cheftacular/stateless_actions/fix_known_hosts.rb +1 -22
- data/lib/cheftacular/stateless_actions/{full_bootstrap.rb → full_bootstrap_from_queue.rb} +8 -15
- data/lib/cheftacular/stateless_actions/knife_upload.rb +14 -3
- data/lib/cheftacular/stateless_actions/reinitialize.rb +1 -1
- data/lib/cheftacular/stateless_actions/remove_client.rb +3 -3
- data/lib/cheftacular/stateless_actions/restart_swap.rb +0 -1
- data/lib/cheftacular/stateless_actions/test_env.rb +24 -18
- data/lib/cheftacular/stateless_actions/update_thecheftacularcookbook.rb +1 -1
- data/lib/cheftacular/stateless_actions/upload_nodes.rb +2 -2
- data/lib/cheftacular/version.rb +1 -1
- data/lib/cloud_interactor/domain/create.rb +2 -2
- data/lib/cloud_interactor/domain/create_record.rb +1 -1
- data/lib/cloud_interactor/domain/destroy.rb +2 -2
- data/lib/cloud_interactor/domain/destroy_record.rb +1 -1
- data/lib/cloud_interactor/domain/list_records.rb +1 -1
- data/lib/cloud_interactor/domain/read.rb +1 -1
- data/lib/cloud_interactor/domain/read_record.rb +1 -1
- data/lib/cloud_interactor/domain/update.rb +2 -2
- data/lib/cloud_interactor/domain/update_record.rb +2 -2
- data/lib/cloud_interactor/helpers.rb +11 -6
- data/lib/cloud_interactor/server/attach_volume.rb +1 -1
- data/lib/cloud_interactor/server/create.rb +4 -4
- data/lib/cloud_interactor/server/detach_volume.rb +2 -2
- data/lib/cloud_interactor/server/list_volumes.rb +1 -1
- data/lib/cloud_interactor/server/poll.rb +2 -2
- data/lib/cloud_interactor/server/read_volume.rb +1 -1
- data/lib/cloud_interactor/version.rb +1 -1
- data/lib/cloud_interactor/volume/create.rb +1 -1
- data/lib/sshkit/getters.rb +9 -1
- metadata +25 -10
- data/lib/cheftacular/stateless_actions/bootstrappers/ubuntu_bootstrap.rb +0 -116
- data/lib/cheftacular/stateless_actions/bootstrappers/vyatta_bootstrap.rb +0 -7
- data/lib/cheftacular/stateless_actions/chef_bootstrap.rb +0 -63
@@ -30,7 +30,7 @@ class Cheftacular
|
|
30
30
|
|
31
31
|
`rm -Rf #{ @config['locs']['cookbooks'] }/TheCheftacularCookbook` if File.exists?(File.expand_path("#{ @config['locs']['cookbooks'] }/TheCheftacularCookbook"))
|
32
32
|
`cp -Rf #{ @config['locs']['berks'] }/#{ cheftacular_cookbook['location'] } #{ @config['locs']['cookbooks'] }/TheCheftacularCookbook`
|
33
|
-
|
33
|
+
|
34
34
|
break
|
35
35
|
end
|
36
36
|
end
|
@@ -27,7 +27,7 @@ class Cheftacular
|
|
27
27
|
end
|
28
28
|
|
29
29
|
class StatelessAction
|
30
|
-
def upload_nodes invalidate_file_node_cache=
|
30
|
+
def upload_nodes invalidate_file_node_cache=true
|
31
31
|
@config['filesystem'].cleanup_file_caches('current-nodes') if invalidate_file_node_cache
|
32
32
|
|
33
33
|
raise "This action can only be performed if the mode is set to devops" if !@config['helper'].running_in_mode?('devops') && !@options['in_scaling']
|
@@ -38,7 +38,7 @@ class Cheftacular
|
|
38
38
|
@config['initializer'].initialize_node_roles_bag_contents env
|
39
39
|
end
|
40
40
|
|
41
|
-
nodes = @options['multi-step'] ? @config['getter'].get_true_node_objects(true
|
41
|
+
nodes = @options['multi-step'] ? @config['getter'].get_true_node_objects(true) : @config['getter'].get_true_node_objects(true)
|
42
42
|
|
43
43
|
node_roles_hash, bag_hash, allowed_changes_hash = {},{},{}
|
44
44
|
|
data/lib/cheftacular/version.rb
CHANGED
@@ -4,14 +4,14 @@ class CloudInteractor
|
|
4
4
|
read args, false
|
5
5
|
|
6
6
|
unless @main_obj["specific_#{ IDENTITY }"].empty?
|
7
|
-
puts "#{ IDENTITY } #{ args[IDENTITY.singularize] } already exists... returning."
|
7
|
+
puts "(#{ IDENTITY.capitalize }) #{ IDENTITY } #{ args[IDENTITY.singularize] } already exists... returning."
|
8
8
|
|
9
9
|
return false
|
10
10
|
end
|
11
11
|
|
12
12
|
@classes['auth'].auth_service(RESOURCE).instance_eval('zones').create(domain: args[IDENTITY.singularize], email: @auth_hash['cloud_authentication'][@options['preferred_cloud']]['email'])
|
13
13
|
|
14
|
-
puts "Created #{ IDENTITY } #{ args[IDENTITY.singularize] }..."
|
14
|
+
puts "(#{ IDENTITY.capitalize }) Created #{ IDENTITY } #{ args[IDENTITY.singularize] }..."
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -22,7 +22,7 @@ class CloudInteractor
|
|
22
22
|
|
23
23
|
specific_fog_object.records.create(name: args['target_domain'], value: args['target_ip'], type: args['type'], ttl: args['ttl'])
|
24
24
|
|
25
|
-
puts "Attached #{ args['subdomain'] } (#{ args['target_ip'] }) to #{ args[IDENTITY.singularize] } (#{ args['target_domain'] })..."
|
25
|
+
puts "(#{ IDENTITY.capitalize }) Attached #{ args['subdomain'] } (#{ args['target_ip'] }) to #{ args[IDENTITY.singularize] } (#{ args['target_domain'] })..."
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -4,14 +4,14 @@ class CloudInteractor
|
|
4
4
|
read args, false
|
5
5
|
|
6
6
|
if @main_obj["specific_#{ IDENTITY }"].empty? && @main_obj["specific_#{ IDENTITY }"].last[IDENTITY.singularize] != args[IDENTITY.singularize]
|
7
|
-
puts "#{ IDENTITY } #{ args[IDENTITY.singularize] } doesn't exist... returning."
|
7
|
+
puts "(#{ IDENTITY.capitalize }) #{ IDENTITY } #{ args[IDENTITY.singularize] } doesn't exist... returning."
|
8
8
|
|
9
9
|
return false
|
10
10
|
end
|
11
11
|
|
12
12
|
@classes['auth'].auth_service(RESOURCE).instance_eval('zones').get(@main_obj["specific_#{ IDENTITY }"].last['id']).destroy
|
13
13
|
|
14
|
-
puts "Destroyed #{ IDENTITY.singularize } #{ args[IDENTITY.singularize] }..."
|
14
|
+
puts "(#{ IDENTITY.capitalize }) Destroyed #{ IDENTITY.singularize } #{ args[IDENTITY.singularize] }..."
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -13,7 +13,7 @@ class CloudInteractor
|
|
13
13
|
|
14
14
|
raise "Subdomain not found for #{ args[IDENTITY.singularize] }" unless already_exists
|
15
15
|
|
16
|
-
puts "Destroying #{ args['subdomain'] } from #{ args[IDENTITY.singularize] }..."
|
16
|
+
puts "(#{ IDENTITY.capitalize }) Destroying #{ args['subdomain'] } from #{ args[IDENTITY.singularize] }..."
|
17
17
|
|
18
18
|
specific_fog_object = @classes['auth'].auth_service(RESOURCE).instance_eval('zones').get @main_obj["specific_#{ IDENTITY }"].last['id']
|
19
19
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CloudInteractor
|
2
2
|
class Domain
|
3
3
|
def list_records args, output=false
|
4
|
-
puts "Querying #{ args["domain"] } for records..."
|
4
|
+
puts "(#{ IDENTITY.capitalize }) Querying #{ args["domain"] } for records..."
|
5
5
|
|
6
6
|
specific_fog_object = @classes['auth'].auth_service(RESOURCE).instance_eval('zones').get @main_obj["specific_#{ IDENTITY }"].last['id']
|
7
7
|
|
@@ -17,7 +17,7 @@ class CloudInteractor
|
|
17
17
|
|
18
18
|
ap(@main_obj["specific_#{ IDENTITY }"]) if output
|
19
19
|
|
20
|
-
puts("#{ specific_identity } not found in #{ IDENTITY }!") if @main_obj["specific_#{ IDENTITY }"].empty?
|
20
|
+
puts("(#{ IDENTITY.capitalize }) #{ specific_identity } not found in #{ IDENTITY }!") if @main_obj["specific_#{ IDENTITY }"].empty?
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -21,7 +21,7 @@ class CloudInteractor
|
|
21
21
|
ap(record_hash) if output
|
22
22
|
end
|
23
23
|
|
24
|
-
puts("#{ args[IDENTITY.singularize] } does not have the subdomain #{ args['subdomain'] }!") if @main_obj["specific_queried_domains"].nil?
|
24
|
+
puts("(#{ IDENTITY.capitalize }) #{ args[IDENTITY.singularize] } does not have the subdomain #{ args['subdomain'] }!") if @main_obj["specific_queried_domains"].nil?
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -5,14 +5,14 @@ class CloudInteractor
|
|
5
5
|
read args, false
|
6
6
|
|
7
7
|
if (@main_obj["specific_#{ IDENTITY }"].nil? || @main_obj["specific_#{ IDENTITY }"].empty?) && @main_obj["specific_#{ IDENTITY }"].last[IDENTITY.singularize] != args[IDENTITY.singularize]
|
8
|
-
puts "#{ IDENTITY } #{ args[IDENTITY.singularize] } doesn't exist... returning."
|
8
|
+
puts "(#{ IDENTITY.capitalize }) #{ IDENTITY } #{ args[IDENTITY.singularize] } doesn't exist... returning."
|
9
9
|
|
10
10
|
return false
|
11
11
|
end
|
12
12
|
|
13
13
|
@classes['auth'].auth_service(resource).instance_eval('zones').get(@main_obj["specific_#{ IDENTITY }"].last['id']).update(ttl: 5, email: @auth_hash['cloud_authentication'][@options['preferred_cloud']]['email'])
|
14
14
|
|
15
|
-
puts "Updated #{ IDENTITY } #{ args[IDENTITY.singularize] }..."
|
15
|
+
puts "(#{ IDENTITY.capitalize }) Updated #{ IDENTITY } #{ args[IDENTITY.singularize] }..."
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -8,7 +8,7 @@ class CloudInteractor
|
|
8
8
|
|
9
9
|
read args, false
|
10
10
|
|
11
|
-
puts "Updating #{ args['subdomain'] } for #{ args[IDENTITY.singularize] }..."
|
11
|
+
puts "(#{ IDENTITY.capitalize }) Updating #{ args['subdomain'] } for #{ args[IDENTITY.singularize] }..."
|
12
12
|
|
13
13
|
@main_obj['specific_records'][args[IDENTITY.singularize]].each do |record_hash|
|
14
14
|
already_created = true if record_hash['name'] == args['target_domain'] && record_hash['type'] == args['type']
|
@@ -35,7 +35,7 @@ class CloudInteractor
|
|
35
35
|
raise "Unsupported action #{ __method__ } for #{ @options['preferred_cloud'] }. Please create an issue on github or submit a PR to fix this issue."
|
36
36
|
end
|
37
37
|
|
38
|
-
puts "Updated #{ args['subdomain'] } (#{ args['target_ip'] }) to #{ args[IDENTITY.singularize] } (#{ args['target_domain'] })..."
|
38
|
+
puts "(#{ IDENTITY.capitalize }) Updated #{ args['subdomain'] } (#{ args['target_ip'] }) to #{ args[IDENTITY.singularize] } (#{ args['target_domain'] })..."
|
39
39
|
else
|
40
40
|
create_record [ args ]
|
41
41
|
end
|
@@ -14,7 +14,7 @@ class CloudInteractor
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def generic_list_call identity, resource, output=true
|
17
|
-
puts "Returning list of #{ identity } for #{ resource == 'DNS' ? @options['route_dns_changes_via'] : @options['preferred_cloud'] }..."
|
17
|
+
puts "(#{ identity.capitalize }) Returning list of #{ identity } for #{ resource == 'DNS' ? @options['route_dns_changes_via'] : @options['preferred_cloud'] }..."
|
18
18
|
|
19
19
|
@main_obj[identity] = JSON.parse(@classes['auth'].auth_service(resource).instance_eval(identity).to_json)
|
20
20
|
|
@@ -30,7 +30,7 @@ class CloudInteractor
|
|
30
30
|
|
31
31
|
@main_obj[identity].each do |identity_hash|
|
32
32
|
if specific_identity.nil?
|
33
|
-
puts("Query arguments \"#{ args }\" are not being mapped correctly for #{ identity.singularize } reads from method #{ caller[3][/`.*'/][1..-2] }! This read will return no objects.")
|
33
|
+
puts("(#{ identity.capitalize }) Query arguments \"#{ args }\" are not being mapped correctly for #{ identity.singularize } reads from method #{ caller[3][/`.*'/][1..-2] }! This read will return no objects.")
|
34
34
|
|
35
35
|
break
|
36
36
|
end
|
@@ -46,19 +46,24 @@ class CloudInteractor
|
|
46
46
|
ap(identity_hash) if output
|
47
47
|
end
|
48
48
|
|
49
|
-
puts("#{ specific_identity }
|
49
|
+
puts("(#{ identity.capitalize }) #{ specific_identity } matched and being utilized for #{ identity }.") unless @main_obj["specific_#{ identity }"].empty?
|
50
|
+
puts("(#{ identity.capitalize }) #{ specific_identity } not found in #{ identity }!") if @main_obj["specific_#{ identity }"].empty?
|
50
51
|
end
|
51
52
|
|
52
53
|
def generic_destroy_parse destroy_hash, identity, resource, mode='name'
|
53
54
|
puts("Queried #{ identity } #{ ap @main_obj["specific_#{ identity }"] }") if @options['verbose']
|
54
55
|
|
55
|
-
|
56
|
+
if @main_obj["specific_#{ identity }"].empty?
|
57
|
+
puts "#{ destroy_hash[mode] } was not found in #{ identity.singularize } to destroy!"
|
58
|
+
|
59
|
+
return false
|
60
|
+
end
|
56
61
|
|
57
62
|
if destroy_hash[mode].empty? || @main_obj["specific_#{ identity }"].last[mode] != destroy_hash[mode] #without this it will delete the first object in the list, this is obviously bad
|
58
63
|
raise "Name mismatch on destroy! Expected #{ destroy_hash[mode] } and was going to destroy #{ @main_obj["specific_#{ identity }"].last[mode] }"
|
59
64
|
end
|
60
65
|
|
61
|
-
puts "Destroying #{ destroy_hash[mode] }..."
|
66
|
+
puts "(#{ identity.capitalize }) Destroying #{ destroy_hash[mode] }..."
|
62
67
|
|
63
68
|
specific_fog_object = @classes['auth'].auth_service(resource).instance_eval(identity).get @main_obj["specific_#{ identity }"].last['id']
|
64
69
|
|
@@ -68,7 +73,7 @@ class CloudInteractor
|
|
68
73
|
@main_obj["#{ identity }_destroy_request"] = specific_fog_object.destroy
|
69
74
|
end
|
70
75
|
|
71
|
-
puts "REMINDER! This destroy is not instant! It can take up to a few minutes for a #{ identity.singularize } to actually be fully destroyed!"
|
76
|
+
puts "(#{ identity.capitalize }) REMINDER! This destroy is not instant! It can take up to a few minutes for a #{ identity.singularize } to actually be fully destroyed!"
|
72
77
|
end
|
73
78
|
end
|
74
79
|
end
|
@@ -17,7 +17,7 @@ class CloudInteractor
|
|
17
17
|
@classes['volume'].read args
|
18
18
|
end
|
19
19
|
|
20
|
-
puts "Attaching #{ args['volume_name'] } to #{ args['server_name'] } in #{ IDENTITY }..."
|
20
|
+
puts "(#{ IDENTITY }) Attaching #{ args['volume_name'] } to #{ args['server_name'] } in #{ IDENTITY }..."
|
21
21
|
|
22
22
|
read args, false, 'name', 'server_name'
|
23
23
|
|
@@ -5,7 +5,7 @@ class CloudInteractor
|
|
5
5
|
@classes['image'].read @options['preferred_cloud_image'], false
|
6
6
|
|
7
7
|
#Note, if no flavor is passed it defaults to a 512MB standard!
|
8
|
-
@classes['flavor'].read args['flavor']
|
8
|
+
@classes['flavor'].read args['flavor'], @options.has_key?('verbose')
|
9
9
|
|
10
10
|
@classes['region'].read(@options['preferred_cloud_region'], false) if @options['preferred_cloud'] == 'digitalocean'
|
11
11
|
@classes['sshkey'].bootstrap if @options['preferred_cloud'] == 'digitalocean'
|
@@ -13,12 +13,12 @@ class CloudInteractor
|
|
13
13
|
read args, false
|
14
14
|
|
15
15
|
unless @main_obj["specific_#{ IDENTITY }"].empty?
|
16
|
-
puts "#{ IDENTITY } #{ args['name'] } already exists... returning."
|
16
|
+
puts "(#{ IDENTITY }) #{ IDENTITY } #{ args['name'] } already exists... returning."
|
17
17
|
|
18
18
|
return false
|
19
19
|
end
|
20
20
|
|
21
|
-
puts "Creating #{ args['name'] } in #{ IDENTITY }..."
|
21
|
+
puts "(#{ IDENTITY }) Creating #{ args['name'] } in #{ IDENTITY }..."
|
22
22
|
|
23
23
|
final_create_args = {
|
24
24
|
name: args['name'],
|
@@ -45,7 +45,7 @@ class CloudInteractor
|
|
45
45
|
@main_obj["#{ IDENTITY }_created_details"] ||= {}
|
46
46
|
@main_obj["#{ IDENTITY }_created_details"][args['name']] = @main_obj["#{ IDENTITY }_create_request"]
|
47
47
|
|
48
|
-
puts "Successfully created #{ args['name'] } with pass #{ @main_obj["#{ IDENTITY }_created_passwords"][args['name']] }"
|
48
|
+
puts "(#{ IDENTITY }) Successfully created #{ args['name'] } with pass #{ @main_obj["#{ IDENTITY }_created_passwords"][args['name']] }"
|
49
49
|
|
50
50
|
@main_obj['output']['admin_passwords'] = { args['name'] => @main_obj["#{ IDENTITY }_created_passwords"][args['name']] }
|
51
51
|
end
|
@@ -5,7 +5,7 @@ class CloudInteractor
|
|
5
5
|
|
6
6
|
read_volume args, false, true
|
7
7
|
|
8
|
-
puts "Detaching #{ args['volume_name'] } from #{ args['server_name'] } in #{ IDENTITY }..."
|
8
|
+
puts "(#{ IDENTITY }) Detaching #{ args['volume_name'] } from #{ args['server_name'] } in #{ IDENTITY }..."
|
9
9
|
|
10
10
|
specific_fog_object = @classes['auth'].auth_service(RESOURCE).instance_eval(IDENTITY).get @main_obj["specific_#{ IDENTITY }"].last['id']
|
11
11
|
|
@@ -15,7 +15,7 @@ class CloudInteractor
|
|
15
15
|
out << attachment.detach.to_s
|
16
16
|
end
|
17
17
|
|
18
|
-
puts "The state of the volume detachment is #{ out } for #{ args['server_name'] } in #{ IDENTITY }"
|
18
|
+
puts "(#{ IDENTITY }) The state of the volume detachment is #{ out } for #{ args['server_name'] } in #{ IDENTITY }"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CloudInteractor
|
2
2
|
class Server
|
3
3
|
def list_volumes args, output=true
|
4
|
-
puts "Returning list of volumes for #{ args['server_name'] } in #{ IDENTITY }..."
|
4
|
+
puts "(#{ IDENTITY }) Returning list of volumes for #{ args['server_name'] } in #{ IDENTITY }..."
|
5
5
|
|
6
6
|
read(args, false, 'name', 'server_name') if @main_obj["specific_#{ IDENTITY }"].nil?
|
7
7
|
|
@@ -5,7 +5,7 @@ class CloudInteractor
|
|
5
5
|
|
6
6
|
raise "Server #{ args['name'] } does not exist!" if @main_obj["specific_#{ IDENTITY }"].empty?
|
7
7
|
|
8
|
-
puts "Polling #{ args['name'] } for status...(execution will continue when the server is finished building)"
|
8
|
+
puts "(#{ IDENTITY.capitalize }) Polling #{ args['name'] } for status...(execution will continue when the server is finished building)"
|
9
9
|
|
10
10
|
specific_fog_object = @classes['auth'].auth_service(RESOURCE).instance_eval(IDENTITY).get @main_obj["specific_#{ IDENTITY }"].last['id']
|
11
11
|
|
@@ -16,7 +16,7 @@ class CloudInteractor
|
|
16
16
|
|
17
17
|
@main_obj['output']["created_servers"] << JSON.parse(specific_fog_object.reload.to_json)
|
18
18
|
|
19
|
-
puts "#{ args['name'] } became active in #{ duration_hash[:duration] } seconds!"
|
19
|
+
puts "(#{ IDENTITY.capitalize }) #{ args['name'] } became active in #{ duration_hash[:duration] } seconds!"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -18,7 +18,7 @@ class CloudInteractor
|
|
18
18
|
ap(volume_hash) if output
|
19
19
|
end
|
20
20
|
|
21
|
-
puts("#{ specific_volume } not attached to #{ args['server_name'] }!") if @main_obj["specific_attached_volumes"].nil?
|
21
|
+
puts("(#{ IDENTITY }) #{ specific_volume } not attached to #{ args['server_name'] }!") if @main_obj["specific_attached_volumes"].nil?
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CloudInteractor
|
2
2
|
class Volume
|
3
3
|
def create args
|
4
|
-
puts "Creating #{ args['display_name'] } in #{ IDENTITY }..."
|
4
|
+
puts "(#{ IDENTITY }) Creating #{ args['display_name'] } in #{ IDENTITY }..."
|
5
5
|
|
6
6
|
puts("Creating #{ IDENTITY.singularize } with args #{ ap(args) }") if @options['verbose']
|
7
7
|
|
data/lib/sshkit/getters.rb
CHANGED
@@ -23,7 +23,7 @@ module SSHKit
|
|
23
23
|
raise "Unknown repository or rolename for #{ name }"
|
24
24
|
end
|
25
25
|
|
26
|
-
def get_node_from_address nodes, address, ret_node
|
26
|
+
def get_node_from_address nodes, address, ret_node=nil
|
27
27
|
nodes.each do |n|
|
28
28
|
if n.public_ipaddress == address
|
29
29
|
ret_node = n
|
@@ -64,6 +64,14 @@ module SSHKit
|
|
64
64
|
|
65
65
|
ret
|
66
66
|
end
|
67
|
+
|
68
|
+
def get_server_hash_from_address array_of_server_hashes, address, ret_hash=nil
|
69
|
+
array_of_server_hashes.each do |server_hash|
|
70
|
+
ret_hash = server_hash if server_hash['address'] == address
|
71
|
+
end
|
72
|
+
|
73
|
+
ret_hash
|
74
|
+
end
|
67
75
|
end
|
68
76
|
end
|
69
77
|
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.11.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-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '11.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httpclient
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.7'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.7'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: ridley
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -253,14 +267,14 @@ files:
|
|
253
267
|
- lib/cheftacular/stateless_actions/add_ssh_key_to_bag.rb
|
254
268
|
- lib/cheftacular/stateless_actions/arguments.rb
|
255
269
|
- lib/cheftacular/stateless_actions/backups.rb
|
256
|
-
- lib/cheftacular/stateless_actions/bootstrappers/
|
257
|
-
- lib/cheftacular/stateless_actions/bootstrappers/
|
258
|
-
- lib/cheftacular/stateless_actions/bootstrappers/
|
259
|
-
- lib/cheftacular/stateless_actions/bootstrappers/
|
260
|
-
- lib/cheftacular/stateless_actions/bootstrappers/
|
261
|
-
- lib/cheftacular/stateless_actions/bootstrappers/
|
270
|
+
- lib/cheftacular/stateless_actions/bootstrappers/centos_bootstrap_from_queue.rb
|
271
|
+
- lib/cheftacular/stateless_actions/bootstrappers/coreos_bootstrap_from_queue.rb
|
272
|
+
- lib/cheftacular/stateless_actions/bootstrappers/fedora_bootstrap_from_queue.rb
|
273
|
+
- lib/cheftacular/stateless_actions/bootstrappers/redhat_bootstrap_from_queue.rb
|
274
|
+
- lib/cheftacular/stateless_actions/bootstrappers/ubuntu_bootstrap_from_queue.rb
|
275
|
+
- lib/cheftacular/stateless_actions/bootstrappers/vyatta_bootstrap_from_queue.rb
|
262
276
|
- lib/cheftacular/stateless_actions/check_cheftacular_yml_keys.rb
|
263
|
-
- lib/cheftacular/stateless_actions/
|
277
|
+
- lib/cheftacular/stateless_actions/chef_bootstrap_from_queue.rb
|
264
278
|
- lib/cheftacular/stateless_actions/chef_server.rb
|
265
279
|
- lib/cheftacular/stateless_actions/cheftacular_config.rb
|
266
280
|
- lib/cheftacular/stateless_actions/cheftacular_yml_help.rb
|
@@ -271,6 +285,7 @@ files:
|
|
271
285
|
- lib/cheftacular/stateless_actions/client_list.rb
|
272
286
|
- lib/cheftacular/stateless_actions/cloud.rb
|
273
287
|
- lib/cheftacular/stateless_actions/cloud_bootstrap.rb
|
288
|
+
- lib/cheftacular/stateless_actions/cloud_bootstrap_from_queue.rb
|
274
289
|
- lib/cheftacular/stateless_actions/compile_audit_log.rb
|
275
290
|
- lib/cheftacular/stateless_actions/compile_readme.rb
|
276
291
|
- lib/cheftacular/stateless_actions/create_git_key.rb
|
@@ -278,7 +293,7 @@ files:
|
|
278
293
|
- lib/cheftacular/stateless_actions/environment.rb
|
279
294
|
- lib/cheftacular/stateless_actions/file.rb
|
280
295
|
- lib/cheftacular/stateless_actions/fix_known_hosts.rb
|
281
|
-
- lib/cheftacular/stateless_actions/
|
296
|
+
- lib/cheftacular/stateless_actions/full_bootstrap_from_queue.rb
|
282
297
|
- lib/cheftacular/stateless_actions/get_active_ssh_connections.rb
|
283
298
|
- lib/cheftacular/stateless_actions/get_haproxy_log.rb
|
284
299
|
- lib/cheftacular/stateless_actions/get_log_from_bag.rb
|
@@ -1,116 +0,0 @@
|
|
1
|
-
class Cheftacular
|
2
|
-
class StatelessActionDocumentation
|
3
|
-
def ubuntu_bootstrap
|
4
|
-
@config['documentation']['stateless_action'][__method__] ||= {}
|
5
|
-
@config['documentation']['stateless_action'][__method__]['long_description'] = [
|
6
|
-
"`cft ubuntu_bootstrap ADDRESS ROOT_PASS` This command will bring a fresh server to a state " +
|
7
|
-
"where chef-client can be run on it via `cft chef-bootstrap`. It should be noted that it is in "+
|
8
|
-
"this step where a server's randomized deploy_user sudo password is generated."
|
9
|
-
]
|
10
|
-
|
11
|
-
@config['documentation']['stateless_action'][__method__]['short_description'] = 'Updates an ubuntu server to have more secure defaults'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class StatelessAction
|
16
|
-
def ubuntu_bootstrap out=[]
|
17
|
-
raise "This action can only be performed if the mode is set to devops" if !@config['helper'].running_in_mode?('devops') && !@options['in_scaling']
|
18
|
-
|
19
|
-
@options['address'] = ARGV[1] unless @options['address']
|
20
|
-
@options['client_pass'] = ARGV[2] unless @options['address']
|
21
|
-
|
22
|
-
if `which sshpass`.empty?
|
23
|
-
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)"
|
24
|
-
end
|
25
|
-
|
26
|
-
new_deploy_pass = @config['helper'].gen_pass(@config['cheftacular']['server_pass_length'])
|
27
|
-
|
28
|
-
deploy_user = @config['cheftacular']['deploy_user']
|
29
|
-
|
30
|
-
root_commands = [
|
31
|
-
"cd /home",
|
32
|
-
"adduser #{ deploy_user } --gecos \",,,,\" --disabled-password",
|
33
|
-
"echo #{ deploy_user }:#{ new_deploy_pass } | chpasswd",
|
34
|
-
"adduser #{ deploy_user } www-data",
|
35
|
-
"adduser #{ deploy_user } sudo",
|
36
|
-
"mkdir -p /home/#{ deploy_user }/.ssh",
|
37
|
-
"touch /home/#{ deploy_user }/.ssh/authorized_keys && touch /home/#{ deploy_user }/.ssh/known_hosts",
|
38
|
-
"chown -R #{ deploy_user }:www-data /home/#{ deploy_user }/.ssh",
|
39
|
-
'sed -i "s/StrictModes yes/StrictModes yes\nPasswordAuthentication no\nUseDNS no\nAllowUsers deploy postgres\n/" /etc/ssh/sshd_config'.gsub('deploy', deploy_user),
|
40
|
-
'sed -i "s/PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config'
|
41
|
-
]
|
42
|
-
|
43
|
-
@config['default']['authentication_bag_hash']['authorized_keys'].each do |line|
|
44
|
-
root_commands << "echo \"#{ line }\" >> /home/#{ deploy_user }/.ssh/authorized_keys"
|
45
|
-
end
|
46
|
-
|
47
|
-
sudo = "echo #{ new_deploy_pass } | sudo -S"
|
48
|
-
|
49
|
-
deploy_commands = [
|
50
|
-
"#{ sudo } apt-get update",
|
51
|
-
"#{ sudo } apt-get install curl #{ @config['cheftacular']['pre_install_packages'] } -y",
|
52
|
-
"#{ sudo } apt-get upgrade -y"
|
53
|
-
]
|
54
|
-
|
55
|
-
final_commands = []
|
56
|
-
|
57
|
-
if @config['cheftacular']['install_rvm_on_boot']
|
58
|
-
deploy_commands << "gpg --keyserver hkp://keys.gnupg.net --recv-keys #{ @config['cheftacular']['rvm_gpg_key'] }"
|
59
|
-
deploy_commands << "curl -L https://get.rvm.io | bash -s stable"
|
60
|
-
|
61
|
-
rvm_source = "source /home/deploy/.rvm/bin/rvm &&"
|
62
|
-
|
63
|
-
final_commands = [
|
64
|
-
"#{ rvm_source } echo '#{ new_deploy_pass }' | rvmsudo -S rvm requirements",
|
65
|
-
"#{ rvm_source } rvm install #{ @config['cheftacular']['ruby_version'] }",
|
66
|
-
"#{ rvm_source } rvm alias create default #{ @config['cheftacular']['ruby_version'] }",
|
67
|
-
"#{ rvm_source } rvm gemset empty --force"
|
68
|
-
]
|
69
|
-
|
70
|
-
final_commands << "#{ rvm_source } rvm install 1.9.3-p327" if @config['cheftacular']['chef_version'].to_i < 12
|
71
|
-
end
|
72
|
-
|
73
|
-
root_execute_string = "sshpass -p \"#{ @options['client_pass'] }\" ssh -t -oStrictHostKeyChecking=no root@#{ @options['address'] } '#{ root_commands.join(' && ') } && service ssh restart'"
|
74
|
-
|
75
|
-
while system(root_execute_string) != true
|
76
|
-
tries ||= 5
|
77
|
-
puts "Unable to complete step 1 of setup process, trying again in 60 seconds, there are #{ tries } more tries"
|
78
|
-
sleep 60
|
79
|
-
tries -= 1
|
80
|
-
raise "Unable to complete step 1 of setup process!" if tries <= 0
|
81
|
-
end
|
82
|
-
|
83
|
-
out << $?.to_s #output from the system command above
|
84
|
-
|
85
|
-
puts("Finished initial setup...stage 1 of 3 for server #{ @options['address'] }") if @options['in_scaling']
|
86
|
-
|
87
|
-
puts(out.last) unless @options['quiet'] || @options['in_scaling']
|
88
|
-
|
89
|
-
deploy_commands.each do |cmnd|
|
90
|
-
puts("(#{ @options['address'] }) Running #{ cmnd.gsub("#{ new_deploy_pass }", "sudo password") }") unless @options['quiet'] || @options['in_scaling']
|
91
|
-
|
92
|
-
out << `ssh -t -oStrictHostKeyChecking=no #{ deploy_user }@#{ @options['address'] } "#{ cmnd }"`
|
93
|
-
|
94
|
-
puts(out.last) unless @options['quiet'] || @options['in_scaling']
|
95
|
-
end
|
96
|
-
|
97
|
-
puts("Finished deploy setup....stage 2 of 3 for server #{ @options['address'] }") if @options['in_scaling']
|
98
|
-
|
99
|
-
final_commands.each do |cmnd|
|
100
|
-
puts "(#{ @options['address'] }) Running #{ cmnd.gsub("#{ new_deploy_pass }", "sudo password") }"
|
101
|
-
|
102
|
-
out << `ssh -t -oStrictHostKeyChecking=no #{ deploy_user }@#{ @options['address'] } "#{ cmnd }"`
|
103
|
-
|
104
|
-
puts(out.last) unless @options['quiet'] || @options['in_scaling']
|
105
|
-
end
|
106
|
-
|
107
|
-
puts("Finished ruby setup......stage 3 of 3 for server #{ @options['address'] }") if @options['in_scaling']
|
108
|
-
|
109
|
-
@config[@options['env']]['server_passwords_bag_hash']["#{ @options['address'] }-root-pass"] = @options['client_pass']
|
110
|
-
@config[@options['env']]['server_passwords_bag_hash']["#{ @options['address'] }-deploy-pass"] = new_deploy_pass
|
111
|
-
@config[@options['env']]['server_passwords_bag_hash']["#{ @options['address'] }-name"] = @options['node_name'] if @options['node_name']
|
112
|
-
|
113
|
-
@config['ChefDataBag'].save_server_passwords_bag unless @options['in_scaling']
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|