From 543354bb66ff542dd8b02fb0d27eb15d815c2066 Mon Sep 17 00:00:00 2001 From: Thierry Martinez <Thierry.Martinez@inria.fr> Date: Wed, 8 Feb 2023 01:48:35 +0100 Subject: [PATCH] Ignore failures on destruction --- README.md | 6 ++++-- main.tf | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d3122c1..86679d7 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ resource "cloudstack_instance" "runner" { } provisioner "remote-exec" { when = destroy - inline = ["sudo gitlab-runner unregister --all-runners"] + inline = ["sudo gitlab-runner unregister --all-runners || true"] } } ``` @@ -133,7 +133,9 @@ We cannot use a variable for passing the path to this file, since the connection is used by a destroy provisioner, that cannot refer to variables. This destroy provisioner executes `gitlab-runner unregister` -before the destruction of the virtual machine. +before the destruction of the virtual machine; failures are ignored +in case of the `gitlab-runner` command was not yet installed +when destroying occurs. ## The pipeline specification file [`.gitlab-ci.yml`](.gitlab-ci.yml) diff --git a/main.tf b/main.tf index 7c14476..96d7f64 100644 --- a/main.tf +++ b/main.tf @@ -55,6 +55,6 @@ resource "cloudstack_instance" "runner" { } provisioner "remote-exec" { when = destroy - inline = ["sudo gitlab-runner unregister --all-runners"] + inline = ["sudo gitlab-runner unregister --all-runners || true"] } } -- GitLab