Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…initMultiDomain.sh instead of directly using it
  • Loading branch information
suhancz committed Feb 22, 2024
1 parent 2525eda commit 10a2e78
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 2 deletions.
13 changes: 12 additions & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
daemon_reload: yes
enabled: yes
state: restarted
- name: Restart cyrus-imapd
ansible.builtin.systemd_service:
name: cyrus-imapd
daemon_reload: yes
enabled: yes
state: restarted
- name: "Restart dirsrv@{{ mailserver_hostname }}"
ansible.builtin.systemd_service:
name: "dirsrv@{{ mailserver_hostname }}"
Expand Down Expand Up @@ -49,10 +55,15 @@
state: restarted
- name: Restart kolab
ansible.builtin.systemd_service:
name: kolabd
name: "{{ kolab_service }}"
daemon_reload: yes
enabled: yes
state: restarted
loop:
- kolabd
- kolab-saslauthd
loop_control:
loop_var: kolab_service
- name: Restart mongod
ansible.builtin.systemd_service:
name: mongod
Expand Down
213 changes: 212 additions & 1 deletion tasks/kolab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@
backup: true
register: kolab_configure
with_items:
- { key: 'quota', value: '0'}
- { key: 'partition', value: 'archive' }
- { key: 'policy_uid', value: "'%(givenname)s'[0:1].lower()" }
- { key: 'primary_mail', value: "'%(givenname)s'[0:1]@%(domain)s" }
- { key: 'postfix_virtual_file', value: '/etc/postfix/virtual_alias_maps_manual.cf' }
notify:
- Restart kolab
tags:
Expand All @@ -72,13 +75,194 @@
group: root
mode: u=rwx,og=

