forked from Netz39_Admin/netz39-infra-ansible
Use docker-install
This commit is contained in:
parent
1a50bbdfc7
commit
5a18def5ed
3 changed files with 6 additions and 95 deletions
9
main.yml
9
main.yml
|
@ -50,10 +50,13 @@
|
||||||
include_tasks: tasks/users.yml
|
include_tasks: tasks/users.yml
|
||||||
|
|
||||||
- name: Install Docker
|
- name: Install Docker
|
||||||
include_tasks: tasks/docker_install.yml
|
include_role:
|
||||||
|
name: install-docker
|
||||||
|
vars:
|
||||||
|
docker_users: "{{ admin_users }}"
|
||||||
|
|
||||||
- name: Setup Docker Containers
|
- name: Setup Docker Environment
|
||||||
include_tasks: tasks/docker_setup.yml
|
include_tasks: tasks/docker_env.yml
|
||||||
|
|
||||||
- name: Setup httpd
|
- name: Setup httpd
|
||||||
include_tasks: tasks/httpd.yml
|
include_tasks: tasks/httpd.yml
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
# This file is a mash-up of:
|
|
||||||
# https://github.com/geerlingguy/ansible-role-docker/blob/master/tasks/docker-compose.yml
|
|
||||||
# https://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-debian-9
|
|
||||||
# and our own stuff …
|
|
||||||
---
|
|
||||||
- name: Gather package facts
|
|
||||||
package_facts:
|
|
||||||
manager: "auto"
|
|
||||||
|
|
||||||
- name: Exit if docker.io is installed
|
|
||||||
fail:
|
|
||||||
msg: "Please remove docker.io (Debian vanilla docker package) first!"
|
|
||||||
when: "'docker.io' in ansible_facts.packages"
|
|
||||||
|
|
||||||
- name: Install Docker APT deps
|
|
||||||
package:
|
|
||||||
name: "{{ packages }}"
|
|
||||||
state: present
|
|
||||||
vars:
|
|
||||||
packages:
|
|
||||||
- apt-transport-https
|
|
||||||
- ca-certificates
|
|
||||||
- gnupg2
|
|
||||||
- software-properties-common
|
|
||||||
|
|
||||||
- name: add Docker apt-key
|
|
||||||
apt_key:
|
|
||||||
url: https://download.docker.com/linux/debian/gpg
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: add Docker's APT repository
|
|
||||||
apt_repository:
|
|
||||||
repo: deb https://download.docker.com/linux/debian buster stable
|
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
filename: 'docker'
|
|
||||||
|
|
||||||
- name: install Docker
|
|
||||||
package:
|
|
||||||
name: "{{ packages }}"
|
|
||||||
state: present
|
|
||||||
vars:
|
|
||||||
packages:
|
|
||||||
- docker-ce
|
|
||||||
- python-docker
|
|
||||||
|
|
||||||
- name: Set docker configuration
|
|
||||||
copy:
|
|
||||||
dest: /etc/docker/daemon.json
|
|
||||||
content: |
|
|
||||||
{
|
|
||||||
"exec-opts": ["native.cgroupdriver=systemd"],
|
|
||||||
"log-driver": "json-file",
|
|
||||||
"log-opts": {
|
|
||||||
"max-size": "100m"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
register: docker_config
|
|
||||||
|
|
||||||
- name: Restart docker for changed configuration
|
|
||||||
service:
|
|
||||||
name: docker
|
|
||||||
state: restarted
|
|
||||||
enabled: yes
|
|
||||||
when: docker_config.changed
|
|
||||||
|
|
||||||
- name: Check current docker-compose version.
|
|
||||||
command: docker-compose --version
|
|
||||||
register: docker_compose_current_version
|
|
||||||
changed_when: false
|
|
||||||
failed_when: false
|
|
||||||
|
|
||||||
- name: Delete existing docker-compose version if it's different.
|
|
||||||
file:
|
|
||||||
path: "{{ docker_compose_path }}"
|
|
||||||
state: absent
|
|
||||||
when: >
|
|
||||||
docker_compose_current_version.stdout is defined
|
|
||||||
and docker_compose_version not in docker_compose_current_version.stdout
|
|
||||||
|
|
||||||
- name: Install Docker Compose (if configured).
|
|
||||||
get_url:
|
|
||||||
url: https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64
|
|
||||||
dest: "{{ docker_compose_path }}"
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: Place admin users in docker group
|
|
||||||
user:
|
|
||||||
name: "{{ item }}"
|
|
||||||
groups: docker
|
|
||||||
append: yes
|
|
||||||
with_items: "{{ admin_users }}"
|
|
Loading…
Reference in a new issue