From 9b5b6317455aa5f553bafcbbddb2880c26b6d4b4 Mon Sep 17 00:00:00 2001 From: aikidouke Date: Tue, 15 Mar 2016 18:09:11 +0000 Subject: [PATCH 1/2] 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 --- roles/base/tasks/main.yml | 12 ++++++++++++ roles/base/templates/setps1.sh.j2 | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100644 roles/base/templates/setps1.sh.j2 diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index ddc751dbbc..8527f1e32d 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -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 + diff --git a/roles/base/templates/setps1.sh.j2 b/roles/base/templates/setps1.sh.j2 new file mode 100644 index 0000000000..6eca2dcb38 --- /dev/null +++ b/roles/base/templates/setps1.sh.j2 @@ -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 }% + From f5cbec16e63ecdd7a24961bf818c366fbc615c50 Mon Sep 17 00:00:00 2001 From: aikidouke Date: Tue, 5 Apr 2016 18:43:37 +0000 Subject: [PATCH 2/2] testing a change to PS1 --- roles/badges/backend/tasks/main.yml | 16 ++++++++++++++++ roles/badges/backend/templates/setps1.sh.j2 | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 roles/badges/backend/templates/setps1.sh.j2 diff --git a/roles/badges/backend/tasks/main.yml b/roles/badges/backend/tasks/main.yml index 6775ef3c03..97c90e0305 100644 --- a/roles/badges/backend/tasks/main.yml +++ b/roles/badges/backend/tasks/main.yml @@ -167,3 +167,19 @@ - scripts - badges - badges/backend + +#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=templates/setps1.sh.j2 + dest=/etc/profile.d/setps1.sh + owner=root + group=sysadmin-badges + mode=644 + when: {{ env in ['production','staging'] }} + tags: + - base + - config + diff --git a/roles/badges/backend/templates/setps1.sh.j2 b/roles/badges/backend/templates/setps1.sh.j2 new file mode 100644 index 0000000000..6eca2dcb38 --- /dev/null +++ b/roles/badges/backend/templates/setps1.sh.j2 @@ -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 }% +