Jordi
Jordi

Reputation: 23277

Chef: Setting environment variables up

I'm deploying j2ee applications which need environment variables in order to set the application context up. I mean applications are looking for environment variables in order to get the ACCESS_TOKEN for getting access to any remote service.

Unfortunately Unix has no general purpose solution for global environment variables. I've took a look over there but I don't quite figure out how to set them up on provisioning. There's a problem with setting variables on bash processes and their inheritance.

According to this answer, I guess there're a lot of things to do in order to work it around.

How could I automate it using chef? My main goal is to set environment variables in order for wildfly user to be able to get the FOO environment variable value.

I don't know if I've explained so well...

Upvotes: 0

Views: 144

Answers (1)

coderanger
coderanger

Reputation: 54249

You can't do it with Chef because you can't do it at all. If it's a service, put it in the service definition (usually a systemd unit these days). If it's for a user tool, put it in their shell init files. You would do both with a template resource, or maybe poise_service for the former if feeling very fancy.

Upvotes: 1

Related Questions