Skip to content

Commit

Permalink
Apply linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenhard Reuter committed Jun 27, 2023
1 parent 454b111 commit 06043c8
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 85 deletions.
5 changes: 5 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exclude_paths:
- .github
- tests
skip_list:
- role-name
19 changes: 10 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
repos:
- repo: https://github.com/ansible-community/ansible-lint.git
rev: v6.6.1
hooks:
- id: ansible-lint
files: \.(yaml|yml)$
- repo: https://github.com/ansible-community/ansible-lint.git
rev: v6.17.2
hooks:
- id: ansible-lint
files: \.(yaml|yml)$

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

Copyright (C) 2021 AIT Austrian Institute of Technology
Copyright (C) 2021 AIT Austrian Institute of Technology

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ Installs and configures [horde webmail](https://www.horde.org/)
## License

GPL-3.0

2 changes: 2 additions & 0 deletions meta/.galaxy_install_info
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
install_date: Wed Oct 12 12:22:08 2022
version: v1.3.2
53 changes: 27 additions & 26 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
---
- name: Configurate horde
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dst }}"
mode: 0644
group: "{{ item.group | default('www-data') }}"
loop: "{{ horde_templates_list }}"
src: '{{ item.src }}'
dest: '{{ item.dst }}'
mode: '0644'
group: "{{ item.group | default('www-data') }}"
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 }}"
src: '{{ item.src }}'
dest: '{{ item.dest }}'
mode: '{{ item.mode }}'
loop: '{{ horde_certificate }}'

- name: Remove default apache2 configs
ansible.builtin.file:
dest: /etc/apache2/{{ item }}
state: absent
dest: /etc/apache2/{{ item }}
state: absent
loop:
- sites-available/000-default.conf
- sites-enabled/000-default.conf
- sites-available/default-ssl.conf
- sites-enabled/default-ssl.conf
- conf-available/php-horde.conf
- conf-enabled/php-horde.conf
- sites-available/000-default.conf
- sites-enabled/000-default.conf
- sites-available/default-ssl.conf
- sites-enabled/default-ssl.conf
- conf-available/php-horde.conf
- conf-enabled/php-horde.conf
notify: Restart apache2

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

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

- name: Manual apache2 restart
ansible.builtin.service:
name: apache2
state: restarted
name: apache2
state: restarted

- name: Activate webmail
ansible.builtin.command: a2ensite webmail
args:
creates: /etc/apache2/sites-enabled/webmail.conf
creates: /etc/apache2/sites-enabled/webmail.conf
notify: Restart apache2
changed_when: false
38 changes: 23 additions & 15 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
---
- name: Setup database
ansible.builtin.include_role:
name: mariadb
name: mariadb
vars:
mariadb_databases:
- name: "{{ horde_db_name }}"
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: Gather os specific variables
ansible.builtin.include_vars: "{{ item }}"
ansible.builtin.include_vars: '{{ item }}'
with_first_found:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
- default.yml
- '{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml'
- default.yml

- name: Install required apt packages
ansible.builtin.package:
name: "{{ horde_apt_packages }}"
state: present
name: '{{ horde_apt_packages }}'
state: present

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

- 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 }}"
echo: true
command: webmail-install
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
Expand Down
66 changes: 38 additions & 28 deletions tasks/pear.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,80 @@
---

- name: Check if horde pear channel is installed
ansible.builtin.shell:
cmd: |
set -o pipefail && \
pear list-channels | grep pear.horde.org
executable: /usr/bin/bash
cmd: |
set -o pipefail && \
pear list-channels | grep pear.horde.org
executable: /usr/bin/bash
register: channel_registered
failed_when: channel_registered.rc >= 2
changed_when: channel_registered.stdout

- name: Discover horde PEAR channel
ansible.builtin.command: pear channel-discover pear.horde.org
ansible.builtin.command:
cmd: pear channel-discover pear.horde.org
changed_when: false
when: channel_registered.stdout == ''

