From 23d7bc1fcb4c51216d8b6c1cd9ddc79e21fd0fc5 Mon Sep 17 00:00:00 2001 From: saibotk Date: Sat, 2 Jan 2021 04:41:33 +0100 Subject: [PATCH] docker_compose: Add Ubuntu / Debian support --- roles/docker_compose/defaults/main.yml | 6 +---- roles/docker_compose/meta/main.yml | 3 +++ roles/docker_compose/tasks/Debian.yml | 32 ++++++++++++++++++++++++++ roles/docker_compose/tasks/RedHat.yml | 32 ++++++++++++++++++++++++++ roles/docker_compose/tasks/main.yml | 19 +++++++-------- 5 files changed, 76 insertions(+), 16 deletions(-) create mode 100644 roles/docker_compose/tasks/Debian.yml create mode 100644 roles/docker_compose/tasks/RedHat.yml diff --git a/roles/docker_compose/defaults/main.yml b/roles/docker_compose/defaults/main.yml index 03c9098..74f1732 100644 --- a/roles/docker_compose/defaults/main.yml +++ b/roles/docker_compose/defaults/main.yml @@ -32,12 +32,8 @@ docker_compose_wrapper_path: /usr/local/bin/docker-compose docker_compose_python_package_install: true docker_compose_python_package_path: /opt/ansible-dependencies -# The name of the package to install pip via the package manager -docker_compose_python_pip_package: "python-pip" +# The package states of needed packages to install for the python libraries docker_compose_python_pip_package_state: "present" - -# The name of the package to install virtualenv via the package manager -docker_compose_python_virtualenv_package: "python-virtualenv" docker_compose_python_virtualenv_package_state: "present" # The pip package name of for `docker-compose` diff --git a/roles/docker_compose/meta/main.yml b/roles/docker_compose/meta/main.yml index fc9e611..9574af7 100644 --- a/roles/docker_compose/meta/main.yml +++ b/roles/docker_compose/meta/main.yml @@ -8,6 +8,9 @@ galaxy_info: - name: CentOS versions: - 7 + - name: Ubuntu + versions: + - 20.04 galaxy_tags: [] diff --git a/roles/docker_compose/tasks/Debian.yml b/roles/docker_compose/tasks/Debian.yml new file mode 100644 index 0000000..c7293d8 --- /dev/null +++ b/roles/docker_compose/tasks/Debian.yml @@ -0,0 +1,32 @@ +--- +# Tasks file for the docker_compose role + +# Infrastructure +# Ansible instructions to deploy the infrastructure +# +# Copyright (C) 2020 Saibotk +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +- name: Ensure pip & virtualenv are installed. + package: + name: "{{ item.name }}" + state: "{{ item.state }}" + loop: + - name: "python3-pip" + state: "{{ docker_compose_python_pip_package_state }}" + - name: "python3-virtualenv" + state: "{{ docker_compose_python_virtualenv_package_state }}" + when: + - docker_compose_python_package_install + become: true diff --git a/roles/docker_compose/tasks/RedHat.yml b/roles/docker_compose/tasks/RedHat.yml new file mode 100644 index 0000000..ef17f33 --- /dev/null +++ b/roles/docker_compose/tasks/RedHat.yml @@ -0,0 +1,32 @@ +--- +# Tasks file for the docker_compose role + +# Infrastructure +# Ansible instructions to deploy the infrastructure +# +# Copyright (C) 2020 Saibotk +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +- name: Ensure pip & virtualenv are installed. + package: + name: "{{ item.name }}" + state: "{{ item.state }}" + loop: + - name: "python-pip" + state: "{{ docker_compose_python_pip_package_state }}" + - name: "python-virtualenv" + state: "{{ docker_compose_python_virtualenv_package_state }}" + when: + - docker_compose_python_package_install + become: true diff --git a/roles/docker_compose/tasks/main.yml b/roles/docker_compose/tasks/main.yml index 45898cb..da96dec 100644 --- a/roles/docker_compose/tasks/main.yml +++ b/roles/docker_compose/tasks/main.yml @@ -23,17 +23,14 @@ state: "{{ docker_compose_package_state }}" become: true -- name: Ensure pip & virtualenv is installed. - package: - name: "{{ item.name }}" - state: "{{ item.state }}" - become: true - loop: - - name: "{{ docker_compose_python_pip_package }}" - state: "{{ docker_compose_python_pip_package_state }}" - - name: "{{ docker_compose_python_virtualenv_package }}" - state: "{{ docker_compose_python_virtualenv_package_state }}" - when: docker_compose_python_package_install +- name: "Select tasks for {{ ansible_distribution }} {{ ansible_distribution_major_version }}" + include_tasks: "{{ distro_file }}" + with_first_found: + - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml" + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" + loop_control: + loop_var: distro_file - name: Install docker-compose python package. pip: