M #-: add Terraform debug log messages (#1013)

This commit is contained in:
Alejandro Huertas Herrero authored and GitHub committed 2021-03-23 12:58:43 +01:00
1 parent bf61c17457
commit 9c411e2c85
4 files changed
+28 -2

No files matched your search

+11
View File
@@ -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
+2
View File
@@ -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
+6 -2
View File
@@ -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"
)