63 lines
1.7 KiB
YAML
63 lines
1.7 KiB
YAML
- block:
|
|
# TODO Check if and how you can get SHA256 checksum dynamically
|
|
- name: Download golang archive
|
|
get_url:
|
|
url: "{{ golang_dl_link }}.tar.gz"
|
|
dest: "/tmp/go{{ golang_version }}.linux-{{ golang_arch }}.tar.gz"
|
|
register: _download_archive
|
|
until: _download_archive is succeeded
|
|
retries: 5
|
|
delay: 2
|
|
|
|
- name: "Create data directory"
|
|
file:
|
|
path: "{{ golang_home }}"
|
|
state: directory
|
|
owner: "root"
|
|
group: "root"
|
|
mode: 'u=rwX,g=rX,o='
|
|
recurse: true
|
|
|
|
- name: Unpack golang binary
|
|
unarchive:
|
|
remote_src: yes
|
|
src: "/tmp/go{{ golang_version }}.linux-{{ golang_arch }}.tar.gz"
|
|
dest: "{{ golang_home }}"
|
|
mode: 0755
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Create go symlink
|
|
file:
|
|
src: "{{ golang_home }}/go/bin/go"
|
|
dest: "/usr/local/bin/go"
|
|
state: link
|
|
|
|
- name: Create gofmt symlink
|
|
file:
|
|
src: "{{ golang_home }}/go/bin/gofmt"
|
|
dest: "/usr/local/bin/gofmt"
|
|
state: link
|
|
|
|
- block:
|
|
- name: Delete all files
|
|
file:
|
|
path: "/var/lib/go/{{ golang_active_version }}"
|
|
state: "absent"
|
|
|
|
# - name: Load old files
|
|
# find:
|
|
# paths: "/var/lib/go/{{ golang_active_version }}"
|
|
# recurse: true
|
|
# hidden: true
|
|
# file_type: any
|
|
# register: files_to_delete
|
|
|
|
# - name: Delete old files
|
|
# file:
|
|
# path: "{{ item.path }}"
|
|
# state: absent
|
|
# with_items: "{{ files_to_delete.files }}"
|
|
when: golang_delete_old|bool
|
|
when: (not golang_version_check|bool) or (golang_active_version != golang_version)
|