Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenhard Reuter committed Mar 27, 2024
1 parent 6efc973 commit 78e1386
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 61 deletions.
2 changes: 0 additions & 2 deletions meta/.galaxy_install_info

This file was deleted.

27 changes: 10 additions & 17 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
---
- name: Configurate horde
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dst }}"
mode: "0644"
src: '{{ item.src }}'
dest: '{{ item.dst }}'
mode: '0644'
group: "{{ item.group | default('www-data') }}"
loop: "{{ horde_templates_list }}"
loop: '{{ horde_templates_list }}'
notify: Restart services

# Enable HTTPS
- name: Copy certificate
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
loop: "{{ horde_certificate }}"

- name: Remove default apache2 configs
ansible.builtin.file:
dest: /etc/apache2/{{ item }}
Expand All @@ -31,15 +23,15 @@

- name: Ensure log directory exist
ansible.builtin.file:
path: "{{ horde_log_path }}"
path: '{{ horde_log_path }}'
state: directory
mode: "0750"
mode: '0750'

- name: Activate apache2_modules
community.general.apache2_module:
name: "{{ item }}"
name: '{{ item }}'
state: present
loop: "{{ horde_apache2modules }}"
loop: '{{ horde_apache2modules }}'
become: true

- name: Manual apache2 restart
Expand All @@ -48,7 +40,8 @@
state: restarted

- name: Activate webmail
ansible.builtin.command: a2ensite webmail
ansible.builtin.command:
cmd: a2ensite webmail
args:
creates: /etc/apache2/sites-enabled/webmail.conf
notify: Restart apache2
Expand Down
33 changes: 22 additions & 11 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,51 @@
ansible.builtin.include_role:
name: mariadb
vars:
mariadb_users:
[
{
name: '{{ horde_db_user }}',
password: '{{ horde_db_pass }}',
privileges: '{{ horde_db_name }}.*:ALL,GRANT',
},
]
mariadb_databases:
- name: "{{ horde_db_name }}"
mariadb_users: [{ name: "{{ horde_db_user }}", password: "{{ horde_db_pass }}", privileges: "{{ horde_db_name }}.*:ALL,GRANT" }]
- name: '{{ horde_db_name }}'

- name: Gather os specific variables
ansible.builtin.include_vars: "{{ item }}"
ansible.builtin.include_vars: '{{ item }}'
with_first_found:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
- '{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml'
- default.yml

- name: Install required apt packages
become: true
ansible.builtin.apt:
name: "{{ horde_apt_packages }}"
name: '{{ horde_apt_packages }}'
state: present
update_cache: true
cache_valid_time: 3600

- name: Install Horde via pear
ansible.builtin.include_tasks: pear.yml
when: ansible_distribution_version != '18.04'
ansible.builtin.include_tasks:
file: pear.yml

- name: Install required pip packages
ansible.builtin.pip:
name: "{{ horde_pip_packages }}"
name: '{{ horde_pip_packages }}'

- name: Run webmail install
ansible.builtin.expect:
args:
command: webmail-install
responses: "{{ horde_webinstall_responses }}"
responses: '{{ horde_webinstall_responses }}'
echo: true
register: expect_webmail_install_result
failed_when: expect_webmail_install_result.rc != 0 and 'Thank you for using Horde Groupware Webmail Edition!' not in expect_webmail_install_result.stdout
failed_when:
expect_webmail_install_result.rc != 0 and 'Thank you for using Horde
Groupware Webmail Edition!' not in expect_webmail_install_result.stdout
become: true

- name: Configure Horde and Apache
ansible.builtin.import_tasks: configure.yml
ansible.builtin.import_tasks:
file: configure.yml
10 changes: 7 additions & 3 deletions tasks/pear.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
ansible.builtin.command:
cmd: pear channel-discover pear.horde.org
register: channel_discovery
failed_when: channel_discovery.rc != 0 and 'already initialized' not in channel_discovery.stdout
failed_when:
channel_discovery.rc != 0 and 'already initialized' not in
channel_discovery.stdout
changed_when: "'succeeded' in channel_discovery.stdout"

- name: Install pear package horde/horde_role
Expand All @@ -17,10 +19,12 @@
ansible.builtin.expect:
args:
command: pear run-scripts horde/horde_role
responses: "{{ horde_run_scripts_responses }}"
responses: '{{ horde_run_scripts_responses }}'
echo: true
register: run_scripts_install_result
failed_when: run_scripts_install_result.rc != 0 and 'Install scripts complete' not in run_scripts_install_result.stdout
failed_when:
run_scripts_install_result.rc != 0 and 'Install scripts complete' not in
run_scripts_install_result.stdout

- name: Install pear package horde/webmail
become: true
Expand Down
4 changes: 2 additions & 2 deletions templates/vhost.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ErrorLog {{ horde_log_path }}/horde-error.log

SSLEngine on
SSLCertificateFile {{ horde_cert.dest }}
SSLCertificateKeyFile {{ horde_cert_key.dest }}
SSLCertificateFile {{ horde_cert }}
SSLCertificateKeyFile {{ horde_cert_key }}

</VirtualHost>
28 changes: 2 additions & 26 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
---
# # Horde install
# horde_admin_username: "admin"
# horde_admin_password: "admin"

# # mail config
# horde_mail_domain: "organisation.cyberrange.at"
# horde_mail_imap_servername: "Organisation mailserver"
# horde_mail_imap_server: "mailserver.organisation.cyberrange.at"
# horde_mail_imap_port: 143
# horde_mail_imap_secure: "tls"
# horde_mail_protocol: "imap"
# horde_mail_smtp_server: "mailserver.organisation.cyberrange.at"
# horde_mail_smtp_port: 587
# horde_mail_smtp_secure: "tls"

# # Database
# horde_db_user: "horde"
# horde_db_pass: "horde"
# horde_db_name: "horde"
# horde_db:
# - name: "{{ horde_db_name }}"
# horde_db_users:
# - { name: "{{ horde_db_user }}", password: "{{ horde_db_pass }}" }

horde_services:
- apache2
- "{{ horde_sender_service }}" # postfix
- "{{ horde_receiver_service }}" # dovecot
- '{{ horde_sender_service }}' # postfix
- '{{ horde_receiver_service }}' # dovecot

0 comments on commit 78e1386

Please sign in to comment.