Skip to content

Commit

Permalink
Updating the configure_instance command to have a specific tutor dev/…
Browse files Browse the repository at this point in the history
…nightly flag; updating docs for same; updating overall Tutor docs with a few more things after testing with nightly/dev
  • Loading branch information
jkachel committed Mar 17, 2023
1 parent 9ffca12 commit e31bcfb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
12 changes: 8 additions & 4 deletions docs/source/commands/configure_instance.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
``configure_instance``
======================

Configures a fresh MITx Online instance. For more information, see :doc:`MITx Online Quick Start<../configuration/quickstart>`.
Configures a fresh MITx Online instance. For more information, see :doc:`MITx Online Quick Start<../configuration/quickstart>` and :doc:`Local Open edX Tutor and MITx Online Deployment<../configuration/tutor>`.

For Tutor deployments, this will use ``local.overhang.io`` for URLs for the edX platform. If you're running a dev deployment, or are using Tutor Nightly, ``--tutor-dev`` will additionally add the proper ports (as Caddy is disabled in these cases). In either case, the two demo courses will still be created but only the Demonstration Course (``course-v1:edX+DemoX+Demo_Course``) will exist in edX, and then only if you import the demo course using the relevant Tutor command.

Syntax
------

``configure_instance <platform> [--dont-enroll|-D] [--dont-create-superuser|-S] [--edx-oauth-client <client id>] [--edx-oauth-secret <client secret>] [--gateway <ip>]``
``configure_instance <platform> [--dont-enroll|-D] [--dont-create-superuser|-S] [--edx-oauth-client <client id>] [--edx-oauth-secret <client secret>] [--gateway <ip>] [--tutor|-T] [--tutor-dev]``

