mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-10-31 10:19:09 +00:00 
			
		
		
		
	sys-svc-rdbms: Refactor database service templates and add version support for Magento
- Unified Jinja2 variable spacing in tasks and templates
- Introduced database_image and database_version variables in vars/database.yml
- Updated mariadb.yml.j2 and postgres.yml.j2 to use {{ database_image }}:{{ database_version }}
- Ensured env file paths and includes are consistent
- Prepared support for versioned database images (needed for Magento deployment)
Ref: https://chatgpt.com/share/68b96a9d-c100-800f-856f-cd23d1eda2ed
			
			
This commit is contained in:
		| @@ -1,20 +1,23 @@ | ||||
| # Helper variables | ||||
| _dbtype:                          "{{ (database_type | d('') | trim) }}" | ||||
| _database_id:                     "{{ ('svc-db-' ~ _dbtype) if _dbtype else '' }}" | ||||
| _database_central_name:           "{{ (applications | get_app_conf(_database_id, 'docker.services.' ~ _dbtype ~ '.name', False, '')) if _dbtype else '' }}" | ||||
| _database_consumer_id:            "{{ database_application_id | d(application_id) }}" | ||||
| _database_consumer_entity_name:   "{{ _database_consumer_id | get_entity_name }}" | ||||
| _database_central_enabled:        "{{ (applications | get_app_conf(_database_consumer_id, 'features.central_database', False)) if _dbtype else False }}" | ||||
| _dbtype:                            "{{ (database_type | d('') | trim) }}" | ||||
| _database_id:                       "{{ ('svc-db-' ~ _dbtype) if _dbtype else '' }}" | ||||
| _database_central_name:             "{{ (applications | get_app_conf(_database_id, 'docker.services.' ~ _dbtype ~ '.name', False, '')) if _dbtype else '' }}" | ||||
| _database_consumer_id:              "{{ database_application_id | d(application_id) }}" | ||||
| _database_consumer_entity_name:     "{{ _database_consumer_id | get_entity_name }}" | ||||
| _database_central_enabled:          "{{ (applications | get_app_conf(_database_consumer_id, 'features.central_database', False)) if _dbtype else False }}" | ||||
| _database_default_version:          "{{ applications | get_app_conf(_database_id, 'docker.services.' ~ _dbtype ~ '.version') }}" | ||||
|  | ||||
| # Definition | ||||
|  | ||||
| database_name:      "{{ _database_consumer_entity_name }}" | ||||
| database_instance:  "{{ _database_central_name if _database_central_enabled else database_name }}" # This could lead to bugs at dedicated database @todo cleanup | ||||
| database_host:      "{{ _database_central_name if _database_central_enabled else 'database' }}"    # This could lead to bugs at dedicated database @todo cleanup | ||||
| database_username:  "{{ _database_consumer_entity_name }}" | ||||
| database_password:  "{{ applications | get_app_conf(_database_consumer_id, 'credentials.database_password', true) }}" | ||||
| database_port:      "{{ (ports.localhost.database[_database_id] | d('')) if _dbtype else '' }}" | ||||
| database_env:       "{{ docker_compose.directories.env }}{{ database_type }}.env" | ||||
| database_url_jdbc:  "jdbc:{{ database_type if database_type == 'mariadb' else 'postgresql' }}://{{ database_host }}:{{ database_port }}/{{ database_name }}" | ||||
| database_url_full:  "{{ database_type }}://{{ database_username }}:{{ database_password }}@{{ database_host }}:{{ database_port }}/{{ database_name }}" | ||||
| database_volume:    "{{ _database_consumer_entity_name ~ '_' if not _database_central_enabled }}{{ database_host }}" | ||||
| database_name:          "{{ _database_consumer_entity_name }}" | ||||
| database_instance:      "{{ _database_central_name if _database_central_enabled else database_name }}" # This could lead to bugs at dedicated database @todo cleanup | ||||
| database_host:          "{{ _database_central_name if _database_central_enabled else 'database' }}"    # This could lead to bugs at dedicated database @todo cleanup | ||||
| database_username:      "{{ _database_consumer_entity_name }}" | ||||
| database_password:      "{{ applications | get_app_conf(_database_consumer_id, 'credentials.database_password', true) }}" | ||||
| database_port:          "{{ (ports.localhost.database[_database_id] | d('')) if _dbtype else '' }}" | ||||
| database_env:           "{{ docker_compose.directories.env }}{{ database_type }}.env" | ||||
| database_url_jdbc:      "jdbc:{{ database_type if database_type == 'mariadb' else 'postgresql' }}://{{ database_host }}:{{ database_port }}/{{ database_name }}" | ||||
| database_url_full:      "{{ database_type }}://{{ database_username }}:{{ database_password }}@{{ database_host }}:{{ database_port }}/{{ database_name }}" | ||||
| database_volume:        "{{ _database_consumer_entity_name ~ '_' if not _database_central_enabled }}{{ database_host }}" | ||||
| database_image:         "{{ _dbtype }}" | ||||
| database_version:       "{{ applications | get_app_conf( _database_consumer_id, 'docker.services.' ~ _dbtype ~ '.version', False, _database_default_version) }}" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user