-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from UdelaRInterior/issue2-upstream
PostgreSQL integration
- Loading branch information
Showing
6 changed files
with
195 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
# sympa | ||
This is an Ansible role which sets up a sympa | ||
|
||
This is an Ansible role which sets up a [Sympa](https://sympa.org) mailing list manager. | ||
|
||
|
||
## Requirements | ||
|
||
Debian or Ubuntu with a webserver that serves the sympa web app and a mysql database for it. | ||
Debian stretch or Ubuntu server. MySQL/MariaDB or PostgreSQL database options. Database manager can be previously installed in the host (default) or optionnally installed by the role itself. Webserver for Sympa should be configured elsewhere. | ||
|
||
|
||
## Role Variables | ||
|
||
For the full documentation see https://sympa-community.github.io/, this was tested with Sympa Version 6.2.16 | ||
For the full documentation see https://sympa-community.github.io/, this role was tested with Sympa Version 6.2.16 (Debian stretch sympa package). | ||
|
||
### List Templates | ||
`sympa_template_lists` is a list of templates to be defined. | ||
|
@@ -58,7 +59,7 @@ Each entry consists of the following: | |
| `name` | :heavy_check_mark: | Name of the auth option like ldap, user_table | | ||
| `options` | :heavy_check_mark: | Dict of options for the auth method | | ||
|
||
## Example | ||
#### Example | ||
|
||
```yaml | ||
sympa_auth: | ||
|
@@ -90,7 +91,7 @@ Each list entry contains the following: | |
| `path` | :heavy_check_mark: | Path of the category | | ||
| `title` | :heavy_check_mark: | Title of the category | | ||
|
||
## Example | ||
#### Example | ||
|
||
```yaml | ||
sympa_topics: | ||
|
@@ -100,6 +101,13 @@ title: Art | |
title: Expressionism | ||
``` | ||
|
||
### Database manager | ||
|
||
| Name | Required/Default | Description | | ||
|:---------------------------|:------------------:|:------------------------------------------------------------------------------------------| | ||
| `sympa_db_type` | `mysql` | Choice of database manager. `MySQL` or `PostgreSQL`. `mysql` and `Pg` values are acceptable, but deprecated. Other database options are not managed. | | ||
| `sympa_install_db_package` | `False` | Whether the db manager is installed previously (`False`) or the role installs it (`True`) | | ||
|
||
### Sympa Variables | ||
|
||
| Name | Required/Default | Description | | ||
|
@@ -207,3 +215,4 @@ This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 Inter | |
## Author Information | ||
|
||
* [Fritz Otlinghaus (Scriptkiddi)](https://github.com/Scriptkiddi) [email protected]_ | ||
* [UdelaR Interior](https://github.com/UdelaRInterior) contributions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
## MySQL configuration for sympa | ||
|
||
- name: Check MySQL installation | ||
block: | ||
- name: Gather installed packages | ||
package_facts: | ||
manager: auto | ||
|
||
- name: Check if mysql server package is installed | ||
assert: | ||
that: > | ||
ansible_facts.packages['default-mysql-server'] is defined or | ||
ansible_facts.packages['mysql-server'] is defined or | ||
ansible_facts.packages['mariadb-server-10.1'] is defined | ||
## The last condition could be replaced by a jinja2 json_query filter to match any version | ||
fail_msg: "No mysql package found. We stop, because we can't install sympa without its database. Sorry." | ||
success_msg: "mysql package found. We can continue!" | ||
when: not sympa_install_db_package | ||
|
||
- name: Install MySQL packages | ||
apt: | ||
name: | ||
- default-mysql-server | ||
- python-dev | ||
- default-libmysqlclient-dev | ||
state: present | ||
when: sympa_install_db_package | ||
|
||
- name: Install pip, if not yet installed | ||
apt: | ||
name: python-pip | ||
state: present | ||
|
||
- name: install mysqlclient pip module, if not yet installed | ||
pip: | ||
name: mysqlclient | ||
state: present | ||
|
||
- name: Create a new database with name '{{ sympa_db_name }}' | ||
mysql_db: | ||
name: "{{ sympa_db_name }}" | ||
encoding: utf8 | ||
|
||
- name: Create DB user '{{ sympa_db_user }}' | ||
mysql_user: | ||
name: "{{ sympa_db_user }}" | ||
password: "{{ sympa_db_password | mandatory }}" | ||
priv: '{{ sympa_db_name }}.*:ALL,GRANT' | ||
no_log: True | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
## PostgreSQL installation and configuration for sympa | ||
|
||
- name: Check PostgreSQL installation | ||
block: | ||
- name: Gather installed packages | ||
package_facts: | ||
manager: auto | ||
|
||
- name: Check if postgresql server package is installed | ||
assert: | ||
that: ansible_facts.packages['postgresql'] is defined | ||
fail_msg: "No postgresql package found. We stop, because we can't install sympa without its database. Sorry." | ||
success_msg: "postgresql package found. We can continue!" | ||
when: not sympa_install_db_package | ||
|
||
- name: Install PostgreSQL | ||
apt: | ||
state: present | ||
update_cache: yes | ||
cache_valid_time: 3600 | ||
name: | ||
- postgresql | ||
- postgresql-contrib | ||
- libpq-dev | ||
- python-psycopg2 | ||
- dbconfig-pgsql | ||
when: sympa_install_db_package | ||
tags: postgresql | ||
|
||
- name: Create sympa database | ||
become: true | ||
become_user: postgres | ||
postgresql_db: | ||
name: "{{ sympa_db_name }}" | ||
encoding: UTF-8 | ||
lc_collate: es_UY.UTF-8 | ||
lc_ctype: es_UY.UTF-8 | ||
template: template0 | ||
state: present | ||
tags: postgresql | ||
|
||
- name: Create sympa user with access to the database | ||
become: true | ||
become_user: postgres | ||
postgresql_user: | ||
db: "{{ sympa_db_name }}" | ||
name: "{{ sympa_db_user }}" | ||
password: "{{ sympa_db_password | mandatory }}" | ||
priv: ALL | ||
state: present | ||
|
||
|
||
## Debconf keys for sympa database | ||
|
||
- name: Set password debconf option for Sympa PostgreSQL database | ||
debconf: | ||
name: sympa | ||
question: sympa/pgsql/app-pass | ||
value: "{{ sympa_db_password | mandatory }}" | ||
vtype: password | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters