Due to the way bash is compiled on FreeBSD, we need to flip an
extra switch in order to convince it to process the shell profile
even when we're running commands non-interactively through ssh.

Signed-off-by: Andrea Bolognani <abolo...@redhat.com>
---
 guests/tasks/kludges.yml | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/guests/tasks/kludges.yml b/guests/tasks/kludges.yml
index 001b5c6..0196559 100644
--- a/guests/tasks/kludges.yml
+++ b/guests/tasks/kludges.yml
@@ -29,3 +29,21 @@
   when:
     - os_name == 'FreeBSD'
     - os_version == '11'
+
+# FreeBSD compiles bash without defining SSH_SOURCE_BASHRC, which means
+# it won't try to detect when it's spawned by ssh and source ~/.bashrc
+# when that's the case. Our workaround is setting $BASH_ENV globally
+- name: Enable ~/.bashrc
+  replace:
+    path: /etc/login.conf
+    regexp: '^(.*):setenv=(BASH_ENV=[^,]*,)?(.*):\\$'
+    replace: '\1:setenv=BASH_ENV=~/.bashrc,\3:\\'
+    validate: 'cap_mkdb %s'
+  register: loginconf
+  when:
+    - os_name == 'FreeBSD'
+
+- name: Enable ~/.bashrc
+  command: cap_mkdb /etc/login.conf
+  when:
+    - loginconf.changed
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to