Options
-------
Expand All @@ -15,5 +17,7 @@ Options
* ``--dont-enroll|-D`` - Don't enroll the test learner account in any courses. (Defaults to enrolling the account in ``course-v1:edX+DemoX+Demo_Course``.)
* ``--dont-create-superuser|-S`` - Don't create a superuser account.
* ``--gateway <ip>`` - The Docker gateway IP. Required on Linux. See :doc:`Configure Open edX<../configuration/open_edx>` for more info.
* ``--edx-oauth-client <client id>`` - Use the specified client ID for the edX OAuth2 client. (Useful if you're redoing your MITx Online instance and you've already created the corresponding record in edX, since you're not allowed to edit it there.)
* ``--edx-oauth-secret <client secret>`` - Use the specified client secret for the edX OAuth2 client. (Useful if you're redoing your MITx Online instance and you've already created the corresponding record in edX, since you're not allowed to edit it there.)
* ``--edx-oauth-client <client id>`` - Use the specified client ID for the edX OAuth2 client. (Useful if you're redoing your MITx Online instance and you've already created the corresponding record in edX, since you're not allowed to edit it there.)
* ``--edx-oauth-secret <client secret>`` - Use the specified client secret for the edX OAuth2 client. (Useful if you're redoing your MITx Online instance and you've already created the corresponding record in edX, since you're not allowed to edit it there.)
* ``--tutor|-T`` - Configure the instance for use with a Tutor edX deployment.
* ``--tutor-dev`` - Configure the instnace for use with Tutor dev or nightly.
14 changes: 9 additions & 5 deletions docs/source/configuration/tutor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ These instructions describe setting up MITx Online and Tutor from scratch on Lin

..
These instructions may work for you if you need to do Open edX development too. However, these instructions *are not* geared towards that end. You may be able to replace calls to ``tutor local`` with calls to ``tutor dev``\ , but I had a number of problems with CORS headers when trying to log in. Your mileage may vary.
These instructions should work for a Tutor Dev or Tutor Nightly deployment as well. Specify ``--tutor-dev`` instead of ``--tutor`` when running ``configure_instance`` so the URLs have a port on them.


At the end of this guide, you should have:
Expand Down Expand Up @@ -132,10 +132,10 @@ These steps will also disable the AuthN SSO MFE, so from here on you'll get norm
SKIP_EMAIL_VALIDATION: true

to the ``FEATURES`` block (should be at the top).
#. Edit the ``env/apps/openedx/settings/lms/production.py`` settings file.
#. Edit the ``env/apps/openedx/settings/lms/production.py`` and/or ``env/apps/openedx/settings/lms/development.py`` settings file. (The former is used by a local instance, where the latter is used by both dev and nightly instances.)

* Add to the end of the file:

* ``THIRD_PARTY_AUTH_BACKENDS = ['social_auth_mitxpro.backends.MITxProOAuth2']``
* ``AUTHENTICATION_BACKENDS.append('social_auth_mitxpro.backends.MITxProOAuth2')``
* ``IDA_LOGOUT_URI_LIST.append('http://mitxonline.odl.local:8013/logout/')`` - there's an existing one of these around like 300 in production.py too.
Expand Down Expand Up @@ -171,7 +171,7 @@ These steps will also disable the AuthN SSO MFE, so from here on you'll get norm
* Enable sso id verification is checked.
* Backend name: ``mitxpro-oauth2``
* Client ID and Client Secret: from record created by ``configure_instance`` when you set up MITx Online.
* Other settings:
* Other settings:

{
"AUTHORIZATION_URL": "\http://mitxonline.odl.local:8013/oauth2/authorize/",
Expand Down Expand Up @@ -212,4 +212,8 @@ Other Notes

**Trying to set configuration settings via ``tutor config`` will undo the specialty configuration above.** If you need to make changes to the configuration, either manually edit the ``env/apps/openedx/config/lms.env.yml`` file or the ``env/apps/openedx/settings/lms/production.py`` file and restart your Tutor instance.

**Make sure your service worker account is active.** It's an easy checkbox to miss.
**Make sure your service worker account is active.** It's an easy checkbox to miss.

**Restarting** If you want to rebuild from scratch, make sure you ``docker image prune``. It's also recommended to remove the Tutor project root folder - ``tutor config printroot`` will tell you where that is.

**Running Multiple Tutor Instances** If you want to run more than one Tutor instance, it's pretty important to specify the project root explicitly or you may end up with one instance trying to use config files from another and things getting confused from there. `See the Tutor documentation for this. <https://docs.tutor.overhang.io/local.html#tutor-root>`_ (A suggestion: configure aliases to the ``tutor`` command that run ``tutor --root=<whatever>`` so you don't have to rely on environment variables, especially if you keep multiple terminal sessions going.)
22 changes: 19 additions & 3 deletions main/management/commands/configure_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
for test CyberSource transactions.
If the --tutor/-T option is passed, the command will use the local.overhang.io
address for links to edX rather than edx.odl.local:18000.
address for links to edX rather than edx.odl.local:18000.
This uses other management commands to complete these tasks. So, if you just
want to run part of this, use one of these commands:
Expand Down Expand Up @@ -117,11 +117,27 @@ def add_arguments(self, parser):
dest="tutor",
)

parser.add_argument(
"--tutor-dev",
help="Configure for Tutor Dev/Nightly.",
action="store_true",
dest="tutordev",
)

def determine_edx_hostport(self, *args, **kwargs):
"""Returns a tuple of the edX host and port depending on what the user's passed in"""

if kwargs["tutor"]:
return ("local.overhang.io", "")
elif kwargs["tutordev"]:
return ("local.overhang.io", ":8000")
else:
return ("edx.odl.local:18000", ":18000")

def handle(self, *args, **kwargs):
"""Coordinates the other commands."""

edx_host = "local.overhang.io" if kwargs["tutor"] else "edx.odl.local:18000"
edx_gateway_port = "" if kwargs["tutor"] else ":18000"
(edx_host, edx_gateway_port) = self.determine_edx_hostport(**kwargs)

# Step -1: run createsuperuesr
if kwargs["superuser"]:
Expand Down

0 comments on commit e31bcfb

Please sign in to comment.