From 32be2d9067c9da8e0e7d8a5f914e5614bb8e9aab Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 3 Feb 2023 14:23:49 +1100 Subject: [PATCH] ensure-skopeo: add install from upstream option To test current buildx we need a later skopeo that understands the OCI manifest formats. c.f. the zuul-executor image updates with Iab667a92a5b6e6f8591db2aa435a782913d9d34f. A recent enough version (1.9) isn't packaged for any LTS distros. So add an upstream option, but it's only implemented (for now) on Jammy, where we will test with it. Change-Id: I206a3cbfb16575f409771d96c2b7e49929e61a49 --- roles/ensure-skopeo/README.rst | 16 ++++++++ roles/ensure-skopeo/defaults/main.yaml | 2 + roles/ensure-skopeo/tasks/Ubuntu-22.04.yaml | 44 ++++++++++++++++++++- test-playbooks/ensure-skopeo/main.yaml | 7 ++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 roles/ensure-skopeo/defaults/main.yaml diff --git a/roles/ensure-skopeo/README.rst b/roles/ensure-skopeo/README.rst index 3f7f44aac..4ad4fea34 100644 --- a/roles/ensure-skopeo/README.rst +++ b/roles/ensure-skopeo/README.rst @@ -1 +1,17 @@ Install skopeo + +**Role Variables** + +.. zuul:rolevar:: ensure_skopeo_install_from_upstream + :default: false + + Build and install skopeo from upstream. This installs a go + development environment and build dependencies. The binary is + installed into ``/usr/local/bin``. + + Currently only implemented for Ubuntu Jammy + +.. zuul:rolevar:: ensure_skopeo_install_from_upstream_version + :default: v1.9.3 + + When building skoepo locally, the version tag to use. diff --git a/roles/ensure-skopeo/defaults/main.yaml b/roles/ensure-skopeo/defaults/main.yaml new file mode 100644 index 000000000..ad4385db1 --- /dev/null +++ b/roles/ensure-skopeo/defaults/main.yaml @@ -0,0 +1,2 @@ +ensure_skopeo_install_from_upstream: false +ensure_skopeo_install_from_upstream_version: 'v1.9.3' diff --git a/roles/ensure-skopeo/tasks/Ubuntu-22.04.yaml b/roles/ensure-skopeo/tasks/Ubuntu-22.04.yaml index 4c27227d7..a95fd24c4 100644 --- a/roles/ensure-skopeo/tasks/Ubuntu-22.04.yaml +++ b/roles/ensure-skopeo/tasks/Ubuntu-22.04.yaml @@ -1,7 +1,49 @@ -- name: Install skopeo +- name: Install skopeo from packages + when: not ensure_skopeo_install_from_upstream package: name: - skopeo - uidmap state: present become: yes + +- name: Install skopeo from upstream + when: ensure_skopeo_install_from_upstream + block: + + - name: Install dependencies + become: yes + package: + name: + - libgpgme-dev + - libassuan-dev + - libbtrfs-dev + - libdevmapper-dev + - pkg-config + - build-essential + - golang + state: present + + - name: Clone upstream source + git: + repo: https://github.com/containers/skopeo + dest: '{{ ansible_user_dir }}/skopeo' + version: '{{ ensure_skopeo_install_from_upstream_version }}' + + - name: Build skopeo + command: 'make bin/skopeo' + args: + chdir: '{{ ansible_user_dir }}/skopeo' + + - name: Install binary + become: yes + copy: + src: '{{ ansible_user_dir}}/skopeo/bin/skopeo' + dest: '/usr/local/bin/skopeo' + owner: root + group: root + mode: '0755' + remote_src: yes + + - name: Test binary + command: '/usr/local/bin/skopeo --version' diff --git a/test-playbooks/ensure-skopeo/main.yaml b/test-playbooks/ensure-skopeo/main.yaml index 7e37837f7..b928b85e4 100644 --- a/test-playbooks/ensure-skopeo/main.yaml +++ b/test-playbooks/ensure-skopeo/main.yaml @@ -5,6 +5,13 @@ - hosts: all tasks: + - name: Additionally test from source on Ubuntu 22.04 + when: ansible_distribution_release == 'jammy' + include_role: + name: ensure-skopeo + vars: + ensure_skopeo_install_from_upstream: true + - name: Exercise skopeo command: /usr/bin/skopeo -v register: output