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:
aikidouke 2016-03-15 18:09:11 +00:00
parent 69eae7b8bc
commit 9b5b631745
2 changed files with 20 additions and 0 deletions

View file

@ -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

View 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 }%