Skip to Content.
Sympa Menu

grouper-users - RE: [grouper-users] passing bash variables in grouper.properties file to grouper

Subject: Grouper Users - Open Discussion List

List archive

RE: [grouper-users] passing bash variables in grouper.properties file to grouper


Chronological Thread 
  • From: "Hyzer, Chris" <>
  • To: Jay Hoff <>
  • Cc: "" <>
  • Subject: RE: [grouper-users] passing bash variables in grouper.properties file to grouper
  • Date: Fri, 8 Apr 2016 19:56:10 +0000
  • Accept-language: en-US
  • Authentication-results: psu.edu; dkim=none (message not signed) header.d=none;psu.edu; dmarc=none action=none header.from=isc.upenn.edu;
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:23

I tried it and it works.  I updated the wiki.  Does this work for you?  If not, what version of Grouper do you have?  Im afraid maybe your version doesn’t support if this doesn’t work for you?  Cant think of another reason…  make sure you do exactly as I have done.  Any property in any property file can do this.  Its generic for the config hierarchical library.  To show the value just do what I did in this.  You want to see all?  You would need to loop through but I think to verify it is working just see the ones you change to use ENV vars, ok?

 

When I have this in grouper.properties:

 

# in cases where grouper is logging or emailing, it will use this to differentiate test vs dev vs prod

grouper.env.name = GROUPERDEMO_2_2_2

 

I can print it out in gsh:

 

gsh 1% edu.internet2.middleware.grouper.cfg.GrouperConfig.retrieveConfig().propertyValueString("grouper.env.name")

GROUPERDEMO_2_2_2

 

Add an env variable:

 

[appadmin@i2midev1 bin]$ export GROUPER_ENV=GROUPER_2_2_2_fromEnv

[appadmin@i2midev1 bin]$ echo $GROUPER_ENV

GROUPER_2_2_2_fromEnv

 

Change grouper.properties

 

# grouper.env.name = GROUPERDEMO_2_2_2

grouper.env.name.elConfig = ${java.lang.System.getenv().get('GROUPER_ENV')}

 

Restart GSH, try again

 

gsh 0% edu.internet2.middleware.grouper.cfg.GrouperConfig.retrieveConfig().propertyValueString("grouper.env.name")

GROUPER_2_2_2_fromEnv

 

 

From: Jay Hoff [mailto:]
Sent: Thursday, April 07, 2016 12:44 PM
To: Hyzer, Chris <>
Cc:
Subject: Re: [grouper-users] passing bash variables in grouper.properties file to grouper

 

Chris, thanks for your response. Below are some questions from one of our developers, Scott Cole. We are running RHEL 6.x, fyi.

 

-Jay

 

Hello,

 

We would like to be able to dynamically populate some of the property values in a configuration overlay for grouper.properties but are struggling to get our changes using the elConfig suffix to work as described in the Wiki.

 

Specifically, we would like to set the grouper.env.name and grouper.ui.url properties dynamically. The problem I see is that the Grouper source code seems to be expecting those property names as is, not grouper.env.name.elConfig. At least that is how the GrouperStartup printConfigOnce method handles things. 

 

For example, I have attempted to set the environment name as follows: grouper.env.name.elConfig = ${java.lang.System.getenv().get('IDS_ENV')}, where IDS_ENV is an environment variable with value TEST.

 

When we deploy that change and restart Grouper, the log file shows the <no label configured> value for the environment, presumably because the property being looked at is "grouper.env.name", not "grouper.env.name.elConfig". 

 

That leaves me with 2 questions:

 

1. Is there a way to view all of the properties that are in use while Grouper is running with the dynamic properties showing their resolved value?

2. Is it even possible to use the elConfig suffix on base properties like grouper.env.name and grouper.ui.url?

 

Thank you for your time."

 

Scott Cole

 

 

On Apr 6, 2016, at 7:30 PM, Hyzer, Chris <> wrote:

 

Yes, it turned out this is possible!  :)  I updated the wiki.

https://spaces.internet2.edu/display/Grouper/Grouper+configuration+overlay#Grouperconfigurationoverlay-Environmentvariables

Environment variables

If you want a config to be pulled from an environment variable, do this:

somethingWhatever.elConfig = ${java.lang.System.getenv().get('JAVA_HOME')}

That will cause the property "somethingWhatever" to have the value "c:\dev_inst\java" or whatever it is set to.  Do the following two things:

1. append    .elConfig        to the propertyName
2. this is the value: ${java.lang.System.getenv().get('JAVA_HOME')}

Thanks
Chris

-----Original Message-----
From: [] On Behalf Of Jay Hoff
Sent: Tuesday, April 05, 2016 2:55 PM
To:
Subject: [grouper-users] passing bash variables in grouper.properties file to grouper

I have a question about passing a bash variable value into Grouper.  I’m working on making the file grouper.properties free of any system specific configuration so that it can be replicated to other Grouper nodes without the need to configure the file for each specific system. Specifically, in grouper.properties I have the following line:

mail.from.address = (the actual FQDN for the node is used)

Which is used for mailing the daily Grouper reports.

What I would like to be able to do, is to pass the value for the bash variable ${HOSTNAME} to Grouper. I’ve tried this:

mail.from.address = grouper_test@${HOSTNAME}

but the ${HOSTNAME} is treated as text and the variable is not expanded.

Any thoughts would be helpful.


Thanks much,


Jay




 




Archive powered by MHonArc 2.6.16.

Top of Page