From c3fc3d3c54985d580ddcc455dd499be22147b19e Mon Sep 17 00:00:00 2001 From: L3D Date: Sun, 13 Jan 2019 20:06:29 +0100 Subject: [PATCH] Use a tmeplate --- tasks/main.yml | 2 +- templates/bash.bashrc | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 00a7608..af32a67 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,7 +6,7 @@ when: ansible_distribution == "Fedora" - name: Create a global bashrc configuration - copy: + template: src: 'templates/bash.bashrc' dest: '/etc/bash.bashrc' owner: root diff --git a/templates/bash.bashrc b/templates/bash.bashrc index 5198232..61788b8 100644 --- a/templates/bash.bashrc +++ b/templates/bash.bashrc @@ -1,4 +1,5 @@ # /etc/bashrc +{% raw %} # System wide functions and aliases # Environment stuff goes in /etc/profile @@ -8,6 +9,9 @@ # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates. +# This file may be overwritten by ansible. Please think about commiting +# changes you want to keep persistent. + # Prevent doublesourcing if [ -z "$BASHRCSOURCED" ]; then BASHRCSOURCED="Y" @@ -43,6 +47,7 @@ if [ -z "$BASHRCSOURCED" ]; then # Turn on checkwinsize shopt -s checkwinsize [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ " +{% endraw %} # You might want to have e.g. tty in prompt (e.g. more virtual machines) # and console windows # If you want to do so, just add e.g. @@ -51,8 +56,9 @@ if [ -z "$BASHRCSOURCED" ]; then fi # to your custom modification shell script in /etc/profile.d/ directory fi +{% raw %} - if ! shopt -q login_shell ; then # We're not a login shell +if ! shopt -q login_shell ; then # We're not a login shell # Need to redefine pathmunge, it gets undefined at the end of /etc/profile pathmunge () { case ":${PATH}:" in @@ -76,8 +82,10 @@ if [ -z "$BASHRCSOURCED" ]; then else umask 022 fi +{% endraw %} SHELL={{ bash.shell }} + # Only display echos from profile.d scripts if we are no login shell # and interactive - otherwise just process them to set envvars for i in /etc/profile.d/*.sh; do