puppet-wildfly icon indicating copy to clipboard operation
puppet-wildfly copied to clipboard

CLI command always runs even when test is false

Open aledesmablvd opened this issue 7 years ago • 2 comments

Hi,

Looking at the issues list I've encountered the issue where the KeycloakDS datasource can't be changed because of the expression on the jdbc URL.

Trying to bypass this issue, I've tried removing the old H2 datasource and create it again but only if the driver is set to h2 using:

wildfly::cli { 'Remove old KeycloakDS':
  command => '/profile=auth-server-clustered/subsystem=datasources/data-source=KeycloakDS:remove',
  unless  => '(driver-name == h2) of /profile=auth-server-clustered/subsystem=datasources/data-source=KeycloakDS:read-attribute(name=driver-name)',
}

But every time I do a puppet run the cli command runs even tho the driver-name is no longer h2.

before: /profile=auth-server-clustered/subsystem=datasources/data-source=KeycloakDS:read-attribute(name=driver-name) { "outcome" => "success", "result" => "h2" }

after: /profile=auth-server-clustered/subsystem=datasources/data-source=KeycloakDS:read-attribute(name=driver-name) { "outcome" => "success", "result" => "mysql" }

Is that a supported way to do "unless" ?

Is there another way to run a CLI command where it tests for a specific value of the resource?

aledesmablvd avatar Jul 03 '17 00:07 aledesmablvd

You should be able to do it with:

wildfly::cli { 'Remove old KeycloakDS':
  command => '/profile=auth-server-clustered/subsystem=datasources/data-source=KeycloakDS:remove',
  unless  => '(result == h2) of /profile=auth-server-clustered/subsystem=datasources/data-source=KeycloakDS:read-attribute(name=driver-name)',
}

jairojunior avatar Jul 03 '17 22:07 jairojunior

In fact, if I understood correct. You'd need onlyif instead of unless.

jairojunior avatar Jul 04 '17 10:07 jairojunior