diff --git a/README.md b/README.md index 94390ae..2178ddb 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,12 @@ You can control whether the package is installed, uninstalled, or at the latest Variables to control the state of the `docker` service, and whether it should start on boot. If you're installing Docker inside a Docker container without systemd or sysvinit, you should set `docker_service_manage` to `false`. + docker_install_compose_plugin: false + docker_compose_package: docker-compose-plugin + docker_compose_package_state: present + +Docker Compose Plugin installation options. These differ from the below in that docker-compose is installed as a docker plugin (and used with `docker compose`) instead of a standalone binary. + docker_install_compose: true docker_compose_version: "1.26.0" docker_compose_arch: x86_64 diff --git a/defaults/main.yml b/defaults/main.yml index 4c4b9a2..21fd4a9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -10,6 +10,11 @@ docker_service_state: started docker_service_enabled: true docker_restart_handler_state: restarted +# Docker Compose Plugin options. +docker_install_compose_plugin: false +docker_compose_package: docker-compose-plugin +docker_compose_package_state: present + # Docker Compose options. docker_install_compose: true docker_compose_version: "v2.4.1" diff --git a/tasks/main.yml b/tasks/main.yml index cc2de4a..842e0e2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -22,6 +22,23 @@ ignore_errors: "{{ ansible_check_mode }}" when: "ansible_version.full is version_compare('2.12', '>=') and ansible_os_family in ['RedHat', 'Debian']" +- name: Install docker-compose plugin. + package: + name: "{{ docker_compose_package }}" + state: "{{ docker_compose_package_state }}" + notify: restart docker + ignore_errors: "{{ ansible_check_mode }}" + when: "docker_install_compose_plugin | bool == true and (ansible_version.full is version_compare('2.12', '<') or ansible_os_family not in ['RedHat', 'Debian'])" + +- name: Install docker-compose-plugin (with downgrade option). + package: + name: "{{ docker_compose_package }}" + state: "{{ docker_compose_package_state }}" + allow_downgrade: true + notify: restart docker + ignore_errors: "{{ ansible_check_mode }}" + when: "docker_install_compose_plugin | bool == true and ansible_version.full is version_compare('2.12', '>=') and ansible_os_family in ['RedHat', 'Debian']" + - name: Ensure /etc/docker/ directory exists. file: path: /etc/docker