cem_acpt 0.8.1 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cem_acpt/provision/terraform.rb +13 -7
- data/lib/cem_acpt/test_runner.rb +20 -1
- data/lib/cem_acpt/utils/shell.rb +1 -25
- data/lib/cem_acpt/version.rb +1 -1
- data/lib/terraform/gcp/linux/goss/puppet_idempotent.yaml +1 -1
- data/lib/terraform/gcp/linux/goss/puppet_noop.yaml +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '049c0d34c878395e52956c95a55dd0b1e2fafa9f8ec2e708982b1574865e0c71'
|
4
|
+
data.tar.gz: 5a69317f0b2da6e09d60f41cde8b45df6bb475167ec84328917f3ec9dcf0fe9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 023d83eeceb14f629ef811781a51d28b4620c45ebd69fd8417f949d3952a1a2e89f94b42392efc93ee408399717dae0906bc820ee5d870b6052500a4f0a78879
|
7
|
+
data.tar.gz: a372082235f0aaf4a533262545f9cb1df04e4ed98f0428e90425d097b1d5e28f2ac8fc40a2b6bf9999707705e88918f6a3398c185eb58680777c95bea16357c6
|
data/Gemfile.lock
CHANGED
@@ -25,6 +25,7 @@ module CemAcpt
|
|
25
25
|
@module_package_path = nil
|
26
26
|
@private_key = nil
|
27
27
|
@public_key = nil
|
28
|
+
@applied = false
|
28
29
|
end
|
29
30
|
|
30
31
|
# @return [Hash] A hash of instance names and IPs
|
@@ -36,13 +37,18 @@ module CemAcpt
|
|
36
37
|
terraform_init
|
37
38
|
terraform_plan(formatted_vars, DEFAULT_PLAN_NAME)
|
38
39
|
terraform_apply(DEFAULT_PLAN_NAME)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
@applied = true
|
41
|
+
end
|
42
|
+
|
43
|
+
def output
|
44
|
+
raise 'Terraform has not been applied yet' unless @applied
|
45
|
+
|
46
|
+
output = terraform_output('instance_name_ip', json: true)
|
47
|
+
logger.debug('CemAcpt::Provision::Terraform') { "Terraform output:\n#{output}" }
|
48
|
+
JSON.parse(output)
|
49
|
+
rescue JSON::ParserError => e
|
50
|
+
logger.error('CemAcpt::Provision::Terraform') { "Error parsing Terraform output: #{output}" }
|
51
|
+
raise e
|
46
52
|
end
|
47
53
|
|
48
54
|
def destroy
|
data/lib/cem_acpt/test_runner.rb
CHANGED
@@ -59,7 +59,8 @@ module CemAcpt
|
|
59
59
|
@run_data[:nodes] = new_node_data
|
60
60
|
logger.info('CemAcpt::TestRunner') { 'Created node data...' }
|
61
61
|
logger.verbose('CemAcpt::TestRunner') { "Node data: #{@run_data[:nodes]}" }
|
62
|
-
|
62
|
+
provision_test_nodes
|
63
|
+
@instance_names_ips = provisioner_output
|
63
64
|
logger.info('CemAcpt::TestRunner') { "Instance names and IPs class: #{@instance_names_ips.class}" }
|
64
65
|
@provisioned = true
|
65
66
|
logger.info('CemAcpt::TestRunner') { 'Provisioned test nodes...' }
|
@@ -156,6 +157,24 @@ module CemAcpt
|
|
156
157
|
@provisioner.provision
|
157
158
|
end
|
158
159
|
|
160
|
+
def provisioner_output
|
161
|
+
logger.info('CemAcpt::TestRunner') { 'Getting provisioner output...' }
|
162
|
+
@attempts = 0
|
163
|
+
@max_attempts = 3
|
164
|
+
output = nil
|
165
|
+
while @attempts < @max_attempts
|
166
|
+
@attempts += 1
|
167
|
+
output = @provisioner.output
|
168
|
+
break unless (output.nil? || output.empty?) && @attempts < @max_attempts # Don't sleep if this is last attempt
|
169
|
+
|
170
|
+
logger.info('CemAcpt::TestRunner') { "Provisioner output is nil or empty, retrying (#{@attempts}/#{@max_attempts})" }
|
171
|
+
sleep 3
|
172
|
+
end
|
173
|
+
raise 'Provisioner output is nil or empty' if output.nil? || output.empty?
|
174
|
+
|
175
|
+
output
|
176
|
+
end
|
177
|
+
|
159
178
|
def destroy_test_nodes
|
160
179
|
logger.info('CemAcpt::TestRunner') { 'Destroying test nodes if necessary...' }
|
161
180
|
if !@provisioned
|
data/lib/cem_acpt/utils/shell.rb
CHANGED
@@ -30,19 +30,10 @@ module CemAcpt
|
|
30
30
|
stdin.close
|
31
31
|
outerr.sync = true
|
32
32
|
output_thread = Thread.new do
|
33
|
-
while (line = outerr.
|
33
|
+
while (line = outerr.gets("\n"))
|
34
34
|
output << line if output
|
35
35
|
io_outerr.write(line) unless line.chomp.empty?
|
36
36
|
end
|
37
|
-
rescue IO::WaitReadable
|
38
|
-
begin
|
39
|
-
IO.select([outerr])
|
40
|
-
retry
|
41
|
-
rescue IOError
|
42
|
-
# outerr closed, won't retry
|
43
|
-
end
|
44
|
-
rescue EOFError
|
45
|
-
# outerr closed, won't retry
|
46
37
|
end
|
47
38
|
wait_thr.join
|
48
39
|
output_thread.exit
|
@@ -70,21 +61,6 @@ module CemAcpt
|
|
70
61
|
end
|
71
62
|
nil
|
72
63
|
end
|
73
|
-
|
74
|
-
# IO monkey patch for non-blocking readline
|
75
|
-
class ::IO
|
76
|
-
def readline_nonblock
|
77
|
-
rlnb = []
|
78
|
-
rnlb << read_nonblock(1) while rlnb[-1] != "\n"
|
79
|
-
rlnb.join
|
80
|
-
rescue IO::WaitReadable => blocking
|
81
|
-
raise blocking if rlnb.empty?
|
82
|
-
|
83
|
-
rlnb.join
|
84
|
-
rescue EOFError
|
85
|
-
rlnb.join
|
86
|
-
end
|
87
|
-
end
|
88
64
|
end
|
89
65
|
end
|
90
66
|
end
|
data/lib/cem_acpt/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
command:
|
2
2
|
puppet_idempotent:
|
3
|
-
exec: '
|
3
|
+
exec: '/opt/puppetlabs/puppet/bin/puppet apply --logdest console,/opt/cem_acpt/idempotent_apply.log --debug --verbose --detailed-exitcodes /opt/cem_acpt/manifest.pp'
|
4
4
|
timeout: 300000 # 5 mins in miliseconds
|
5
5
|
stdout:
|
6
6
|
- "/Applied catalog in.*/"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
command:
|
2
2
|
puppet_noop:
|
3
|
-
exec: '
|
3
|
+
exec: '/opt/puppetlabs/puppet/bin/puppet apply --logdest console,/opt/cem_acpt/noop_apply.log --debug --verbose --detailed-exitcodes --noop /opt/cem_acpt/manifest.pp'
|
4
4
|
timeout: 300000 # 5 mins in miliseconds
|
5
5
|
stdout:
|
6
6
|
- "Applied catalog in"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cem_acpt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- puppetlabs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-http
|