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

Attributes with expression value do not work #204

Open alexjfisher opened 7 years ago

alexjfisher commented 7 years ago

Hi

When I try to update the default keycloak standalone-ha database, the code explodes when trying to compare the is and should values.

wildfly::datasources::datasource { 'KeycloakDS':
  config  => {
    'driver-name'    => 'oracle',
    'user-name'      => 'keycloak',
    'password'       => 'password,
    'jndi-name'      => 'java:jboss/datasources/KeycloakDS',
    'connection-url' => 'jdbc:oracle:thin:@//host:1521/sid',
  },
  notify   => Wildfly::Reload['Reload if necessary'],
  require  => Wildfly::Datasources::Driver['Oracle driver'],
}
Error: undefined method `keys' for "jdbc:oracle:thin:@//host:1521/sid":String
/opt/puppetlabs/puppet/cache/lib/puppet_x/wildfly/deep_hash.rb:8:in `block in _deep_intersect'
/opt/puppetlabs/puppet/cache/lib/puppet_x/wildfly/deep_hash.rb:7:in `each'
/opt/puppetlabs/puppet/cache/lib/puppet_x/wildfly/deep_hash.rb:7:in `_deep_intersect'
/opt/puppetlabs/puppet/cache/lib/puppet_x/wildfly/deep_hash.rb:10:in `block in _deep_intersect'
/opt/puppetlabs/puppet/cache/lib/puppet_x/wildfly/deep_hash.rb:7:in `each'
/opt/puppetlabs/puppet/cache/lib/puppet_x/wildfly/deep_hash.rb:7:in `_deep_intersect'
/opt/puppetlabs/puppet/cache/lib/puppet_x/wildfly/deep_hash.rb:38:in `insync?'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/property.rb:277:in `safe_insync?'
Error: /Stage[main]/Profile::Keycloak/Wildfly::Datasources::Datasource[KeycloakDS]/Wildfly::Resource[/subsystem=datasources/data-source=KeycloakDS]/Wildfly_resource[/subsystem=datasources/data-source=KeycloakDS]/state: change from {"allocation-retry"=>nil, "allocation-retry-wait-millis"=>nil, "allow-multiple-users"=>false, "background-validation"=>nil, "background-validation-millis"=>nil, "blocking-timeout-wait-millis"=>nil, "capacity-decrementer-class"=>nil, "capacity-decrementer-properties"=>nil, "capacity-incrementer-class"=>nil, "capacity-incrementer-properties"=>nil, "check-valid-connection-sql"=>nil, "connectable"=>false, "connection-listener-class"=>nil, "connection-listener-property"=>nil, "connection-url"=>{"EXPRESSION_VALUE"=>"jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE"}, "datasource-class"=>nil, "driver-class"=>nil, "driver-name"=>"h2", "enabled"=>true, "enlistment-trace"=>true, "exception-sorter-class-name"=>nil, "exception-sorter-properties"=>nil, "flush-strategy"=>nil, "idle-timeout-minutes"=>nil, "initial-pool-size"=>nil, "jndi-name"=>"java:jboss/datasources/KeycloakDS", "jta"=>true, "max-pool-size"=>nil, "mcp"=>"org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool", "min-pool-size"=>nil, "new-connection-sql"=>nil, "password"=>"sa", "pool-fair"=>nil, "pool-prefill"=>nil, "pool-use-strict-min"=>nil, "prepared-statements-cache-size"=>nil, "query-timeout"=>nil, "reauth-plugin-class-name"=>nil, "reauth-plugin-properties"=>nil, "security-domain"=>nil, "set-tx-query-timeout"=>false, "share-prepared-statements"=>false, "spy"=>false, "stale-connection-checker-class-name"=>nil, "stale-connection-checker-properties"=>nil, "statistics-enabled"=>false, "track-statements"=>"NOWARN", "tracking"=>false, "transaction-isolation"=>nil, "url-delimiter"=>nil, "url-selector-strategy-class-name"=>nil, "use-ccm"=>true, "use-fast-fail"=>false, "use-java-context"=>true, "use-try-lock"=>nil, "user-name"=>"sa", "valid-connection-checker-class-name"=>nil, "valid-connection-checker-properties"=>nil, "validate-on-match"=>nil, "connection-properties"=>nil, "statistics"=>{"pool"=>nil, "jdbc"=>nil}} to {"driver-name"=>"oracle", "user-name"=>"keycloak", "password"=>"password", "jndi-name"=>"java:jboss/datasources/KeycloakDS", "connection-url"=>"jdbc:oracle:thin:@//host:1521/sid"} failed: undefined method `keys' for "jdbc:oracle:thin:@//host:1521/sid":String

I think this happens because the original connection-url is jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE and the API returns this as a hash, not a simple string?

"connection-url"=> {
  "EXPRESSION_VALUE"=>"jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE"
}

This causes keys to be called on a string in _deep_intersect here

I'm new to this module, but I think this might be a recent regression introduced in https://github.com/biemond/biemond-wildfly/commit/dc0771ff475373ed4bb47abfa483b333939c91fb

jairojunior commented 7 years ago

Your assumptions are right. Just read interfaces through Management API and it returned:

"inet-address" : { "EXPRESSION_VALUE" : "${jboss.bind.address.management:127.0.0.1}" }

Merged your PR, it fixes this error, but it's not enough. Attributes with expression values will change every run.

I'll add this resource to the first standalone spec:

wildfly::resource { '/subsystem=webservices':
  content => {
    'wsdl-host' => "\${jboss.bind.address:${facts['hostname']}}",
  },
}

And will only close this issue when acceptance tests are passing :smile: