deploy.yml 4.11 KB
Newer Older
John Jarvis committed
1
- name: create supervisor scripts - ora, ora_celery
2
  template: >
3
    src={{ item }}.conf.j2 dest={{ supervisor_available_dir }}/{{ item }}.conf
4
    owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
5 6 7 8 9 10 11 12 13 14 15
  with_items: ['ora', 'ora_celery']

- name: enable supervisor scripts - ora, ora_celery
  file: >
    src={{ supervisor_available_dir }}/{{ item }}.conf
    dest={{ supervisor_cfg_dir }}/{{ item }}.conf
    state=link
    force=yes
    owner={{ supervisor_user }}
    group={{ common_web_user }}
    mode=0644
16
  notify:
John Jarvis committed
17 18
    - restart ora
    - restart ora_celery
19
  with_items: ['ora', 'ora_celery']
20
  when: not disable_edx_services
21

22 23 24 25 26 27 28
- name: "add gunicorn configuration file"
  template: >
    src=ora_gunicorn.py.j2 dest={{ ora_app_dir }}/ora_gunicorn.py
  sudo_user: "{{ ora_user }}"
  notify:
    - restart ora

29 30
- include: ease.yml

John Jarvis committed
31
- name: create ora application config
32
  template: src=ora.env.json.j2 dest={{ ora_app_dir }}/ora.env.json
33
  sudo_user: "{{ ora_user }}"
34

John Jarvis committed
35
- name: create ora auth file
36
  template: src=ora.auth.json.j2 dest={{ ora_app_dir }}/ora.auth.json
37
  sudo_user: "{{ ora_user }}"
38

John Jarvis committed
39
- name: setup the ora env
40
  notify:
John Jarvis committed
41 42
  - "restart ora"
  - "restart ora_celery"
43 44 45 46 47
  template: >
    src=ora_env.j2 dest={{ ora_app_dir }}/ora_env
    owner={{ ora_user }} group={{ common_web_user }}
    mode=0644

48
# Do A Checkout
John Jarvis committed
49
- name: git checkout ora repo into {{ ora_app_dir }}
50 51 52
  git: >
    dest={{ ora_code_dir }} repo={{ ora_source_repo }} version={{ ora_version }}
    accept_hostkey=yes
53
  sudo_user: "{{ ora_user }}"
John Jarvis committed
54
  notify:
John Jarvis committed
55 56
    - restart ora
    - restart ora_celery
57 58 59 60 61

# TODO: Check git.py _run_if_changed() to see if the logic there to skip running certain
# portions of the deploy needs to be incorporated here.


John Jarvis committed
62
# Install the python pre requirements into {{ ora_venv_dir }}
John Jarvis committed
63
- name: install python pre-requirements
64 65 66
  pip: >
    requirements="{{ ora_pre_requirements_file }}" virtualenv="{{ ora_venv_dir }}" state=present
    extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}"
67
  sudo_user: "{{ ora_user }}"
John Jarvis committed
68
  notify:
John Jarvis committed
69 70
    - restart ora
    - restart ora_celery
71

John Jarvis committed
72
# Install the python post requirements into {{ ora_venv_dir }}
John Jarvis committed
73
- name: install python post-requirements
74 75 76
  pip: >
    requirements="{{ ora_post_requirements_file }}" virtualenv="{{ ora_venv_dir }}" state=present
    extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}"
77
  sudo_user: "{{ ora_user }}"
John Jarvis committed
78
  notify:
John Jarvis committed
79 80
    - restart ora
    - restart ora_celery
81 82

  #Needed if using redis to prevent memory issues
John Jarvis committed
83
- name: change memory commit settings -- needed for redis
84
  command: sysctl vm.overcommit_memory=1
John Jarvis committed
85
  notify:
John Jarvis committed
86 87
    - restart ora
    - restart ora_celery
88

John Jarvis committed
89
- name: syncdb and migrate
90
  shell: SERVICE_VARIANT=ora {{ ora_venv_dir }}/bin/django-admin.py syncdb --migrate --noinput --settings=edx_ora.aws --pythonpath={{ ora_code_dir }}
91
  when: migrate_db is defined and migrate_db|lower == "yes"
92
  sudo_user: "{{ ora_user }}"
John Jarvis committed
93
  notify:
John Jarvis committed
94 95
    - restart ora
    - restart ora_celery
96

John Jarvis committed
97
- name: create users
98
  shell: SERVICE_VARIANT=ora {{ ora_venv_dir }}/bin/django-admin.py update_users --settings=edx_ora.aws --pythonpath={{ ora_code_dir }}
99
  sudo_user: "{{ ora_user }}"
John Jarvis committed
100
  notify:
John Jarvis committed
101 102
    - restart ora
    - restart ora_celery
103 104 105 106 107 108 109


  # call supervisorctl update. this reloads
  # the supervisorctl config and restarts
  # the services if any of the configurations
  # have changed.
  #
John Jarvis committed
110
- name: update supervisor configuration
111 112
  shell:  "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
  register: supervisor_update
113
  when: not disable_edx_services
114
  changed_when: supervisor_update.stdout is defined and supervisor_update.stdout != ""
115

John Jarvis committed
116
- name: ensure ora is started
117
  supervisorctl: >
118 119 120 121
    name=ora
    supervisorctl_path={{ supervisor_ctl }}
    config={{ supervisor_cfg }}
    state=started
122
  when: not disable_edx_services
123

John Jarvis committed
124
- name: ensure ora_celery is started
125
  supervisorctl: >
126 127 128 129
    name=ora_celery
    supervisorctl_path={{ supervisor_ctl }}
    config={{ supervisor_cfg }}
    state=started
130
  when: not disable_edx_services
131

132 133 134 135 136 137 138 139 140
- name: create a symlink for venv python
  file: >
    src="{{ ora_venv_bin }}/{{ item }}"
    dest={{ COMMON_BIN_DIR }}/{{ item }}.ora
    state=link
  with_items:
  - python
  - pip

141
- set_fact: ora_installed=true