EJBCA on Docker: use environmental variables in .properties files - ant

I am trying to configure EJBCA 6.15.2.1 on Wildfly 12.0.0.Final inside a Docker container with the help of EJBCA .properties files. In $EJBCA_HOME/conf/externalra-gui.properties.sample there is a comment showing that one of the default settings is: appserver.home=${env.APPSRV_HOME}. I tried to set other options in a similar way, e. g. in database.properties: database.datasource=${env.WF_DATASRC}.
I run ant clean deployear and it didn't deploy my EJBCA instance properly at first - server.log showed that there is no datasource under the name "${env.WF_DATASRC}". It proceeded correctly after I'd changed the line to: database.datasource=ejbcads, which is the exact value of the variable and the name of the data source inside the WildFly server.
I get similar errors during further installation steps. Is there another way of setting EJBCA configuration using environment variables?

Related

Why isn't telegraf reading environmental variables?

My goal is to put my telegraf config into source control. To do so, I have a repo in my user's home directory with the appropriate config file which has already been tested and proven working.
I have added the path to the new config file in the "default" environment variables file:
/etc/default/telegraf
like this:
TELEGRAF_CONFIG_PATH="/home/ubuntu/some_repo/telegraf.conf"
... as well as other required variables such as passwords.
However, when I attempt to run
telegraf --test
It says No config file specified, and could not find one in $TELEGRAF_CONFIG_PATH etc.
Further, if I force it by
telegraf --test --config /home/ubuntu/some_repo/telegraf.conf
Then the process fails because it is missing the other required variables.
Questions:
What am I doing wrong?
Is there not also a way of specifying a config directory too (I would like to break my file down into separate input files)?
Perhaps as an alternative to all of this... is there not a way of specifying additional configuration files to be included from within the default /etc/telegraf/telegraf.conf file? (I've been unable to find any mention of this in documentation).
What am I doing wrong?
See what user:group owns /etc/default/telegraf. This file is better used when running telegraf as a service via systemd. Additionally, if you run env do you see the TELEGRAF_CONFIG_PATH variable? What about your other variables? If not, then you probably need to source the file first.
Is there not also a way of specifying a config directory too (I would like to break my file down into separate input files)?
Yes! Take a look at all the options of telegraf with telegraf --help and you will find:
--config-directory <directory> directory containing additional *.conf files
Perhaps as an alternative to all of this... is there not a way of specifying additional configuration files to be included from within the default /etc/telegraf/telegraf.conf file? (I've been unable to find any mention of this in documentation).
That is not the method I would suggest going down. Check out the config directory option above I mentioned.
Ok, after a LOT of trial and error, I figured everything out. For those facing similar issues, here is your shortcut to the answer:
Firstly, remember that when adding variables to the /etc/default/telegraf file, it must effectively be reloaded. So for example using ubuntu systemctl, that requires a restart.
You can verify that the variables have been loaded successfully using this:
$ sudo strings /proc/<pid>/environ
where <pid> is the "Main PID" from the telegraf status output
Secondly, when testing (eg telegraf --test) then (this is the part that is not necessarily intuitive and isn't documented) you will have to ALSO load the same environmental variables into the current user (eg: SET var=value) such that running
$ env
shows the same results as the previous command.
Hint: This is a good method for loading the current env file directly rather than doing it manually.

How to setup divolte.io for multiple websites on the same server?

I've setup a data pipeline using divolte.io to stream click data from website to a server. I'm not sure how can I do this for multiple websites because all the streams can get mixed up. Any ideas on how to do this?
On the same server, you need to bind to different ports
Create more than one config file, setting divolte.global.server.port to different values, then run the application with those configs.
In order to set a new config file, it actually needs to be in it's own directory
Divolte Collector will try to find configuration files at startup in the configuration directory. Typically this is the conf/ directory nested under the Divolte Collector installation. Divolte Collector will try to locate the configuration directory at ../conf relative to the startup script. The configuration directory can be overridden by setting the DIVOLTE_CONF_DIR environment variable. If set, the value will be used as configuration directory
Alternatively, you could run the exact same config within many containers/VMs, then use port mappings around that

Setting and accessing environmental variable used by rundeck

I have Rundeck 2.10.6-1 installed on a Ubuntu 16.04.4 LTS server and would like to set environmental variables just for rundeck. Rundeck itself is functioning normally.
I am able to set the environmental variables in /etc/environment for system-wide availability, but I'd like them to be accessible only by the rundeck session. One of them is SQLCMDPASSWORD, a plain text password, utilized by SQLCMD, so I'd like tighter access. We ended up using this approach for PSQL as well.
I have the rundeck $HOME directory identified as /var/lib/rundeck and the $USER name confirmed as 'rundeck'.
I find that adding environmental variables to .bashrc, .bash_profile, or .profile in that directory are not utilized by 'rundeck' as confirmed with a commandline job executing only 'printenv'. When logged in to the server as 'rundeck' I see the variables.
Am I setting these in right place?
So, no, those variables were not set in the correct place. Here's why...
There were some clues in the answers to this question and this question but neither was sufficient. Applications have their environmental variables set in their profile, and for rundeck that would be
$ more /etc/rundeck/profile
Second clue is from the head of that file which, loosely quoted, indicates
NOTE: DO NOT MODIFY THIS FILE. It will be replaced when the package is upgraded and your changes will not be saved. To override variables in this file, you can instead create a file at: /etc/default/rundeckd
So, I created that default file and set my environmental variables by adding the following content
export SQLCMDUSER=batman
export SQLCMDPASSWORD='secret_bat_password'
Now it works as intended.

How to read in other config information into a dropwizard service

I am building a dropwizard service which will connect to multiple data sources including mySQL and Elasticsearch. All the mySQL settings can be defined in the yaml config file which gets read in after running from the commandline.
But what about other settings that I need to read in for other data sources that I will connect with myself, for example Elasticsearch? Where can I define those settings?
I thought I could add another commandline Command - which I tried, but I can only run a single command (from the commandline) at a time - so I can't seem to run both the 'server' command as well as my custom command, 'custom' which is followed by the my own config file for elasticsearch.
How can I introduce settings either individually or from a file - which are defined at run time (not hard coded)?
Thanks
Anton
Check out the Dropwizard Core documentation on adding custom configuration.
You'd create an ElasticSearchFactory class similar to the MessageQueueFactory in the example, reference this in your Configuration (that's in turn referenced in your Application), and then the options you need can be added to your main yaml configuration.

specify env settings in command line

I have a node that runs several applications. These applications each have specific env settings. When I generate a release I start my node by just running ./rel/mynode/bin/mynode start. Is there an option that I could add to this command to override apps' env settings?
To answer your question: No, there is no parameter that you can pass into that command to load a different application env file.
However, if you are trying to load a different config file, for example a development file vs. a production file, you should check out how to do dynamic configuration with rebar.
I use it for running my application between different configured environments (production, and local testing).
I don't quite get what you mean by env settings. If you mean the applications configuration parameters that are set in the {Par,Val} tuples of the key env in the .app files then these can also be overridden in a system configuration file or directly in the command line. See the Configuring an Application section.

Resources