From 04049302586e504ee1ab187dee22405983d5c89c Mon Sep 17 00:00:00 2001 From: Prakasa Date: Tue, 26 Aug 2025 06:17:01 +0700 Subject: [PATCH 1/2] fix: add new tasks, install missing deps --- tasks/deps-debian.yml | 5 +++++ tasks/deps-redhat.yml | 4 ++++ tasks/main.yml | 7 +++++++ vars/debian-11.yml | 2 ++ vars/debian-12.yml | 2 ++ vars/debian.yml | 2 ++ vars/ubuntu-22.yml | 2 ++ vars/ubuntu-24.yml | 2 ++ vars/ubuntu.yml | 2 ++ 9 files changed, 28 insertions(+) create mode 100644 tasks/deps-debian.yml create mode 100644 tasks/deps-redhat.yml diff --git a/tasks/deps-debian.yml b/tasks/deps-debian.yml new file mode 100644 index 0000000..1d31815 --- /dev/null +++ b/tasks/deps-debian.yml @@ -0,0 +1,5 @@ +--- +- name: Install prerequisite packages + ansible.builtin.apt: + name: "{{ dependency_packages }}" + state: present \ No newline at end of file diff --git a/tasks/deps-redhat.yml b/tasks/deps-redhat.yml new file mode 100644 index 0000000..e897bfe --- /dev/null +++ b/tasks/deps-redhat.yml @@ -0,0 +1,4 @@ +- name: Install prerequisite packages + ansible.builtin.package: + name: "{{ dependency_packages }}" + state: present \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index a3ca5fc..ce3c221 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,6 +16,13 @@ tags: - always +- name: Print variables + debug: + msg: "{{ ansible_os_family }}" + +- ansible.builtin.include_tasks: deps-{{ ansible_os_family | lower }}.yml + when: ansible_os_family in ['RedHat', 'Debian', 'Archlinux'] # supported os family + - name: Gather the package facts ansible.builtin.package_facts: manager: auto diff --git a/vars/debian-11.yml b/vars/debian-11.yml index c0aa297..e0aa8b0 100644 --- a/vars/debian-11.yml +++ b/vars/debian-11.yml @@ -1,3 +1,5 @@ --- docker_ip_nft_tables_packages: iptables: "iptables" +dependency_packages: + - python3-apt \ No newline at end of file diff --git a/vars/debian-12.yml b/vars/debian-12.yml index c0aa297..e0aa8b0 100644 --- a/vars/debian-12.yml +++ b/vars/debian-12.yml @@ -1,3 +1,5 @@ --- docker_ip_nft_tables_packages: iptables: "iptables" +dependency_packages: + - python3-apt \ No newline at end of file diff --git a/vars/debian.yml b/vars/debian.yml index c0aa297..e0aa8b0 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -1,3 +1,5 @@ --- docker_ip_nft_tables_packages: iptables: "iptables" +dependency_packages: + - python3-apt \ No newline at end of file diff --git a/vars/ubuntu-22.yml b/vars/ubuntu-22.yml index c0aa297..e0aa8b0 100644 --- a/vars/ubuntu-22.yml +++ b/vars/ubuntu-22.yml @@ -1,3 +1,5 @@ --- docker_ip_nft_tables_packages: iptables: "iptables" +dependency_packages: + - python3-apt \ No newline at end of file diff --git a/vars/ubuntu-24.yml b/vars/ubuntu-24.yml index c0aa297..e0aa8b0 100644 --- a/vars/ubuntu-24.yml +++ b/vars/ubuntu-24.yml @@ -1,3 +1,5 @@ --- docker_ip_nft_tables_packages: iptables: "iptables" +dependency_packages: + - python3-apt \ No newline at end of file diff --git a/vars/ubuntu.yml b/vars/ubuntu.yml index c0aa297..e0aa8b0 100644 --- a/vars/ubuntu.yml +++ b/vars/ubuntu.yml @@ -1,3 +1,5 @@ --- docker_ip_nft_tables_packages: iptables: "iptables" +dependency_packages: + - python3-apt \ No newline at end of file From d0ca5c070f325f3d41a035933b6a0ba10bbcd1a5 Mon Sep 17 00:00:00 2001 From: Prakasa Date: Fri, 3 Apr 2026 12:11:57 +0700 Subject: [PATCH 2/2] feat: support to install docker compose as docker CLI plugins --- defaults/main.yml | 13 ++++++------- tasks/docker-compose-plugin.yml | 10 ++++++++++ ...er-compose.yml => docker-compose-standalone.yml} | 0 tasks/main.yml | 8 ++------ 4 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 tasks/docker-compose-plugin.yml rename tasks/{docker-compose.yml => docker-compose-standalone.yml} (100%) diff --git a/defaults/main.yml b/defaults/main.yml index d956065..0037584 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -62,15 +62,14 @@ docker_ca_certificates_src_dir: "{{ '~/docker-ca-certificates' | expanduser }}" # certificate files (besides other locations). docker_ca_certificates_dst_dir: "/usr/local/share/ca-certificates" -# Currently only "standalone" is supported. So that means on the remote host -# "docker-compose" command will be available and not the "docker compose" -# plugin (without "-"). -# When commented no "docker-compose" will be installed and all "docker_compose_*" -# variables are ignored. -# docker_compose_type: "standalone" +# 2 kind of compose installation are supported (standalone to support legacy environments): +# - standalone: The standalone "docker-compose" binary. This is the old way to use "docker-compose". The binary is called "docker-compose" and is installed in a directory defined by `docker_compose_bin_directory` variable. This is the default value for `docker_compose_type` variable. +# - plugin: The "docker compose" plugin for "docker" CLI. This is the new way to use "docker-compose". The binary is called "docker-compose" and is installed in "/usr/local/lib/docker/cli-plugins/docker-compose". This is the recommended way to use "docker-compose" and is the default value for `docker_compose_type` variable. +# When commented no "docker-compose" will be installed and all "docker_compose_*" variables will be ignored. +docker_compose_type: "plugin" # "docker-compose" version -docker_compose_version: "2.38.2" +docker_compose_version: "5.1.1" # The directory where to "docker-compose" binary will be installed docker_compose_bin_directory: "/usr/local/bin" diff --git a/tasks/docker-compose-plugin.yml b/tasks/docker-compose-plugin.yml new file mode 100644 index 0000000..1086d60 --- /dev/null +++ b/tasks/docker-compose-plugin.yml @@ -0,0 +1,10 @@ +--- + +- name: Downloading docker compose plugins binary v2 and make exec + ansible.builtin.get_url: + url: "https://github.com/docker/compose/releases/download/v{{ docker_compose_version }}/docker-compose-{{ ansible_system | lower }}-{{ ansible_architecture }}" + dest: "/usr/local/lib/docker/cli-plugins/docker-compose" + mode: "{{ docker_compose_bin_file_perm }}" + owner: "{{ docker_compose_bin_owner }}" + group: "{{ docker_compose_bin_group }}" + checksum: "sha256:https://github.com/docker/compose/releases/download/v{{ docker_compose_version }}/docker-compose-{{ ansible_system | lower }}-{{ ansible_architecture }}.sha256" \ No newline at end of file diff --git a/tasks/docker-compose.yml b/tasks/docker-compose-standalone.yml similarity index 100% rename from tasks/docker-compose.yml rename to tasks/docker-compose-standalone.yml diff --git a/tasks/main.yml b/tasks/main.yml index ce3c221..4b88cb5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,10 +16,6 @@ tags: - always -- name: Print variables - debug: - msg: "{{ ansible_os_family }}" - - ansible.builtin.include_tasks: deps-{{ ansible_os_family | lower }}.yml when: ansible_os_family in ['RedHat', 'Debian', 'Archlinux'] # supported os family @@ -180,9 +176,9 @@ - name: Install docker-compose binary when: - - docker_compose_type is defined + - docker_compose_type is defined and docker_compose_type in ['standalone', 'plugin'] ansible.builtin.include_tasks: - file: "tasks/docker-compose.yml" + file: "tasks/docker-compose-{{ docker_compose_type }}.yml" apply: tags: - docker-compose