Commit 57341634 by Clinton Blackburn

Consolidated duplicated edxlocal tasks

Consolidated database and user creation tasks, eliminating duplicated code.

ECOM-2180
parent 22a5d24c
...@@ -6,3 +6,38 @@ edxlocal_debian_pkgs: ...@@ -6,3 +6,38 @@ edxlocal_debian_pkgs:
- python-mysqldb - python-mysqldb
- postfix - postfix
- libjpeg-dev - libjpeg-dev
edxlocal_databases:
- "{{ ECOMMERCE_DEFAULT_DB_NAME | default(None) }}"
- "{{ INSIGHTS_DEFAULT_DB_NAME | default(None) }}"
- "{{ ORA_MYSQL_DB_NAME | default(None) }}"
- "{{ XQUEUE_MYSQL_DB_NAME | default(None) }}"
- "{{ EDXAPP_MYSQL_DB_NAME | default(None) }}"
- "{{ EDX_NOTES_API_MYSQL_DB_NAME | default(None) }}"
edxlocal_database_users:
- {
db: "{{ ECOMMERCE_DEFAULT_DB_NAME | default(None) }}",
user: "{{ ECOMMERCE_DATABASES.default.USER | default(None) }}",
pass: "{{ ECOMMERCE_DATABASES.default.PASSWORD | default(None) }}"
}
- {
db: "{{ INSIGHTS_DEFAULT_DB_NAME | default(None) }}",
user: "{{ INSIGHTS_DATABASES.default.USER | default(None) }}",
pass: "{{ INSIGHTS_DATABASES.default.PASSWORD | default(None) }}"
}
- {
db: "{{ ORA_MYSQL_DB_NAME | default(None) }}",
user: "{{ ORA_MYSQL_USER | default(None) }}",
pass: "{{ ORA_MYSQL_PASSWORD | default(None) }}"
}
- {
db: "{{ XQUEUE_MYSQL_DB_NAME | default(None) }}",
user: "{{ XQUEUE_MYSQL_USER | default(None) }}",
pass: "{{ XQUEUE_MYSQL_PASSWORD | default(None) }}"
}
- {
db: "{{ EDXAPP_MYSQL_DB_NAME | default(None) }}",
user: "{{ EDXAPP_MYSQL_USER | default(None) }}",
pass: "{{ EDXAPP_MYSQL_PASSWORD | default(None) }}"
}
...@@ -43,47 +43,30 @@ ...@@ -43,47 +43,30 @@
- name: install packages needed for single server - name: install packages needed for single server
apt: pkg={{','.join(edxlocal_debian_pkgs)}} install_recommends=yes state=present apt: pkg={{','.join(edxlocal_debian_pkgs)}} install_recommends=yes state=present
- name: setup the edxapp db user - name: create databases
mysql_user: > mysql_db:
name={{ EDXAPP_MYSQL_USER }} db: "{{ item }}"
password={{ EDXAPP_MYSQL_PASSWORD }} state: present
priv='{{ EDXAPP_MYSQL_DB_NAME }}.*:ALL' encoding: utf8
when: EDXAPP_MYSQL_USER is defined when: item != None and item != ''
with_items: "{{ edxlocal_databases }}"
- name: create a database for edxapp
mysql_db: > - name: create database users
db=edxapp mysql_user:
state=present name: "{{ item.user }}"
encoding=utf8 password: "{{ item.pass }}"
when: EDXAPP_MYSQL_USER is defined priv: "{{ item.db }}.*:ALL"
when: item.db != None and item.db != ''
- name: setup the xqueue db user with_items: "{{ edxlocal_database_users }}"
mysql_user: >
name={{ XQUEUE_MYSQL_USER }}
password={{ XQUEUE_MYSQL_PASSWORD }}
priv='{{ XQUEUE_MYSQL_DB_NAME }}.*:ALL'
when: XQUEUE_MYSQL_USER is defined
- name: create a database for xqueue
mysql_db: >
db=xqueue
state=present
encoding=utf8
when: XQUEUE_MYSQL_USER is defined
- name: setup the ora db user
mysql_user: >
name={{ ORA_MYSQL_USER }}
password={{ ORA_MYSQL_PASSWORD }}
priv='{{ ORA_MYSQL_DB_NAME }}.*:ALL'
when: ORA_MYSQL_USER is defined
- name: create a database for ora - name: setup the migration db user
mysql_db: > mysql_user:
db=ora name: "{{ COMMON_MYSQL_MIGRATE_USER }}"
state=present password: "{{ COMMON_MYSQL_MIGRATE_PASS }}"
encoding=utf8 priv: "{{ item }}.*:ALL"
when: ORA_MYSQL_USER is defined append_privs: yes
when: item != None and item != ''
with_items: "{{ edxlocal_databases }}"
- name: create databases for analytics api - name: create databases for analytics api
mysql_db: > mysql_db: >
...@@ -95,34 +78,6 @@ ...@@ -95,34 +78,6 @@
- "{{ ANALYTICS_API_SERVICE_CONFIG['DATABASES']['default']['NAME'] }}" - "{{ ANALYTICS_API_SERVICE_CONFIG['DATABASES']['default']['NAME'] }}"
- "{{ ANALYTICS_API_SERVICE_CONFIG['DATABASES']['reports']['NAME'] }}" - "{{ ANALYTICS_API_SERVICE_CONFIG['DATABASES']['reports']['NAME'] }}"
- name: create database for insights
mysql_db: >
db={{ INSIGHTS_DATABASES.default.NAME }}
state=present
encoding=utf8
when: INSIGHTS_DATABASES is defined
- name: create database user for insights
mysql_user: >
name="{{ INSIGHTS_DATABASES.default.USER }}"
password="{{ INSIGHTS_DATABASES.default.PASSWORD }}"
priv='{{ INSIGHTS_DATABASES.default.NAME }}.*:ALL'
when: INSIGHTS_DATABASES is defined
- name: create database for ecommerce
mysql_db: >
db="{{ ECOMMERCE_DEFAULT_DB_NAME }}"
state=present
encoding=utf8
when: ECOMMERCE_DEFAULT_DB_NAME is defined
- name: setup users for ecommerce
mysql_user: >
name="{{ ECOMMERCE_DATABASES.default.USER }}"
password="{{ ECOMMERCE_DATABASES.default.PASSWORD }}"
priv='{{ ECOMMERCE_DEFAULT_DB_NAME }}.*:ALL'
when: ECOMMERCE_DEFAULT_DB_NAME is defined
- name: create api user for the analytics api - name: create api user for the analytics api
mysql_user: > mysql_user: >
name=api001 name=api001
...@@ -151,13 +106,6 @@ ...@@ -151,13 +106,6 @@
encoding=latin1 encoding=latin1
when: HIVE_METASTORE_DATABASE is defined when: HIVE_METASTORE_DATABASE is defined
- name: setup the edxapp db user
mysql_user: >
name={{ HIVE_METASTORE_DATABASE.user }}
password={{ HIVE_METASTORE_DATABASE.password }}
priv='{{ HIVE_METASTORE_DATABASE.name }}.*:ALL'
when: HIVE_METASTORE_DATABASE is defined
- name: setup the edx-notes-api db user - name: setup the edx-notes-api db user
mysql_user: > mysql_user: >
name={{ EDX_NOTES_API_MYSQL_DB_USER }} name={{ EDX_NOTES_API_MYSQL_DB_USER }}
...@@ -165,29 +113,6 @@ ...@@ -165,29 +113,6 @@
priv='{{ EDX_NOTES_API_MYSQL_DB_NAME }}.*:SELECT,INSERT,UPDATE,DELETE' priv='{{ EDX_NOTES_API_MYSQL_DB_NAME }}.*:SELECT,INSERT,UPDATE,DELETE'
when: EDX_NOTES_API_MYSQL_DB_USER is defined when: EDX_NOTES_API_MYSQL_DB_USER is defined
- name: create a database for edx-notes-api
mysql_db: >
db={{ EDX_NOTES_API_MYSQL_DB_NAME }}
state=present
encoding=utf8
when: EDX_NOTES_API_MYSQL_DB_USER is defined
- name: setup the migration db user
mysql_user: >
name={{ COMMON_MYSQL_MIGRATE_USER }}
password={{ COMMON_MYSQL_MIGRATE_PASS }}
priv='{{ item }}.*:ALL'
append_privs=yes
when: item != 'None'
with_items:
- "{{ EDXAPP_MYSQL_DB_NAME|default('None') }}"
- "{{ XQUEUE_MYSQL_DB_NAME|default('None') }}"
- "{{ ORA_MYSQL_DB_NAME|default('None') }}"
- "{{ EDX_NOTES_API_MYSQL_DB_NAME|default('None') }}"
- "{{ ANALYTICS_API_DEFAULT_DB_NAME|default('None') }}"
- "{{ ANALYTICS_API_REPORTS_DB_NAME|default('None') }}"
- "{{ INSIGHTS_DATABASE_NAME|default('None') }}"
- "{{ ECOMMERCE_DEFAULT_DB_NAME|default('None') }}"
- name: setup the read-only db user - name: setup the read-only db user
mysql_user: > mysql_user: >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment