Commit 40e4ac57 by Feanil Patel

Merge pull request #2473 from edx/feanil/role_tagging

Feanil/role tagging
parents 36a3ca4b 51e14f04
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
src: edx/app/{{ role_name }}/{{ role_name }}_gunicorn.py.j2 src: edx/app/{{ role_name }}/{{ role_name }}_gunicorn.py.j2
dest: "{{ '{{' }} {{ role_name }}_home }}/{{ role_name }}_gunicorn.py" dest: "{{ '{{' }} {{ role_name }}_home }}/{{ role_name }}_gunicorn.py"
sudo_user: "{{ '{{' }} {{ role_name }}_user }}" sudo_user: "{{ '{{' }} {{ role_name }}_user }}"
tags:
- install
- install:configuration
- name: install application requirements - name: install application requirements
pip: pip:
...@@ -27,6 +30,9 @@ ...@@ -27,6 +30,9 @@
state: present state: present
sudo_user: "{{ '{{' }} {{ role_name }}_user }}" sudo_user: "{{ '{{' }} {{ role_name }}_user }}"
with_items: "{{ '{{' }} {{ role_name }}_requirements }}" with_items: "{{ '{{' }} {{ role_name }}_requirements }}"
tags:
- install
- install:app-requirements
- name: migrate - name: migrate
shell: > shell: >
...@@ -37,6 +43,9 @@ ...@@ -37,6 +43,9 @@
sudo_user: "{{ '{{' }} {{ role_name }}_user }}" sudo_user: "{{ '{{' }} {{ role_name }}_user }}"
environment: "{{ '{{' }} {{ role_name }}_environment }}" environment: "{{ '{{' }} {{ role_name }}_environment }}"
when: migrate_db is defined and migrate_db|lower == "yes" when: migrate_db is defined and migrate_db|lower == "yes"
tags:
- migrate
- migrate:db
- name: write out the supervisor wrapper - name: write out the supervisor wrapper
template: template:
...@@ -45,6 +54,9 @@ ...@@ -45,6 +54,9 @@
mode: 0650 mode: 0650
owner: "{{ '{{' }} supervisor_user }}" owner: "{{ '{{' }} supervisor_user }}"
group: "{{ '{{' }} common_web_user }}" group: "{{ '{{' }} common_web_user }}"
tags:
- install
- install:configuration
- name: write supervisord config - name: write supervisord config
template: template:
...@@ -53,6 +65,9 @@ ...@@ -53,6 +65,9 @@
owner: "{{ '{{' }} supervisor_user }}" owner: "{{ '{{' }} supervisor_user }}"
group: "{{ '{{' }} common_web_user }}" group: "{{ '{{' }} common_web_user }}"
mode: 0644 mode: 0644
tags:
- install
- install:configuration
- name: setup the {{ role_name }} env file - name: setup the {{ role_name }} env file
template: template:
...@@ -61,6 +76,9 @@ ...@@ -61,6 +76,9 @@
owner: "{{ '{{' }} {{ role_name }}_user }}" owner: "{{ '{{' }} {{ role_name }}_user }}"
group: "{{ '{{' }} {{ role_name }}_user }}" group: "{{ '{{' }} {{ role_name }}_user }}"
mode: 0644 mode: 0644
tags:
- install
- install:configuration
- name: enable supervisor script - name: enable supervisor script
file: file:
...@@ -69,10 +87,16 @@ ...@@ -69,10 +87,16 @@
state: link state: link
force: yes force: yes
when: not disable_edx_services when: not disable_edx_services
tags:
- install
- install:configuration
- name: update supervisor configuration - name: update supervisor configuration
shell: "{{ '{{' }} supervisor_ctl }} -c {{ '{{' }} supervisor_cfg }} update" shell: "{{ '{{' }} supervisor_ctl }} -c {{ '{{' }} supervisor_cfg }} update"
when: not disable_edx_services when: not disable_edx_services
tags:
- install
- install:configuration
- name: create symlinks from the venv bin dir - name: create symlinks from the venv bin dir
file: file:
...@@ -83,6 +107,9 @@ ...@@ -83,6 +107,9 @@
- python - python
- pip - pip
- django-admin.py - django-admin.py
tags:
- install
- install:base
- name: create symlinks from the repo dir - name: create symlinks from the repo dir
file: file:
...@@ -91,6 +118,9 @@ ...@@ -91,6 +118,9 @@
state: link state: link
with_items: with_items:
- manage.py - manage.py
tags:
- install
- install:base
- name: restart the application - name: restart the application
supervisorctl: supervisorctl:
...@@ -100,3 +130,6 @@ ...@@ -100,3 +130,6 @@
name: "{{ '{{' }} {{ role_name }}_service_name }}" name: "{{ '{{' }} {{ role_name }}_service_name }}"
when: not disable_edx_services when: not disable_edx_services
sudo_user: "{{ '{{' }} supervisor_service_user }}" sudo_user: "{{ '{{' }} supervisor_service_user }}"
tags:
- manage
- manage:start
...@@ -2,10 +2,16 @@ ...@@ -2,10 +2,16 @@
- name: check to see that MongoDB 2.4 is not installed - name: check to see that MongoDB 2.4 is not installed
stat: path=/etc/init.d/mongodb stat: path=/etc/init.d/mongodb
register: mongodb_needs_upgrade register: mongodb_needs_upgrade
tags:
- install
- install:base
- name: verify 2.4 not installed - name: verify 2.4 not installed
fail: msg="MongoDB 2.4 is currently installed and cannot be safely upgraded in a clustered configuration. Please read http://docs.mongodb.org/manual/release-notes/2.6-upgrade/#upgrade-considerations and upgrade to 2.6." fail: msg="MongoDB 2.4 is currently installed and cannot be safely upgraded in a clustered configuration. Please read http://docs.mongodb.org/manual/release-notes/2.6-upgrade/#upgrade-considerations and upgrade to 2.6."
when: mongodb_needs_upgrade.stat.exists and MONGO_CLUSTERED when: mongodb_needs_upgrade.stat.exists and MONGO_CLUSTERED
tags:
- install
- install:base
- name: remove mongo 2.4 if present - name: remove mongo 2.4 if present
apt: > apt: >
...@@ -13,28 +19,43 @@ ...@@ -13,28 +19,43 @@
state=absent purge=yes state=absent purge=yes
force=yes force=yes
when: mongodb_needs_upgrade.stat.exists and not MONGO_CLUSTERED when: mongodb_needs_upgrade.stat.exists and not MONGO_CLUSTERED
tags:
- install
- install:base
- name: install python pymongo for mongo_user ansible module - name: install python pymongo for mongo_user ansible module
pip: > pip: >
name=pymongo state=present name=pymongo state=present
version={{ pymongo_version }} extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}" version={{ pymongo_version }} extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}"
tags:
- install
- install:base
- name: add the mongodb signing key - name: add the mongodb signing key
apt_key: > apt_key: >
id={{ MONGODB_APT_KEY }} id={{ MONGODB_APT_KEY }}
keyserver={{ MONGODB_APT_KEYSERVER }} keyserver={{ MONGODB_APT_KEYSERVER }}
state=present state=present
tags:
- install
- install:base
- name: add the mongodb repo to the sources list - name: add the mongodb repo to the sources list
apt_repository: > apt_repository: >
repo='{{ MONGODB_REPO }}' repo='{{ MONGODB_REPO }}'
state=present state=present
tags:
- install
- install:base
- name: install mongo server and recommends - name: install mongo server and recommends
apt: > apt: >
pkg=mongodb-org={{ mongo_version }} pkg=mongodb-org={{ mongo_version }}
state=present install_recommends=yes state=present install_recommends=yes
force=yes update_cache=yes force=yes update_cache=yes
tags:
- install
- install:base
- name: create mongo dirs - name: create mongo dirs
file: > file: >
...@@ -46,14 +67,23 @@ ...@@ -46,14 +67,23 @@
- "{{ mongo_dbpath }}" - "{{ mongo_dbpath }}"
- "{{ mongo_log_dir }}" - "{{ mongo_log_dir }}"
- "{{ mongo_journal_dir }}" - "{{ mongo_journal_dir }}"
tags:
- install
- install:base
- name: stop mongod service - name: stop mongod service
service: name=mongod state=stopped service: name=mongod state=stopped
tags:
- manage
- manage:stop
- name: move mongodb to {{ mongo_data_dir }} - name: move mongodb to {{ mongo_data_dir }}
command: > command: >
mv /var/lib/mongodb {{ mongo_data_dir}}/. mv /var/lib/mongodb {{ mongo_data_dir}}/.
creates={{ mongo_data_dir }}/mongodb creates={{ mongo_data_dir }}/mongodb
tags:
- install
- install:base
- name: copy mongodb key file - name: copy mongodb key file
copy: > copy: >
...@@ -63,38 +93,65 @@ ...@@ -63,38 +93,65 @@
owner=mongodb owner=mongodb
group=mongodb group=mongodb
when: MONGO_CLUSTERED when: MONGO_CLUSTERED
tags:
- install
- install:configuration
- name: copy configuration template - name: copy configuration template
template: src=mongodb.conf.j2 dest=/etc/mongod.conf backup=yes template: src=mongodb.conf.j2 dest=/etc/mongod.conf backup=yes
notify: restart mongo notify: restart mongo
tags:
- install
- install:configuration
- name: start mongo service - name: start mongo service
service: name=mongod state=started service: name=mongod state=started
tags:
- manage
- manage:start
- name: wait for mongo server to start - name: wait for mongo server to start
wait_for: port=27017 delay=2 wait_for: port=27017 delay=2
tags:
- manage
- manage:start
- name: drop super user script - name: drop super user script
template: src="create_root.js.j2" dest="/tmp/create_root.js" template: src="create_root.js.j2" dest="/tmp/create_root.js"
when: not MONGO_CLUSTERED when: not MONGO_CLUSTERED
tags:
- install
- install:configuration
- name: create super user with js - name: create super user with js
shell: > shell: >
/usr/bin/mongo admin /tmp/create_root.js /usr/bin/mongo admin /tmp/create_root.js
when: not MONGO_CLUSTERED when: not MONGO_CLUSTERED
tags:
- install
- install:configuration
- name: delete super user script - name: delete super user script
file: path=/tmp/create_root.js state=absent file: path=/tmp/create_root.js state=absent
when: not MONGO_CLUSTERED when: not MONGO_CLUSTERED
tags:
- install
- install:configuration
- name: Create the file to initialize the mongod replica set - name: Create the file to initialize the mongod replica set
template: src=repset_init.js.j2 dest=/tmp/repset_init.js template: src=repset_init.js.j2 dest=/tmp/repset_init.js
when: MONGO_CLUSTERED when: MONGO_CLUSTERED
tags:
- install
- install:configuration
- name: Initialize the replication set - name: Initialize the replication set
shell: > shell: >
/usr/bin/mongo /tmp/repset_init.js /usr/bin/mongo /tmp/repset_init.js
when: MONGO_CLUSTERED when: MONGO_CLUSTERED
tags:
- install
- install:configuration
#- name: delete repset script #- name: delete repset script
# file: path=/tmp/repset_init.js state=absent # file: path=/tmp/repset_init.js state=absent
...@@ -111,6 +168,9 @@ ...@@ -111,6 +168,9 @@
state=present state=present
with_items: MONGO_USERS with_items: MONGO_USERS
when: not MONGO_CLUSTERED when: not MONGO_CLUSTERED
tags:
- manage
- manage:app-users
- name: create a mongodb user - name: create a mongodb user
mongodb_user: > mongodb_user: >
...@@ -124,6 +184,9 @@ ...@@ -124,6 +184,9 @@
replica_set={{ mongo_repl_set }} replica_set={{ mongo_repl_set }}
with_items: MONGO_USERS with_items: MONGO_USERS
when: MONGO_CLUSTERED when: MONGO_CLUSTERED
tags:
- manage
- manage:app-users
- name: install s3cmd - name: install s3cmd
pip: > pip: >
...@@ -131,6 +194,9 @@ ...@@ -131,6 +194,9 @@
state=present state=present
extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}" extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}"
when: MONGO_S3_BACKUP when: MONGO_S3_BACKUP
tags:
- install
- install:app-requirements
- name: configure s3cmd - name: configure s3cmd
template: > template: >
...@@ -140,6 +206,9 @@ ...@@ -140,6 +206,9 @@
group=root group=root
mode=0600 mode=0600
when: MONGO_S3_BACKUP when: MONGO_S3_BACKUP
tags:
- install
- install:configuration
- name: install backup-mongo-to-s3 script - name: install backup-mongo-to-s3 script
template: > template: >
...@@ -149,6 +218,9 @@ ...@@ -149,6 +218,9 @@
group=root group=root
mode=0700 mode=0700
when: MONGO_S3_BACKUP when: MONGO_S3_BACKUP
tags:
- install
- install:configuration
- name: schedule backup-mongo-to-3s crontab - name: schedule backup-mongo-to-3s crontab
cron: cron:
...@@ -161,3 +233,6 @@ ...@@ -161,3 +233,6 @@
minute="0" minute="0"
day="{{ MONGO_S3_BACKUP_DAY }}" day="{{ MONGO_S3_BACKUP_DAY }}"
when: MONGO_S3_BACKUP when: MONGO_S3_BACKUP
tags:
- install
- install:configuration
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