From 2ef19d87d01f7b090db294b45b4456401f72b7b7 Mon Sep 17 00:00:00 2001 From: Julien Erard Date: Fri, 19 Feb 2021 08:50:51 -0800 Subject: [PATCH] Update un-install to only run when app is installed --- recipes/newrelic/apm/dotNet/windows/net-install.yml | 2 +- recipes/newrelic/infrastructure/ohi/sql/ms-sql.yml | 4 ++-- recipes/newrelic/infrastructure/windows.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/newrelic/apm/dotNet/windows/net-install.yml b/recipes/newrelic/apm/dotNet/windows/net-install.yml index 3df2fe4b3..9c3f81a50 100644 --- a/recipes/newrelic/apm/dotNet/windows/net-install.yml +++ b/recipes/newrelic/apm/dotNet/windows/net-install.yml @@ -61,7 +61,7 @@ install: remove_any_previous: ignore_error: true cmds: - - powershell -command '$app = Get-WmiObject -Class Win32_Product -Filter "Name like 'New Relic .NET Agent%'"; $app.Uninstall()' + - powershell -command '$app = Get-WmiObject -Class Win32_Product -Filter "Name like 'New Relic .NET Agent%'"; if ($app) { $app.Uninstall() }' install: cmds: diff --git a/recipes/newrelic/infrastructure/ohi/sql/ms-sql.yml b/recipes/newrelic/infrastructure/ohi/sql/ms-sql.yml index 15ac08f1b..fc4039cac 100644 --- a/recipes/newrelic/infrastructure/ohi/sql/ms-sql.yml +++ b/recipes/newrelic/infrastructure/ohi/sql/ms-sql.yml @@ -54,13 +54,13 @@ install: assert_pre_req: cmds: - - powershell -command '$output = Get-Service "newrelic-infra"; if ( -not ($output -like "*newrelic-infra*") ) { Write-Error "The newrelic-infra agent service is not installed on the host, but is required to install this integration." }' + - powershell -command '$output = Get-Service "newrelic-infra"; if ( -not ($output -like "*newrelic-infra*") ) { Write-Error "The newrelic-infra agent service is not installed on the host, but is required to install this integration. Please install the newrelic infrastructure agent." }' - powershell -command '$output = sqlcmd -S {{.NR_CLI_DB_HOSTNAME}},{{.NR_CLI_DB_PORT}} -U {{.NR_CLI_DB_USERNAME}} -P "{{.NR_CLI_DB_PASSWORD}}" -Q "SELECT GETDATE()"; if ( -not ($output -like "*rows affected*") ) { Write-Error "Cannot connect to the SQL Server instance {{.NR_CLI_DB_HOSTNAME}} with the provided username {{.NR_CLI_DB_USERNAME}} and password." }' remove_any_previous: ignore_error: true cmds: - - powershell -command '$app = Get-WmiObject -Class Win32_Product -Filter "Name = 'New Relic Infrastructure Integration, nri-mssql'"; $app.Uninstall()' + - powershell -command '$app = Get-WmiObject -Class Win32_Product -Filter "Name = 'New Relic Infrastructure Integration, nri-mssql'"; if ($app) { $app.Uninstall() }' install: label: "Installing Microsoft SQL Server integration..." diff --git a/recipes/newrelic/infrastructure/windows.yml b/recipes/newrelic/infrastructure/windows.yml index c1efe3be4..f71bbd021 100644 --- a/recipes/newrelic/infrastructure/windows.yml +++ b/recipes/newrelic/infrastructure/windows.yml @@ -34,7 +34,7 @@ install: ignore_error: true cmds: - powershell -command 'net stop newrelic-infra' - - powershell -command '$app = Get-WmiObject -Class Win32_Product -Filter "Name = 'New Relic Infrastructure Agent'"; $app.Uninstall()' + - powershell -command '$app = Get-WmiObject -Class Win32_Product -Filter "Name = 'New Relic Infrastructure Agent'"; if ($app) { $app.Uninstall() }' install: cmds: