|
|
|
@ -410,12 +410,24 @@ func monitorTerraformApplyProgress(
|
|
|
|
|
} else { |
|
|
|
|
//fmt.Printf("NOT PARSE %s\n", lineWithoutAnsiEscapes)
|
|
|
|
|
|
|
|
|
|
// Check if there is a line which contains an exec error.
|
|
|
|
|
// If there is such a line, it won't contain the module that failed, just the command that failed.
|
|
|
|
|
// so we have to look back in the log to find the last time that command was mentioned, which should hit the
|
|
|
|
|
// line which has the module / resource name on it.
|
|
|
|
|
// So for example we could find a line:
|
|
|
|
|
//
|
|
|
|
|
// Error: Error running command './ansible-playbook-wrapper --private-key '/usr/lib/rootsystem/ssh/severgarden_builtin_ed22519' -i '167.71.175.207,' -u root -e 'domain=greenhouseusers.com arch=amd64' playbook.yml': exit status 4. Output:
|
|
|
|
|
//
|
|
|
|
|
// Then we look back in the log for any line which contains that command, and we find:
|
|
|
|
|
//
|
|
|
|
|
// module.ansible-threshold-server.null_resource.ansible_playbook[0] (local-exec): Executing: ["/bin/sh" "-c" "./ansible-playbook-wrapper --private-key '/usr/lib/rootsystem/ssh/severgarden_builtin_ed22519' -i '167.71.175.207,' -u root -e 'domain=greenhouseusers.com arch=amd64' playbook.yml"]
|
|
|
|
|
//
|
|
|
|
|
matches := terraformExecErrorRegex.FindStringSubmatch(lineWithoutAnsiEscapes) |
|
|
|
|
if matches != nil { |
|
|
|
|
commandThatFailed := matches[1] |
|
|
|
|
previousLineContainingCommandThatFailed := "" |
|
|
|
|
for i, previousLine := range logLinesWithoutAnsiEscapes { |
|
|
|
|
if i < len(logLinesWithoutAnsiEscapes.length-2) && strings.Contains(previousLine, commandThatFailed) { |
|
|
|
|
if i < len(logLinesWithoutAnsiEscapes)-2 && strings.Contains(previousLine, commandThatFailed) { |
|
|
|
|
previousLineContainingCommandThatFailed = previousLine |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|