Creating and Updating Databases and Database Users

This article provides an example of how database and database users can be managed via the edX configuration repository

Step-by-step guide

  1. This guide assumes that you have cloned the edX configuration repository and installed the python requirements.
  2. Change to the configuration/playbooks directory.

  3. Create a database configuration file named, say db-config.yml, with the following structure.  You will need to customize this for your own purposes including adding strong passwords.  This also assumes that you already have a root account on the MySQL instance you will be using.

    ---
    
    database_connection: &default_connection
      login_host: "localhost"
      login_user: "root"
      login_password: "secret"
    
    DEFAULT_ENCODING: "utf8"
    
    databases:
      edxapp:
        state: "present"
        encoding: "{{ DEFAULT_ENCODING }}"
        <<: *default_connection
      dashboard:
        state: "present"
        encoding: "{{ DEFAULT_ENCODING }}"
        <<: *default_connection
    
    database_users:
      migrate:
        state: "present"
        password: "migrate_secret"
        host: "%"
        privileges:
          - "edxapp%.*:SELECT,INSERT,UPDATE,DELETE,ALTER,CREATE,DROP,INDEX"
          - "dashboard%.*:SELECT,INSERT,UPDATE,DELETE,ALTER,CREATE,DROP,INDEX"
        <<: *default_connection
      dash:
        state: "present"
        password: "dash_secret"
        host: "%"
        privileges:
          - "dashboard.*:SELECT,INSERT,UPDATE,DELETE"
        <<: *default_connection
  4. Run ansible as follows

    ansible-playbook -i 'localhost,' create_db_and_users.yml -e@/path/to/db-config.yml --ask-sudo-pass

Filter by label

There are no items with the selected labels at this time.