diff --git a/defaults/main.yml b/defaults/main.yml index 40ef5f5..9c1b4f7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index b549aff..07aa0e5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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: diff --git a/tasks/mysql.yml b/tasks/mysql.yml index 56393e2..feb20d1 100644 --- a/tasks/mysql.yml +++ b/tasks/mysql.yml @@ -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 diff --git a/tasks/postgresql.yml b/tasks/postgresql.yml index fe87031..e35641e 100644 --- a/tasks/postgresql.yml +++ b/tasks/postgresql.yml @@ -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 @@ -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 ...