RabbitMQ : How to set and use custom environment variable in RabbitMQ Advance config file - rabbitmq

We have configured RabbitMQ server to communicate with LDAP server for authentication which is working as expected. But we are facing one challenge where we need to externalize one value from configuration to environment variable.
so below is the current configuration present in advance.config file
{other_bind, {"CN=Service_Account,OU=Service Accounts,DC=XYZ,DC=com",{string,"123456"}}},
and want to make it something like this
{other_bind, {"CN=Service_Account,OU=Service Accounts,DC=XYZ,DC=com",{string,"${RABBITMQ_SERVICE_ACCOUNT_PASSWORD}"}}},
so as a result we wanted to externalize our password to some environment variable and use the same in advance.config file.
I tried setting value in rabbitmq-env.conf file but no luck.
Also as per this article we can't set a custom environment variable in rabbitmq-env.conf file, is it right? and if yes then where we can set this value?
https://riptutorial.com/rabbitmq/example/14032/configuring-rabbitmq-on--nix-systems

No, this is not supported:
{other_bind, {"CN=Service_Account,OU=Service Accounts,DC=XYZ,DC=com",{string,"${RABBITMQ_SERVICE_ACCOUNT_PASSWORD}"}}},
One option is to generate the advanced.config from a template before RabbitMQ starts. If RabbitMQ starts via systemd in your environment, you can use the ExecStartPre hook to run a custom script or program.
To create a drop-in override for the RabbitMQ systemd unit (and add ExecStartPre), follow these instructions:
https://wiki.archlinux.org/title/systemd#Editing_provided_units
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Related

Changing the configuration of TF6250-Modbus-TCP when used in TwinCAT/BSD

I have a device running TwinCAT/BSD.
Following section 5 the manual for TwinCAT/BSD I have successfully managed to install the TF6250 package. After updating the firewall rules I have confirmed that I am able connect and issue modbus tcp requests successfully using the Default Configuration from section 4.3 of the TF6250 manual.
My project requires mapping that is different from the default (i.e to the %Q registers rather than %M). Normally (when not not using TwinCAT/BSD) I would be able to edit my mapping via the Modbus TCP Configurator, but there does not appear to be an equivalent tool contained in the package for TwinCAT/BSD.
I have tried copying the mapping files that I would have created in the configurator into the Server directory with no luck. Are you able to tell me how my mapping can be updated in the TwinCAT/BSD environment?
If relevant:
TwinCAT Build: 3.1.4024.19
TC/BSD: 12.2.9.1,2
TF6250-Modbus-TCP: 2.0.1.0_1
pkg repo: https://tcbsd.beckhoff.com/TCBSD/12/stable/packages
I spoke with Beckhoff support who told that TF6250 expects the xml file with the configuration here: /usr/local/etc/TwinCAT/Functions/TF6250-Modbus-TCP/TcModbusSrv.xml
I tested this and it appears to work so all you need to do;
Create the mapping file as per normal (e.g using the windows tool) and copy the file there.
Reboot the device to load the configuration from the file.

How to set Spring active profile while running in WebLogic?

I want to set spring active profile in weblogic settings.
I have three properties in src/main/resources. For examp : application-dev.properties , application-qa.properties , application-test.properties.
I dont want to keep spring.profiles.active property in my application.properties file. As I have to change it every time whenever I want to deploy in different server.
I want to active the profile in weblogic (my deploying server for application). Whats is the way and how to fetch the value in springboot application?
Thanks
Pass the profile as java argument -Dspring.profiles.active=dev
A secure way to set profiles in springboot applications is to set environment variables with it. In general, it is a good approach, so you can define it differently for each one of your environments (dev, qa and prod).
Please check this discussion, which explains specifically about Weblogic. In java, you need the SPRING_PROFILES_ACTIVE environment variable set.

How to set Tomcat.runtime.environment.version as PROD on the web server?

I want to set Tomcat environment variable as PROD. I tried by putting
set "ENVIRONMENT=PROD"
set JAVA_OPTS="-Dtomcat.runtime.environment.version=PROD"
in catalina.bat
and tried to retrieve it with
env = System.getProperty("tomcat.runtime.environment.version");
but every time env is null! Where exactly does the variable have to be declared in catalina.bat and what's the perfect syntax to set the environment variable? Other possible ways to declare variables are also welcome!
Since you are on Windows and in production, I'm going to assume that you are using a Microsoft Windows Service for Tomcat. If that's the case, the .bat files are completely ignored when launching and stopping Tomcat. There is a service binary that reads the configuration from the Windows Registry and no disk-based scripts are used at all.
If you run the program called tomcatXw.exe (where X is your Tomcat major version number), that will run the configuration GUI. From there, you can configure everything stored in the Registry.
Go to the "System Properties" tab and add your system property -Dtomcat.runtime.environment.version=PROD to the list of properties already found in there. Restart your service and you should be able to see the new system property available to your application (actually the whole JVM, of course).

Where are Ambari Macros set

In Knox config file in Ambari we have defined:
<url>http://{{namenode_host}}:{{namenode_http_port}}/webhdfs</url>
The problem is we have 2 namenodes, one active and one passive for high availability. Our active namenode01 failed so namenode02 became active.
This caused problems for a lot scripts as they were hardcoded to point to namenode01. So we used a command to failover namenode02 back to namenode01 using a terminal, not Ambari.
Now, the macro {{namenode_host}} is defined as namenode02 and not namenode01.
So, where is {{namenode_host}} defined?
Or, do we need to failover namenode01 to namenode02, then failover again to namenode01 using Ambari to update the macro?
If we need to failover the namenode using Ambari, I'm assuming we need to select the "Restart" option? There isn't a direct failover command.
See issue here:
https://issues.apache.org/jira/browse/AMBARI-12763
This was committed to Ambari to support HA mode for Knox. However if you're still looking for the location take a look at the file that's edited in the patch. That file is the place where the macros are set. You'll have to find it on your local machine though.
Should be something like params_linux.py

RabbitMQ error on startup - erlexec: HOME must be set

For some reason I cannot start RabbitMQ anymore after it crashed.
I am getting the following error:
erlexec: HOME must be set
I've tried to export my home to /home/ubuntu but still getting the same error.
Any ideas?
I'm assuming that you are trying to start rabbitmq with something like service start rabbitmq-server. If so, the service command strips out environment variables. So you will need to either define it in your start up script or in a config file for your startup script (see https://unix.stackexchange.com/a/44378).
Additionally, I believe the rabbitmq home directory is actually /var/lib/rabbitmq/.
I have found suitable solution for myself. You can run epmd service before RabbitMQ server. This is fixing issue with HOME variable and others.
erlexec needs the environment variable HOME to be set in order to place a cookie (that contains a string). If HOME was for some reason unset in the environment that you are running rabbitmq (or rabbitmqctl) in, then you will get this error.
Try to check if HOME is defined by typing:
$ env
to get the list of defined environments. If it was not defined try to define it with
$ export HOME=/var/lib/rabbitmq
If you are using python3 and tox, note that tox by default does not pass current environment variable to the test environment. You will have to add the following to tox.ini
setdev =
HOME=/var/lib/rabbitmq
Just wanted to mention it because it gave me a headache the entire day today and I finally understood what was the issue and I though I should share this hint.