docker: Add Ubuntu / Debian support
This commit is contained in:
parent
b467b81ba1
commit
26a77be80b
6 changed files with 157 additions and 40 deletions
|
@ -6,7 +6,7 @@ This will install [Docker](https://www.docker.com/) from their official reposito
|
||||||
Requirements
|
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
|
Role Variables
|
||||||
--------------
|
--------------
|
||||||
|
@ -18,7 +18,7 @@ Role Variables
|
||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
|
||||||
- epel
|
- epel (for CentOS)
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
# Infrastructure
|
# Infrastructure
|
||||||
# Ansible instructions to deploy the infrastructure
|
# Ansible instructions to deploy the infrastructure
|
||||||
# Copyright (C) 2020 Saibotk
|
# 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
|
# 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
|
# 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
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# 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).
|
# Edition can be one of: 'ce' (Community Edition) or 'ee' (Enterprise Edition).
|
||||||
docker_edition: 'ce'
|
docker_edition: 'ce'
|
||||||
|
|
||||||
|
@ -28,26 +37,32 @@ docker_package_state: present
|
||||||
docker_service_state: started
|
docker_service_state: started
|
||||||
docker_service_enabled: true
|
docker_service_enabled: true
|
||||||
|
|
||||||
|
# Should the official docker repository be installed?
|
||||||
|
docker_install_repository: true
|
||||||
|
|
||||||
# The repository settings
|
# The repository settings
|
||||||
# The repository will be added as a yum repository to allow downloading/installing the package
|
# The repository will be added as a repository to allow downloading/installing the package
|
||||||
docker_yum_repo_url: https://download.docker.com/linux/centos/docker-{{ docker_edition }}.repo
|
docker_yum_repository_url: https://download.docker.com/linux/centos/docker-{{ docker_edition }}.repo
|
||||||
docker_yum_repo_enable_edge: '0'
|
docker_yum_repository_destination: /etc/yum.repos.d/docker-{{ docker_edition }}.repo
|
||||||
docker_yum_repo_enable_test: '0'
|
|
||||||
|
|
||||||
# Where to fetch the docker repository GPG key from
|
# 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?
|
# Should the python package for docker be installed via pip?
|
||||||
docker_python_package_install: true
|
docker_python_package_install: true
|
||||||
# Where should it be installed? (Note: This will be installed as a standalone without breaking system dependencies)
|
# Where should it be installed? (Note: This will be installed as a standalone without breaking system dependencies)
|
||||||
docker_python_package_path: /opt/ansible-dependencies
|
docker_python_package_path: /opt/ansible-dependencies
|
||||||
|
|
||||||
# The name of the package to install pip via yum
|
# The package states of needed packages to install for the python libraries
|
||||||
docker_python_pip_package: "python-pip"
|
|
||||||
docker_python_pip_package_state: "present"
|
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"
|
docker_python_virtualenv_package_state: "present"
|
||||||
|
|
||||||
# The pip package name of the docker library
|
# The pip package name of the docker library
|
||||||
|
|
|
@ -8,8 +8,10 @@ galaxy_info:
|
||||||
- name: CentOS
|
- name: CentOS
|
||||||
versions:
|
versions:
|
||||||
- 7
|
- 7
|
||||||
|
- name: Ubuntu
|
||||||
|
versions:
|
||||||
|
- 20.04
|
||||||
|
|
||||||
galaxy_tags: []
|
galaxy_tags: []
|
||||||
|
|
||||||
dependencies:
|
dependencies: []
|
||||||
- epel
|
|
||||||
|
|
58
roles/docker/tasks/Debian.yml
Normal file
58
roles/docker/tasks/Debian.yml
Normal 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
|
59
roles/docker/tasks/RedHat.yml
Normal file
59
roles/docker/tasks/RedHat.yml
Normal 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
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
# Infrastructure
|
# Infrastructure
|
||||||
# Ansible instructions to deploy the infrastructure
|
# Ansible instructions to deploy the infrastructure
|
||||||
|
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
|
||||||
# Copyright (C) 2020 Saibotk
|
# Copyright (C) 2020 Saibotk
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- name: Add Docker GPG key.
|
- name: "Select tasks for {{ ansible_distribution }} {{ ansible_distribution_major_version }}"
|
||||||
rpm_key:
|
include_tasks: "{{ distro_file }}"
|
||||||
key: "{{ docker_yum_gpg_key }}"
|
with_first_found:
|
||||||
state: present
|
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||||
become: true
|
- "{{ ansible_distribution }}.yml"
|
||||||
|
- "{{ ansible_os_family }}.yml"
|
||||||
- name: Add Docker repository.
|
loop_control:
|
||||||
get_url:
|
loop_var: distro_file
|
||||||
url: "{{ docker_yum_repo_url }}"
|
|
||||||
dest: '/etc/yum.repos.d/docker-{{ docker_edition }}.repo'
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: '0644'
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Install Docker.
|
- name: Install Docker.
|
||||||
package:
|
package:
|
||||||
|
@ -49,18 +44,6 @@
|
||||||
- name: Ensure handlers are notified now to avoid firewall conflicts.
|
- name: Ensure handlers are notified now to avoid firewall conflicts.
|
||||||
meta: flush_handlers
|
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.
|
- name: Install docker python package.
|
||||||
pip:
|
pip:
|
||||||
name: "{{ docker_pip_package }}"
|
name: "{{ docker_pip_package }}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue