From 80cfb2a93ea0f36d1db1545e586c7e3946cf79ce Mon Sep 17 00:00:00 2001 From: Dan Arnfield Date: Mon, 18 Nov 2019 11:20:01 -0600 Subject: [PATCH] Add matrix_docker_installation_enabled --- roles/matrix-base/defaults/main.yml | 4 ++++ roles/matrix-base/tasks/server_base/setup.yml | 6 ++++++ roles/matrix-base/tasks/server_base/setup_centos.yml | 3 +++ roles/matrix-base/tasks/server_base/setup_debian.yml | 3 +++ 4 files changed, 16 insertions(+) diff --git a/roles/matrix-base/defaults/main.yml b/roles/matrix-base/defaults/main.yml index fc119a44e..a8d272718 100644 --- a/roles/matrix-base/defaults/main.yml +++ b/roles/matrix-base/defaults/main.yml @@ -42,6 +42,10 @@ matrix_docker_network: "matrix" # matrix domain (`matrix_server_fqn_matrix`). matrix_well_known_matrix_server_enabled: true +# Controls whether docker is automatically installed. +# If you change this to false you must install and update docker manually. +matrix_docker_installation_enabled: true + # Variables to Control which parts of our roles run. run_postgres_import: true run_postgres_upgrade: true diff --git a/roles/matrix-base/tasks/server_base/setup.yml b/roles/matrix-base/tasks/server_base/setup.yml index 45feb1527..9ca2ce2e6 100644 --- a/roles/matrix-base/tasks/server_base/setup.yml +++ b/roles/matrix-base/tasks/server_base/setup.yml @@ -1,5 +1,11 @@ --- +- name: Gather package facts + package_facts: + +- set_fact: + run_docker_installation: "{{ matrix_docker_installation_enabled|bool and 'docker.io' not in ansible_facts.packages }}" + - include_tasks: "{{ role_path }}/tasks/server_base/setup_centos.yml" when: ansible_distribution == 'CentOS' diff --git a/roles/matrix-base/tasks/server_base/setup_centos.yml b/roles/matrix-base/tasks/server_base/setup_centos.yml index 1c891ab13..e79797047 100644 --- a/roles/matrix-base/tasks/server_base/setup_centos.yml +++ b/roles/matrix-base/tasks/server_base/setup_centos.yml @@ -9,11 +9,13 @@ mode: 0644 with_items: - docker-ce.repo + when: run_docker_installation|bool - name: Ensure Docker's RPM key is trusted rpm_key: state: present key: https://download.docker.com/linux/centos/gpg + when: run_docker_installation|bool - name: Ensure yum packages are installed yum: @@ -31,3 +33,4 @@ - docker-ce state: latest update_cache: yes + when: run_docker_installation|bool diff --git a/roles/matrix-base/tasks/server_base/setup_debian.yml b/roles/matrix-base/tasks/server_base/setup_debian.yml index d4b16968f..6705366f4 100644 --- a/roles/matrix-base/tasks/server_base/setup_debian.yml +++ b/roles/matrix-base/tasks/server_base/setup_debian.yml @@ -15,12 +15,14 @@ state: present register: add_repository_key ignore_errors: true + when: run_docker_installation|bool - name: Ensure Docker repository is enabled apt_repository: repo: "deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} stable" state: present update_cache: yes + when: run_docker_installation|bool - name: Ensure APT packages are installed apt: @@ -38,3 +40,4 @@ - docker-ce state: latest update_cache: yes + when: run_docker_installation|bool