-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f55b25
commit 07d92e3
Showing
21 changed files
with
277 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# Changelog | ||
|
||
## 1.0.1 | ||
|
||
- add golang role | ||
|
||
## 1.0.0 | ||
|
||
- merge of existing roles to a collection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
become: true | ||
|
||
vars: | ||
golang_version: '1.20.11' | ||
golang_sha256_checksum: 'ced1b5cfd4e8aa7aff5e6a399ed111e5ed2903ee17aaa79ac0c93565fb229776' | ||
|
||
roles: | ||
- role: alphanodes.setup.golang | ||
|
||
post_tasks: | ||
- name: Run go version | ||
ansible.builtin.command: go version | ||
changed_when: false | ||
register: go_version_info | ||
|
||
- name: Show instaled go version | ||
ansible.builtin.debug: | ||
var: go_version_info.stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: instance | ||
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" | ||
command: ${MOLECULE_DOCKER_COMMAND:-""} | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
privileged: true | ||
pre_build_image: true | ||
cgroupns_mode: host | ||
provisioner: | ||
name: ansible | ||
options: | ||
diff: true | ||
config_options: | ||
defaults: | ||
interpreter_python: auto_silent | ||
playbooks: | ||
converge: ${MOLECULE_PLAYBOOK:-converge.yml} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- name: Ensures software_dir exists | ||
ansible.builtin.file: | ||
path: '{{ software_dir }}' | ||
owner: '{{ software_dir_owner | default(omit) }}' | ||
group: '{{ software_dir_group | default(omit) }}' | ||
mode: '{{ software_dir_mode | default(omit) }}' | ||
state: directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Ansible Role: go | ||
|
||
An Ansible Role that installs Go language on Debian and Ubuntu servers. | ||
|
||
## Role Variables | ||
|
||
Available variables can be found in [defaults/main.yml](defaults/main.yml) | ||
|
||
## Example Playbook | ||
|
||
```yaml | ||
- hosts: all | ||
|
||
vars: | ||
golang_version: '1.20.10' | ||
golang_sha256_checksum: d355c5ae3a8f7763c9ec9dc25153aae373958cbcb60dd09e91a8b56c7621b2fc | ||
|
||
roles: | ||
- alphanodes.setup.go | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
|
||
# Go language SDK version number | ||
# use fixed version e.g. '1.20.11' or latest | ||
golang_version: latest | ||
golang_arch: amd64 | ||
|
||
# use it with fixed version | ||
# golang_sha256_checksum: ef79a11aa095a08772d2a69e4f152f897c4e96ee297b0dc20264b7dec2961abe | ||
|
||
# Mirror to download the Go language SDK redistributable package from | ||
golang_mirror: 'https://dl.google.com/go' | ||
|
||
# Base installation directory the Go language SDK distribution | ||
golang_install_dir: '/usr/local/go' | ||
|
||
# create link to /usr/local/bin to go binaries | ||
# NOTE: only if golang_dist_packages = false | ||
golang_link_to_local: true | ||
|
||
golang_link_binaries: | ||
- go | ||
- gofmt | ||
|
||
# Location for GOPATH environment variable | ||
golang_gopath: | ||
|
||
# if true, golang is installed with packages from linux distribution | ||
# (not from golang_mirror) | ||
golang_dist_packages: false | ||
|
||
# only used with golang_dist_packages = true | ||
golang_packages: | ||
- golang-go | ||
- golang-src | ||
|
||
# set it to true, if you want to remove go | ||
golang_remove: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
|
||
dependencies: | ||
- role: alphanodes.setup.common | ||
public: true | ||
|
||
galaxy_info: | ||
description: Install go language. | ||
author: alexandermeindl | ||
company: AlphaNodes GmbH | ||
license: Apache License 2.0 | ||
min_ansible_version: '2.14' | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- focal | ||
- jammy | ||
- name: Debian | ||
versions: | ||
- buster | ||
- bullseye | ||
- bookworm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
|
||
- name: Include setup tasks | ||
ansible.builtin.import_tasks: setup.yml | ||
tags: | ||
- golang | ||
when: not golang_remove | bool | ||
|
||
- name: Include remove tasks | ||
ansible.builtin.import_tasks: remove.yml | ||
tags: | ||
- golang | ||
when: golang_remove | bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
|
||
- name: Remove for non-dist installation | ||
when: not golang_dist_packages | ||
block: | ||
- name: Remove golang files and directories | ||
ansible.builtin.file: | ||
path: '{{ golang_install_dir }}' | ||
state: absent | ||
|
||
- name: Remove links | ||
ansible.builtin.file: | ||
path: "/usr/local/bin/{{ item }}" | ||
state: absent | ||
when: golang_link_to_local | ||
loop: '{{ golang_link_binaries }}' | ||
|
||
- name: Be sure debian packages are removed | ||
ansible.builtin.apt: | ||
name: '{{ golang_packages }}' | ||
purge: true | ||
state: absent | ||
when: golang_dist_packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
|
||
- name: Be sure debian packages are installed - {{ golang_latest_version_url }} | ||
ansible.builtin.apt: | ||
name: '{{ golang_packages }}' | ||
state: present | ||
when: golang_dist_packages | ||
|
||
- name: Install for non-dist installation | ||
when: not golang_dist_packages | ||
block: | ||
- name: Set golang_real_version with latest version | ||
ansible.builtin.set_fact: | ||
golang_real_version: "{{ lookup('url', golang_latest_version_url, wantlist=True) | first }}" | ||
when: golang_version == 'latest' | ||
|
||
- name: Show backup volkstheater | ||
ansible.builtin.debug: | ||
var: golang_real_version | ||
|
||
- name: Set golang_real_version with fixed version | ||
ansible.builtin.set_fact: | ||
golang_real_version: "go{{ golang_version }}" | ||
when: golang_version != 'latest' | ||
|
||
- name: Check golang_file exists - {{ golang_real_version }} | ||
ansible.builtin.stat: | ||
path: '{{ software_dir }}/{{ golang_file }}' | ||
register: golang_file_exists | ||
|
||
- name: Check Go exists | ||
ansible.builtin.stat: | ||
path: '{{ golang_install_dir }}/bin/go' | ||
register: golang_install_dir_exists | ||
|
||
- name: Delete existing path for update - {{ golang_install_dir }} | ||
ansible.builtin.file: | ||
path: '{{ golang_install_dir }}' | ||
state: absent | ||
when: | ||
- not golang_file_exists.stat.exists | ||
- golang_install_dir_exists.stat.exists | ||
|
||
- name: Creating {{ golang_install_dir }} | ||
ansible.builtin.file: | ||
path: '{{ golang_install_dir }}' | ||
state: directory | ||
mode: 0755 | ||
owner: root | ||
group: root | ||
|
||
- name: Download golang_file archive version {{ golang_real_version }} | ||
ansible.builtin.get_url: | ||
url: '{{ golang_mirror }}/{{ golang_file }}' | ||
dest: '{{ software_dir }}/{{ golang_file }}' | ||
mode: 0644 | ||
checksum: "{{ 'sha256:' + golang_sha256_checksum | default(omit) }}" | ||
force: false | ||
use_proxy: true | ||
validate_certs: true | ||
when: not golang_file_exists.stat.exists | ||
|
||
- name: Extract golang_file archive | ||
ansible.builtin.unarchive: | ||
src: '{{ software_dir }}/{{ golang_file }}' | ||
dest: '{{ golang_install_dir }}' | ||
extra_opts: '--strip-components=1' | ||
owner: root | ||
group: root | ||
remote_src: true | ||
when: not golang_install_dir_exists.stat.exists or not golang_file_exists.stat.exists | ||
|
||
- name: Create symlinks to go binaries | ||
ansible.builtin.file: | ||
src: '{{ golang_install_dir }}/bin/{{ item }}' | ||
dest: /usr/local/bin/{{ item }} | ||
force: true | ||
state: link | ||
when: golang_link_to_local | ||
loop: '{{ golang_link_binaries }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
|
||
golang_file: "{{ golang_real_version }}.linux-{{ golang_arch }}.tar.gz" | ||
golang_latest_version_url: https://go.dev/VERSION?m=text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.