39 lines
1.1 KiB
YAML
39 lines
1.1 KiB
YAML
- name: Determine the architecture
|
|
command: dpkg --print-architecture
|
|
register: buildx_arch
|
|
changed_when: false
|
|
|
|
- name: Get the latest Docker Buildx version
|
|
shell: >
|
|
curl -s https://api.github.com/repos/docker/buildx/releases/latest |
|
|
grep "tag_name" |
|
|
cut -d '"' -f 4
|
|
register: buildx_version
|
|
changed_when: false
|
|
|
|
- name: Fail if version is not found
|
|
fail:
|
|
msg: "Failed to fetch the latest Docker Buildx version. Exiting."
|
|
when: buildx_version.stdout == ""
|
|
|
|
- name: Define the directory for Docker plugins
|
|
set_fact:
|
|
plugins_dir: "/home/{{ user }}/.docker/cli-plugins"
|
|
|
|
- name: Create the plugins directory
|
|
file:
|
|
path: "{{ plugins_dir }}"
|
|
state: directory
|
|
|
|
- name: Download and install Docker Buildx
|
|
ansible.builtin.get_url:
|
|
url: "https://github.com/docker/buildx/releases/download/{{ buildx_version.stdout }}/buildx-{{ buildx_version.stdout }}.linux-{{ buildx_arch.stdout }}"
|
|
dest: "{{ plugins_dir }}/docker-buildx"
|
|
mode: '0755'
|
|
owner: 1000
|
|
group: 1000
|
|
|
|
- name: Make Docker Buildx executable
|
|
command: chmod +x "{{ plugins_dir }}/docker-buildx"
|
|
args:
|
|
creates: "{{ plugins_dir }}/docker-buildx" |