Closed Decipher closed 8 years ago
This is something I too would like to see. We could feed the value of this beet_env
variable into the Apache VirtualHost configuration too, like this:
apache_vhosts:
- servername: "{{ beet_domain }}"
serveralias: "{{ beet_aliases | join(' ') }}"
documentroot: "{{ beet_web }}"
extra_parameters: |
SetEnv AH_SITE_ENVIRONMENT {{ beet_env }}
SetEnv DRUPAL_ENVIRONMENT {{ beet_env }}
Then, add something like this to an appropriate Beetbox role to set an environment variable for log-in shells.
---
# Template for beet_env shell environment variable.
- template: src=/templates/profile_beet_env.j2 dest=/etc/profile.d/beet_env.sh
# /etc/profile.d/beet_env.sh
export AH_SITE_ENVIRONMENT='{{ beet_env }}';
export DRUPAL_ENVIRONMENT='{{ beet_env }}';
Here's a post task I created to set the Environment variable for the shell:
File: .beetbox/tasks/post/environment.yml
---
- name: Set environment variable for shell.
lineinfile:
dest: /etc/profile.d/beetbox-beet_env.sh
state: present
create: yes
regexp: "^export {{ env_item }}"
line: "export {{ env_item }}='{{ beet_env }}';"
owner: root
group: root
mode: 0644
with_items:
- "AH_SITE_ENVIRONMENT"
- "DRUPAL_ENVIRONMENT"
loop_control:
loop_var: env_item
Added in #341
I would like to have certain tasks restricted to certain environments (Development/Vagrant, CI, Packer, etc) so having a variable provided by default that could be checked against, and overridden in environment specific configuration files would be extremely helpful.