From 6301321e1660999bd397a134d28aa64f5597f782 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 15 Oct 2019 15:47:52 +0200 Subject: [PATCH] Add support for imap email support to the redmine role. --- library/roles/redmine/defaults/main.yml | 8 ++++++++ library/roles/redmine/tasks/redmine.yml | 17 +++++++++++++++++ .../redmine/templates/redmine-imap-sync.j2 | 4 ++++ 3 files changed, 29 insertions(+) create mode 100644 library/roles/redmine/templates/redmine-imap-sync.j2 diff --git a/library/roles/redmine/defaults/main.yml b/library/roles/redmine/defaults/main.yml index 7c7d4988..2a63d846 100644 --- a/library/roles/redmine/defaults/main.yml +++ b/library/roles/redmine/defaults/main.yml @@ -33,6 +33,14 @@ redmine_glob_user: www-data redmine_glob_group: www-data redmine_glob_users_home_base: /srv/redmine-home +redmine_imap_sync: False +redmine_imap_server: localhost +redmine_imap_user: '' +#redmine_imap_password: 'Use a vault file' +redmine_imap_unknown_user_action: ignore +redmine_imap_starttls: true +redmine_imap_sync_additional_options: '' + # Plugins rm_ldap_auth: False rm_ldap_synch: False diff --git a/library/roles/redmine/tasks/redmine.yml b/library/roles/redmine/tasks/redmine.yml index 737a574f..f97814e7 100644 --- a/library/roles/redmine/tasks/redmine.yml +++ b/library/roles/redmine/tasks/redmine.yml @@ -107,4 +107,21 @@ template: src=redmine-logrotate.j2 dest=/etc/logrotate.d/redmine-{{ redmine_inst_name }} owner=root group=root mode=0444 tags: [ 'redmine', 'logrotate' ] + - name: Install a script that syncs the email to redmine reading from a imap account + template: src=redmine-imap-sync.j2 dest=/usr/local/bin/redmine-imap-sync owner=root group={{ redmine_user }} mode=0750 + when: redmine_imap_sync | bool + tags: [ 'redmine', 'redmine_imap' ] + + - name: Install a cron job that configures the task that reads emails via imap + cron: + cron_file: redmine-email-sync + disabled: no + job: '/usr/local/bin/redmine-imap-sync' + user: '{{ redmine_user }}' + minute: '*/10' + name: 'Redmine update tasks by email' + state: present + when: redmine_imap_sync | bool + tags: [ 'redmine', 'redmine_imap' ] + tags: redmine diff --git a/library/roles/redmine/templates/redmine-imap-sync.j2 b/library/roles/redmine/templates/redmine-imap-sync.j2 new file mode 100644 index 00000000..3484d160 --- /dev/null +++ b/library/roles/redmine/templates/redmine-imap-sync.j2 @@ -0,0 +1,4 @@ +#!/bin/bash + +rake -f {{ redmine_glob_root_dir }}/{{ redmine_inst_dir }}/Rakefile redmine:email:receive_imap RAILS_ENV="production" host={{ redmine_imap_server }} username={{ redmine_imap_user }} password='{{ redmine_imap_password }}' unknown_user={{ redmine_imap_unknown_user_action }} starttls={{ redmine_imap_starttls }} {{ redmine_imap_sync_additional_options }} >> {{ redmine_glob_root_dir }}/{{ redmine_inst_dir }}/log/imap_sync.log 2>&1 +