added a when statement to check if environment is stage or production and trigger a template to add a file in /etc/profile.d that sets PS1
This commit is contained in:
parent
69eae7b8bc
commit
9b5b631745
2 changed files with 20 additions and 0 deletions
|
@ -452,3 +452,15 @@
|
|||
- service
|
||||
- watchdog
|
||||
- base
|
||||
|
||||
#
|
||||
#Set PS1 to show prod/stage environment at PS1
|
||||
#Should work in sh/bash. Needs tested in other shells
|
||||
#
|
||||
- name: set PS1 for prod and stage in /etc/profile.d
|
||||
copy: src=setps1.sh.j2 dest=/etc/profile.d/setps1.sh
|
||||
when: {{ env in ['production','staging'] }}
|
||||
tags:
|
||||
- base
|
||||
- config
|
||||
|
||||
|
|
8
roles/base/templates/setps1.sh.j2
Normal file
8
roles/base/templates/setps1.sh.j2
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Set PS1 based on env:
|
||||
#
|
||||
{% if {{ env }} in 'production' %}
|
||||
PS1="\e[0;31m[PROD]\e[m[\u@\h \W]\$ "
|
||||
{% elif {{ env }} in 'staging' %}
|
||||
PS1="[STG]\e[m[\u@\h \W]\$ "
|
||||
{% endif }%
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue