voxpupuli / puppet-wildfly

Puppet module to install, configure and manage Wildfly (8/9/10+), JBoss EAP (6.1+/7.0+) and some Wildfly based products like apiman, Keycloak and Infinispan.
Apache License 2.0
29 stars 78 forks source link

`wildfly::host::server_config` with `ensure => absent` in already absent server tries to stop it and fails with timeout #292

Closed EmersonPrado closed 9 months ago

EmersonPrado commented 12 months ago

This call from my internal Puppet code:

wildfly::host::server_config { ['server-one', 'server-two']:
  ensure => absent,
}

When 'server-one' and 'server-two' are already absent, fails with:

Profiles::Middleware::Jboss::Domain::Host
Wildfly::Host::Server_config[server-one]
Wildfly_cli[/host=gerenciado-rhel-7/server-config=server-one:stop(blocking=true)]:
Could not evaluate: execution expired

The call runs this code from wildfly::host::server_config:

wildfly_cli { "/host=${hostname}/server-config=${server_name}:stop(blocking=true)":
  onlyif => "(result != STOPPED) of /host=${hostname}/server-config=${server_name}:read-attribute(name=status)",
}

Which runs this one from type wildfly_cli, provider http_api:

onlyif_eval = cli.evaluate(@resource[:onlyif])

Which goes depths to run the onlyif command - read-attribute(name=status) - which fails because the resource isn't there to read status from.

My guess is that type wildfly_cli, provider http_api, method should_execute? should first check resource existence before running anything else in it. And have a parameter to tell it whether to fail or not in this situation. Then, wildfly::host::server_config should call it with this fail flag set to false. This would probably have to propagate down to PuppetX::Wildfly::APIClient, but I digress.