From 5caef1ed20a586d1c9bd1b9029938fb701d54282 Mon Sep 17 00:00:00 2001
From: neutron <neutron@systemli.org>
Date: Fri, 10 Aug 2018 15:01:02 +0200
Subject: [PATCH] [trees] - install dovecot from debian backports, enable pop3

  * adds compatibility for dovecots maildir
  * adds role for installing debian backports
  * installs newer version of dovecot 2.2.* from debian backports
  * in newer versions of dovecot >= 2.2.31 cache index corruption
    is fixed
  * adds note in README.md
  * adds POP3 functionality
---
 vagrant/ansible/playbook.yml                  |  1 +
 .../ansible/roles/dovecot/tasks/install.yml   |  1 +
 .../install_dovecot_libsodium_plugin.yml      |  1 +
 .../templates/dovecot/conf.d/10-mail.conf.j2  |  4 +-
 .../roles/jnv.debian-backports/README.md      | 40 ++++++++++
 .../roles/jnv.debian-backports/UNLICENSE      | 24 ++++++
 .../meta/.galaxy_install_info                 |  1 +
 .../roles/jnv.debian-backports/meta/main.yml  | 79 +++++++++++++++++++
 .../roles/jnv.debian-backports/tasks/main.yml |  6 ++
 .../jnv.debian-backports/vars/Debian.yml      |  3 +
 .../jnv.debian-backports/vars/Ubuntu.yml      |  3 +
 .../roles/jnv.debian-backports/vars/main.yml  |  2 +
 vagrant/ansible/roles/trees/tasks/install.yml |  1 +
 13 files changed, 164 insertions(+), 2 deletions(-)
 create mode 100644 vagrant/ansible/roles/jnv.debian-backports/README.md
 create mode 100644 vagrant/ansible/roles/jnv.debian-backports/UNLICENSE
 create mode 100644 vagrant/ansible/roles/jnv.debian-backports/meta/.galaxy_install_info
 create mode 100644 vagrant/ansible/roles/jnv.debian-backports/meta/main.yml
 create mode 100644 vagrant/ansible/roles/jnv.debian-backports/tasks/main.yml
 create mode 100644 vagrant/ansible/roles/jnv.debian-backports/vars/Debian.yml
 create mode 100644 vagrant/ansible/roles/jnv.debian-backports/vars/Ubuntu.yml
 create mode 100644 vagrant/ansible/roles/jnv.debian-backports/vars/main.yml

diff --git a/vagrant/ansible/playbook.yml b/vagrant/ansible/playbook.yml
index 17b64f7..3490a53 100644
--- a/vagrant/ansible/playbook.yml
+++ b/vagrant/ansible/playbook.yml
@@ -32,6 +32,7 @@
       #  - install libsodium from normal debian repos (current version 1.0.12)
       #  - uses ARGON2
   roles:
+    - jnv.debian-backports
     - init
     - mariadb
     - postfix
diff --git a/vagrant/ansible/roles/dovecot/tasks/install.yml b/vagrant/ansible/roles/dovecot/tasks/install.yml
index e498851..d032533 100644
--- a/vagrant/ansible/roles/dovecot/tasks/install.yml
+++ b/vagrant/ansible/roles/dovecot/tasks/install.yml
@@ -27,6 +27,7 @@
   apt:
     pkg: "{{ item }}"
     state: present
+    default_release: "{{ ansible_distribution_release }}-backports"
   with_items:
     - dovecot-core
     - dovecot-common
diff --git a/vagrant/ansible/roles/dovecot/tasks/install_dovecot_libsodium_plugin.yml b/vagrant/ansible/roles/dovecot/tasks/install_dovecot_libsodium_plugin.yml
index d15a8ec..ca0bad9 100644
--- a/vagrant/ansible/roles/dovecot/tasks/install_dovecot_libsodium_plugin.yml
+++ b/vagrant/ansible/roles/dovecot/tasks/install_dovecot_libsodium_plugin.yml
@@ -3,6 +3,7 @@
   apt:
     pkg: "{{ item }}"
     state: present
+    default_release: "{{ ansible_distribution_release }}-backports"
   with_items:
     - build-essential
     - dovecot-core
