Skip to content

Commit

Permalink
Merge pull request #77 from appsembler/jazzar/extra-requirements
Browse files Browse the repository at this point in the history
Add support for Edxapp Extra Requirements
  • Loading branch information
iamjazzar authored Aug 12, 2021
2 parents 0b4701c + a8a6c31 commit 048f26a
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 1 deletion.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,43 @@ Yup, really works fast and resets it to that glorious state you saved. Nice.
> The instance is secured behind a firewall by default. To override this
> behavior, change `RESTRICT_INSTANCE` value in your configs to `false`.
### 4.5. Adding extra requirements
Sultan supports `EDXAPP_EXTRA_REQUIREMENTS` in its unique way. If you are not
familiar with this variable, edX uses it in its production Ansible deployment
scripts, but they were never incorporated in the devstack.

We introduced a way in our devstack ([devstack#42](https://github.com/appsembler/devstack/pull/42))
to install extra pip packages without modifying edx-platform codebase. This
variable has been added to Sultan as a comma-separated configuration variable
(`EDXAPP_EXTRA_REQUIREMENTS`), and it utilizes our `edxapp-pip` directory
to install extra packages. That's been said, this variable will have no effect
on your devstack unless your using Appsembler's version of the
devstack, unfortunately.

#### How to use it
The configuration variable expects a comma-separated list of pip packages'
git repos:

```shell
EDXAPP_EXTRA_REQUIREMENTS="https://github.com/appsembler/gestore.git==0.1.0-dev3,https://github.com/appsembler/course-access-groups.git"
```

Once you finish adding this requirement, you need to apply it to the machine:
- If you haven't created a machine yet, then you're all sit, the changes will be deployed in the next `sultan setup`.
- If your machine is created and running, run `sultan instance deploy` to have these libraries cloned in your sultan instance.

#### Specifying a package version
To specify the version for your package, simply add `==<branch_or_tag>` after
the repo link. If no version is specified, we will default to the main branch
of the repo (`HEAD`).

> **NOTE**
>
> If the package you're installing is a Django app, then you might need to
> consider adding the app name to your `ADDL_INSTALLED_APPS` in your lms/cms
> YAML configs.

## 5. Development
To change or update edx-platform code from your machine and reflect on the
server immediately, there are so many ways you can choose from. However, we
Expand Down Expand Up @@ -478,7 +515,7 @@ That should fix the problem.
│ │ └── IMAGE_NAME
├── HOST_NAME ─────────────┘
├── PROJECT_ID
├── EXPOSED_PORTS
├── EDXAPP_EXTRA_REQUIREMENTS
├── BOOT_DISK_TYPE
├── DISK_SIZE
├── MACHINE_TYPE
Expand Down
16 changes: 16 additions & 0 deletions ansible/roles/devstack/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@
marker: "# {mark} SULTAN MANAGED BLOCK"
tags: [ server, reconfiguration ]

- name: Install edxapp extra requirements
git:
repo: "{{ repo }}"
version: "{{ version }}"
dest: "{{ extra_requirements_directory }}/{{ package_name }}"
accept_hostkey: yes
key_file: yes
loop: "{{ extra_requirements.split(',') }}"
vars:
repo: "{{ item.split('==').0 }}"
package_name: "{{ repo | basename | regex_replace('^(.*).git$', '\\1') }}"
version: "{{ item.split('==').1 | default('HEAD') }}"
when: extra_requirements
become: no
tags: [ devstack, reconfiguration, env ]

- name: Checkout Github branch
git:
repo: "{{ git_repo_url }}"
Expand Down
1 change: 1 addition & 0 deletions ansible/server-vars.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

extra_requirements_directory: "{{ working_directory }}/src/edxapp-pip"
devstack_directory: "{{ working_directory }}/devstack"

ssh_keys_dir: "~/.ssh"
Expand Down
7 changes: 7 additions & 0 deletions configs/.configs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ DEVSTACK_REPO_BRANCH=open-release/juniper.master
# To work on the master branches and latest images, unset OPENEDX_RELEASE or set it to an empty string.
OPENEDX_RELEASE="${DEVSTACK_REPO_BRANCH//open-release\//}"

# A comma-separated list of extra requirements to install inside your edxapp. This is an
# alternative to the EDXAPP_EXTRA_REQUIREMENTS in edX Ansible scripts. At the moment
# We only support cloneable git repos so that they persist in your setup. More info
# in https://github.com/appsembler/devstack/pull/42.
# Example: EDXAPP_EXTRA_REQUIREMENTS="https://github.com/appsembler/gestore.git==0.1.0-dev3,https://github.com/appsembler/course-access-groups.git"
EDXAPP_EXTRA_REQUIREMENTS=""

# The command that runs all of your devstack services (LMS, Studio, ...) Change it if you have a custom one.
DEVSTACK_RUN_COMMAND=dev.up

Expand Down
2 changes: 2 additions & 0 deletions scripts/instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ deploy() {
git_repo_url=$DEVSTACK_REPO_URL
openedx_release=$OPENEDX_RELEASE
git_repo_branch=$DEVSTACK_REPO_BRANCH
extra_requirements=$EDXAPP_EXTRA_REQUIREMENTS
virtual_env_dir=$VIRTUAL_ENV" &> "$SHELL_OUTPUT"
success "Your virtual machine has been deployed successfully!"
message "Run ${BOLD}${CYAN}sultan instance provision${NORMAL}${MAGENTA} to start provisioning your devstack."
Expand Down Expand Up @@ -262,6 +263,7 @@ _image_setup() {
ci_build=$ETC_HOSTS_HACK
git_repo_url=$DEVSTACK_REPO_URL
git_repo_branch=$DEVSTACK_REPO_BRANCH
extra_requirements=$EDXAPP_EXTRA_REQUIREMENTS
openedx_release=$OPENEDX_RELEASE
virtual_env_dir=$VIRTUAL_ENV
home_dir=$HOME_DIR
Expand Down
7 changes: 7 additions & 0 deletions tests/configs.test
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ DEVSTACK_REPO_BRANCH=${DEVSTACK_BRANCH:-juniper}
# To work on the master branches and latest images, unset OPENEDX_RELEASE or set it to an empty string.
OPENEDX_RELEASE="juniper.master"

# A comma-separated list of extra requirements to install inside your edxapp. This is an
# alternative to the EDXAPP_EXTRA_REQUIREMENTS in edX Ansible scripts. At the moment
# We only support cloneable git repos so that they persist in your setup. More info
# in https://github.com/appsembler/devstack/pull/42.
# Example: EDXAPP_EXTRA_REQUIREMENTS="https://github.com/appsembler/gestore.git==0.1.0-dev3,https://github.com/appsembler/course-access-groups.git"
EDXAPP_EXTRA_REQUIREMENTS=""

# The command that runs all of your devstack services (LMS, Studio, ...) Change it if you have a custom one.
DEVSTACK_RUN_COMMAND="HOST=devstack.tahoe dev.up"

Expand Down

0 comments on commit 048f26a

Please sign in to comment.