From a4ec35e5b38c470966de70910d356db0f61ff3e0 Mon Sep 17 00:00:00 2001 From: Matthew Stobbs Date: Tue, 11 Feb 2025 20:22:42 -0700 Subject: [PATCH] move a lot of configuration around --- tasks/src/go.yml | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tasks/src/go.yml diff --git a/tasks/src/go.yml b/tasks/src/go.yml new file mode 100644 index 0000000..598837e --- /dev/null +++ b/tasks/src/go.yml @@ -0,0 +1,52 @@ +# vim: set filetype=yaml.ansible : +--- +- name: check go version + ansible.builtin.command: + cmd: "go version" + register: r_go_version + ignore_errors: true + +- name: install/update go + block: + - name: set go arch + ansible.builtin.set_fact: + arch: "{{ pkgconfig_go.archmap[ansible_architecture] }}" + + - name: set go archive filename + ansible.builtin.set_fact: + go_archive: "go{{ pkgconfig_go.version }}.{{ ansible_system | lower }}-{{ arch }}.{{ pkgconfig_go.extmap[ansible_system] }}" + + - name: create temp path + ansible.builtin.tempfile: + state: directory + prefix: go_dl. + register: d_go_dl_tmp + + - name: download go archive + become: true + ansible.builtin.get_url: + dest: "{{ d_go_dl_tmp.path }}/{{ go_archive }}" + url: "https://go.dev/dl/{{ go_archive }}" + checksum: "{{ pkgconfig_go.sums[pkgconfig_go.version][ansible_system][arch] }}" + decompress: false + + - name: ensure go install dir exists + become: true + ansible.builtin.file: + path: "{{ pkgconfig_go.install_path }}" + state: directory + + - name: extract go package + ansible.builtin.unarchive: + dest: "{{ pkgconfig_go.install_path }}" + src: "{{ d_go_dl_tmp.path }}/{{ go_archive }}" + remote_src: true + when: ansible_system == 'Linux' + become: true + + - name: install go macOS use pkg file + ansible.builtin.command: + cmd: "installer -pkg {{ d_go_dl_tmp.path }}/{{ go_archive }} -target /" + when: ansible_system == 'Darwin' + become: true + when: pkgconfig_go.version not in r_go_version.stdout