opsicle 2.5.0 → 2.6.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62234a4db3f58fa24aff77217786dd4be48d0763
|
4
|
+
data.tar.gz: ac69c2625a780fdd78ceaaf38e3299fe2c1807c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c38462e8b4c1cc7205bc71a73936e6e9df19845cfed644ea18078339d872a7e132ee9be688e03ea587642b83ba0d2a4a8b23da5caa09a26a4dfa67752548fd26
|
7
|
+
data.tar.gz: 702c9a75c1e83385437d41a5603c62f7b0d57564228444f4e1a8e1e056793eb05bc4df66d10f10a4e8573c2f445526733484f777964717b80be567ef1ee25aba
|
@@ -34,9 +34,10 @@ module Opsicle
|
|
34
34
|
new_instance_hostname = make_new_hostname(self.hostname)
|
35
35
|
ami_id = verify_ami_id
|
36
36
|
agent_version = verify_agent_version
|
37
|
+
subnet_id = verify_subnet_id
|
37
38
|
instance_type = verify_instance_type
|
38
39
|
|
39
|
-
create_new_instance(new_instance_hostname, instance_type, ami_id, agent_version)
|
40
|
+
create_new_instance(new_instance_hostname, instance_type, ami_id, agent_version, subnet_id)
|
40
41
|
end
|
41
42
|
|
42
43
|
def make_new_hostname(old_hostname)
|
@@ -49,8 +50,7 @@ module Opsicle
|
|
49
50
|
end
|
50
51
|
|
51
52
|
puts "\nAutomatically generated hostname: #{new_instance_hostname}\n"
|
52
|
-
|
53
|
-
new_instance_hostname = @cli.ask("Please write in the new instance's hostname and press ENTER:") if rewriting == 1
|
53
|
+
new_instance_hostname = ask_for_new_option("instance's hostname") if ask_for_overriding_permission("hostname", false)
|
54
54
|
|
55
55
|
new_instance_hostname
|
56
56
|
end
|
@@ -71,8 +71,19 @@ module Opsicle
|
|
71
71
|
ami_id = self.layer.ami_id
|
72
72
|
else
|
73
73
|
puts "\nCurrent AMI id is #{self.ami_id}"
|
74
|
-
|
75
|
-
|
74
|
+
|
75
|
+
if ask_for_overriding_permission("AMI ID", true)
|
76
|
+
instances = @opsworks.describe_instances(stack_id: self.stack_id).instances
|
77
|
+
ami_ids = instances.collect { |i| i.ami_id }.uniq
|
78
|
+
ami_ids << "Provide a different AMI ID."
|
79
|
+
ami_id = ask_for_possible_options(ami_ids, "AMI ID")
|
80
|
+
|
81
|
+
if ami_id == "Provide a different AMI ID."
|
82
|
+
ami_id = ask_for_new_option('AMI ID')
|
83
|
+
end
|
84
|
+
else
|
85
|
+
ami_id = self.ami_id
|
86
|
+
end
|
76
87
|
end
|
77
88
|
|
78
89
|
self.layer.ami_id = ami_id
|
@@ -84,35 +95,71 @@ module Opsicle
|
|
84
95
|
agent_version = self.layer.agent_version
|
85
96
|
else
|
86
97
|
puts "\nCurrent agent version is #{self.agent_version}"
|
87
|
-
|
88
|
-
|
98
|
+
|
99
|
+
if ask_for_overriding_permission("agent version", true)
|
100
|
+
agents = @opsworks.describe_agent_versions(stack_id: self.stack_id).agent_versions
|
101
|
+
version_ids = agents.collect { |i| i.version }.uniq
|
102
|
+
agent_version = ask_for_possible_options(version_ids, "agent version")
|
103
|
+
else
|
104
|
+
agent_version = self.agent_version
|
105
|
+
end
|
89
106
|
end
|
90
107
|
|
91
108
|
self.layer.agent_version = agent_version
|
92
109
|
agent_version
|
93
110
|
end
|
94
111
|
|
95
|
-
def
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
112
|
+
def verify_subnet_id
|
113
|
+
if self.layer.subnet_id
|
114
|
+
subnet_id = self.layer.subnet_id
|
115
|
+
else
|
116
|
+
puts "\nCurrent subnet id is #{self.subnet_id}"
|
117
|
+
|
118
|
+
if ask_for_overriding_permission("subnet ID", true)
|
119
|
+
instances = @opsworks.describe_instances(stack_id: self.stack_id).instances
|
120
|
+
subnet_ids = instances.collect { |i| i.subnet_id }.uniq
|
121
|
+
subnet_ids << "Provide a different subnet ID."
|
122
|
+
subnet_id = ask_for_possible_options(subnet_ids, "subnet ID")
|
123
|
+
|
124
|
+
if subnet_id == "Provide a different subnet ID."
|
125
|
+
subnet_id = ask_for_new_option('subnet ID')
|
126
|
+
end
|
127
|
+
else
|
128
|
+
subnet_id = self.subnet_id
|
129
|
+
end
|
101
130
|
end
|
102
131
|
|
103
|
-
|
104
|
-
|
105
|
-
version_ids[id_index]
|
132
|
+
self.layer.subnet_id = subnet_id
|
133
|
+
subnet_id
|
106
134
|
end
|
107
135
|
|
108
136
|
def verify_instance_type
|
109
137
|
puts "\nCurrent instance type is #{self.instance_type}"
|
110
|
-
rewriting =
|
111
|
-
instance_type = rewriting
|
138
|
+
rewriting = ask_for_overriding_permission("instance type", false)
|
139
|
+
instance_type = rewriting ? ask_for_new_option('instance type') : self.instance_type
|
112
140
|
instance_type
|
113
141
|
end
|
114
142
|
|
115
|
-
def
|
143
|
+
def ask_for_possible_options(arr, description)
|
144
|
+
arr.each_with_index { |id, index| puts "#{index.to_i + 1}) #{id}"}
|
145
|
+
id_index = @cli.ask("Which #{description}?\n", Integer) { |q| q.in = 1..arr.length.to_i } - 1
|
146
|
+
arr[id_index]
|
147
|
+
end
|
148
|
+
|
149
|
+
def ask_for_new_option(description)
|
150
|
+
@cli.ask("Please write in the new #{description} and press ENTER:")
|
151
|
+
end
|
152
|
+
|
153
|
+
def ask_for_overriding_permission(description, overriding_all)
|
154
|
+
if overriding_all
|
155
|
+
ans = @cli.ask("Do you wish to override this #{description}? By overriding, you are choosing to override the current #{description} for all instances you are cloning.\n1) Yes\n2) No", Integer)
|
156
|
+
else
|
157
|
+
ans = @cli.ask("Do you wish to override this #{description}?\n1) Yes\n2) No", Integer)
|
158
|
+
end
|
159
|
+
ans == 1
|
160
|
+
end
|
161
|
+
|
162
|
+
def create_new_instance(new_instance_hostname, instance_type, ami_id, agent_version, subnet_id)
|
116
163
|
new_instance = @opsworks.create_instance({
|
117
164
|
stack_id: self.stack_id, # required
|
118
165
|
layer_ids: self.layer_ids, # required
|
@@ -124,7 +171,7 @@ module Opsicle
|
|
124
171
|
ssh_key_name: self.ssh_key_name,
|
125
172
|
availability_zone: self.availability_zone,
|
126
173
|
virtualization_type: self.virtualization_type,
|
127
|
-
subnet_id:
|
174
|
+
subnet_id: subnet_id,
|
128
175
|
architecture: self.architecture, # accepts x86_64, i386
|
129
176
|
root_device_type: self.root_device_type, # accepts ebs, instance-store
|
130
177
|
install_updates_on_boot: self.install_updates_on_boot,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Opsicle
|
2
2
|
class CloneableLayer
|
3
|
-
attr_accessor :name, :layer_id, :instances, :opsworks, :cli, :agent_version, :ami_id
|
3
|
+
attr_accessor :name, :layer_id, :instances, :opsworks, :cli, :agent_version, :ami_id, :subnet_id
|
4
4
|
|
5
5
|
def initialize(name, layer_id, opsworks, cli)
|
6
6
|
self.name = name
|
data/lib/opsicle/version.rb
CHANGED
@@ -21,8 +21,17 @@ module Opsicle
|
|
21
21
|
allow(@layer).to receive(:agent_version=)
|
22
22
|
allow(@layer).to receive(:agent_version)
|
23
23
|
allow(@layer).to receive(:add_new_instance)
|
24
|
+
allow(@layer).to receive(:subnet_id=)
|
25
|
+
allow(@layer).to receive(:subnet_id)
|
24
26
|
@new_instance = double('new_instance', :instance_id => 1029384756)
|
25
27
|
@opsworks = double('opsworks', :create_instance => @new_instance)
|
28
|
+
@agent_version_1 = double('agent_version', :version => '3434-20160316181345')
|
29
|
+
@agent_version_2 = double('agent_version', :version => '3435-20160406115841')
|
30
|
+
@agent_version_3 = double('agent_version', :version => '3436-20160418214624')
|
31
|
+
@agent_versions = double('agent_versions', :agent_versions => [@agent_version_1, @agent_version_2, @agent_version_3])
|
32
|
+
allow(@opsworks).to receive(:describe_agent_versions).with({:stack_id=>1234567890}).and_return(@agent_versions)
|
33
|
+
@instances = double('instances', :instances => [@instance])
|
34
|
+
allow(@opsworks).to receive(:describe_instances).with({:stack_id=>1234567890}).and_return(@instances)
|
26
35
|
@cli = double('cli', :ask => 2)
|
27
36
|
end
|
28
37
|
|
@@ -51,6 +60,7 @@ module Opsicle
|
|
51
60
|
it "should increment the hostname" do
|
52
61
|
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
53
62
|
expect(instance).to receive(:hostname_unique?).and_return('example-hostname-03')
|
63
|
+
allow(@opsworks).to receive(:describe_agent_version).with({})
|
54
64
|
instance.increment_hostname('example-hostname-01', ['example-hostname-01', 'example-hostname-02'])
|
55
65
|
end
|
56
66
|
end
|
@@ -67,6 +77,7 @@ module Opsicle
|
|
67
77
|
expect(instance).to receive(:verify_ami_id)
|
68
78
|
expect(instance).to receive(:verify_agent_version)
|
69
79
|
expect(instance).to receive(:verify_instance_type)
|
80
|
+
expect(instance).to receive(:verify_subnet_id)
|
70
81
|
instance.clone({})
|
71
82
|
end
|
72
83
|
|
@@ -83,7 +94,7 @@ module Opsicle
|
|
83
94
|
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
84
95
|
allow(@layer).to receive(:agent_version).and_return(nil)
|
85
96
|
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this version? By overriding, you are choosing to override the current agent version for all instances you are cloning.\n1) Yes\n2) No", Integer).and_return(1)
|
86
|
-
expect(instance).to receive(:
|
97
|
+
expect(instance).to receive(:ask_for_possible_options)
|
87
98
|
instance.verify_agent_version
|
88
99
|
end
|
89
100
|
|
@@ -94,13 +105,31 @@ module Opsicle
|
|
94
105
|
end
|
95
106
|
end
|
96
107
|
|
108
|
+
context '#verify_subnet_id' do
|
109
|
+
it "should check the subnet id and ask if the user wants a new subnet id" do
|
110
|
+
@cli = double('cli', :ask => 1)
|
111
|
+
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
112
|
+
allow(@layer).to receive(:subnet_id).and_return(nil)
|
113
|
+
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this id? By overriding, you are choosing to override the current agent version for all instances you are cloning.\n1) Yes\n2) No", Integer).and_return(1)
|
114
|
+
expect(instance).to receive(:ask_for_possible_options)
|
115
|
+
instance.verify_subnet_id
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should see if the layer already has overwritten the subnet id" do
|
119
|
+
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
120
|
+
expect(@layer).to receive(:subnet_id)
|
121
|
+
instance.verify_subnet_id
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
97
125
|
context '#verify_ami_id' do
|
98
126
|
it "should check the ami id and ask if the user wants a new ami" do
|
99
127
|
@cli = double('cli', :ask => 1)
|
100
128
|
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
101
129
|
allow(@layer).to receive(:ami_id).and_return(nil)
|
102
130
|
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this AMI? By overriding, you are choosing to override the current AMI for all instances you are cloning.\n1) Yes\n2) No", Integer).and_return(1)
|
103
|
-
expect(@cli).to receive(:ask)
|
131
|
+
expect(@cli).to receive(:ask)
|
132
|
+
expect(instance).to receive(:ask_for_possible_options)
|
104
133
|
instance.verify_ami_id
|
105
134
|
end
|
106
135
|
|
@@ -126,7 +155,7 @@ module Opsicle
|
|
126
155
|
it "should create an instance" do
|
127
156
|
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
128
157
|
expect(@opsworks).to receive(:create_instance)
|
129
|
-
instance.create_new_instance('hostname', 'type', 'ami', 'agent_version')
|
158
|
+
instance.create_new_instance('hostname', 'type', 'ami', 'agent_version', 'subnet_id')
|
130
159
|
end
|
131
160
|
|
132
161
|
it "should take information from old instance" do
|
@@ -138,8 +167,7 @@ module Opsicle
|
|
138
167
|
expect(instance).to receive(:ssh_key_name)
|
139
168
|
expect(instance).to receive(:availability_zone)
|
140
169
|
expect(instance).to receive(:virtualization_type)
|
141
|
-
|
142
|
-
instance.create_new_instance('hostname', 'type', 'ami', 'agent_version')
|
170
|
+
instance.create_new_instance('hostname', 'type', 'ami', 'agent_version', 'subnet_id')
|
143
171
|
end
|
144
172
|
end
|
145
173
|
end
|
@@ -37,16 +37,23 @@ module Opsicle
|
|
37
37
|
@client = double('client', :config => @config, :opsworks => @opsworks)
|
38
38
|
allow(Client).to receive(:new).with(:environment).and_return(@client)
|
39
39
|
allow(@instances).to receive(:each_with_index)
|
40
|
+
@agent_version_1 = double('agent_version', :version => '3434-20160316181345')
|
41
|
+
@agent_version_2 = double('agent_version', :version => '3435-20160406115841')
|
42
|
+
@agent_version_3 = double('agent_version', :version => '3436-20160418214624')
|
43
|
+
@agent_versions = double('agent_versions', :agent_versions => [@agent_version_1, @agent_version_2, @agent_version_3])
|
44
|
+
allow(@opsworks).to receive(:describe_agent_versions).and_return(@agent_versions)
|
40
45
|
allow_any_instance_of(HighLine).to receive(:ask).with("Layer?\n", Integer).and_return(2)
|
41
46
|
allow_any_instance_of(HighLine).to receive(:ask).with("Instances? (enter as a comma separated list)\n", String).and_return('2')
|
42
|
-
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to
|
47
|
+
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this hostname?\n1) Yes\n2) No", Integer).and_return(2)
|
43
48
|
allow_any_instance_of(HighLine).to receive(:ask).with("Please write in the new instance's hostname and press ENTER:").and_return('example-hostname')
|
44
|
-
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this AMI? By overriding, you are choosing to override the current AMI for all instances you are cloning.\n1) Yes\n2) No", Integer).and_return(2)
|
45
|
-
allow_any_instance_of(HighLine).to receive(:ask).with("
|
46
|
-
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this version? By overriding, you are choosing to override the current agent version for all instances you are cloning.\n1) Yes\n2) No", Integer).and_return(2)
|
47
|
-
allow_any_instance_of(HighLine).to receive(:ask).with("Which agent version
|
49
|
+
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this AMI ID? By overriding, you are choosing to override the current AMI ID for all instances you are cloning.\n1) Yes\n2) No", Integer).and_return(2)
|
50
|
+
allow_any_instance_of(HighLine).to receive(:ask).with("Which AMI ID?\n", Integer).and_return(1)
|
51
|
+
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this agent version? By overriding, you are choosing to override the current agent version for all instances you are cloning.\n1) Yes\n2) No", Integer).and_return(2)
|
52
|
+
allow_any_instance_of(HighLine).to receive(:ask).with("Which agent version?\n", Integer).and_return(1)
|
48
53
|
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this instance type?\n1) Yes\n2) No", Integer).and_return(2)
|
49
54
|
allow_any_instance_of(HighLine).to receive(:ask).with("Please write in the new instance type press ENTER:").and_return('t2.micro')
|
55
|
+
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this subnet ID? By overriding, you are choosing to override the current subnet ID for all instances you are cloning.\n1) Yes\n2) No", Integer).and_return(2)
|
56
|
+
allow_any_instance_of(HighLine).to receive(:ask).with("Which subnet ID?\n", Integer).and_return(1)
|
50
57
|
end
|
51
58
|
|
52
59
|
context "#execute" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opsicle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Fleener
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|