Can we define separate parts of some tag in clickhouse config with environment variables?
For example we can use:
<engine from_env="ENGINE"/>
then all the value comes from env variable.
But can we use something like this:
<engine>ENGINE = MergeTree PARTITION BY ${PARTITIONING}
ORDER BY (event_date, event_time)
TTL ${TTL}
</engine>
Or is there some other option for this purpose?
Related
I'm currently building a Shopify store and would like to use env variables in Themekit's config.yml file. What I'm confused about is how to connect the .env file to the yml file, since I don't think you can just require dotenv. I have my .env file, and the code below in the config.yml. Thanks!
password: ${DEV_PASSWD}
theme_id: ${DEV_THEMEID}
store: ${DEV_SHOP}
You can't include .env file inside a YAML one. However, you can interpolate variables into your config.yml file using the ${} notation.
To help you interpolate variables, there are special files that can be used to automatically to load environment variables for Theme Kit. The following table lists the file paths for each operating system:
macOs: ${HOME}/Library/Application Support/Shopify/Themekit/variables
Linux/BSD: ${XDG_CONFIG_HOME}/Shopify/Themekit/variables
Windows: %APPDATA%\Shopify\Themekit\variables
Even more, you can use the --vars flag in any command to provide a path to a file for loading variables. The variables file has the same format as most .env type files. But note, the .env file is not interpolated by YAML itself and it cannot be connected using standard YAML include directives. All magic is provided exclusively by shopify and its --vars flag.
I'm changing Laravel .env variable after a process, and checking that variable everytime, if it's true code doing one thing, if it's false another thing. But after changing the .env variable I have to restart with php artisan serve, I don't want to do this. Why Laravel does not read the new env variable, it changes on the .env file itself.
You shouldn't have to manipulate environment variables during runtime. If you're trying to manipulate an environment variable, you should probably instead utilize a config value. These configuration files are placed in the config/ directory of your project.
Then during runtime, you can use the following built-in config helper to get/set your config variable.
$value = config('app.timezone');
// To set configuration values at runtime, pass an array to the config helper
config(['app.timezone' => 'America/Chicago']);
$newValue = config('app.timezone');
You can read more about this process here (you can change the version to your version):
https://laravel.com/docs/5.5/configuration#accessing-configuration-values
In my Logstash config file I have many jdbc inputs and all of them use the same database and the same credentials. Each time I want to change for example connection string I have to loop through all jdbc inputs manually. Can I somehow define variables once and then use them in the config file for example like that?
CONNECTION_STRING_VARIABLE => "MY_CONNECTION_STRING"
jdbc {
...
jdbc_connection_string => CONNECTION_STRING_VARIABLE
...
}
I don't want to use environmental variables because of user and password fields and I want to store variables in one place.
For passwords, you may use property jdbc_password_filepath.
I read that you don't want to set environment variables. I am giving a way here, so that, it will not be available in environment of every shell but will get loaded for logstash only.
You may create a script that exports all variables for logstash and call it in logstash service or logstash command line.
For example, create a file - exportVariablesForLogstash.sh
export jdbc_url="jdbc:mysql://example.local:3306/sampledb"
export jdbc_username=mysqluser
Add following in starting of logstash service or logstash commandline script. Note dot at starting.
. exportVariablesForLogstash.sh
And then you may use these variables as documented here. https://www.elastic.co/guide/en/logstash/current/environment-variables.html. I believe you already know this one.
I have a key with different value on each server(host), how can I save all those values in a single file, so that when my playbook is executed it reads from that file.
From Ansible documentation: I found under host_vars/hostname I have to create a file for each server and add the variable. It would be cumbersome if I have like 100 servers
You can set variables by host in your inventory file like this: https://docs.ansible.com/ansible/intro_inventory.html#host-variables
Groups and group_vars are another solution that may be fit your requirements.
Is it possible to set env variables in systemd units according to content of the file. Something like ENV=`cat somefile`?
I need to set path to the executable file according to content of somefile. I didn't find any info about variables in systemd ,exept env variables so I try to use them, but with no luck
I've tried to use Environment = 'ENV=`cat somefile`' but with no luck. It just set the value of the variable to `cat somefile`. I've tried to use cat and /bin/cat but result is the same.
There is a special directive exactly for this purpose: EnvironmentFile. You should put it into your [Service] section like this:
[Service]
EnvironmentFile=/etc/default/somefile
If the file isn't there the service won't start, so to be able to start it despite the presence of the file you can add leading - sign in front of the file name, like:
[Service]
EnvironmentFile=-/etc/default/somefile
Be aware, that although this file looks like shell script it's not and behaviour of variables declaration sligtly differs, in particular, you can't reference other variables in the declaration of the variable.
Please, read EnvironmentFile and Environment options description for more details. Command lines could be helpfl too.