Skip to content

Commit

Permalink
According to @Scriptkiddi code review, except sympa/dbconfig-install …
Browse files Browse the repository at this point in the history
…debconf parameter
  • Loading branch information
ulvida committed Feb 24, 2020
1 parent 555e70d commit ef2b37c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sympa_template_lists: []

## Database variables
sympa_db_type: mysql # mysql or PostgreSQL
sympa_install_db_package: false # yes for this role to install mysql or postgres, no if installed elsewhere
sympa_install_db_package: False # yes for this role to install mysql or postgres, no if installed elsewhere
sympa_db_name: sympa
sympa_db_host: localhost
sympa_db_port: 3306
Expand Down
11 changes: 9 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
---
## Sympa configuration main tasks file

- name: Check that "debconf" and "debconf-utils" are installed
apt:
name:
- debconf
- debconf-utils
state: latest

- name: MySQL/MariaDB configuration
include_tasks: mysql.yml
when: sympa_db_type == 'mysql'
when: sympa_db_type | lower == 'mysql'

- name: PostgreSQL configuration
include_tasks: postgresql.yml
when: sympa_db_type == 'PostgreSQL'
when: sympa_db_type | lower == 'postgresql'

- name: Set debconf options for sympa
debconf:
Expand Down
8 changes: 4 additions & 4 deletions tasks/mysql.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
## MySQL configuration for sympa

- name: check MySQL installation
- name: Check MySQL installation
block:
- name: Gather installed packages
package_facts:
manager: auto

- name: check if MySQL is installed
- 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 pachage found. We stop, because we can't install sympa without its database. Sorry."
success_msg: "MySQL package found. We can continue!"
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
Expand Down
21 changes: 9 additions & 12 deletions tasks/postgresql.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
## PostgreSQL installation and configuration for sympa

- name: check PostgreSQL installation
- name: Check PostgreSQL installation
block:
- name: Gather installed packages
package_facts:
manager: auto

- name: check if postgres is installed
- name: Check if postgresql server package is installed
assert:
that: ansible_facts.packages['postgresql'] is defined
fail_msg: "No PostgreSQL pachage found. We stop, because we can't install sympa without its database. Sorry."
success_msg: "PostgreSQL package found. We can continue!"
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
Expand Down Expand Up @@ -53,13 +53,10 @@

## Debconf keys for sympa database

- name: Definir opciones debconf de sympa, relativas a la base PostgreSQL
- name: Define sympa postgresql database's password through debconf
debconf:
name: "{{ item.name }}"
question: "{{ item.question }}"
value: "{{ item.value }}"
vtype: "{{ item.vtype }}"
loop:
## Set the sympa database password
- { name: 'sympa', question: 'sympa/pgsql/app-pass', value: '{{ sympa_db_password | mandatory }}' , vtype: password }
name: sympa
question: 'sympa/pgsql/app-pass'
value: '{{ sympa_db_password | mandatory }}'
vtype: password
...

0 comments on commit ef2b37c

Please sign in to comment.