Created
October 10, 2012 14:28
-
-
Save oc/3865980 to your computer and use it in GitHub Desktop.
template - default variables prob...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## /etc/unicorn/blahblah.conf | |
RACK_ROOT="/srv/www/blahblah.muda.no" | |
IS_RAILS="True" | |
UNICORN_BIN="bundle exec bin/unicorn_rails" | |
UNICORN_PORT="None" # <=========== WRONG!! WTF?! | |
# Export RACK_ENV. | |
export RACK_ENV="custom" | |
# Map other environment variables to set in launcher | |
export SHITFOO="custom" | |
export LOGIN="foo" | |
## /etc/unicorn/staging.conf | |
RACK_ROOT="/srv/www/staging.muda.no" | |
IS_RAILS="True" | |
UNICORN_BIN="bundle exec bin/unicorn" # <=========== default value works here... | |
UNICORN_PORT="3000" | |
# Export RACK_ENV. | |
export RACK_ENV="production" | |
# Map other environment variables to set in launcher |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# salt state init - only the relevant parts... | |
{% for svc in pillar['unicorn_services'] %} | |
/etc/unicorn/{{ svc.name }}.conf: | |
file.managed: | |
- source: salt://unicorn/etc/unicorn/unicorn.conf.jinja | |
- template: jinja | |
- user: www-data | |
- group: www-data | |
- context: | |
name: {{ svc.name }} | |
root: {{ svc.root }} | |
unicorn_bin: {{ svc.unicorn_bin or "bundle exec bin/unicorn" }} | |
unicorn_port: {{ svc.unicorn_port or "" }} # <======================= PROBLEM, returns "None" | |
rack_env: {{ svc.rack_env or "production"}} | |
rails: {{ svc.rails or "" }} | |
environment: {{ svc.environment or {} }} | |
- require: | |
- file: /etc/unicorn | |
{% endfor %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RACK_ROOT="{{ root }}" | |
IS_RAILS="{{ rails }}" | |
UNICORN_BIN="{{ unicorn_bin }}" | |
UNICORN_PORT="{{ unicorn_port }}" | |
# Export RACK_ENV. | |
export RACK_ENV="{{ rack_env }}" | |
# Map other environment variables to set in launcher | |
{% for k, v in environment.items() %} | |
export {{ k }}="{{ v }}" | |
{%- endfor %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Pillar data | |
unicorn_services: | |
# first element should have no unicorn_port (should default to empty string) | |
- name: blahblah | |
root: /srv/www/blahblah.muda.no | |
unicorn_bin: bundle exec bin/unicorn_rails | |
rack_env: custom | |
rails: True | |
environment: | |
SHITFOO: custom | |
LOGIN: foo | |
# second element should has a unicorn_port (is correctly set) | |
- name: staging | |
root: /srv/www/staging.muda.no | |
unicorn_port: 3000 | |
rack_env: production | |
rails: True | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment