Skip to content

Commit 7f46a6d

Browse files
gionnpmacius
andauthored
OPSEXP-3235 refactor: extract db common vars to the main playbook (#1174)
Co-authored-by: pmacius <[email protected]> Co-authored-by: pmacius <[email protected]>
1 parent 57b0830 commit 7f46a6d

File tree

13 files changed

+42
-31
lines changed

13 files changed

+42
-31
lines changed

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,5 @@
203203
}
204204
]
205205
},
206-
"generated_at": "2025-05-14T10:07:54Z"
206+
"generated_at": "2025-05-23T12:57:23Z"
207207
}

playbooks/acs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@
334334
tomcat_version: "{{ acs_play_tomcat_version }}" # noqa: var-naming[no-role-prefix]
335335
repository_nexus_username: "{{ nexus_user }}"
336336
repository_nexus_password: "{{ nexus_password }}"
337-
repository_db_url: "{{ acs_play_repo_db_url }}"
337+
repository_db_url: "{{ acs_play_computed_repo_db_url }}"
338338
repository_acs_is_enterprise: "{{ acs_is_enterprise }}"
339339
repository_acs_version: "{{ acs_play_repository_acs_version }}"
340340
repository_acs_artifact_name: "{{ acs_play_repository_acs_artifact_name }}"
@@ -537,9 +537,9 @@
537537
name: "../roles/search_enterprise"
538538
vars:
539539
java_version: "{{ acs_play_java_version }}" # noqa: var-naming[no-role-prefix]
540-
search_enterprise_repo_db_url: "{{ acs_play_repo_db_url }}"
541-
search_enterprise_repo_db_name: "{{ acs_play_repo_db_name }}"
540+
search_enterprise_repo_db_url: "{{ acs_play_computed_repo_db_url }}"
542541
search_enterprise_repo_db_username: "{{ acs_play_repo_db_username }}"
542+
search_enterprise_repo_db_password: "{{ repo_db_password }}"
543543
search_enterprise_version: "{{ acs_play_search_enterprise_version }}"
544544
search_enterprise_zip_url: "{{ acs_play_search_enterprise_zip_url }}"
545545
search_enterprise_zip_checksum: "{{ acs_play_search_enterprise_zip_checksum }}"
@@ -687,7 +687,7 @@
687687
sync_jdbc_driver_version: "{{ acs_play_sync_jdbc_driver_version }}"
688688
sync_jdbc_driver_url: "{{ acs_play_sync_jdbc_driver_url }}"
689689
sync_jdbc_driver_checksum: "{{ acs_play_sync_jdbc_driver_checksum }}"
690-
sync_db_url: "{{ acs_play_sync_db_url }}"
690+
sync_db_url: "{{ acs_play_computed_sync_db_url }}"
691691
sync_db_driver: "{{ acs_play_sync_db_driver }}"
692692
sync_db_name: "{{ acs_play_sync_db_name }}"
693693
sync_db_username: "{{ acs_play_sync_db_username }}"

playbooks/facts.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@
1111
ansible.builtin.set_fact:
1212
hxi_enabled: "{{ groups.hxi | default([]) | length > 0 }}"
1313

14+
- name: Set facts related to hosts
15+
ansible.builtin.set_fact:
16+
db_host: >-
17+
{{ groups['database']
18+
| default([])
19+
| map('extract', hostvars, ['ansible_default_ipv4', 'address'])
20+
| first
21+
| default('127.0.0.1') }}
22+
23+
- name: Set facts computed with some logic
24+
ansible.builtin.set_fact:
25+
acs_play_computed_repo_db_url: >-
26+
{{ acs_play_repo_db_url if acs_play_repo_db_url else
27+
'jdbc:postgresql://' + db_host + ':' + ports_cfg_postgres_sql | string + '/' + acs_play_repo_db_name }}
28+
acs_play_computed_sync_db_url: >-
29+
{{ acs_play_sync_db_url if acs_play_sync_db_url else
30+
'jdbc:postgresql://' + db_host + ':' + ports_cfg_postgres_sql | string + '/' + acs_play_sync_db_name }}
31+
1432
- name: Validate acs edition value
1533
ansible.builtin.assert:
1634
that:

playbooks/group_vars/all.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ acs_play_community_repository_acs_artifact_name: alfresco-content-services-commu
6464
acs_play_community_repository_acs_repository: "{{ nexus_repository.releases }}"
6565
acs_play_community_repository_amp_googledrive_repo_artifact_name: alfresco-googledrive-repo-community
6666
acs_play_community_repository_amp_googledrive_repo_repository: "{{ nexus_repository.releases }}/integrations"
67+
68+
ports_cfg_postgres_sql: 5432