- name: Initiate multi-domain
block:
- name: Configure IMAPD
ansible.builtin.lineinfile:
dest: /etc/imapd.conf
regexp: "^{{ item.key }}: "
line: "{{ item.key }}: {{ item.value}}"
backup: yes
loop:
- { key: "ldap_base", value: "dc=%2,dc=%1" }
- { key: "ldap_group_base", value: "dc=%2,dc=%1" }
- { key: "ldap_member_base", value: "ou=People,dc=%2,dc=%1" }
- { key: "ldap_domain_base_dn", value: "cn=kolab,cn=config" }
- { key: "ldap_domain_filter", value: "(&(objectclass=domainrelatedobject)(associateddomain=%s))" }
- { key: "ldap_domain_name_attribute", value: "associatedDomain" }
- { key: "ldap_domain_scope", value: "sub" }
- { key: "ldap_domain_result_attribute", value: "inetdomainbasedn" }
register: kolab_imapd_config_patch
notify: Restart cyrus-imapd
- name: Restart cyrus-imapd
when: kolab_imapd_config_patch.changed
ansible.builtin.systemd_service:
name: cyrus-imapd
daemon_reload: yes
enabled: yes
state: restarted
- name: Configure unique UID across domains
community.general.ini_file:
path: /etc/kolab/kolab.conf
section: kolab
option: unique_uid_across_domains
value: "true"
mode: u=rw,go=r
backup: true
notify: Restart kolab
- name: Collect LDAP Postfix .cf files
ansible.builtin.find:
paths: /etc/postfix/ldap
patterns: '*.cf'
register: postfix_ldap_cf_files
- name: Create custom LDAP Postfix .cf files
ansible.builtin.copy:
src: "{{ item.path }}"
dest: "{{ item.path | replace('.cf', '_3.cf')}}"
remote_src: yes
backup: true
loop: "{{ postfix_ldap_cf_files.files }}"
notify: Restart postfix
- name: Set query filter in mydestination_3.cf
ansible.builtin.lineinfile:
dest: /etc/postfix/ldap/mydestination_3.cf
regexp: "^query_filter = .*$"
line: 'query_filter = (\&(associateddomain=%s)(associateddomain=*.*.*))'
backup: yes
notify: Restart postfix
- name: "Set search base in {{ item }}"
ansible.builtin.lineinfile:
dest: "{{ item.path }}"
regexp: "^search_base = .*$"
line: 'search_base = dc=%2,dc=%1'
backup: yes
loop: "{{ postfix_ldap_cf_files.files }}"
notify: Restart postfix
- name: "Set domain in {{ item | replace('.cf', '_3.cf') }}"
ansible.builtin.lineinfile:
dest: "{{ item.path | replace('.cf', '_3.cf') }}"
regexp: "^domain = .*$"
line: 'domain = ldap:/etc/postfix/ldap/mydestination_3.cf'
backup: yes
loop: "{{ postfix_ldap_cf_files.files }}"
notify: Restart postfix
- name: Patch Postfix main.cf
ansible.builtin.lineinfile:
dest: /etc/postfix/main.cf
regexp: "^{{ item.key }} = .*$"
line: '{{ item.key }} = {{ item.value }}'
backup: yes
loop:
- { key: "transport_maps", value: "ldap:/etc/postfix/ldap/transport_maps.cf, ldap:/etc/postfix/ldap/transport_maps_3.cf, hash:/etc/postfix/transport" }
- { key: "virtual_alias_maps", value: "$alias_maps, ldap:/etc/postfix/ldap/virtual_alias_maps.cf, hash:/etc/postfix/virtual_alias_maps_manual.cf, ldap:/etc/postfix/ldap/virtual_alias_maps_3.cf, ldap:/etc/postfix/ldap/mailenabled_distgroups_3.cf, ldap:/etc/postfix/ldap/mailenabled_dynamic_distgroups_3.cf, ldap:/etc/postfix/ldap/virtual_alias_maps_sharedfolders_3.cf, ldap:/etc/postfix/ldap/virtual_alias_maps_mailforwarding.cf, ldap:/etc/postfix/ldap/virtual_alias_maps_sharedfolders.cf, ldap:/etc/postfix/ldap/mailenabled_distgroups.cf, ldap:/etc/postfix/ldap/mailenabled_dynamic_distgroups.cf, ldap:/etc/postfix/ldap/virtual_alias_maps_catchall.cf, ldap:/etc/postfix/ldap/virtual_alias_maps_catchall_3.cf" }
- { key: "local_recipient_maps", value: "ldap:/etc/postfix/ldap/local_recipient_maps.cf, ldap:/etc/postfix/ldap/local_recipient_maps_3.cf" }
notify: Restart postfix
- name: Set up domain aliases
ansible.builtin.lineinfile:
dest: /etc/postfix/virtual_alias_maps_manual.cf
line: '@{{ item }} @{{ mailserver_domain }}'
backup: yes
create: yes
loop: "{{ custom_domains }}"
notify: Restart postfix
- name: Set up default mail aliases
ansible.builtin.lineinfile:
dest: /etc/postfix/virtual_alias_maps_manual.cf
line: '{{ item }}@{{ mailserver_domain }} {{ mailserver_admin_user }}@{{ mailserver_domain }}'
backup: yes
create: yes
loop:
- abuse
- dmarc-reports
- spam-report
- ham-report
- hostmaster
- postmaster
- root
- ssl
- vpn
- webmaster
notify: Restart postfix
- name: Set up user mail aliases
ansible.builtin.import_tasks: user_mail_alias.yml
loop: "{{ users }}"
loop_control:
loop_var: user
notify: Restart postfix
- name: Configure Roundcube authentication
ansible.builtin.lineinfile:
dest: /etc/roundcubemail/kolab_auth.inc.php
insertafter: '=> 389,'
line: "{{ item }}"
backup: yes
loop:
- "'domain_base_dn' => 'cn=kolab,cn=config'"
- "'domain_filter' => '(\&(objectclass=domainrelatedobject)(associateddomain=%s))',"
- "'domain_name_attr' => 'associateddomain',"
notify: Restart kolab
- name: Configure Roundcube organizational units
ansible.builtin.replace:
path: /etc/roundcubemail/kolab_auth.inc.php
regexp: "'ou={{ item }},.*'"
replace: "'ou={{ item }},%dc'"
backup: yes
loop:
- People
- Groups
notify: Restart kolab
- name: Enable freebusy for the main domain
community.general.ini_file:
path: /usr/share/kolab-freebusy/config/config.ini
section: 'directory "kolab-people"'
option: domain_base_dn
value: "%dc"
mode: u=rw,go=r
backup: true
notify: Restart kolab
- name: Enable freebusy for all domains
community.general.ini_file:
path: /usr/share/kolab-freebusy/config/config.ini
section: "{{ item }}"
option: base_dn
value: "%dc"
mode: u=rw,go=r
backup: true
loop:
- 'directory "kolab-people"'
- 'directory "kolab-resources"'
- 'directory "kolab-resource-collections"'
- httpauth
notify: Restart kolab
- name: Fix global address book
ansible.builtin.replace:
path: /etc/roundcubemail/config.inc.php
regexp: "'ou={{ item }},.*'"
replace: "'ou={{ item }},%dc'"
backup: yes
loop:
- People
- Groups
notify: Restart kolab
- name: Configure kolab.conf
community.general.ini_file:
path: /etc/kolab/kolab.conf
section: kolab_wap
option: "{{ item.key }}"
value: "{{ item.value }}"
mode: u=rw,go=r
backup: true
loop:
- { key: 'memcache_hosts', value: '127.0.0.1:11211' }
- { key: 'memcache_pconnect', value: 'true' }
notify: Restart kolab

