Commit 6d715a84 by Kevin Falcone

Allow the migrate scripts to run sudoless

pre_supervisor expects to run the migrate tests as the supervisor user,
which does not have sudo.  Add an env variable flag that allows you to
claim "I know what I'm doing, don't sudo".
parent 40f470e2
{% include "edxapp_common.j2" %}
if [[ -z "$NO_EDXAPP_SUDO" ]]; then
SUDO='sudo -E -u {{ edxapp_user }} env "PATH=$PATH"'
fi
{% for db in cms_auth_config.DATABASES.keys() %}
{%- if db != 'read_replica' %}
sudo -E -u {{ edxapp_user }} env "PATH=$PATH" {{ edxapp_venv_bin}}/python manage.py cms migrate --database {{ db }} --noinput --settings $EDX_PLATFORM_SETTINGS $@
$SUDO {{ edxapp_venv_bin}}/python manage.py cms migrate --database {{ db }} --noinput --settings $EDX_PLATFORM_SETTINGS $@
{% endif %}
{% endfor %}
{% include "edxapp_common.j2" %}
if [[ -z "$NO_EDXAPP_SUDO" ]]; then
SUDO='sudo -E -u {{ edxapp_user }} env "PATH=$PATH"'
fi
{% for db in lms_auth_config.DATABASES.keys() %}
{%- if db != 'read_replica' %}
sudo -E -u {{ edxapp_user }} env "PATH=$PATH" {{ edxapp_venv_bin}}/python manage.py lms migrate --database {{ db }} --noinput --settings $EDX_PLATFORM_SETTINGS $@
$SUDO {{ edxapp_venv_bin}}/python manage.py lms migrate --database {{ db }} --noinput --settings $EDX_PLATFORM_SETTINGS $@
{% endif %}
{% endfor %}
......@@ -11,8 +11,8 @@ import time
# Services that should be checked for migrations.
MIGRATION_COMMANDS = {
'lms': ". {env_file}; /edx/bin/edxapp-migrate-lms --noinput --list",
'cms': ". {env_file}; /edx/bin/edxapp-migrate-cms --noinput --list",
'lms': "NO_EDXAPP_SUDO=1 /edx/bin/edxapp-migrate-lms --noinput --list",
'cms': "NO_EDXAPP_SUDO=1 /edx/bin/edxapp-migrate-cms --noinput --list",
'xqueue': "{python} {code_dir}/manage.py xqueue migrate --noinput --settings=aws --db-dry-run --merge",
'ecommerce': ". {env_file}; {python} {code_dir}/manage.py migrate --noinput --list",
'programs': ". {env_file}; {python} {code_dir}/manage.py migrate --noinput --list",
......
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