docker: Add Ubuntu / Debian support

This commit is contained in:
saibotk 2021-01-02 04:39:35 +01:00
parent b467b81ba1
commit 26a77be80b
No known key found for this signature in database
GPG key ID: A3299C587D5DF523
6 changed files with 157 additions and 40 deletions

View file

@ -6,7 +6,7 @@ This will install [Docker](https://www.docker.com/) from their official reposito
Requirements
------------
You will need to have the EPEL repository enabled (eg. by installing the `epel-release` package).
For CentOS: You will need to have the EPEL repository enabled (eg. by installing the `epel-release` package).
Role Variables
--------------
@ -18,7 +18,7 @@ Role Variables
Dependencies
------------
- epel
- epel (for CentOS)
License
-------

View file

@ -4,6 +4,7 @@
# Infrastructure
# Ansible instructions to deploy the infrastructure
# Copyright (C) 2020 Saibotk
# Copyright (C) 2020 nickjj (https://github.com/nickjj/ansible-docker)
#
# 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
@ -17,6 +18,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Architecture mapping for apt repositories
docker_apt_architecture_map:
"x86_64": "amd64"
"aarch64": "arm64"
"aarch": "arm64"
"armhf": "armhf"
"armv7l": "armhf"
# Edition can be one of: 'ce' (Community Edition) or 'ee' (Enterprise Edition).
docker_edition: 'ce'
@ -28,26 +37,32 @@ docker_package_state: present
docker_service_state: started
docker_service_enabled: true
# Should the official docker repository be installed?
docker_install_repository: true
# The repository settings
# The repository will be added as a yum repository to allow downloading/installing the package
docker_yum_repo_url: https://download.docker.com/linux/centos/docker-{{ docker_edition }}.repo
docker_yum_repo_enable_edge: '0'
docker_yum_repo_enable_test: '0'
# The repository will be added as a repository to allow downloading/installing the package
docker_yum_repository_url: https://download.docker.com/linux/centos/docker-{{ docker_edition }}.repo
docker_yum_repository_destination: /etc/yum.repos.d/docker-{{ docker_edition }}.repo
# Where to fetch the docker repository GPG key from
docker_yum_gpg_key: https://download.docker.com/linux/centos/gpg
docker_yum_repository_gpg_key: https://download.docker.com/linux/centos/gpg
# The apt repository settings
docker_apt_key_id: "9DC858229FC7DD38854AE2D88D81803C0EBFCD88"
docker_apt_key_url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
docker_apt_repository: >
deb [arch={{ docker_apt_architecture_map[ansible_architecture] }}]
https://download.docker.com/linux/{{ ansible_distribution | lower }}
{{ ansible_distribution_release }} stable
# Should the python package for docker be installed via pip?
docker_python_package_install: true
# Where should it be installed? (Note: This will be installed as a standalone without breaking system dependencies)
docker_python_package_path: /opt/ansible-dependencies
# The name of the package to install pip via yum
docker_python_pip_package: "python-pip"
# The package states of needed packages to install for the python libraries
docker_python_pip_package_state: "present"
# The name of the package to install virtualenv via yum
docker_python_virtualenv_package: "python-virtualenv"
docker_python_virtualenv_package_state: "present"
# The pip package name of the docker library

View file

@ -8,8 +8,10 @@ galaxy_info:
- name: CentOS
versions:
- 7
- name: Ubuntu
versions:
- 20.04
galaxy_tags: []
dependencies:
- epel
dependencies: []

View file

@ -0,0 +1,58 @@
---
# Tasks file for the docker 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 <http://www.gnu.org/licenses/>.
- name: Ensure dependencies are installed.
apt:
name:
- apt-transport-https
- ca-certificates
- gnupg2
state: present
become: true
- name: Add Docker GPG key.
apt_key:
id: "{{ docker_apt_key_id }}"
url: "{{ docker_apt_key_url }}"
state: present
when:
- docker_install_repository
become: true
- name: Add Docker repository.
apt_repository:
repo: "{{ docker_apt_repository }}"
update_cache: true
when:
- docker_install_repository
become: true
- name: Ensure pip & virtualenv are installed.
package:
name: "{{ item.name }}"
state: "{{ item.state }}"
loop:
- name: "python3-pip"
state: "{{ docker_python_pip_package_state }}"
- name: "python3-virtualenv"
state: "{{ docker_python_virtualenv_package_state }}"
when:
- docker_python_package_install
become: true

View file

@ -0,0 +1,59 @@
---
# Tasks file for the docker 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 <http://www.gnu.org/licenses/>.
- name: Ensure old versions of Docker are not installed.
package:
name:
- docker
- docker-common
- docker-engine
state: absent
- name: Add Docker GPG key.
rpm_key:
key: "{{ docker_yum_repository_gpg_key }}"
state: present
when:
- docker_install_repository
become: true
- name: Add Docker repository.
get_url:
url: "{{ docker_yum_repository_url }}"
dest: "{{ docker_yum_repository_destination }}"
owner: root
group: root
mode: '0644'
when:
- docker_install_repository
become: true
- name: Ensure pip & virtualenv are installed.
package:
name: "{{ item.name }}"
state: "{{ item.state }}"
loop:
- name: "python-pip"
state: "{{ docker_python_pip_package_state }}"
- name: "python-virtualenv"
state: "{{ docker_python_virtualenv_package_state }}"
when:
- docker_python_package_install
become: true

View file

@ -3,6 +3,7 @@
# Infrastructure
# Ansible instructions to deploy the infrastructure
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
# Copyright (C) 2020 Saibotk
#
# This program is free software: you can redistribute it and/or modify
@ -17,20 +18,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
- name: Add Docker GPG key.
rpm_key:
key: "{{ docker_yum_gpg_key }}"
state: present
become: true
- name: Add Docker repository.
get_url:
url: "{{ docker_yum_repo_url }}"
dest: '/etc/yum.repos.d/docker-{{ docker_edition }}.repo'
owner: root
group: root
mode: '0644'
become: true
- 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.
package:
@ -49,18 +44,6 @@
- name: Ensure handlers are notified now to avoid firewall conflicts.
meta: flush_handlers
- name: Ensure pip & virtualenv is installed.
package:
name: "{{ item.name }}"
state: "{{ item.state }}"
become: true
loop:
- name: "{{ docker_python_pip_package }}"
state: "{{ docker_python_pip_package_state }}"
- name: "{{ docker_python_virtualenv_package }}"
state: "{{ docker_python_virtualenv_package_state }}"
when: docker_python_package_install
- name: Install docker python package.
pip:
name: "{{ docker_pip_package }}"