Add self-building support to matrix-email2matrix

This commit is contained in:
Slavi Pantaleev 2021-08-04 15:03:45 +03:00
parent 2697590d28
commit 421f85defa
4 changed files with 36 additions and 3 deletions

View file

@ -29,6 +29,7 @@ List of roles where self-building the Docker image is currently possible:
- `matrix-bridge-mx-puppet-skype` - `matrix-bridge-mx-puppet-skype`
- `matrix-bot-mjolnir` - `matrix-bot-mjolnir`
- `matrix-bot-matrix-reminder-bot` - `matrix-bot-matrix-reminder-bot`
- `matrix-email2matrix`
Adding self-building support to other roles is welcome. Feel free to contribute! Adding self-building support to other roles is welcome. Feel free to contribute!

View file

@ -1037,6 +1037,8 @@ matrix_dynamic_dns_enabled: false
matrix_email2matrix_enabled: false matrix_email2matrix_enabled: false
matrix_email2matrix_container_image_self_build: "{{ matrix_architecture != 'amd64' }}"
###################################################################### ######################################################################
# #
# /matrix-email2matrix # /matrix-email2matrix

View file

@ -2,9 +2,15 @@ matrix_email2matrix_enabled: true
matrix_email2matrix_base_path: "{{ matrix_base_data_path }}/email2matrix" matrix_email2matrix_base_path: "{{ matrix_base_data_path }}/email2matrix"
matrix_email2matrix_config_dir_path: "{{ matrix_email2matrix_base_path }}/config" matrix_email2matrix_config_dir_path: "{{ matrix_email2matrix_base_path }}/config"
matrix_email2matrix_docker_src_files_path: "{{ matrix_email2matrix_base_path }}/docker-src"
matrix_email2matrix_container_image_self_build: false
matrix_email2matrix_container_image_self_build_repo: "https://github.com/devture/email2matrix.git"
matrix_email2matrix_container_image_self_build_branch: "{{ matrix_email2matrix_version }}"
matrix_email2matrix_version: 1.0.1 matrix_email2matrix_version: 1.0.1
matrix_email2matrix_docker_image: "{{ matrix_container_global_registry_prefix }}devture/email2matrix:{{ matrix_email2matrix_version }}" matrix_email2matrix_docker_image_prefix: "{{ 'localhost/' if matrix_email2matrix_container_image_self_build else matrix_container_global_registry_prefix }}"
matrix_email2matrix_docker_image: "{{ matrix_email2matrix_docker_image_prefix }}devture/email2matrix:{{ matrix_email2matrix_version }}"
matrix_email2matrix_docker_image_force_pull: "{{ matrix_email2matrix_docker_image.endswith(':latest') }}" matrix_email2matrix_docker_image_force_pull: "{{ matrix_email2matrix_docker_image.endswith(':latest') }}"
# A list of extra arguments to pass to the container # A list of extra arguments to pass to the container

View file

@ -8,8 +8,10 @@
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
with_items: with_items:
- "{{ matrix_email2matrix_base_path }}" - { path: "{{ matrix_email2matrix_base_path }}", when: true }
- "{{ matrix_email2matrix_config_dir_path }}" - { path: "{{ matrix_email2matrix_config_dir_path }}", when: true }
- { path: "{{ matrix_email2matrix_docker_src_files_path }}", when: "{{ matrix_email2matrix_container_image_self_build }}"}
when: "item.when|bool"
- name: Ensure Email2Matrix configuration file created - name: Ensure Email2Matrix configuration file created
template: template:
@ -25,6 +27,28 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_email2matrix_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force_source: "{{ matrix_email2matrix_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_email2matrix_docker_image_force_pull }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_email2matrix_docker_image_force_pull }}"
when: "not matrix_email2matrix_container_image_self_build|bool"
- name: Ensure Email2Matrix repository is present on self-build
git:
repo: "{{ matrix_email2matrix_container_image_self_build_repo }}"
dest: "{{ matrix_email2matrix_docker_src_files_path }}"
version: "{{ matrix_email2matrix_container_image_self_build_branch }}"
force: "yes"
register: matrix_email2matrix_git_pull_results
when: "matrix_email2matrix_container_image_self_build|bool"
- name: Ensure Email2Matrix Docker image is built
docker_image:
name: "{{ matrix_email2matrix_docker_image }}"
source: build
force_source: "{{ matrix_email2matrix_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_email2matrix_git_pull_results.changed }}"
build:
dockerfile: etc/docker/Dockerfile
path: "{{ matrix_email2matrix_docker_src_files_path }}"
pull: yes
when: "matrix_email2matrix_container_image_self_build|bool"
- name: Ensure matrix-email2matrix.service installed - name: Ensure matrix-email2matrix.service installed
template: template: