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

[feature] different exec according to environment #10

Closed
florentvaldelievre opened this Issue Mar 12, 2015 · 7 comments

Comments

Projects
None yet
2 participants
@florentvaldelievre
Copy link

florentvaldelievre commented Mar 12, 2015

Hi Mark,

At the moment, we only have one endpoint to exec something inside our container: common.yaml.
It would be nice to externalize this logic to have it per environment based.

Use case:

For production environment we need to launch td-agent to collect stats. It is not necessary to have it for development environment.
Currently, the only way to do it, is to have a script called launch.sh and to put the logic inside it.

Maybe it would be more versatile if we move the 'exec:' from common.yaml to environments/{env}.yaml.

Let me know what you think.

Cheers and keep up your good work

@markround

This comment has been minimized.

Copy link
Owner

markround commented Mar 13, 2015

Code comitted to develop branch; this will be in the upcoming 0.5.0 release. You can override any of the settings in common.yaml by adding a common: block in your environment file, e.g.

common:
  api_enable: true
  exec: foo -n

and so on...

@florentvaldelievre

This comment has been minimized.

Copy link
Author

florentvaldelievre commented Mar 13, 2015

Amazing, good job !

@markround

This comment has been minimized.

Copy link
Owner

markround commented Mar 16, 2015

Release 0.5.0 pushed. Note that this version now requires ruby >= 1.9.2. Let me know how it works out for you, if it's all good just close this issue :)

@florentvaldelievre

This comment has been minimized.

Copy link
Author

florentvaldelievre commented Mar 17, 2015

I must do something wrong, but it does not seem to take my environment sent as environment variable into account. Any idea ?

Update: It works by sending a plain environment variable docker run -it -e environment=development api-test but does not work using tiller_json

common.yaml

exec: echo "common exec"
data_sources:
  - file
  - environment_json
template_sources:
  - file
default_environment: default

environments/default.yaml

server.xml.erb:
  target: /var/lib/tomcat7/conf/server.xml
  config: {}
hibe-webapp-config.groovy.erb:
  target: /root/.grails/hibe-webapp-config.groovy
  config: {}
td-agent.conf.erb:
  target: /etc/td-agent/td-agent.conf
  config: {}

environments/development.yaml

common:
  exec: echo "overrided from dev"
docker run -it -e tiller_json='{"environment":"development"}' api-test

output

[shopmedia@staging3:/tmp/api] $docker run -it -e tiller_json='{"environment":"development"}' api-test
tiller v0.5.0 (https://github.com/markround/tiller) <github@markround.com>
Using configuration from /app/tiller
Using plugins from /var/lib/gems/2.1.0/gems/tiller-0.5.0/lib/tiller
Using environment default
Template sources loaded [FileTemplateSource]
Data sources loaded [FileDataSource, EnvironmentJsonDataSource]
Templates to build ["server.xml.erb", "hibe-webapp-config.groovy.erb", "td-agent.conf.erb"]
Warning, merging duplicate global values.
environment => 'default' being replaced by : 'development' from EnvironmentJsonDataSource
Building template server.xml.erb
Setting ownership/permissions on /var/lib/tomcat7/conf/server.xml
Building template hibe-webapp-config.groovy.erb
Setting ownership/permissions on /root/.grails/hibe-webapp-config.groovy
Building template td-agent.conf.erb
Setting ownership/permissions on /etc/td-agent/td-agent.conf
Template generation completed
Executing echo "common exec"...
Child process forked with PID 8.
common exec
Child process finished, Tiller is stopping.

@florentvaldelievre

This comment has been minimized.

Copy link
Author

florentvaldelievre commented Mar 17, 2015

It actually make sense we have to use -e environment={env} and not tiller_json. I close the issue, and thanks again!

@markround

This comment has been minimized.

Copy link
Owner

markround commented Mar 17, 2015

Cool. Oh, and one other thing - as you're running a recent Tiller, you don't need the empty

config: {}

lines. You can just omit them, and it'll still work...

@florentvaldelievre

This comment has been minimized.

Copy link
Author

florentvaldelievre commented Mar 17, 2015

brillant thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.