diff --git a/docs/ansible.md b/docs/ansible.md index e8a0ddb21..49dbd7eaf 100644 --- a/docs/ansible.md +++ b/docs/ansible.md @@ -53,7 +53,7 @@ You can either [run Ansible in a container on the Matrix server itself](#running To run Ansible in a (Docker) container on the Matrix server itself, you need to have a working Docker installation. Docker is normally installed by the playbook, so this may be a bit of a chicken and egg problem. To solve it: -- you **either** need to install Docker manually first. Follow [the upstream instructions](https://docs.docker.com/engine/install/) for your distribution and consider setting `matrix_docker_installation_enabled: false` in your `vars.yml` file, to prevent the playbook from installing Docker +- you **either** need to install Docker manually first. Follow [the upstream instructions](https://docs.docker.com/engine/install/) for your distribution and consider setting `matrix_playbook_docker_installation_enabled: false` in your `vars.yml` file, to prevent the playbook from installing Docker - **or** you need to run the playbook in another way (e.g. [Running Ansible in a container on another computer (not the Matrix server)](#running-ansible-in-a-container-on-another-computer-not-the-matrix-server)) at least the first time around Once you have a working Docker installation on the server, **clone the playbook** somewhere on the server and configure it as per usual (`inventory/hosts`, `inventory/host_vars/..`, etc.), as described in [configuring the playbook](configuring-playbook.md). diff --git a/docs/faq.md b/docs/faq.md index f2df8698b..d2b88cf66 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -317,7 +317,7 @@ If you've installed [Jitsi](configuring-playbook-jitsi.md) (not installed by def Yes, we can stop installing Docker ourselves. Just use this in your `vars.yml` file: ```yaml -matrix_docker_installation_enabled: true +matrix_playbook_docker_installation_enabled: true ``` ### I run another webserver on the same server where I wish to install Matrix. What now? diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 23ce1d3d6..403188e73 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -9,6 +9,23 @@ # You can also override ANY variable (seen here or in any given role), # by re-defining it in your own configuration file (`inventory/host_vars/matrix.`). +######################################################################## +# # +# Playbook # +# # +######################################################################## + +# Controls whether to install Docker or not +# Also see `devture_docker_sdk_for_python_installation_enabled`. +matrix_playbook_docker_installation_enabled: true + +######################################################################## +# # +# /Playbook # +# # +######################################################################## + + ######################################################################## # # diff --git a/playbooks/matrix.yml b/playbooks/matrix.yml index 6c7dc3833..1ecfba327 100755 --- a/playbooks/matrix.yml +++ b/playbooks/matrix.yml @@ -11,6 +11,20 @@ - role: custom/matrix_playbook_migration + - when: matrix_playbook_docker_installation_enabled | bool + role: galaxy/geerlingguy.docker + vars: + docker_install_compose: false + tags: + - setup-docker + - setup-all + + - when: devture_docker_sdk_for_python_installation_enabled | bool + role: galaxy/com.devture.ansible.role.docker_sdk_for_python + tags: + - setup-docker + - setup-all + - when: devture_timesync_installation_enabled | bool role: galaxy/com.devture.ansible.role.timesync tags: diff --git a/requirements.yml b/requirements.yml index a57b63a9b..ed4b8fb18 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,5 +1,11 @@ --- +- src: geerlingguy.docker + version: 6.0.3 + +- src: git+https://github.com/devture/com.devture.ansible.role.docker_sdk_for_python.git + version: 7047b40314c1020e97ed3f15b44876fa88faf874 + - src: git+https://github.com/devture/com.devture.ansible.role.playbook_help.git version: c1f40e82b4d6b072b6f0e885239322bdaaaf554f diff --git a/roles/custom/matrix-base/defaults/main.yml b/roles/custom/matrix-base/defaults/main.yml index 5c0f16dcf..f0d86c707 100644 --- a/roles/custom/matrix-base/defaults/main.yml +++ b/roles/custom/matrix-base/defaults/main.yml @@ -253,14 +253,6 @@ matrix_well_known_matrix_server_enabled: true # See `matrix_homeserver_admin_contacts`, `matrix_homeserver_support_url`, etc. matrix_well_known_matrix_support_enabled: false -# Controls whether Docker is automatically installed. -# If you change this to false you must install and update Docker manually. You also need to install the docker (https://pypi.org/project/docker/) Python package. -matrix_docker_installation_enabled: true - -# Controls the Docker package that is installed. -# Possible values are "docker-ce" (default) and "docker.io" (Debian). -matrix_docker_package_name: docker-ce - # Variables to Control which parts of our roles run. run_postgres_import: true run_postgres_upgrade: true diff --git a/roles/custom/matrix-base/tasks/main.yml b/roles/custom/matrix-base/tasks/main.yml index 164bd3539..29e97cd17 100644 --- a/roles/custom/matrix-base/tasks/main.yml +++ b/roles/custom/matrix-base/tasks/main.yml @@ -14,12 +14,6 @@ - setup-all - common -- ansible.builtin.import_tasks: "{{ role_path }}/tasks/server_base/setup.yml" - when: run_setup | bool - tags: - - setup-all - - common - # This needs to always run, because it populates `matrix_user_uid` and `matrix_user_gid`, # which are required by many other roles. - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_matrix_user.yml" diff --git a/roles/custom/matrix-base/tasks/server_base/setup.yml b/roles/custom/matrix-base/tasks/server_base/setup.yml deleted file mode 100644 index d0b9f0b95..000000000 --- a/roles/custom/matrix-base/tasks/server_base/setup.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- - -- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_redhat.yml" - when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int < 8 - -- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_redhat8.yml" - when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int > 7 and ansible_distribution_major_version | int < 30 - -- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_fedora.yml" - when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int > 30 - -- when: ansible_os_family == 'Debian' - block: - # ansible_lsb is only available if lsb-release is installed. - - name: Ensure lsb-release installed - ansible.builtin.apt: - name: - - lsb-release - state: present - update_cache: true - register: lsb_release_installation_result - - - name: Reread ansible_lsb facts if lsb-release got installed - ansible.builtin.setup: - filter: ansible_lsb* - when: lsb_release_installation_result.changed - - - ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_debian.yml" - when: (ansible_os_family == 'Debian') and (ansible_lsb.id != 'Raspbian') - - - ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_raspbian.yml" - when: (ansible_os_family == 'Debian') and (ansible_lsb.id == 'Raspbian') - -- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_archlinux.yml" - when: ansible_distribution == 'Archlinux' - -- name: Ensure Docker is started and autoruns - ansible.builtin.service: - name: docker - state: started - enabled: true diff --git a/roles/custom/matrix-base/tasks/server_base/setup_archlinux.yml b/roles/custom/matrix-base/tasks/server_base/setup_archlinux.yml deleted file mode 100644 index a93136148..000000000 --- a/roles/custom/matrix-base/tasks/server_base/setup_archlinux.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -- name: Install host dependencies - community.general.pacman: - name: - - python-docker - - python-dnspython - state: present - update_cache: true - -- name: Ensure Docker is installed - community.general.pacman: - name: - - docker - state: present - when: matrix_docker_installation_enabled | bool diff --git a/roles/custom/matrix-base/tasks/server_base/setup_debian.yml b/roles/custom/matrix-base/tasks/server_base/setup_debian.yml deleted file mode 100644 index 412a11d02..000000000 --- a/roles/custom/matrix-base/tasks/server_base/setup_debian.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- - -- name: Ensure APT usage dependencies are installed - ansible.builtin.apt: - name: - - apt-transport-https - - ca-certificates - - gnupg - state: present - update_cache: true - -- name: Ensure Docker's APT key is trusted - ansible.builtin.apt_key: - url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg" - id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 - state: present - register: add_repository_key - ignore_errors: true - when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce' - -- name: Ensure Docker repository is enabled - ansible.builtin.apt_repository: - repo: "deb [arch={{ matrix_debian_arch }}] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable" - state: present - update_cache: true - when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce' - -- name: Ensure Docker is installed - ansible.builtin.apt: - name: - - "{{ matrix_docker_package_name }}" - - "python{{ '3' if ansible_python.version.major == 3 else '' }}-docker" - state: present - when: matrix_docker_installation_enabled | bool diff --git a/roles/custom/matrix-base/tasks/server_base/setup_fedora.yml b/roles/custom/matrix-base/tasks/server_base/setup_fedora.yml deleted file mode 100644 index 19d465718..000000000 --- a/roles/custom/matrix-base/tasks/server_base/setup_fedora.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- - -- name: Ensure Docker repository is enabled - ansible.builtin.template: - src: "{{ role_path }}/files/yum.repos.d/{{ item }}" - dest: "/etc/yum.repos.d/docker-ce.repo" - owner: "root" - group: "root" - mode: 0644 - with_items: - - docker-ce-fedora.repo - when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce' - -- name: Ensure Docker's RPM key is trusted - ansible.builtin.rpm_key: - state: present - key: https://download.docker.com/linux/fedora/gpg - when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce' - -- name: Ensure Docker is installed - ansible.builtin.yum: - name: - - "{{ matrix_docker_package_name }}" - - python3-pip - state: present - when: matrix_docker_installation_enabled | bool - -- name: Ensure Docker-Py is installed - ansible.builtin.pip: - name: docker-py - state: present - when: matrix_docker_installation_enabled | bool diff --git a/roles/custom/matrix-base/tasks/server_base/setup_raspbian.yml b/roles/custom/matrix-base/tasks/server_base/setup_raspbian.yml deleted file mode 100644 index 6959b39c8..000000000 --- a/roles/custom/matrix-base/tasks/server_base/setup_raspbian.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- - -- name: Ensure APT usage dependencies are installed - ansible.builtin.apt: - name: - - apt-transport-https - - ca-certificates - - gnupg - state: present - update_cache: true - -- name: Ensure Docker's APT key is trusted - ansible.builtin.apt_key: - url: https://download.docker.com/linux/raspbian/gpg - id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 - state: present - register: add_repository_key - ignore_errors: true - when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce' - -- name: Ensure Docker repository is enabled - ansible.builtin.apt_repository: - repo: "deb [arch={{ matrix_debian_arch }}] https://download.docker.com/linux/raspbian {{ ansible_distribution_release }} stable" - state: present - update_cache: true - when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce' - -- name: Ensure Docker is installed - ansible.builtin.apt: - name: - - "{{ matrix_docker_package_name }}" - - "python{{ '3' if ansible_python.version.major == 3 else '' }}-docker" - state: present - when: matrix_docker_installation_enabled | bool diff --git a/roles/custom/matrix-base/tasks/server_base/setup_redhat.yml b/roles/custom/matrix-base/tasks/server_base/setup_redhat.yml deleted file mode 100644 index dbddd9130..000000000 --- a/roles/custom/matrix-base/tasks/server_base/setup_redhat.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - -- name: Ensure Docker repository is enabled - ansible.builtin.template: - src: "{{ role_path }}/files/yum.repos.d/docker-ce-centos.repo" - dest: "/etc/yum.repos.d/docker-ce.repo" - owner: "root" - group: "root" - mode: 0644 - when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce' - -- name: Ensure Docker's RPM key is trusted - ansible.builtin.rpm_key: - state: present - key: https://download.docker.com/linux/centos/gpg - when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce' - -- name: Ensure Docker is installed - ansible.builtin.yum: - name: - - "{{ matrix_docker_package_name }}" - - docker-python - state: present - when: matrix_docker_installation_enabled | bool diff --git a/roles/custom/matrix-base/tasks/server_base/setup_redhat8.yml b/roles/custom/matrix-base/tasks/server_base/setup_redhat8.yml deleted file mode 100644 index c303abb8f..000000000 --- a/roles/custom/matrix-base/tasks/server_base/setup_redhat8.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- - -- name: Ensure Docker repository is enabled - ansible.builtin.template: - src: "{{ role_path }}/files/yum.repos.d/docker-ce-centos.repo" - dest: "/etc/yum.repos.d/docker-ce.repo" - owner: "root" - group: "root" - mode: 0644 - when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce' - -- name: Ensure Docker's RPM key is trusted - ansible.builtin.rpm_key: - state: present - key: https://download.docker.com/linux/centos/gpg - when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce' - -- name: Ensure EPEL is installed - ansible.builtin.yum: - name: - - epel-release - state: present - update_cache: true - -- name: Ensure Docker is installed - ansible.builtin.yum: - name: - - "{{ matrix_docker_package_name }}" - - python3-pip - state: present - when: matrix_docker_installation_enabled | bool - -- name: Ensure Docker-Py is installed - ansible.builtin.pip: - name: docker-py - state: present - when: matrix_docker_installation_enabled | bool diff --git a/roles/custom/matrix_playbook_migration/tasks/validate_config.yml b/roles/custom/matrix_playbook_migration/tasks/validate_config.yml index 6a837605e..93f977d1b 100644 --- a/roles/custom/matrix_playbook_migration/tasks/validate_config.yml +++ b/roles/custom/matrix_playbook_migration/tasks/validate_config.yml @@ -27,3 +27,6 @@ - {'old': 'matrix_nginx_proxy_synapse_cache_path', 'new': 'matrix_synapse_reverse_proxy_companion_synapse_cache_path'} - {'old': 'matrix_nginx_proxy_synapse_cache_enabled', 'new': 'matrix_synapse_reverse_proxy_companion_synapse_cache_enabled'} + + - {'old': 'matrix_docker_installation_enabled', 'new': 'matrix_playbook_docker_installation_enabled'} + - {'old': 'matrix_docker_package_name', 'new': ''}