fubarhouse / ansible-role-golang

Installs the Go programming language and packages on Mac & Linux (Ubuntu, CentOS)
MIT License
105 stars 32 forks source link

Additional platform support for Amazon Linux #131

Closed mattiasvh closed 5 years ago

mattiasvh commented 5 years ago

Only the OS specific tasks for CentOS need to be executed on Amazon Linux to have support for Amazon Linux

mattiasvh commented 5 years ago

Possible patch:

diff --git a/tasks/setup.yml b/tasks/setup.yml
index 7b1dbfe..41f4f79 100644
--- a/tasks/setup.yml
+++ b/tasks/setup.yml
@@ -21,9 +21,9 @@
     fubarhouse_user_dir: "{{ shell_home_dir.stdout }}"
   when: fubarhouse_user_dir is not defined

-- name: "Go-Lang | Include OS-Specific tasks (CentOS)"
+- name: "Go-Lang | Include OS-Specific tasks (CentOS and Amazon)"
   include_tasks: tasks-CentOS.yml
-  when: ansible_distribution == "CentOS"
+  when: ansible_distribution == "CentOS" or ansible_distribution == "Amazon"

 - name: "Go-Lang | Include OS-Specific tasks (Darwin)"
   include_tasks: tasks-Darwin.yml
@@ -42,6 +42,7 @@
   when:
     - ansible_os_family == "RedHat"
     - ansible_distribution != "CentOS"
+    - ansible_distribution != "Amazon"

 - name: "Go-Lang | Define GO111MODULE"
   set_fact:
fubarhouse commented 5 years ago

I can draft a PR - would you be prepared to test it on the environment for feedback?

mattiasvh commented 5 years ago

yes, I can test it

fubarhouse commented 5 years ago

If you weren't aware, it's ready for testing. Please let me know how this goes.

mattiasvh commented 5 years ago

Hi,

Thanks for adding these changes. I have tested the changes in branch origin/issue/131, but it fails on this branch:

How I get it working:

How it fails:


failed: [testNode] (item={u'url': u'golang.org/x/vgo', u'name': u'vgo'}) => {"ansible_loop_var": "item", "changed": false, "cmd": ["/usr/local/go/bin/go", "get", "-u", "golang.org/x/vgo"], "delta": "0:00:01.514037", "end": "2019-07-29 08:40:43.669417", "item": {"name": "vgo", "url": "golang.org/x/vgo"}, "msg": "non-zero return code", "rc": 2, "start": "2019-07-29 08:40:42.155380", "stderr": "go: finding golang.org/x/vgo latest\ngo: downloading golang.org/x/vgo v0.0.0-20180912184537-9d567625acf4\ngo: extracting golang.org/x/vgo v0.0.0-20180912184537-9d567625acf4\n# golang.org/x/vgo\n../pki/go/pkg/mod/golang.org/x/vgo@v0.0.0-20180912184537-9d567625acf4/main.go:31:2: undefined: main.Main", "stderr_lines": ["go: finding golang.org/x/vgo latest", "go: downloading golang.org/x/vgo v0.0.0-20180912184537-9d567625acf4", "go: extracting golang.org/x/vgo v0.0.0-20180912184537-9d567625acf4", "# golang.org/x/vgo", "../pki/go/pkg/mod/golang.org/x/vgo@v0.0.0-20180912184537-9d567625acf4/main.go:31:2: undefined: main.Main"], "stdout": "", "stdout_lines": []}```
fubarhouse commented 5 years ago

The following indicates vgo should be removed from the defaults/main.yml file.

I can have this adjusted for testing tonight for you.

golang.org/x/vgo\n../pki/go/pkg/mod/golang.org/x/vgo@v0.0.0-20180912184537-9d567625acf4/main.go:31:2: undefined: main.Main
mattiasvh commented 5 years ago

Ok great, I would like to test it

fubarhouse commented 5 years ago

Apologies for the delay - I've just removed vgo from the branch. You are welcome to continue testing.

mattiasvh commented 5 years ago

Hi, Thanks for the changes, I have tested it again, but without success. Error is now:

TASK [../roles/ansible-role-golang : Go-Lang | Run get commands] ******************************************************************************************************************************************* task path: ~/ansible/roles/ansible-role-golang/tasks/go-get.yml:21 failed: [testNode] (item={u'url': u'github.com/golang/dep/cmd/dep', u'name': u'dep'}) => {"ansible_loop_var": "item", "changed": false, "cmd": ["/usr/local/go/bin/go", "get", "-u", "github.com/golang/dep/cmd/dep"], "delta": "0:00:01.221634", "end": "2019-08-09 06:57:27.615809", "item": {"name": "dep", "url": "github.com/golang/dep/cmd/dep"}, "msg": "non-zero return code", "rc": 2, "start": "2019-08-09 06:57:26.394175", "stderr": "go: finding github.com/golang/dep/cmd/dep latest\ngo: finding github.com/golang/dep/cmd latest\ngo: finding github.com/sdboyer/constext latest\ngo: finding github.com/golang/protobuf/proto latest\ngo: finding github.com/nightlyone/lockfile latest\ngo: finding golang.org/x/sync/errgroup latest\ngo: finding golang.org/x/sync latest\ngo: finding golang.org/x/sys/unix latest\ngo: finding golang.org/x/sys latest\n# github.com/golang/dep/gps\n../pki/go/pkg/mod/github.com/golang/dep@v0.5.4/gps/constraint.go:149:4: undefined: semver.Constraint", "stderr_lines": ["go: finding github.com/golang/dep/cmd/dep latest", "go: finding github.com/golang/dep/cmd latest", "go: finding github.com/sdboyer/constext latest", "go: finding github.com/golang/protobuf/proto latest", "go: finding github.com/nightlyone/lockfile latest", "go: finding golang.org/x/sync/errgroup latest", "go: finding golang.org/x/sync latest", "go: finding golang.org/x/sys/unix latest", "go: finding golang.org/x/sys latest", "# github.com/golang/dep/gps", "../pki/go/pkg/mod/github.com/golang/dep@v0.5.4/gps/constraint.go:149:4: undefined: semver.Constraint"], "stdout": "", "stdout_lines": []}

fubarhouse commented 5 years ago

@mattiasvh,

I'm not entirely sure why but it seems your environment isn't coping with go get very well... I would recommend emptying the variable by setting it:

Unfortunately I've no way to directly test any changes, but all I can do now is change the value and hope for the best.

mattiasvh commented 5 years ago

Hi, By setting go_get: [] there are no failures anymore in the playbook and it can be installed on Amazon linux machines Thanks

fubarhouse commented 5 years ago

@mattiasvh,

Excellent, I'm glad we could get around that 😀 It might be worth removing those values by default and re-add them for testing only.

I'll get this merged and I'll cut a release in the next couple of days 👍

mattiasvh commented 5 years ago

Thanks a lot!