Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL integration #11

Merged
merged 7 commits into from
Mar 7, 2020

Conversation

ulvida
Copy link
Contributor

@ulvida ulvida commented Feb 24, 2020

As previously discussed, this PR with PostgreSQL option for the sympa database.

As initially in our code we install Postgres in the role itself, in order to act similarly for pgsql and mysql, I added a flag that gives the option to install the database package within the role itself or outside. And, by the way, I added some requirements checks.

As far as tested, all the four options work, meaning that the role doesn't fail and let Sympa installed and running, with its database configured. However, as the role doesn't configure Apache with Sympa web interface, I couldn't fully test yet all functionalities. It would be good if you could test also.

I will be working in the integration of Apache configuration for Sympa, with robots and other features.

Also, it seems to me that the role still makes some assumptions about the host, particularly the presence of postfix or other sendmail-like MTA. I will be also working on it, as well as DKIM integration.

@ulvida
Copy link
Contributor Author

ulvida commented Feb 24, 2020

Post Scriptum: I struggled a lot with debconf sympa parameters (see #4). Particularly, it seems that sympa/dbconfig-install has no effect here, as Sympa, when seeing a sympa.conf already present performs an upgrade, that configures the empty database provided.

In your initial code sympa/dbconfig-install was set to no, now it's set to true, but aparently it doesn't matter.

Copy link
Contributor

@Scriptkiddi Scriptkiddi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good already, I have to test it though.
Could you also please add the 2 new variables to the documentation.
Have you tested the postgresql capitalization for the config file? Can we transform it to a lowercase string?

- name: check if postgres 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."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

tasks/mysql.yml Outdated
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."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo


## Debconf keys for sympa database

- name: Definir opciones debconf de sympa, relativas a la base PostgreSQL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English please :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry... copy/paste... :)

tasks/main.yml Outdated
## set the database type
- { name: 'sympa', question: 'sympa/database-type', value: '{{ sympa_db_type }}' , vtype: select }
## Configure the database at sympa installation with dbconfig
- { name: 'sympa', question: 'sympa/dbconfig-install', value: 'true' , vtype: boolean }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want this setting? Arent we configuring the database on our own

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried again: for PostgreSQL, when I set this to false, sympa installation fails with the message:

Database sympa defined in sympa.conf has not the right structure or is unreachable. verify db_xxx parameters in sympa.conf

