Skip to content

Commit

Permalink
feat: Add Go installation support using GVM
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziwi01 committed May 6, 2023
1 parent 68ef2d6 commit 03ae48b
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .latest-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ github_packages:
win32yank: latest
git_fuzzy: latest
nvm: latest
terraform: latest
terragrunt: latest
tpm: latest
pes: latest
p10k: latest
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Please read below README carefully and go through the scripts to see whats going
* [Other software](#other-software)
* [Languages](#languages)
* [Python](#python)
* [Go](#go)
* [Ruby](#ruby)
* [JAVA/groovy](#java/groovy)
* [Node](#node)
Expand Down Expand Up @@ -211,6 +212,10 @@ Also, there is [`pyenv-virtualenv`](https://github.com/pyenv/pyenv-virtualenv) a

For usage examples see [Usages.md](./Usages.md)

### Go

Automatic installation of Go is done using [`GVM`](https://github.com/moovweb/gvm) - Go Version Manager. By default `go1.20.4` gets installed (at the time of writing). See [`Usages.md`](./Usages.md) for details.

#### Ruby

For Ruby management, there is [Ruby Version Manager (RVM)](https://rvm.io/) installed. See available Ruby's with `rvm list`, use particular with `rvm use <ruby_version>`. There are some gems already preinstalled on Rubys available here (like `neovim` gem, or if Puppet is being installed, it installs `puppet` and `puppet-lint` gems).
Expand Down
4 changes: 2 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# TODO

- [ ] fix(playbooks): Analyze shell commands and add missing changed_when/failed_when directives
- [ ] fix(puppet): Go to definition sometimes does not load
- [ ] feat(go): Install GVM (Go Version Manager) and default GO.
- [ ] feat(neovim): Add Vimux keymaps (Telescope?), document usage.
- [ ] feat(neovim): Integrate DirDiff with Nvim Tree, introduce simple shortcuts/marks for diffing two directories.
- [ ] feat(AWS): AWS cli installation/setup
- [ ] docs(gita): Describe `gita` usage and example
- [x] feat(go): Install GVM (Go Version Manager) and default GO.
- [x] fix(vim): Markdown treesitter / LSP not working. Add/replace better plugins.
- [x] fix(ansible): Use the same version in `prepare-ubuntu.sh` which is set in vars.yml
- -[ ] fix(puppet): Go to definition sometimes does not load-: this is tracked in [puppet-editor-services issue #337](https://github.com/puppetlabs/puppet-editor-services/issues/337)
- [x] feat(python): add and use `pyenv`, `pipenv`, use latest Python+Ansible
- [x] feat(kubernetes): install docker, kubectl, k9s, kind
- [x] feat(neovim): Install neovim-ruby-host for all rubies
Expand Down
22 changes: 22 additions & 0 deletions Usages.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This document describes all the tools and features which I find useful for every
* [LazyGit](#lazygit)
* [Languages](#languages)
* [Python](#python)
* [Go](#go)
* [Ruby](#ruby)
* [Java/Gradle/Groovy](#java/gradle/groovy)
* [Tmux](#tmux)
Expand Down Expand Up @@ -284,6 +285,27 @@ To change running version:
- to change default: `pyenv global <version>`
- to change version whenever you are in current directory, use `pyenv local <version>`

#### Go

Automatic installation of Go is done using [`GVM`](https://github.com/moovweb/gvm) - Go Version Manager. By default `go1.20.4` gets installed (at the time of writing).

You can install more Go versions either manually (`gvm install <version>`) or you can add/set your prefered version(s) in `ansible/vars/overrides.yml` (and run the automation):

```yaml
go_versions:
- go1.20.4
go_default: go1.20.4
```
Note that `go_default` value must be in `go_versions` :)

- list installed Go versions: `gvm list`
- list all available Go versions: `gvm listall`
- install: `gvm install <version>`
- uninstall: `gvm uninstall <version>`
- switch to different version: `gvm use <version>`
- switch and set default: `gvm use <version> --default`

#### Ruby

Ruby is managed through [`rvm`](https://github.com/rvm/rvm) (Ruby enVironment Manager). By default, fairly recent version of Ruby is installed (check with `rvm list`).
Expand Down
28 changes: 28 additions & 0 deletions ansible/roles/software/tasks/gvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Install GVM (Go Version Manager)
# Source: https://github.com/moovweb/gvm
---
- name: "[GVM] Install/update GVM"
ansible.builtin.shell: |
set -e -o pipefail
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
register: gvm_install
args:
creates: "{{ ansible_env.HOME }}/.gvm"
executable: /bin/bash

- name: "[GVM] Show GVM install/update info"
ansible.builtin.debug:
msg: "{{ gvm_install.stdout | default('No output was passed from GVM install command') }}"

- name: "[Go] Install Go versions"
ansible.builtin.command: "gvm install {{ goversion }} -B"
args:
creates: "{{ ansible_env.HOME}}/.gvm/environments/{{ goversion }}"
loop: "{{ go_versions }}"
loop_control:
loop_var: goversion

- name: "[Go] Set default to {{ go_default }}"
ansible.builtin.shell: ". {{ ansible_env.HOME }}/.gvm/scripts/gvm; gvm use {{ go_default }} --default"
args:
executable: /bin/bash
14 changes: 14 additions & 0 deletions ansible/roles/software/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,20 @@
- versions
- rust

# GVM
- name: "[Software] Install Go Version Manager"
ansible.builtin.include_tasks:
file: gvm.yml
apply:
tags:
- software
- gvm
when: "'gvm' not in software_tasks_exclude"
tags:
- software
- versions
- gvm

# Ansible PIP
- name: "[Software] Install Ansible"
ansible.builtin.include_tasks:
Expand Down
11 changes: 11 additions & 0 deletions ansible/roles/software/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ default_apt_packages:
- apt-transport-https # Required for Azure CLI
- lsb-release # Required for Azure CLI
- gnupg # Required for Azure CLI
- make # Required for GVM
- binutils # Required for GVM
- bison # Required for GVM
- build-essential # Required for GVM
- mercurial # Required for GVM

# Specific versions for software (github)
# Fixed versions should be set without `v` prefix (e.g: 1.4.3)
github_packages:
Expand Down Expand Up @@ -170,3 +176,8 @@ sdkman_flush_caches_after: []
# Link SDKMAN installed packages
# Reference: https://linux.die.net/man/8/update-alternatives
sdkman_update_alternatives: []

# Go versions installed with GVM
go_versions:
- go1.20.4
go_default: go1.20.4

0 comments on commit 03ae48b

Please sign in to comment.