Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playbooks/roles/common_vars/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ COMMON_ENVIRONMENT: 'default_env'
COMMON_DEPLOYMENT: 'default_deployment'
COMMON_PIP_VERBOSITY: ''
COMMON_PYPI_MIRROR_URL: 'https://pypi.python.org/simple'
COMMON_NPM_MIRROR_URL: 'http://registry.npmjs.org'
COMMON_NPM_MIRROR_URL: 'https://registry.npmjs.org'
COMMON_UBUNTU_APT_KEYSERVER: "http://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search="

COMMON_EDX_PPA: "deb http://ppa.edx.org {{ ansible_distribution_release }} main"
Expand Down
6 changes: 4 additions & 2 deletions playbooks/roles/edxapp/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,9 @@ edxapp_log_dir: "{{ COMMON_LOG_DIR }}/edxapp"
edxapp_venvs_dir: "{{ edxapp_app_dir }}/venvs"
edxapp_venv_dir: "{{ edxapp_venvs_dir }}/edxapp"
edxapp_venv_bin: "{{ edxapp_venv_dir }}/bin"
edxapp_node_bin: "{{ edxapp_code_dir }}/node_modules/.bin"
edxapp_nodeenv_dir: "{{ edxapp_app_dir }}/nodeenvs/edxapp"
edxapp_node_bin: "{{ edxapp_nodeenv_dir }}/bin"
edxapp_node_version: "0.10.37"
edxapp_user: edxapp
edxapp_deploy_path: "{{ edxapp_venv_bin }}:{{ edxapp_code_dir }}/bin:{{ edxapp_node_bin }}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
edxapp_staticfile_dir: "{{ edxapp_data_dir }}/staticfiles"
Expand Down Expand Up @@ -692,7 +694,7 @@ edxapp_generic_doc_store_config: &edxapp_generic_default_docstore
socketTimeoutMS: 3000 # default is never timeout while the connection is open, this means it needs to explicitly close raising pymongo.errors.NetworkTimeout
connectTimeoutMS: 2000 # default is 20000, I believe raises pymongo.errors.ConnectionFailure
# Not setting waitQueueTimeoutMS and waitQueueMultiple since pymongo defaults to nobody being allowed to wait


EDXAPP_LMS_DRAFT_DOC_STORE_CONFIG:
<<: *edxapp_generic_default_docstore
Expand Down
74 changes: 43 additions & 31 deletions playbooks/roles/edxapp/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,37 +109,6 @@
- install:code
- install:app-requirements

# Set the npm registry
# This needs to be done as root since npm is weird about
# chown - https://github.com/npm/npm/issues/3565
- name: Set the npm registry
shell:
npm config set registry '{{ COMMON_NPM_MIRROR_URL }}'
creates="{{ edxapp_app_dir }}/.npmrc"
environment: "{{ edxapp_environment }}"
tags:
- install
- install:app-requirements

# Set the npm registry permissions
- name: Set the npm registry permissions
file:
path: "{{ edxapp_app_dir }}/.npmrc"
owner: "{{ edxapp_user }}"
group: "{{ edxapp_user }}"
tags:
- install
- install:app-requirements

# Node play that need to be run after platform updates.
- name: Install edx-platform npm dependencies
shell: npm install chdir={{ edxapp_code_dir }}
become_user: "{{ edxapp_user }}"
environment: "{{ edxapp_environment }}"
tags:
- install
- install:app-requirements

- name: Create the virtualenv to install the Python requirements
command: >
virtualenv {{ edxapp_venv_dir }}
Expand Down Expand Up @@ -241,6 +210,49 @@
- install
- install:app-requirements

- name: create nodeenv
shell: >
{{ edxapp_venv_dir }}/bin/nodeenv {{ edxapp_nodeenv_dir }} --node={{ edxapp_node_version }} --prebuilt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use --force then this can be idempotent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The creates arg below means that it won't attempt to create it when the directory is present. However, this won't replace a nodeenv with the wrong node version. Are you saying we should ditch creates and only use --force? That's not how we're doing it elsewhere.

I think the right approach might be to make that change in all the places that create nodeenvs in a separate PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I missed the creates arg. No, you are right...that's how idempotency is achieved. I was more concerned with running the same script twice than I was changing the node version. Perhaps you need to register the node version and ensure that's what was created?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about it, the more I think creates actually does the wrong thing. I think --force is safer, but we should do it in a separate PR in all the places that make nodeenvs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed ^

args:
creates: "{{ edxapp_nodeenv_dir }}"
tags:
- install
- install:app-requirements

# Set the npm registry
# This needs to be done as root since npm is weird about
# chown - https://github.com/npm/npm/issues/3565
- name: Set the npm registry
shell: >
npm config set registry '{{ COMMON_NPM_MIRROR_URL }}'
args:
creates: "{{ edxapp_app_dir }}/.npmrc"
environment: "{{ edxapp_environment }}"
tags:
- install
- install:app-requirements

# Set the npm registry permissions
- name: Set the npm registry permissions
file:
path: "{{ edxapp_app_dir }}/.npmrc"
owner: "{{ edxapp_user }}"
group: "{{ edxapp_user }}"
tags:
- install
- install:app-requirements

- name: install node dependencies
npm:
executable: "{{ edxapp_node_bin }}/npm"
path: "{{ edxapp_code_dir }}"
production: yes
environment: "{{ edxapp_environment }}"
become_user: "{{ edxapp_user }}"
tags:
- install
- install:app-requirements

# The next few tasks set up the python code sandbox

# need to disable this profile, otherwise the pip inside the sandbox venv has no permissions
Expand Down