summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2025-09-02 18:52:42 +0200
committerAhmed Abdelhalim <[email protected]>2025-09-02 18:52:42 +0200
commite1d3cc942662a132d8a86d3211857ab5e92d296e (patch)
treeee462edd2b3ff911275d5bcbd4a9b00285c889ac
parent9c775d0d9ceb52b74d44decfb8757b7750969750 (diff)
Initial go role draft implementation
-rw-r--r--roles/go/defaults/main.yml5
-rw-r--r--roles/go/meta/argument_specs.yml12
-rw-r--r--roles/go/meta/main.yml19
-rw-r--r--roles/go/tasks/main.yml25
4 files changed, 61 insertions, 0 deletions
diff --git a/roles/go/defaults/main.yml b/roles/go/defaults/main.yml
new file mode 100644
index 00000000..9f2cae76
--- /dev/null
+++ b/roles/go/defaults/main.yml
@@ -0,0 +1,5 @@
+---
+go_global_version: "1.23"
+go_versions:
+ - "1.21"
+ - "1.23"
diff --git a/roles/go/meta/argument_specs.yml b/roles/go/meta/argument_specs.yml
new file mode 100644
index 00000000..4f8cebe7
--- /dev/null
+++ b/roles/go/meta/argument_specs.yml
@@ -0,0 +1,12 @@
+---
+argument_specs:
+ main:
+ options:
+ go_global_version:
+ type: "str"
+ description: "The go global version to use"
+ go_versions:
+ type: "list"
+ description: "The go versions to install"
+ elements: "str"
+ default: []
diff --git a/roles/go/meta/main.yml b/roles/go/meta/main.yml
new file mode 100644
index 00000000..17484257
--- /dev/null
+++ b/roles/go/meta/main.yml
@@ -0,0 +1,19 @@
+---
+dependencies:
+ - role: "homebrew"
+galaxy_info:
+ author: "a14m"
+ description: "Install Go (versions) on Linux distributions"
+ company: "kartoffeln.work GmbH."
+ license: "MIT"
+ min_ansible_version: "2.18"
+ platforms:
+ - name: "ArchLinux"
+ versions:
+ - "all"
+ - name: "Ubuntu"
+ versions:
+ - "noble"
+ - name: "Debian"
+ versions:
+ - "bookworm"
diff --git a/roles/go/tasks/main.yml b/roles/go/tasks/main.yml
new file mode 100644
index 00000000..27515584
--- /dev/null
+++ b/roles/go/tasks/main.yml
@@ -0,0 +1,25 @@
+---
+- name: "Add Go to shell profile"
+ ansible.builtin.blockinfile:
+ path: "{{ ansible_env.HOME }}/.bashrc"
+ state: "present"
+ prepend_newline: true
+ append_newline: true
+ marker: "# ==== {mark} ANSIBLE GO CONFIG"
+ block: |
+ if command -v go 1>/dev/null 2>&1; then
+ export PATH="$HOME/go/bin:$PATH"
+ fi
+
+- name: "Instal Go versions"
+ community.general.homebrew:
+ name:
+ - "go@{{ item }}"
+ with_items: "{{ go_versions }}"
+
+- name: "Set global go version"
+ ansible.builtin.command:
+ cmd: "brew link go@{{ go_global_version }}"
+ environment:
+ PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
+ changed_when: false