Add Go to path in /etc/environment 06/2506/15
authorEric Ball <eball@linuxfoundation.org>
Thu, 13 Feb 2020 13:24:52 +0000 (05:24 -0800)
committerEric Ball <eball@linuxfoundation.org>
Thu, 27 Feb 2020 16:13:37 +0000 (08:13 -0800)
Ubuntu isn't running /etc/profile.d/golang.sh. This will force the
addition of the Go path into the PATH var if it is missing.

Issue-ID: LF-Jira IT-18590
Change-Id: Ic2d3edce11897bc018f6ae2e2a542f46027a09fb
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
packer/common-packer
packer/provision/local-docker.yaml

index 1d5bbea..da5d5cf 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 1d5bbea3f4a9c037228a923e47dd76f70aeae2a9
+Subproject commit da5d5cf92fafcdc0f31a76d2955e8ac9c327c100
index fb158e8..609bbf3 100644 (file)
@@ -7,6 +7,10 @@
   become_user: root
   become_method: sudo
 
+  vars:
+    golang_version: 1.12
+    gopath: '/opt/go/{{golang_version}}/bin'
+
   pre_tasks:
     - include_role: name=lfit.system-update
 
     - include_role:
         name: gantsign.golang
       vars:
-        golang_version: 1.12
         ansible_become: true
+
+    - name: Add Go to Ubuntu path
+      lineinfile:
+        path: /etc/environment
+        regexp: 'PATH=(["]*)((?!.*?{{gopath}}).*?)(["]*)$'
+        line: 'PATH=\1\2:{{gopath}}\3'
+        backrefs: yes
+      when: ansible_distribution == 'Ubuntu'
+      become: yes