playbooks/group_vars/repository.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ acs_play_port: >-
6363
global_properties:
6464
db:
6565
url: >-
66-
{{ acs_play_repo_db_url if acs_play_repo_db_url else 'jdbc:postgresql://' + db_host + ':' + ports_cfg.postgres.sql | string + '/' + acs_play_repo_db_name }}
66+
{{ acs_play_computed_repo_db_url }}
6767
driver: "{{ acs_play_repo_db_driver }}"
6868
username: "{{ acs_play_repo_db_username }}"
6969
password: "{{ repo_db_password }}"

playbooks/prerun-network-checks.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
22
# This playbook is used to run preliminary network checks for the hosts in the ACS deployment.
3+
- name: Include vars based on acs major version
4+
ansible.builtin.import_playbook: include-vars.yml
5+
- name: Populate deployment configuration facts
6+
ansible.builtin.import_playbook: facts.yml
37
- name: Gather facts on all the hosts
48
hosts: all:!external
59
gather_facts: false
@@ -19,7 +23,7 @@
1923
ansible.builtin.include_tasks: "tasks/check_port.yml"
2024
vars:
2125
checked_host: "{{ db_host }}"
22-
checked_port: "{{ ports_cfg.postgres.sql }}"
26+
checked_port: "{{ ports_cfg_postgres_sql }}"
2327
delegate_target: "{{ groups.database | first }}"
2428
when: acs_play_repo_db_url == "" and groups.database | default([]) | length > 0
2529

@@ -116,7 +120,7 @@
116120
ansible.builtin.include_tasks: "tasks/check_port.yml"
117121
vars:
118122
checked_host: "{{ db_host }}"
119-
checked_port: "{{ ports_cfg.postgres.sql }}"
123+
checked_port: "{{ ports_cfg_postgres_sql }}"
120124
delegate_target: "{{ groups.database | first }}"
121125
when: acs_play_repo_db_url == "" and groups.database | default([]) | length > 0
122126

roles/common/defaults/main.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ activemq_transport: >-
4040
| first
4141
| default('tcp') }}
4242
activemq_protocol: openwire
43-
db_host: >-
44-
{{ groups['database']
45-
| default([])
46-
| map('extract', hostvars, ['ansible_default_ipv4', 'address'])
47-
| first
48-
| default('127.0.0.1') }}
4943
solr_host: >-
5044
{{ groups['search']
5145
| default([])
@@ -119,8 +113,6 @@ ports_cfg:
119113
http: 8080
120114
https: 8443
121115
shutdown: 8005
122-
postgres:
123-
sql: 5432
124116
transformers:
125117
tengine: 8090
126118
trouter: 8095

roles/repository/tasks/main.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,6 @@
514514
owner: root
515515
group: root
516516

517-
- name: Wait-for-db
518-
ansible.builtin.wait_for:
519-
host: "{{ db_host }}"
520-
port: "{{ ports_cfg.postgres.sql }}"
521-
when: not repository_db_url | default(false)
522-
523517
- name: Check if service restart is needed
524518
ansible.builtin.debug:
525519
msg: triggering service restart

roles/search_enterprise/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ search_enterprise_zip_username: null
1515
search_enterprise_zip_password: null
1616

1717
search_enterprise_repo_db_url: ""
18-
search_enterprise_repo_db_name: "alfresco"
1918
search_enterprise_repo_db_username: "alfresco"
19+
search_enterprise_repo_db_password: ""

roles/search_enterprise/meta/argument_specs.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ argument_specs:
2323
required: false
2424
search_enterprise_repo_db_url:
2525
description: |
26-
URL of the database to use for the Search Enterprise
26+
URL of the database to use for the Search Enterprise Bulk Ingester
2727
required: false
28-
search_enterprise_repo_db_name:
28+
search_enterprise_repo_db_username:
2929
description: |
30-
Name of the database to use for the Search Enterprise
30+
Username to use to connect to the database for the Search Enterprise Bulk Ingester
3131
required: false
32-
search_enterprise_repo_db_username:
32+
search_enterprise_repo_db_password:
3333
description: |
34-
Username to use to connect to the database for the Search Enterprise
34+
Password to use to connect to the database for the Search Enterprise Bulk Ingester
3535
required: false

0 commit comments

Comments
 (0)