mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-16 18:03:06 -06:00
include vars based on the type of database
This commit is contained in:
@@ -100,6 +100,11 @@ atl_db_engine_to_db_type_map:
|
|||||||
rds_postgres: "postgres72"
|
rds_postgres: "postgres72"
|
||||||
rds_mysql: "mysql57"
|
rds_mysql: "mysql57"
|
||||||
atl_db_type: "{{ atl_db_engine_to_db_type_map[atl_db_engine] | default('postgres72') }}"
|
atl_db_type: "{{ atl_db_engine_to_db_type_map[atl_db_engine] | default('postgres72') }}"
|
||||||
|
atl_db_general_type_map:
|
||||||
|
aurora_postgres: "postgres"
|
||||||
|
rds_postgres: "postgres"
|
||||||
|
rds_mysql: "mysql"
|
||||||
|
atl_db_general_type: "{{ atl_db_general_type_map[atl_db_engine] }}"
|
||||||
|
|
||||||
atl_jdbc_db_name: "{{ lookup('env', 'ATL_JDBC_DB_NAME') }}"
|
atl_jdbc_db_name: "{{ lookup('env', 'ATL_JDBC_DB_NAME') }}"
|
||||||
atl_jdbc_user: "{{ lookup('env', 'ATL_JDBC_USER') }}"
|
atl_jdbc_user: "{{ lookup('env', 'ATL_JDBC_USER') }}"
|
||||||
@@ -111,11 +116,7 @@ atl_jdbc_template: "{{ lookup('env', 'ATL_JDBC_TEMPLATE') or 'template1' }}"
|
|||||||
atl_jdbc_query_params_for_engine:
|
atl_jdbc_query_params_for_engine:
|
||||||
aurora_postgres: "?targetServerType=master"
|
aurora_postgres: "?targetServerType=master"
|
||||||
rds_mysql: "?useUnicode=true&characterEncoding=UTF8&sessionVariables=default_storage_engine=InnoDB"
|
rds_mysql: "?useUnicode=true&characterEncoding=UTF8&sessionVariables=default_storage_engine=InnoDB"
|
||||||
atl_jdbc_engine_map:
|
atl_jdbc_url: "jdbc:{{ atl_db_general_type }}://{{ atl_db_host }}:{{ atl_db_port }}/{{ atl_jdbc_db_name }}{{ atl_jdbc_query_params_for_engine[atl_db_engine]| default('') }}"
|
||||||
aurora_postgres: "postgres"
|
|
||||||
rds_postgres: "postgres"
|
|
||||||
rds_mysql: "mysql"
|
|
||||||
atl_jdbc_url: "jdbc:{{ atl_jdbc_engine_map[atl_db_engine] }}://{{ atl_db_host }}:{{ atl_db_port }}/{{ atl_jdbc_db_name }}{{ atl_jdbc_query_params_for_engine[atl_db_engine]| default('') }}"
|
|
||||||
|
|
||||||
atl_jvm_heap: "{{ lookup('env', 'ATL_JVM_HEAP') or '2048m' }}"
|
atl_jvm_heap: "{{ lookup('env', 'ATL_JVM_HEAP') or '2048m' }}"
|
||||||
atl_jvm_opts: "{{ lookup('env', 'ATL_JVM_OPTS') or '' }}"
|
atl_jvm_opts: "{{ lookup('env', 'ATL_JVM_OPTS') or '' }}"
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
- name: Include database specific configuration
|
||||||
|
include_vars:
|
||||||
|
file:
|
||||||
|
|
||||||
- name: Initialise database
|
- name: Initialise database
|
||||||
include_tasks: "{{ atl_jdbc_engine_map[atl_db_engine] }}.yml" # TODO this is done to have same tasks for aurora and postgres
|
include_tasks: "{{ atl_db_general_type }}.yml" # TODO this is done to have same tasks for aurora and postgres
|
||||||
|
|
||||||
@@ -14,13 +14,13 @@
|
|||||||
|
|
||||||
- name: Download and unzip MySQL driver
|
- name: Download and unzip MySQL driver
|
||||||
unarchive:
|
unarchive:
|
||||||
src: https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.21.tar.gz
|
src: "{{ mysql_jdbc_connector_url }}"
|
||||||
dest: /tmp
|
dest: /tmp
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
|
|
||||||
- name: Copy the MySQL driver
|
- name: Copy the MySQL driver
|
||||||
copy:
|
copy:
|
||||||
src: /tmp/mysql-connector-java-8.0.21/mysql-connector-java-8.0.21.jar
|
src: "/tmp/{{ mysql_jdbc_connector }}/{{ mysql_jdbc_connector }}.jar"
|
||||||
dest: "{{ atl_product_installation_versioned }}/lib"
|
dest: "{{ atl_product_installation_versioned }}/lib"
|
||||||
|
|
||||||
- name: Create application DB user
|
- name: Create application DB user
|
||||||
@@ -42,34 +42,16 @@
|
|||||||
login_password: "{{ atl_db_root_password }}"
|
login_password: "{{ atl_db_root_password }}"
|
||||||
login_port: "{{ atl_db_port }}"
|
login_port: "{{ atl_db_port }}"
|
||||||
name: "{{ atl_jdbc_db_name }}"
|
name: "{{ atl_jdbc_db_name }}"
|
||||||
encoding: "utf8" # TODO "{{ atl_jdbc_encoding }}"
|
encoding: utf8mb4 # TODO "{{ atl_jdbc_encoding }}"
|
||||||
collation: "utf8_bin" # TODO "{{ atl_jdbc_collation }}"
|
collation: "utf8mb4_bin" # TODO "{{ atl_jdbc_collation }}"
|
||||||
register: db_created
|
register: db_created
|
||||||
|
|
||||||
- name: Assert ownership of public schema
|
- name: Assert ownership of public schema
|
||||||
command: >
|
command: >
|
||||||
mysql --user={{ atl_db_root_user }} --password={{ atl_db_root_password }} {{ atl_jdbc_db_name }}
|
mysql --user={{ atl_db_root_user }} --password={{ atl_db_root_password }} {{ atl_jdbc_db_name }}
|
||||||
--host={{ atl_db_host }} --port={{ atl_db_port }} --batch --skip-column-names
|
--host={{ atl_db_host }} --port={{ atl_db_port }} --batch --skip-column-names
|
||||||
--execute="GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on {{ atl_jdbc_db_name }}.* TO '{{ atl_jdbc_user }}'@'{{ atl_db_host }}' IDENTIFIED BY '{{ atl_jdbc_password }}'; flush privileges;"
|
--execute="GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX,REFERENCES on {{ atl_jdbc_db_name }}.* TO '{{ atl_jdbc_user }}'@'{{ atl_db_host }}' IDENTIFIED BY '{{ atl_jdbc_password }}'; flush privileges;"
|
||||||
no_log: true
|
no_log: true
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- new_only
|
- new_only
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# - name: Grant privs to root user on public schema
|
|
||||||
# postgresql_query:
|
|
||||||
# login_host: "{{ atl_db_host }}"
|
|
||||||
# login_user: "{{ atl_db_root_user }}"
|
|
||||||
# login_password: "{{ atl_db_root_password }}"
|
|
||||||
# db: "{{ atl_jdbc_db_name }}"
|
|
||||||
# query: "GRANT ALL ON SCHEMA public TO {{ atl_db_root_user }};"
|
|
||||||
|
|
||||||
# - name: Grant privs to application user on public schema
|
|
||||||
# postgresql_query:
|
|
||||||
# login_host: "{{ atl_db_host }}"
|
|
||||||
# login_user: "{{ atl_db_root_user }}"
|
|
||||||
# login_password: "{{ atl_db_root_password }}"
|
|
||||||
# db: "{{ atl_jdbc_db_name }}"
|
|
||||||
# query: "GRANT ALL ON SCHEMA public TO {{ atl_jdbc_user }};"
|
|
||||||
|
|||||||
10
roles/database_init/vars/mysql.yml
Normal file
10
roles/database_init/vars/mysql.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
atl_db_port: '5432'
|
||||||
|
atl_db_root_user: 'root'
|
||||||
|
atl_jdbc_encoding: 'utf8mb4'
|
||||||
|
atl_jdbc_collation: 'utf8mb4_bin'
|
||||||
|
atl_jdbc_ctype: 'utf8mb4_bin'
|
||||||
|
|
||||||
|
mysql_jdbc_connector: 'mysql-connector-java-8.0.21'
|
||||||
|
mysql_jdbc_connector_url: "https://dev.mysql.com/get/Downloads/Connector-J/{{ mysql_jdbc_connector }}.tar.gz"
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
<name>defaultDS</name>
|
<name>defaultDS</name>
|
||||||
<delegator-name>default</delegator-name>
|
<delegator-name>default</delegator-name>
|
||||||
<database-type>{{ atl_db_type }}</database-type>
|
<database-type>{{ atl_db_type }}</database-type>
|
||||||
|
{% if atl_db_general_type == 'postgres' %}}
|
||||||
<schema-name>public</schema-name>
|
<schema-name>public</schema-name>
|
||||||
|
{% endif %}}
|
||||||
<jdbc-datasource>
|
<jdbc-datasource>
|
||||||
<url>{{ atl_jdbc_url }}</url>
|
<url>{{ atl_jdbc_url }}</url>
|
||||||
<username>{{ atl_jdbc_user }}</username>
|
<username>{{ atl_jdbc_user }}</username>
|
||||||
|
|||||||
Reference in New Issue
Block a user