mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-04 17:47:00 +03:00
M #-: add Terraform debug log messages (#1013)
This commit is contained in:
parent
bf61c17457
commit
9c411e2c85
@ -211,6 +211,17 @@ module CLIHelper
|
||||
end
|
||||
end
|
||||
|
||||
# Get text in green colour
|
||||
#
|
||||
# @param text [String] String to print
|
||||
def self.green(text)
|
||||
if $stdout.tty?
|
||||
ANSI_GREEN + text + ANSI_RESET
|
||||
else
|
||||
state
|
||||
end
|
||||
end
|
||||
|
||||
# Print header
|
||||
#
|
||||
# @param str [String] String with header content
|
||||
|
@ -129,9 +129,11 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
STDERR.puts rc.message
|
||||
exit(-1)
|
||||
elsif rc.to_i < 0
|
||||
puts CLIHelper.green('Provision successfully created')
|
||||
puts "ID: #{rc}"
|
||||
rc
|
||||
else
|
||||
puts CLIHelper.green('Provision successfully created')
|
||||
puts "ID: #{rc}"
|
||||
0
|
||||
end
|
||||
|
@ -98,6 +98,15 @@ module OneProvision
|
||||
instance.logger.warn(msg)
|
||||
end
|
||||
|
||||
# Gets Terraform log level
|
||||
def self.tf_log
|
||||
if instance.logger.level == 0
|
||||
'DEBUG'
|
||||
else
|
||||
'INFO'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Singleton running mode
|
||||
|
@ -147,7 +147,9 @@ module OneProvision
|
||||
# Apply
|
||||
Driver.retry_loop("Driver action 'tf deploy' failed", provision) do
|
||||
_, e, s = Driver.run(
|
||||
"cd #{tempdir}; terraform apply -auto-approve"
|
||||
"cd #{tempdir}; " \
|
||||
"export TF_LOG=#{OneProvisionLogger.tf_log}; " \
|
||||
'terraform apply -auto-approve'
|
||||
)
|
||||
|
||||
unless s && s.success?
|
||||
@ -224,7 +226,9 @@ module OneProvision
|
||||
# Destroy
|
||||
Driver.retry_loop("Driver action 'tf destroy' failed", provision) do
|
||||
_, e, s = Driver.run(
|
||||
"cd #{tempdir}; terraform refresh; " \
|
||||
"cd #{tempdir}; " \
|
||||
"export TF_LOG=#{OneProvisionLogger.tf_log}; " \
|
||||
'terraform refresh; ' \
|
||||
"terraform destroy #{target} -auto-approve"
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user