We will need to know ccache's absolute path at the playbook
level later on, so while we're at it we might as well treat
all OS-dependent paths the same way and figure them out when
configuring the guest rather than at login time.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
guests/tasks/paths.yml | 32 ++++++++++++++++++++++++++++++++
guests/templates/bashrc | 8 +++++---
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/guests/tasks/paths.yml b/guests/tasks/paths.yml
index 36b699f..00decc9 100644
--- a/guests/tasks/paths.yml
+++ b/guests/tasks/paths.yml
@@ -8,7 +8,12 @@
register: which
with_items:
- bash
+ - ccache
+ - gmake
- java
+ - make
+ - python2
+ - python3
- su
- name: 'Look for files'
@@ -32,6 +37,33 @@
- name: 'Export paths'
set_fact:
bash: '{{ commands["bash"] }}'
+ ccache: '{{ commands["ccache"] }}'
java: '{{ commands["java"] }}'
su: '{{ commands["su"] }}'
sudoers: '{{ files["sudoers"] }}'
+
+# Prefer gmake, fall back to make
+- name: 'Export paths'
+ set_fact:
+ make: '{{ commands["gmake"] }}'
+ when:
+ - commands["gmake"] != ''
+
+- name: 'Export paths'
+ set_fact:
+ make: '{{ commands["make"] }}'
+ when:
+ - make is undefined
+
+# Prefer python3, fall back to python2
+- name: 'Export paths'
+ set_fact:
+ python: '{{ commands["python3"] }}'
+ when:
+ - commands["python3"] != ''
+
+- name: 'Export paths'
+ set_fact:
+ python: '{{ commands["python2"] }}'
+ when:
+ - python is undefined
diff --git a/guests/templates/bashrc b/guests/templates/bashrc
index e925cd9..65c82cd 100644
--- a/guests/templates/bashrc
+++ b/guests/templates/bashrc
@@ -11,9 +11,11 @@ export OSINFO_SYSTEM_DIR="{{ OSINFO_SYSTEM_DIR }}"
export PERL5LIB="{{ PERL5LIB }}"
export PYTHONPATH="{{ PYTHONPATH }}"
-which python3 >/dev/null 2>&1 && export PYTHON="python3" ||
export PYTHON="python2"
-which gmake >/dev/null 2>&1 && export MAKE="gmake" || export
MAKE="make"
-which ccache >/dev/null 2>&1 && export CC="ccache cc"
+export CCACHE="{{ ccache }}"
+export MAKE="{{ make }}"
+export PYTHON="{{ python }}"
+
+test "$CCACHE" && export CC="$CCACHE cc"
# Enable bash completion. Only needed on FreeBSD, the system-wide
# shell profile will take care of it for us everywhere else
--
2.14.3