Commit 1aefd20a by Kevin Falcone Committed by GitHub

Merge pull request #3451 from edx/jibsheet/programs-on-16.04

Jibsheet/programs on 16.04
parents 1907f9f1 cce020ca
# To build this Dockerfile:
#
# From the root of configuration:
#
# docker build -f docker/build/programs/Dockerfile .
#
# This allows the dockerfile to update /edx/app/edx_ansible/edx_ansible
# with the currently checked-out configuration repo.
FROM edxops/xenial-common:latest
MAINTAINER edxops
ENV PROGRAMS_VERSION=master
ENV REPO_OWNER=edx
ADD . /edx/app/edx_ansible/edx_ansible
WORKDIR /edx/app/edx_ansible/edx_ansible/docker/plays
COPY docker/build/programs/ansible_overrides.yml /
RUN sudo /edx/app/edx_ansible/venvs/edx_ansible/bin/ansible-playbook programs.yml \
-c local -i '127.0.0.1,' \
-t 'install,assets' \
--extra-vars="@/ansible_overrides.yml" \
--extra-vars="PROGRAMS_VERSION=$PROGRAMS_VERSION" \
--extra-vars="COMMON_GIT_PATH=$REPO_OWNER"
USER root
CMD ["/edx/app/supervisor/venvs/supervisor/bin/supervisord", "-n", "--configuration", "/edx/app/supervisor/supervisord.conf"]
---
DOCKER_TLD: "edx"
# The prod settings assume an rsyslogd
# In addition, on systemd systems, and newer rsyslogd
# there may be issues with /dev/log existing
# http://www.projectatomic.io/blog/2014/09/running-syslog-within-a-docker-container/
PROGRAMS_DJANGO_SETTINGS_MODULE: programs.settings.local
PROGRAMS_DATABASES:
# rw user
default:
ENGINE: 'django.db.backends.mysql'
NAME: '{{ PROGRAMS_DEFAULT_DB_NAME }}'
USER: 'programs001'
PASSWORD: 'password'
HOST: 'db.{{ DOCKER_TLD }}'
PORT: '3306'
ATOMIC_REQUESTS: true
CONN_MAX_AGE: 60
FROM ubuntu:xenial
MAINTAINER edxops
ENV ANSIBLE_REPO="https://github.com/edx/ansible"
ENV CONFIGURATION_REPO="https://github.com/edx/configuration.git"
ENV CONFIGURATION_VERSION="master"
ADD util/install/ansible-bootstrap.sh /tmp/ansible-bootstrap.sh
RUN chmod +x /tmp/ansible-bootstrap.sh
RUN /tmp/ansible-bootstrap.sh
- name: Deploy Programs
hosts: all
sudo: True
gather_facts: True
roles:
- nginx
- docker
- role: programs
nginx_default_sites:
- programs
......@@ -63,6 +63,9 @@
ansible_distribution_release in common_custom_ppa_releases
- name: Add custom edX PPA
# Ensure that we get a current version of Git and latest version of python 2.7
# GitHub requires version 1.7.10 or later
# https://help.github.com/articles/https-cloning-errors
apt_repository:
repo: "{{ COMMON_EDX_PPA }}"
when: >
......
......@@ -77,13 +77,15 @@
- install:base
# adding chris-lea nodejs repo
# TODO: 16.04
- name: add ppas for current versions of nodejs
apt_repository:
repo: "{{ edxapp_chrislea_ppa }}"
tags:
- install
- install:base
when: ansible_distribution_release == 'precise'
- name: install system packages on which LMS and CMS rely
apt:
name: "{{ item }}"
......
......@@ -190,5 +190,9 @@ programs_debian_pkgs:
- libjpeg-dev
- libmysqlclient-dev
- libssl-dev
- gettext
# Temporarily, while we get 16.04 rolled out everywhere
# Then this goes back in common_vars
- python2.7
programs_redhat_pkgs: []
......@@ -26,6 +26,9 @@
src: edx/app/programs/programs_gunicorn.py.j2
dest: "{{ programs_home }}/programs_gunicorn.py"
become_user: "{{ programs_user }}"
tags:
- install
- install:configuration
- name: install application requirements
pip:
......@@ -35,6 +38,9 @@
state: present
become_user: "{{ programs_user }}"
with_items: "{{ programs_requirements }}"
tags:
- install
- install:app-requirements
- name: migrate
shell: >
......@@ -45,6 +51,9 @@
become_user: "{{ programs_user }}"
environment: "{{ programs_environment }}"
when: migrate_db is defined and migrate_db|lower == "yes"
tags:
- migrate
- migrate:db
- name: run collectstatic
shell: >
......@@ -53,6 +62,9 @@
become_user: "{{ programs_user }}"
environment: "{{ programs_environment }}"
when: not devstack
tags:
- assets
- assets:gather
# NOTE this isn't used or needed when s3 is used for PROGRAMS_MEDIA_STORAGE_BACKEND
- name: create programs media dir
......@@ -61,6 +73,9 @@
owner="{{ programs_user }}" group="{{ common_web_group }}"
with_items:
- "{{ PROGRAMS_MEDIA_ROOT }}"
tags:
- install
- install:base
- name: write out the supervisor wrapper
template:
......@@ -69,6 +84,9 @@
mode: 0650
owner: "{{ supervisor_user }}"
group: "{{ common_web_user }}"
tags:
- install
- install:configuration
- name: write supervisord config
template:
......@@ -77,6 +95,9 @@
owner: "{{ supervisor_user }}"
group: "{{ common_web_user }}"
mode: 0644
tags:
- install
- install:configuration
- name: setup the programs env file
template:
......@@ -85,6 +106,9 @@
owner: "{{ programs_user }}"
group: "{{ programs_user }}"
mode: 0644
tags:
- install
- install:configuration
- name: enable supervisor script
file:
......@@ -93,10 +117,16 @@
state: link
force: yes
when: not disable_edx_services
tags:
- install
- install:configuration
- name: update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
when: not disable_edx_services
tags:
- manage
- manage:start
- name: create symlinks from the venv bin dir
file:
......@@ -107,6 +137,9 @@
- python
- pip
- django-admin.py
tags:
- install
- install:app-requirements
- name: create symlinks from the repo dir
file:
......@@ -115,6 +148,9 @@
state: link
with_items:
- manage.py
tags:
- install
- install:app-requirements
- name: restart the application
supervisorctl:
......@@ -124,3 +160,6 @@
name: "{{ programs_service_name }}"
when: not disable_edx_services
become_user: "{{ supervisor_service_user }}"
tags:
- manage
- manage:start
......@@ -115,13 +115,14 @@
- install
- install:base
# 12.04, 14.04, etc.
- name: Create supervisor upstart job
template:
src: "etc/init/supervisor-upstart.conf.j2"
dest: "/etc/init/{{ supervisor_service }}.conf"
owner: root
group: root
when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int < 16
when: ansible_distribution_release == 'precise' or ansible_distribution_release == 'trusty'
tags:
- install
- install:base
......@@ -129,6 +130,8 @@
# This script is aws specific and looks up instances
# tags and enables services based on the 'services' tag
# on instance startup.
# TODO: 16.04 this cannot simply be dropped, enabling needs to be moved somewhere
# also should not be here, should be in the aws role if it's aws specific
- name: create pre_supervisor upstart job
template:
src: "etc/init/pre_supervisor.conf.j2"
......@@ -137,7 +140,7 @@
group: root
when: >
supervisor_service == "supervisor" and disable_edx_services and not devstack
and ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int < 16
and (ansible_distribution_release == 'precise' or ansible_distribution_release == 'trusty')
tags:
- to-remove
- aws-specfic
......@@ -149,7 +152,7 @@
dest: "/etc/systemd/system/{{ supervisor_service }}.service"
owner: root
group: root
when: not (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int < 16)
when: ansible_distribution_release == 'xenial'
tags:
- install
- install:base
......@@ -213,11 +216,21 @@
- install
- install:configuration
# This command and the subsequent check in the when condition are related
# to this bug: https://github.com/ansible/ansible-modules-core/issues/593
- name: Are we in a Docker container
shell: echo $(egrep -q 'docker' /proc/self/cgroup && echo 'yes' || echo 'no')
ignore_errors: yes
register: docker_container
tags:
- install
- install:base
- name: Enable supervisor to start on boot
service:
name: "{{ supervisor_service }}.service"
enabled: yes
when: not (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int < 16)
when: ansible_distribution_release == 'xenial' and docker_container.stdout != 'yes'
tags:
- install
- install:base
......
......@@ -44,7 +44,7 @@ PYTHON_BIN="${VIRTUAL_ENV}/bin"
ANSIBLE_DIR="/tmp/ansible"
CONFIGURATION_DIR="/tmp/configuration"
EDX_PPA="deb http://ppa.edx.org precise main"
EDX_PPA_KEY_SERVER="pgp.mit.edu"
EDX_PPA_KEY_SERVER="hkp://pgp.mit.edu:80"
EDX_PPA_KEY_ID="69464050"
cat << EOF
......@@ -72,10 +72,13 @@ then
elif grep -q 'Trusty Tahr' /etc/os-release
then
SHORT_DIST="trusty"
elif grep -q 'Xenial Xerus' /etc/os-release
then
SHORT_DIST="xenial"
else
cat << EOF
This script is only known to work on Ubuntu Precise and Trusty,
This script is only known to work on Ubuntu Precise, Trusty and Xenial,
exiting. If you are interested in helping make installation possible
on other platforms, let us know.
......@@ -93,24 +96,39 @@ if [ "${UPGRADE_OS}" = true ]; then
echo "Upgrading the OS..."
apt-get upgrade -y
fi
# Required for add-apt-repository
apt-get install -y software-properties-common python-software-properties
# Add git PPA
add-apt-repository -y ppa:git-core/ppa
# Add python PPA
apt-key adv --keyserver "${EDX_PPA_KEY_SERVER}" --recv-keys "${EDX_PPA_KEY_ID}"
add-apt-repository -y "${EDX_PPA}"
# For older distributions we need to install a PPA for Python 2.7.10
if [[ "precise" = "${SHORT_DIST}" || "trusty" = "${SHORT_DIST}" ]]; then
# Add python PPA
apt-key adv --keyserver "${EDX_PPA_KEY_SERVER}" --recv-keys "${EDX_PPA_KEY_ID}"
add-apt-repository -y "${EDX_PPA}"
fi
# Install python 2.7 latest, git and other common requirements
# NOTE: This will install the latest version of python 2.7 and
# which may differ from what is pinned in virtualenvironments
apt-get update -y
apt-get install -y build-essential sudo git-core python2.7 python2.7-dev python-pip python-apt python-yaml python-jinja2 libmysqlclient-dev
pip install --upgrade pip=="${PIP_VERSION}"
apt-get install -y python2.7 python2.7-dev python-pip python-apt python-yaml python-jinja2 build-essential sudo git-core libmysqlclient-dev
# Workaround for a 16.04 bug, need to upgrade to latest and then
# potentially downgrade to the preferred version.
if [[ "xenial" = "${SHORT_DIST}" ]]; then
#apt-get install -y python2.7 python2.7-dev python-pip python-apt python-yaml python-jinja2
pip install --upgrade pip
pip install --upgrade pip=="${PIP_VERSION}"
#apt-get install -y build-essential sudo git-core libmysqlclient-dev
else
#apt-get install -y python2.7 python2.7-dev python-pip python-apt python-yaml python-jinja2 build-essential sudo git-core libmysqlclient-dev
pip install --upgrade pip=="${PIP_VERSION}"
fi
# pip moves to /usr/local/bin when upgraded
PATH=/usr/local/bin:${PATH}
......
......@@ -21,3 +21,4 @@ weights:
- ecommerce: 6
- rabbitmq: 2
- automated: 1
- programs: 4
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