[ 
https://issues.apache.org/jira/browse/UNOMI-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16713228#comment-16713228
 ] 

Serge Huber commented on UNOMI-216:
-----------------------------------

Thanks Michael for the suggestion but the question is how to link the 
properties in the centralized configuration file to the config admin or XML 
files. 

For the moment this is what I'm trying to do:

In a config admin file I put stuff like this : 
{code:java}
encryption.enabled = ${org.apache.unomi.security.encryption.enabled:-false}
{code}
then in the unomi.properties file I put something like this : 
{code:java}
org.apache.unomi.security.encryption.enabled=${env:UNOMI_ENCRYPTION_ENABLED:-false}
{code}
Which means that you can then set the UNOMI_ENCRYPTION_ENABLED environment to 
enable/disable the encryption. It also has default values everywhere in case 
the values is not set.

For hazelcast.xml I changed it like this :
{code:java}
<tcp-ip enabled="true">
    <members>${org.apache.unomi.hazelcast.tcp-ip.members}</members>
    <interface>${org.apache.unomi.hazelcast.tcp-ip.interface}</interface>
</tcp-ip>{code}
And then in the custom.system.properties I setup the values like this : 
{code:java}
org.apache.unomi.hazelcast.tcp-ip.members=${env:UNOMI_HAZELCAST_TCPIP_MEMBERS:-127.0.0.1}
org.apache.unomi.hazelcast.tcp-ip.interface=${env:UNOMI_HAZELCAST_TCPIP_INTERFACE:-127.0.0.1}{code}

The biggest issue with this type of solution is that it requires to put the 
placeholders in a lot of properties just in case someone needs to override them 
using environment variables. 

What would be fantastic would be some kind of universal override that could 
work in any configuration files. Right now Docker recommends to do that with 
"sed" commands but something more specific to Java properties file (maybe a 
bootstrap mechanism for Karaf ?) would be fantastic.

What do you think ?

> Configure Unomi by editing one configuration file & read env variables for 
> Docker compatibility
> -----------------------------------------------------------------------------------------------
>
>                 Key: UNOMI-216
>                 URL: https://issues.apache.org/jira/browse/UNOMI-216
>             Project: Apache Unomi
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.0.0-incubating, 1.1.0-incubating, 1.2.0-incubating, 
> 1.3.0-incubating, 1.4.0-incubating
>            Reporter: Serge Huber
>            Assignee: Serge Huber
>            Priority: Major
>             Fix For: 1.4.0-incubating
>
>
> The idea here is to make it easy to "override" common configuration 
> properties in Apache Unomi by modifying a single configuration file. Of 
> course this type of deployment is focused on "static" deployments, not 
> deployment where the configuration admin is used to dynamically update 
> configuration. Also this will address the need of Docker containers that pass 
> configuration through environment variables.
> As a consequence, default Unomi properties should be "placeholdered", with 
> default values
> Here is the section in the Karaf documentation about configuration, including 
> environment variables references : 
> [http://karaf.apache.org/manual/latest/#_configuration_3]
> "Properties can be referenced inside configuration files using the syntax 
> {{$\{<name>}}}. Default and alternate values can be specified using 
> {{$\{<name>:-<default_value>}}} and {{$\{<name>:+<alternate_value>}}} 
> syntaxes respectively."
> "Environment variables can be referenced inside configuration files using the 
> syntax {{$\{env:<name>}}} (e.g.{{property=$\{env:FOO}}} will set "property" 
> to the value of the enviroment variable "FOO"). Default and alternate values 
> can be defined for them as well using the same syntax as above." 
> Some difficulty might come from configuration files such as the Hazelcast XML 
> configuration file that can only reference system properties, so we might 
> have to setup the placeholders in the custom.system.properties file.
> This story includes modifications to the documentation to use this 
> centralized file, both on the Unomi website.
> Migration will be handle through documentation as well, indicating where the 
> properties must be moved.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to