- name: Patch kolab
ansible.builtin.command: "bash /usr/src/KolabScripts/kolab/{{ item }}"
args:
chdir: /usr/src/KolabScripts/kolab
with_items:
- initRoundcubePlugins.sh
- initMultiDomain.sh
# - initMultiDomain.sh
- initMailForward.sh
- initMailCatchall.sh

Expand Down Expand Up @@ -137,3 +321,30 @@
- "{{ [mailserver_domain] + custom_domains }}"
notify:
- Restart kolab
- name: Set timestamp format
community.general.ini_file:
path: /etc/kolab/kolab.conf
section: ldap
option: modifytimestamp_format
value: "%%Y%%m%%d%%H%%M%%SZ"
mode: u=rw,go=r
backup: true
- name: Set IMAP virtual domains
community.general.ini_file:
path: /etc/kolab/kolab.conf
section: imap
option: virtual_domains
value: userid
mode: u=rw,go=r
backup: true
- name: Restart kolab
ansible.builtin.systemd_service:
name: "{{ kolab_service }}"
daemon_reload: yes
enabled: yes
state: restarted
loop:
- kolabd
- kolab-saslauthd
loop_control:
loop_var: kolab_service
1 change: 1 addition & 0 deletions tasks/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@
- imapsync
- aide
- kolab
- php-pecl-memcache
# - php56-php-bcmath
# - php56-php-channel-horde
# - php56-php-horde-horde-lz4
Expand Down
9 changes: 9 additions & 0 deletions tasks/user_mail_alias.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

Check failure on line 1 in tasks/user_mail_alias.yml

View workflow job for this annotation

GitHub Actions / Lint Code Base

load-failure[runtimeerror]

Failed to load YAML file: tasks/user_mail_alias.yml
- name: "Set up mail aliases for {{ user }}"
ansible.builtin.lineinfile:
dest: /etc/postfix/virtual_alias_maps_manual.cf
line: '{{ item }} {{ user.name }}@{{ mailserver_domain }}'
backup: yes
create: yes
loop: {{ user.aliases }}
notify: Restart postfix

0 comments on commit 10a2e78

Please sign in to comment.