- name: Check if horde pear package is installed
ansible.builtin.shell:
cmd: |
set -o pipefail && \
pear list -c pear.horde.org | grep Horde_Role
executable: /usr/bin/bash
cmd: |
set -o pipefail && \
pear list -c pear.horde.org | grep Horde_Role
executable: /usr/bin/bash
register: package_installed
failed_when: package_installed.rc >= 2
changed_when: package_installed.stdout == ''

- name: Install horde package
ansible.builtin.command: pear install horde/horde_role
ansible.builtin.command:
cmd: pear install horde/horde_role
changed_when: false
become: true
when: package_installed.stdout == ''

- name: Fix unexpected 'new' (T_NEW) error
ansible.builtin.shell:
cmd: |
pear uninstall File_Fstab && \
pear uninstall Services_Weather && \
pear uninstall horde/Horde_Service_Weather
executable: /usr/bin/bash
ansible.builtin.command:
cmd: |
pear uninstall File_Fstab && \
pear uninstall Services_Weather && \
pear uninstall horde/Horde_Service_Weather
executable: /usr/bin/bash
changed_when: false

- name: Execute Horde run scripts
ansible.builtin.expect:
args:
command: pear run-scripts horde/horde_role
responses: "{{ horde_run_scripts_responses }}"
echo: true
command: pear run-scripts horde/horde_role
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
become: true

- name: Check if horde pear webmail is installed
ansible.builtin.shell:
cmd: |
set -o pipefail && \
pear list -c pear.horde.org | grep webmail
executable: /usr/bin/bash
cmd: |
set -o pipefail && \
pear list -c pear.horde.org | grep webmail
executable: /usr/bin/bash
register: webmail_package_installed
failed_when: webmail_package_installed.rc >= 2
changed_when: webmail_package_installed.stdout == ''

- name: Install horde webmail
ansible.builtin.command: pear install -a -B --force horde/webmail
ansible.builtin.command:
cmd: pear install -a -B --force horde/webmail
changed_when: false
become: true
when: webmail_package_installed.stdout == ''

- name: Fixing syntax error in a dependency PHP module.
ansible.builtin.command: sed -i '167s/&//' /usr/share/php/Services/Weather.php
ansible.builtin.command:
cmd: sed -i '167s/&//' /usr/share/php/Services/Weather.php
changed_when: false
when: package_installed.stdout == ''
tags:
- skip_ansible_lint
- skip_ansible_lint
become: true
2 changes: 1 addition & 1 deletion templates/backends.php.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ $servers['imap'] = array(
IMP_Mailbox::MBOX_SENT => 'Sent',
),
'autocreate_special' => true,
);
);
2 changes: 1 addition & 1 deletion templates/hooks.php.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class Horde_Hooks
}
return '';
}
}
}
2 changes: 1 addition & 1 deletion templates/mnemo.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ $conf['storage']['params']['driverconfig'] = 'horde';
$conf['storage']['driver'] = 'sql';
$conf['notepads']['driver'] = 'default';
$conf['menu']['import_export'] = true;
/* CONFIG END. DO NOT CHANGE ANYTHING IN OR BEFORE THIS LINE. */
/* CONFIG END. DO NOT CHANGE ANYTHING IN OR BEFORE THIS LINE. */
2 changes: 1 addition & 1 deletion templates/prefs.php.j2
Original file line number Diff line number Diff line change
Expand Up @@ -508,4 +508,4 @@ $_prefs['last_logintasks'] = array(
$_prefs['upgrade_tasks'] = array(
// value = serialize(array())
'value' => 'a:0:{}'
);
);
2 changes: 1 addition & 1 deletion templates/vhost.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
SSLCertificateFile {{ horde_cert.dest }}
SSLCertificateKeyFile {{ horde_cert_key.dest }}

</VirtualHost>
</VirtualHost>

0 comments on commit 06043c8

Please sign in to comment.