Skip to content

darkwizard242/ansible-role-go

Repository files navigation

[build-test release Ansible Role Ansible Role Ansible Quality Score Quality Gate Status Maintainability Rating Reliability Rating Security Rating GitHub tag (latest SemVer) GitHub repo size

Ansible Role: go

Role to install (by default) go programming language on Debian/Ubuntu and EL systems.

Requirements

None.

Role Variables

Available variables are listed below (located in defaults/main.yml):

Variables list:

go_app: go
go_setup: true
go_version: 1.22.2
go_os: linux
go_arch: amd64
go_dl_url: "https://dl.google.com/{{ go_app }}/{{ go_app }}{{ go_version }}.{{ go_osarch }}.tar.gz"
go_bin_path: /usr/local
go_profile_template_export_line: "{{ go_bin_path}}/go/bin"
go_profile_template_path: /etc/profile.d
go_profile_template_source_file: go.j2
go_profile_template_dest_file: go.sh

Variables table:

Variable Description
go_app Defines the app to install i.e. go
go_setup Boolean variable that only allows true or false values. Defaults to true. When set to true it will setup/install go. When set to false, it will remove go from the system - assuming it was installed via this role and value for go_bin_path path is correct.
go_version Defined to dynamically fetch the desired version to install. Defaults to: 1.22.2
go_os Defines OS type. Used for obtaining the correct type of binaries based on OS. Defaults to: linux
go_arch Defines Architecture type. Used for obtaining the correct type of binaries based on Architecture. Defaults to: amd64
go_dl_url Defines URL to download the go binary from.
go_bin_path Defined to dynamically set the appropriate path to store go binary into. Defaults to: /usr/local - which is sourced using a handler.
go_profile_template_export_line Defined to set the line for export to path within a custom file generated into /etc/profile.d directory.
go_profile_template_path Directory in which to generate go's PATH export template to.
go_profile_template_source_file Source template file for export of go's binary into PATH.
go_profile_template_dest_file Destination filename that will be placed in /etc/profile.d with go's PATH export as.

Dependencies

None

Example Playbook

For default behaviour of role (i.e. installation of go) in ansible playbooks.

- hosts: servers
  roles:
    - darkwizard242.go

For customizing behavior of role (i.e. specifying the desired go version) in ansible playbooks.

- hosts: servers
  roles:
    - darkwizard242.go
  vars:
    go_version: 1.14.0
    go_setup: true

For customizing behavior of role (i.e. placing binary of go package in different location) in ansible playbooks.

- hosts: servers
  roles:
    - darkwizard242.go
  vars:
    go_bin_path: /bin/

License

MIT

Author Information

This role was created by Ali Muhammad.