Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correctly /etc/sysconfig and /etc/default env defaults #50

Closed
arm4b opened this issue Jul 20, 2016 · 1 comment
Closed

Use correctly /etc/sysconfig and /etc/default env defaults #50

arm4b opened this issue Jul 20, 2016 · 1 comment

Comments

@arm4b
Copy link
Member

arm4b commented Jul 20, 2016

There are places for default env variables in different distro families:

  • /etc/sysconfig - for Red Hat-like
  • /etc/default - for debian-like

We support them in init files:
https://github.com/StackStorm/st2chatops/blob/master/debian/st2chatops.upstart#L24
https://github.com/StackStorm/st2chatops/blob/master/rpm/st2chatops.service#L10

So st2chatops.env should not overwrite env variable, if it was already passed.
The good example is: https://github.com/StackStorm/st2chatops/blob/master/st2chatops.env#L1

export ST2_HOSTNAME="${ST2_HOSTNAME:-localhost}"

^^ Do that for every other env variable in st2chatops.env as a rule.


Ideally, apart of editing existing st2chatops.env (sed-like stuff is error-prone) user can just place his custom variables (good to do with Configuration Management tools) in /etc/sysconfig/st2chatops or /etc/default/st2chatops and be sure that they're used as a priority.

@cognifloyd
Copy link
Member

Currently it is also impossible to override most of the vars in st2chatops.env when running bin/hubot from the command line because of

. $HERE/st2chatops.env

In the smoke tests of the ansible-st2 playbook, essentially, we run:

HUBOT_LOG_LEVEL=debug timeout 10 bash -c '(sleep 5; echo exit ) | bin/hubot'

Note that I don't think defining the variables with a bash default is sufficient, even though this it would allow overriding the variables from the command line:

export ST2_HOSTNAME="${ST2_HOSTNAME:-localhost}"

That's not enough because it would make handling those settings through configuration management more error prone and problematic. We need a dedicated configuration file for system-specific settings that overrides the default settings in st2chatops.env. Putting this system-specific config file in the distro-specific environment variables file makes sense to me.

Please change the implementation of bin/hubot to support setting the variables outside of st2chatops.env including from the command line (for testing purposes) and from distro-specific environment variable files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants