Skip to content

Instantly share code, notes, and snippets.

@mtelvers
Created April 1, 2025 16:41
Show Gist options
  • Select an option

  • Save mtelvers/ced9d981b9137c491c95780390ce802c to your computer and use it in GitHub Desktop.

Select an option

Save mtelvers/ced9d981b9137c491c95780390ce802c to your computer and use it in GitHub Desktop.
Upgrade to the latest Go and Docker on Ubuntu
- hosts: all
vars:
go_version: 1.24.1
tasks:
- name: apt packages
apt:
name:
- docker.io
- golang
state: present
- name: remove /usr/lib/go
file:
path: /usr/lib/go
follow: false
state: absent
- name: Extract go {{ go_version }}
unarchive:
src: https://go.dev/dl/go{{ go_version }}.linux-riscv64.tar.gz
dest: /usr/lib
remote_src: yes
creates: /usr/lib/go-{{ go_version}}
extra_opts:
- --transform
- s/^go/go-{{ go_version }}/
- name: Create a symbolic link go -> go-{{ go_version }}
ansible.builtin.file:
src: go-{{ go_version }}
dest: /usr/lib/go
state: link
- name: Create a symbolic link go -> go-{{ go_version }}
ansible.builtin.file:
src: ../lib/go-{{ go_version }}/bin/go
dest: /usr/bin/go
state: link
- name: checkout moby
git:
repo: https://github.com/moby/moby
dest: /root/moby
register: moby
- name: build and install moby
shell: |
AUTO_GOPATH=1 ./hack/make.sh binary
install bundles/binary-daemon/docker /usr/bin
install bundles/binary-daemon/dockerd /usr/bin
install bundles/binary-daemon/docker-proxy /usr/bin
args:
chdir: /root/moby
when: moby.changed
- name: Restart service docker
service:
name: docker
state: restarted
when: moby.changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment