Commit 21bd55dc by John Eskew

Replce 'migrate --list' with 'showmigrations'.

parent be6982f9
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
# EDXAPP_AUTOMATED_USERS: # EDXAPP_AUTOMATED_USERS:
# ecom: # ecom:
# sudo_commands: # sudo_commands:
# - command: "/edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py lms migrate --list --settings=aws" # - command: "/edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py lms showmigrations --settings=aws"
# sudo_user: "edxapp" # sudo_user: "edxapp"
# - command: "/edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py cms migrate --list --settings=aws" # - command: "/edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py cms showmigrations --settings=aws"
# sudo_user: "edxapp" # sudo_user: "edxapp"
# authorized_keys: # authorized_keys:
# - 'ssh-rsa <REDACTED> ecom+admin@example.com' # - 'ssh-rsa <REDACTED> ecom+admin@example.com'
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
mode: "0440" mode: "0440"
validate: 'visudo -cf %s' validate: 'visudo -cf %s'
with_dict: "{{ AUTOMATED_USERS }}" with_dict: "{{ AUTOMATED_USERS }}"
- name: Create .ssh directory - name: Create .ssh directory
file: file:
path: "/home/{{ item.key }}/.ssh" path: "/home/{{ item.key }}/.ssh"
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
owner: "{{ item.key }}" owner: "{{ item.key }}"
group: "{{ item.key }}" group: "{{ item.key }}"
with_dict: "{{ AUTOMATED_USERS }}" with_dict: "{{ AUTOMATED_USERS }}"
- name: Build authorized_keys file - name: Build authorized_keys file
template: template:
src: "home/automator/.ssh/authorized_keys.j2" src: "home/automator/.ssh/authorized_keys.j2"
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
owner: "{{ item.key }}" owner: "{{ item.key }}"
group: "{{ item.key }}" group: "{{ item.key }}"
with_dict: "{{ AUTOMATED_USERS }}" with_dict: "{{ AUTOMATED_USERS }}"
- name: Build known_hosts file - name: Build known_hosts file
file: file:
path: "/home/{{ item.key }}/.ssh/known_hosts" path: "/home/{{ item.key }}/.ssh/known_hosts"
......
...@@ -191,7 +191,7 @@ edx_django_service_config: '{{ edx_django_service_config_default|combine(edx_dja ...@@ -191,7 +191,7 @@ edx_django_service_config: '{{ edx_django_service_config_default|combine(edx_dja
edx_django_service_automated_users: edx_django_service_automated_users:
automated_user: automated_user:
sudo_commands: sudo_commands:
- command: '{{ edx_django_service_venv_dir }}/python {{ edx_django_service_code_dir }}/manage.py migrate --list' - command: '{{ edx_django_service_venv_dir }}/python {{ edx_django_service_code_dir }}/manage.py showmigrations'
sudo_user: '{{ edx_django_service_user }}' sudo_user: '{{ edx_django_service_user }}'
authorized_keys: authorized_keys:
- 'SSH authorized key' - 'SSH authorized key'
......
...@@ -412,7 +412,7 @@ EDXAPP_SANDBOX_ENFORCE: true ...@@ -412,7 +412,7 @@ EDXAPP_SANDBOX_ENFORCE: true
EDXAPP_AUTOMATED_USERS: EDXAPP_AUTOMATED_USERS:
automated_user: automated_user:
sudo_commands: sudo_commands:
- command: "{{ edxapp_venv_bin }}/python {{ edxapp_code_dir }}/manage.py lms migrate --list --settings={{ edxapp_settings }}" - command: "{{ edxapp_venv_bin }}/python {{ edxapp_code_dir }}/manage.py lms showmigrations --settings={{ edxapp_settings }}"
sudo_user: "edxapp" sudo_user: "edxapp"
authorized_keys: authorized_keys:
- "SSH authorized key" - "SSH authorized key"
......
...@@ -4,8 +4,25 @@ if [[ -z "${NO_EDXAPP_SUDO:-}" ]]; then ...@@ -4,8 +4,25 @@ if [[ -z "${NO_EDXAPP_SUDO:-}" ]]; then
SUDO='sudo -E -u {{ edxapp_user }} env "PATH=$PATH"' SUDO='sudo -E -u {{ edxapp_user }} env "PATH=$PATH"'
fi fi
remove_unwanted_args () {
ARGS=("")
args_to_remove="(--list|--noinput)"
for var in "$@"; do
# Ignore known unneeded arguments
if [[ "$var" =~ $args_to_remove ]]; then
continue
fi
ARGS+=("$var")
done
}
{% for db in cms_auth_config.DATABASES.keys() %} {% for db in cms_auth_config.DATABASES.keys() %}
{%- if db != 'read_replica' %} {%- if db != 'read_replica' %}
${SUDO:-} {{ edxapp_venv_bin }}/python manage.py cms migrate --database {{ db }} --noinput --settings $EDX_PLATFORM_SETTINGS $@ if [[ $@ =~ .*--list.* ]]; then
remove_unwanted_args $@
${SUDO:-} {{ edxapp_venv_bin }}/python manage.py cms showmigrations --database {{ db }} --settings $EDX_PLATFORM_SETTINGS ${ARGS[@]}
else
${SUDO:-} {{ edxapp_venv_bin }}/python manage.py cms migrate --database {{ db }} --noinput --settings $EDX_PLATFORM_SETTINGS $@
fi
{% endif %} {% endif %}
{% endfor %} {% endfor %}
...@@ -4,8 +4,25 @@ if [[ -z "${NO_EDXAPP_SUDO:-}" ]]; then ...@@ -4,8 +4,25 @@ if [[ -z "${NO_EDXAPP_SUDO:-}" ]]; then
SUDO='sudo -E -u {{ edxapp_user }} env "PATH=$PATH"' SUDO='sudo -E -u {{ edxapp_user }} env "PATH=$PATH"'
fi fi
remove_unwanted_args () {
ARGS=("")
args_to_remove="(--list|--noinput)"
for var in "$@"; do
# Ignore known unneeded arguments
if [[ "$var" =~ $args_to_remove ]]; then
continue
fi
ARGS+=("$var")
done
}
{% for db in lms_auth_config.DATABASES.keys() %} {% for db in lms_auth_config.DATABASES.keys() %}
{%- if db != 'read_replica' %} {%- if db != 'read_replica' %}
${SUDO:-} {{ edxapp_venv_bin }}/python manage.py lms migrate --database {{ db }} --noinput --settings $EDX_PLATFORM_SETTINGS $@ if [[ $@ =~ .*--list.* ]]; then
remove_unwanted_args $@
${SUDO:-} {{ edxapp_venv_bin }}/python manage.py lms showmigrations --database {{ db }} --settings $EDX_PLATFORM_SETTINGS ${ARGS[@]}
else
${SUDO:-} {{ edxapp_venv_bin }}/python manage.py lms migrate --database {{ db }} --noinput --settings $EDX_PLATFORM_SETTINGS $@
fi
{% endif %} {% endif %}
{% endfor %} {% endfor %}
...@@ -13,7 +13,7 @@ import time ...@@ -13,7 +13,7 @@ import time
MIGRATION_COMMANDS = { MIGRATION_COMMANDS = {
'lms': "/edx/bin/edxapp-migrate-lms --noinput --list", 'lms': "/edx/bin/edxapp-migrate-lms --noinput --list",
'cms': "/edx/bin/edxapp-migrate-cms --noinput --list", 'cms': "/edx/bin/edxapp-migrate-cms --noinput --list",
'xqueue': "SERVICE_VARIANT=xqueue sudo -E -u xqueue {python} {code_dir}/manage.py migrate --noinput --list --settings=xqueue.aws_settings", 'xqueue': "SERVICE_VARIANT=xqueue sudo -E -u xqueue {python} {code_dir}/manage.py showmigrations --settings=xqueue.aws_settings",
'ecommerce': ". {env_file}; sudo -E -u ecommerce {python} {code_dir}/manage.py showmigrations", 'ecommerce': ". {env_file}; sudo -E -u ecommerce {python} {code_dir}/manage.py showmigrations",
'insights': ". {env_file}; sudo -E -u insights {python} {code_dir}/manage.py showmigrations", 'insights': ". {env_file}; sudo -E -u insights {python} {code_dir}/manage.py showmigrations",
'analytics_api': ". {env_file}; sudo -E -u analytics_api {python} {code_dir}/manage.py showmigrations", 'analytics_api': ". {env_file}; sudo -E -u analytics_api {python} {code_dir}/manage.py showmigrations",
......
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