diff --git a/vagrant/ansible/roles/dovecot/templates/dovecot/conf.d/10-mail.conf.j2 b/vagrant/ansible/roles/dovecot/templates/dovecot/conf.d/10-mail.conf.j2
index cf2a040..260d521 100644
--- a/vagrant/ansible/roles/dovecot/templates/dovecot/conf.d/10-mail.conf.j2
+++ b/vagrant/ansible/roles/dovecot/templates/dovecot/conf.d/10-mail.conf.j2
@@ -28,8 +28,8 @@
 # <doc/wiki/MailLocation.txt>
 #
 
-#mail_location = mdbox:/var/vmail/%Ld/%Ln/Maildir
-mail_location = {{ dovecot_mailbox_type }}:/var/vmail/%Ld/%Ln/Maildir
+mail_home = /var/vmail/%Ld/%Ln
+mail_location = {{ dovecot_mailbox_type }}:~/Maildir
 
 # If you need to set multiple mailbox locations or want to change default
 # namespace settings, you can do it by defining namespace sections.
diff --git a/vagrant/ansible/roles/jnv.debian-backports/README.md b/vagrant/ansible/roles/jnv.debian-backports/README.md
new file mode 100644
index 0000000..1de495e
--- /dev/null
+++ b/vagrant/ansible/roles/jnv.debian-backports/README.md
@@ -0,0 +1,40 @@
+# [Debian/Ubuntu Backports with Ansible](https://github.com/jnv/ansible-role-debian-backports)
+
+Adds backports repository for Debian and Ubuntu.
+
+## Usage
+
+Install via [Galaxy](https://galaxy.ansibleworks.com/):
+
+```
+ansible-galaxy install jnv.debian-backports
+```
+
+In your playbook:
+
+```yaml
+- hosts: all
+  roles:
+    # ...
+    - jnv.debian-backports
+```
+
+The role uses [apt_repository module](http://docs.ansible.com/apt_repository_module.html) which has additional dependencies. I highly recommend to use [bootstrap-debian](https://github.com/cederberg/ansible-bootstrap-debian) role to setup common Ansible requirements on Debian-based systems.
+
+You can use `default_release` option for [apt module](http://docs.ansible.com/apt_module.html) to install package from backports. For example:
+
+```yaml
+tasks:
+  - apt: name=mosh state=present default_release={{ansible_distribution_release}}-backports
+```
+
+`ansible_distribution_release` variable contains release name, i.e. `precise` or `wheezy`.
+
+## Variables
+
+- `backports_uri`: URI of the backports repository; change this if you want to use a particular mirror.
+    + Debian: `http://ftp.debian.org/debian`
+    + Ubuntu: `http://archive.ubuntu.com/ubuntu`
+- `backports_components`: Release and components for sources.list
+    + Debian: `{{backports_distribution}}-backports backports main contrib non-free`
+    + Ubuntu: `{{backports_distribution}}-backports main restricted universe multiverse`
diff --git a/vagrant/ansible/roles/jnv.debian-backports/UNLICENSE b/vagrant/ansible/roles/jnv.debian-backports/UNLICENSE
new file mode 100644
index 0000000..cf1ab25
--- /dev/null
+++ b/vagrant/ansible/roles/jnv.debian-backports/UNLICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org>
diff --git a/vagrant/ansible/roles/jnv.debian-backports/meta/.galaxy_install_info b/vagrant/ansible/roles/jnv.debian-backports/meta/.galaxy_install_info
new file mode 100644
index 0000000..2c9fe53
--- /dev/null
+++ b/vagrant/ansible/roles/jnv.debian-backports/meta/.galaxy_install_info
@@ -0,0 +1 @@
+{install_date: 'Fri Aug 10 08:05:23 2018', version: v0.2.0}
diff --git a/vagrant/ansible/roles/jnv.debian-backports/meta/main.yml b/vagrant/ansible/roles/jnv.debian-backports/meta/main.yml
new file mode 100644
index 0000000..f73d4dc
--- /dev/null
+++ b/vagrant/ansible/roles/jnv.debian-backports/meta/main.yml
@@ -0,0 +1,79 @@
+---
+galaxy_info:
+  author: Jan Vlnas
+  description: Add backports repository for Debian and Ubuntu
+  license: Unlicense
+  min_ansible_version: 1.2
+  #
+  # Below are all platforms currently available. Just uncomment
+  # the ones that apply to your role. If you don't see your
+  # platform on this list, let us know and we'll get it added!
+  #
+  platforms:
+  #- name: EL
+  #  versions:
+  #  - all
+  #  - 5
+  #  - 6
+  #- name: GenericUNIX
+  #  versions:
+  #  - all
+  #  - any
+  #- name: Fedora
+  #  versions:
+  #  - all
+  #  - 16
+  #  - 17
+  #  - 18
+  #  - 19
+  #  - 20
+  #- name: opensuse
+  #  versions:
+  #  - all
+  #  - 12.1
+  #  - 12.2
+  #  - 12.3
+  #  - 13.1
+  #  - 13.2
+  #- name: GenericBSD
+  #  versions:
+  #  - all
+  #  - any
+  #- name: FreeBSD
+  #  versions:
+  #  - all
+  #  - 8.0
+  #  - 8.1
+  #  - 8.2
+  #  - 8.3
+  #  - 8.4
+  #  - 9.0
+  #  - 9.1
+  #  - 9.1
+  #  - 9.2
+  - name: Ubuntu
+    versions:
+    - all
+  - name: Debian
+    versions:
+    - all
+  categories:
+  #- cloud
+  #- cloud:ec2
+  #- cloud:gce
+  #- cloud:rax
+  #- database
+  #- database:nosql
+  #- database:sql
+  #- development
+  #- monitoring
+  #- networking
+  - packaging
+  - system
+  #- web
+dependencies: []
+  # List your role dependencies here, one per line. Only
+  # dependencies available via galaxy should be listed here.
+  # Be sure to remove the '[]' above if you add dependencies
+  # to this list.
+
diff --git a/vagrant/ansible/roles/jnv.debian-backports/tasks/main.yml b/vagrant/ansible/roles/jnv.debian-backports/tasks/main.yml
new file mode 100644
index 0000000..87fd77a
--- /dev/null
+++ b/vagrant/ansible/roles/jnv.debian-backports/tasks/main.yml
@@ -0,0 +1,6 @@
+---
+- name: add distribution-specific variables
+  include_vars: "{{ ansible_distribution }}.yml"
+
+- name: add backports repository
+  apt_repository: repo='deb {{backports_uri}} {{backports_components}}' state=present update_cache=yes
diff --git a/vagrant/ansible/roles/jnv.debian-backports/vars/Debian.yml b/vagrant/ansible/roles/jnv.debian-backports/vars/Debian.yml
new file mode 100644
index 0000000..4943727
--- /dev/null
+++ b/vagrant/ansible/roles/jnv.debian-backports/vars/Debian.yml
@@ -0,0 +1,3 @@
+---
+backports_uri: http://http.debian.net/debian
+backports_components: "{{backports_distribution}}-backports main contrib non-free"
diff --git a/vagrant/ansible/roles/jnv.debian-backports/vars/Ubuntu.yml b/vagrant/ansible/roles/jnv.debian-backports/vars/Ubuntu.yml
new file mode 100644
index 0000000..6666ac7
--- /dev/null
+++ b/vagrant/ansible/roles/jnv.debian-backports/vars/Ubuntu.yml
@@ -0,0 +1,3 @@
+---
+backports_uri: http://archive.ubuntu.com/ubuntu
+backports_components: "{{backports_distribution}}-backports main restricted universe multiverse"
diff --git a/vagrant/ansible/roles/jnv.debian-backports/vars/main.yml b/vagrant/ansible/roles/jnv.debian-backports/vars/main.yml
new file mode 100644
index 0000000..0b79f68
--- /dev/null
+++ b/vagrant/ansible/roles/jnv.debian-backports/vars/main.yml
@@ -0,0 +1,2 @@
+---
+backports_distribution: "{{ansible_distribution_release}}"
diff --git a/vagrant/ansible/roles/trees/tasks/install.yml b/vagrant/ansible/roles/trees/tasks/install.yml
index 76912d2..8903173 100644
--- a/vagrant/ansible/roles/trees/tasks/install.yml
+++ b/vagrant/ansible/roles/trees/tasks/install.yml
@@ -4,6 +4,7 @@
   apt:
     pkg: "{{ item }}"
     state: present
+    default_release: "{{ ansible_distribution_release }}-backports"
   with_items:
     - build-essential
     - dovecot-core
-- 
GitLab