(and I tried again with postgresql or PostgreSQL for sympa parameter db_type, and that's the same).

For MySQL, when I tried yesterday there was no difference wether I put true or false. I'll try to figure out what is the difference between PostgreSQL and MySQL installation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm too puzzled with this dbconfig parameter. I think my initial interpretation was right: seeing sympa.conf file, sympa tries an upgrade but, with PostreSQL, fails when running:

# /usr/lib/sympa/bin/sympa.pl --health_check

One strange thing is that I don't find any reference to db_passwd in database drivers code. dbconfig must do something that I don't identify, that solves this issue.

In order to avoid staying stucked, I propose you to set sympa/dbconfig-install to true for PostgreSQL and to maintain it set to false for MySQL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible solution here. I'll test again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible solution here. I'll test again.

Eureka! Yes, it did!

@@ -113,4 +117,5 @@ sympa_default_home: home
sympa_edit_list: owner
sympa_ldap_force_canonical_email: 1
sympa_review_page_size: 25
sympa_webserver_type: Other # 'Other' or 'Apache 2'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets use lowercase strings without a space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this variables is there to set a debconf parameter of select type. When you install sympa manually, and after checking the debconf db with debconf-get-selections it clearly proposes "Other" and "Apache 2".

I did some test, pre-setting the parameter with:

echo "sympa wwsympa/webserver_type select <value>" | debconf-set-selections

trying with <value> set to Other, other, apache2, Apache 2, etc.

Without changing debconf priorities, when setting the value to Other it silently preserves this value. When setting other values, it silently overwrites to the default value Apache 2.

So I think that there, we have to stick to the exact spelling proposed for the two debconf select options.

BTW, I struggled a lot with sympa debconf parameter. Sympa has a quite peculiar behaviour: most of the parameters are low o medium priority (so they aren't asked for), several are "internal", and most of all, they seem to be heavily overwritten at installation with default values, eventually built from linux hostname.

loop:
## Set the sympa database password
- { name: 'sympa', question: 'sympa/pgsql/app-pass', value: '{{ sympa_db_password | mandatory }}' , vtype: password }
...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are those dots for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's YAML syntax for the end of a YAML section. It's not needed by Ansible, but I prefer to stick to the upstream syntax over Ansible pidgin.

tasks/postgresql.yml Outdated Show resolved Hide resolved
---
## PostgreSQL installation and configuration for sympa

- name: check PostgreSQL installation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please start with a capital Letter

tasks/mysql.yml Outdated Show resolved Hide resolved
tasks/mysql.yml Outdated
package_facts:
manager: auto

- name: check if MySQL is installed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please start with a capital letter

@ulvida
Copy link
Contributor Author

ulvida commented Feb 24, 2020

Looks good already, I have to test it though.

Good! No hurry..

Could you also please add the 2 new variables to the documentation.

Right! (going to bed I realized I forgot to update the README... :)

Have you tested the postgresql capitalization for the config file? Can we transform it to a lowercase string?

I sticked to sympa documentation, considering also that letter case matters in Perl. However, I just tried with postgresql and it works, and the very same documentation mentions different letter cases for MySQL. So Ok, let's try to use lower case.

@ulvida
Copy link
Contributor Author

ulvida commented Feb 24, 2020

PostgreSQL or postgresql?

My colleague @santiagomr tackles me arguing that proper names start with a capital case letter. And PostgreSQL project itself uses this ElephantC... sorry CamelCase wording.

On another hand, Debian packages' names are all lower case, and I understand the principle you propose to use only lower case in variable values.

So I propose you: let's use lower case (and no space) to refer to packages and, as far as possible, for variable values, but accept capital letters when refering to a proper name. Do you agree?

name:
- debconf
- debconf-utils
state: latest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this requirements' check, as suggested by Ansible documentation, even if it seems to work without debconf-utils package.

@ulvida
Copy link
Contributor Author

ulvida commented Feb 25, 2020

Have you tested the postgresql capitalization for the config file? Can we transform it to a lowercase string?

I sticked to sympa documentation, considering also that letter case matters in Perl. However, I just tried with postgresql and it works, and the very same documentation mentions different letter cases for MySQL. So Ok, let's try to use lower case.

Well, despite the fact that on the first run of the playbook It works ok with lowercase postgresql, when I re-run it on a server installed, then sympa falls to a misconfigured state with systemctl giving the message:

feb 25 15:04:59 cazuela sympa_msg[17412]: err main::#87 > main::_load#314 > Sympa::DatabaseManager::instance#54 > Sympa::Database::new#62 Unable to use Sympa::DatabaseDriver::postgresql module: Can't locate Symp...

This Sympa::DatabaseDriver::postgresql is a reference to the Perl code files of sympa, so I think it needs the correct case spelling.

@ulvida ulvida changed the title PostgreSQL integration WIP: PostgreSQL integration Feb 25, 2020
@ulvida
Copy link
Contributor Author

ulvida commented Feb 26, 2020

Have you tested the postgresql capitalization for the config file? Can we transform it to a lowercase string?
After my heavily checked last commit, I tried again with lower case postgresql for db_type sympa.conf parameter, and then sympa package installation clearly hangs with message:

Database sympa defined in sympa.conf has not the right structure or is unreachable. verify db_xxx parameters in sympa.conf

So precise spelling is clearly needed, as part of Perl code.

According to documentation (PosgreSQL and MySQL), Pg and mysql are deprecated/obsoleted values of this parameter.

@ulvida ulvida changed the title WIP: PostgreSQL integration PostgreSQL integration Feb 26, 2020
@ulvida
Copy link
Contributor Author

ulvida commented Feb 26, 2020

I think I'm done with this PR. Whenever you can review it, I have more proposals for you.

If you want, I can squash my commits, eventually preserving the versioned ones.

@Scriptkiddi Scriptkiddi merged commit 37f2ad6 into stuvusIT:master Mar 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants