Git initial commit

This commit is contained in:
lhahn committed 2023-09-17 10:55:59 +02:00
commit 296ddb8113
35 files changed
+2279

No files matched your search

+83
View File
@@ -0,0 +1,83 @@
- name: install requirements for Dovecot
apt:
update_cache: yes
state: "{% if hcs_update | bool %}latest{% else %}present{% endif %}"
install_recommends: yes
pkg:
- dovecot-core
- dovecot-imapd
- dovecot-pop3d
- dovecot-lmtpd
- dovecot-mysql
- dovecot-pgsql
- dovecot-sieve
- dovecot-managesieved
- dovecot-antispam
- name: setup modoboa management with dovecot every minute for modoboa user
cron:
name: manage modoboa
user: "vmail"
job: "{{ modoboa_py_venv_bin }}/python3 {{ dovcot_target_instance }}/manage.py handle_mailbox_operations"
notify: restart dovecot
- name: setup dovecot configuration
template:
src: etc/dovecot/dovecot.conf.j2
dest: "{{ dovecot_dir }}/dovecot.conf"
mode: 0664
group: "{{ modoboa_user }}"
- name: "setup db-engine sql connection for db type {{ modoboa_db_type }}"
template:
src: "etc/dovecot/dovecot-{{ modoboa_db_type }}.conf.ext.j2"
dest: "{{ dovecot_dir }}/dovecot-sql.conf.ext"
mode: 0664
group: "{{ modoboa_user }}"
notify: restart dovecot
- name: setup required configs
template:
src: "etc/dovecot/conf.d/{{ config }}.j2"
dest: "{{ dovecot_dir }}/conf.d/{{ config }}"
mode: 0664
group: "{{ modoboa_user }}"
loop:
- 10-mail.conf
- 10-auth.conf
- 10-master.conf
- 10-ssl.conf
- 15-lda.conf
- 20-imap.conf
- 20-lmtp.conf
- 20-managesieve.conf
- 90-sieve.conf
- auth-sql.conf.ext
loop_control:
loop_var: config
label: "{{ config }}"
notify: restart dovecot
- name: setup quota config
template:
src: "etc/dovecot/conf.d/90-quota.conf.j2"
dest: "{{ dovecot_dir }}/conf.d/90-quota.conf"
mode: 0644
group: "{{ modoboa_user }}"
# notify: quota update
notify: restart dovecot
- name: setup postlogin script
template:
src: "usr/local/bin/postlogin_{{ modoboa_db_type }}.sh"
dest: "{{ dovecot_sieve_exec }}"
mode: 0775
group: "{{ modoboa_user }}"
notify: restart dovecot
- name: enable dovecot systemd unit
systemd:
name: dovecot
enabled: yes
daemon_reload: yes
state: started
+40
View File
@@ -0,0 +1,40 @@
---
- name: install Gunicorn with dedicated pip virtualenv
pip:
name:
- gunicorn
state: "{% if hcs_update | bool %}latest{% else %}present{% endif %}"
virtualenv: "{{ modoboa_py_venv }}"
- name: setup required logging folder
file:
state: directory
path: "{{ prefix }}/gunicorn"
loop:
- /var/log
- /var/run
loop_control:
loop_var: prefix
label: "{{ prefix }}/gunicorn"
- name: setup gunicorn modoboa config
template:
src: app/modoboa/instance/gunicorn.conf.py.j2
dest: "{{ modoboa_instance_folder }}/{{ modoboa_instance }}/gunicorn.conf.py"
mode: 0740
group: www-data
notify: reload gunicorn
- name: setup gunicorn service unit
template:
src: etc/systemd/system/gunicorn.service.j2
dest: /etc/systemd/system/gunicorn.service
mode: 0755
notify: reload gunicorn
- name: enable gunicorn systemd unit
systemd:
name: gunicorn
enabled: yes
daemon_reload: yes
state: started
Executable
+84
View File
@@ -0,0 +1,84 @@
---
- name: install requirements for Modoboa
apt:
update_cache: yes
state: "{% if hcs_update | bool %}latest{% else %}present{% endif %}"
install_recommends: yes
pkg:
- python3-dev
- build-essential
- libxml2-dev
- libxslt-dev
- libjpeg-dev
- librrd-dev
- rrdtool
- libffi-dev
- libssl-dev
- virtualenv
- libexttextcat-2.0-0
- libexttextcat-data
- libopendbx1-pgsql
- liblua5.3-0
- libstemmer0d
- libpq-dev
- name: Setup required groups of users
group:
name: "{{ group }}"
state: present
loop:
- "{{ modoboa_user }}"
- "vmail"
loop_control:
loop_var: group
label: "{{ group }}"
- name: setup modoboa user
user:
name: "vmail"
group: "vmail"
groups:
- "vmail"
comment: Virtual Mail User
shell: /sbin/nologin
state: present
- name: setup modoboa user
user:
name: "{{ modoboa_user }}"
group: "{{ modoboa_user }}"
groups:
- "{{ modoboa_user }}"
- "{{ hcs_shared_group }}"
- "www-data"
comment: Modoboa
shell: /sbin/nologin
state: present
register: modoboa_user_stat
- name: setup modoboa instance folder
file:
path: "{{ modoboa_instance_folder }}"
state: directory
mode: 0750
owner: "root"
group: "www-data"
- name: setup modoboa storage
file:
path: "{{ modoboa_storage }}"
state: directory
mode: 0770
owner: "vmail"
group: "{{ modoboa_user }}"
- include_tasks: modoboa.yml
- include_tasks: gunicorn.yml
- include_tasks: dovecot.yml
- include_tasks: postfix.yml
- include_tasks: opendkim.yml
+25
View File
@@ -0,0 +1,25 @@
---
- name: install Modoboa with dedicated pip virtualenv
pip:
name:
- "modoboa{% if modoboa_version is defined and modoboa_version is not none and modoboa_version != ''%}=={{ modoboa_version }}{% endif %}"
- "psycopg2-binary{% if psycopg2_version is defined and psycopg2_version is not none and psycopg2_version != ''%}=={{ psycopg2_version }}{% endif %}"
state: "{% if hcs_update | bool %}latest{% else %}present{% endif %}"
virtualenv: "{{ modoboa_py_venv }}"
- name: deploy modoboa instance
shell:
cmd: >
{{ modoboa_py_venv_bin }}/python3 {{ modoboa_py_venv_bin }}/modoboa-admin.py
deploy {{ modoboa_instance }}
--collectstatic
--domain {{ modoboa_url }}
--dburl default:{% if modoboa_db_type == 'pgsql' %}postgres{% else %}{{ modoboa_db_type }}{% endif %}://{{ modoboa_db_configs.dbuser }}:{{ modoboa_db_configs.dbpass }}@{{ modoboa_db_host }}/{{ modoboa_db_configs.dbname }}
--extensions {{ modoboa_extensions | join(' ') }}
chdir: "{{ modoboa_instance_folder }}"
creates: "{{ modoboa_instance_folder }}/{{ modoboa_instance }}"
- name: setup cronjobs for modoboa functionality
template:
src: "etc/cron.d/modoboa.j2"
dest: "/etc/cron.d/modoboa"
+50
View File
@@ -0,0 +1,50 @@
---
- name: install requirements for Postfix
apt:
update_cache: yes
state: "{% if hcs_update | bool %}latest{% else %}present{% endif %}"
install_recommends: yes
pkg:
- opendkim
- name: Setup opendkim config
template:
src: etc/opendkim.conf.j2
dest: /etc/opendkim.conf
group: "{{ modoboa_user }}"
mode: 0640
notify: "opendkim update"
- name: off-setup opendkim configuration
lineinfile:
path: "/etc/default/opendkim"
regexp: '^{{ configline.split("=")[0]}}='
line: "#{{ configline }}"
backrefs: yes
group: "{{ modoboa_user }}"
mode: 0640
loop: "{{ opendkim_config_lines_off }}"
loop_control:
loop_var: configline
label: "#{{ configline }}"
notify: restart opendkim
- name: setup default opendkim config
lineinfile:
path: "/etc/default/opendkim"
regexp: '^#?{{ configline.split("=")[0]}}='
line: "{{ configline }}"
group: "{{ modoboa_user }}"
mode: 0640
loop: "{{ opendkim_config_lines }}"
loop_control:
loop_var: configline
label: "{{ configline }}"
notify: restart opendkim
- name: enable opendkim systemd unit
systemd:
name: opendkim
enabled: yes
daemon_reload: yes
state: started
+40
View File
@@ -0,0 +1,40 @@
---
- name: install requirements for Postfix
apt:
update_cache: yes
state: "{% if hcs_update | bool %}latest{% else %}present{% endif %}"
install_recommends: yes
pkg:
- postfix
- postfix-pgsql
- postfix-mysql
- name: install Postfix pip requirements with dedicated pip virtualenv
pip:
name:
- psycopg2-binary
state: "{% if hcs_update | bool %}latest{% else %}present{% endif %}"
virtualenv: "{{ modoboa_py_venv }}"
- name: setup folder for postfix mapping files
file:
state: directory
path: "{{ postfix_mapping_folder }}"
mode: 0660
notify: postfix mappings setup
- name: setup postfix config
template:
src: etc/postfix/main.cf.j2
dest: "{{ postfix_dir }}/main.cf"
owner: "root"
group: "modoboa"
mode: 0664
notify: reload postfix
- name: enable postfix systemd unit
systemd:
name: postfix
enabled: yes
daemon_reload: yes
state: started