Alfresco / alfresco-ansible-deployment

Ansible playbooks for deploying ACS
https://alfresco.github.io/alfresco-ansible-deployment/
Apache License 2.0
29 stars 33 forks source link

Postgres Deployment post-task fails when external database is used #716

Closed jalvarezferr closed 9 months ago

jalvarezferr commented 10 months ago

The post task is missing a when clause, so it is run even when Postgres is not installed because repo_db_url or sync_db_url where provided.

https://github.com/Alfresco/alfresco-ansible-deployment/blob/ecc58887a6072b5613ccd16048a2de1e4c60297a/playbooks/acs.yml#L44

alxgomz commented 10 months ago

internally tracked in OPSEXP-2407

alxgomz commented 10 months ago

The error actually triggers as you probably still have a database host set in your inventory file while also providing external urls.

gionn commented 10 months ago

@jalvarezferr can you confirm that removing every host from the database group in your inventory solve the issue?

alxgomz commented 10 months ago

Delayed fix to OPSEXP-2408 (target 3.0.0)

morgan-patou commented 9 months ago

I was planning to test the external DB today and I just found your issue so please allow me to participate here.

My understanding of the external DB is the following one: when defining yourself repo_db_url, the playbook is supposed to not use the "internal" PG but instead use the following properties to setup Alfresco:

repo_db_name: "alfresco"
repo_db_username: "alfresco"
repo_db_driver: "org.postgresql.Driver"
repo_db_url: "jdbc:postgresql://<host>:<port>/{{ repo_db_name }}"

When using this repo_db_url, you are indeed supposed to not have any host as part of the group database, otherwise there could be some side effects. The role for PG installation will still be executed if sync_db_url is empty (default), even if there is no syncservice group member, which isn't optimal. I quickly checked above #720 link and it seems that this was taken into account but isn't yet in the master branch. So that means for now, you should either not have anything in the database group OR define both repo_db_url AND sync_db_url to something not empty, otherwise the postgres role will be executed.

I tested on my side and for me, it works properly when the database role is empty with the following properties defined:

repo_db_host: "DB_HOST_VIP"
repo_db_port: "5432"
repo_db_name: "alfresco"
repo_db_username: "alfresco"
repo_db_driver: "org.postgresql.Driver"
repo_db_url: "jdbc:postgresql://{{ repo_db_host }}:{{ repo_db_port }}/{{ repo_db_name }}"

sync_db_host: "{{ repo_db_host }}"
sync_db_port: "{{ repo_db_port }}"
sync_db_name: "alfresco-sync"
sync_db_username: "alfresco-sync"
sync_db_driver: "org.postgresql.Driver"
sync_db_url: ""

There is only 1 issue I faced related to the driver but I will open a PR for that.

gionn commented 9 months ago

we will refactor the external db handling and move it to the inventory like we did for external activemq and elasticsearch. For now we assume that, beside configuring all the repo_db_* and sync_db_*, also the inventory must have no hosts defined in the database group.

Thanks @morgan-patou for confirming it works as described above.

jalvarezferr commented 9 months ago

@jalvarezferr can you confirm that removing every host from the database group in your inventory solve the issue?

Hi. Sorry I was absent from the thread. The notifications got lost in my email. I see the update done and applied to 2.4.2, but I believe the issue persists as in the scenario that I experienced with 2.3.0, I was using the included inventory-localhos.yml file for a single sever deployment, where no database hosts are defined. Yet, the post-task was run anyway and caused the error. I'll test with 2.4.2 as soon as I can adopt the new version in my automations.

alxgomz commented 9 months ago

Hi @jalvarezferr

Actually the inventory file we ship as inventory_local.yml DO contain a database host. It is specificied as all.children.database.children.repository which means that any host that's memeber of repository is member of database, and repository group has one host: localhost. you need to remove all.children.database.children to clear out any database host 

jalvarezferr commented 9 months ago

Thanks. That's very true. Anyway, it seems that the code uses two different ways for the same purpose. On one hand the role has the when clause depending on the jdbc url vars to be set or not, and on the other hand the post_tasks rely on the inventory. Even if the JDBC urls are there for a side case I have not identified, then the post-taks would need a when clause too. Or neither of them do. Isn't it?

alxgomz commented 9 months ago

As stated by @gionn this code needs refactoring. These repo_db_url & sync_db_url are legacy vars we want to get rid of and align external database handling to other external services (through inventory). This is work we can only undertake for 3.0 as this would break the configuration interface used IN 0.x, 1.x & 2.x