YAML syntax for ansible tasks

parent eefa76e1
......@@ -20,48 +20,52 @@
# Example play:
#
#
- name: "add gunicorn configuration file"
template: >
src=edx/app/ecommerce/ecommerce_gunicorn.py.j2
dest={{ ecommerce_home }}/ecommerce_gunicorn.py
- name: Add gunicorn configuration file
template:
src: "edx/app/ecommerce/ecommerce_gunicorn.py.j2"
dest: "{{ ecommerce_home }}/ecommerce_gunicorn.py"
become_user: "{{ ecommerce_user }}"
- name: install application requirements
pip: >
requirements="{{ ecommerce_requirements_base }}/{{ item }}"
virtualenv="{{ ecommerce_venv_dir }}"
state=present
- name: Install application requirements
pip:
requirements: "{{ ecommerce_requirements_base }}/{{ item }}"
virtualenv: "{{ ecommerce_venv_dir }}"
state: present
become_user: "{{ ecommerce_user }}"
with_items: ecommerce_requirements
with_items: "{{ ecommerce_requirements }}"
- name: create nodeenv
shell: >
creates={{ ecommerce_nodeenv_dir }}
{{ ecommerce_venv_dir }}/bin/nodeenv {{ ecommerce_nodeenv_dir }} --prebuilt
- name: Create nodeenv
shell: "{{ ecommerce_venv_dir }}/bin/nodeenv {{ ecommerce_nodeenv_dir }} --prebuilt"
args:
creates: "{{ ecommerce_nodeenv_dir }}"
become_user: "{{ ecommerce_user }}"
- name: install node dependencies
npm: executable={{ ecommerce_nodeenv_bin }}/npm path={{ ecommerce_code_dir }} production=yes
- name: Install node dependencies
npm:
executable: "{{ ecommerce_nodeenv_bin }}/npm"
path: "{{ ecommerce_code_dir }}"
production: yes
become_user: "{{ ecommerce_user }}"
environment: "{{ ecommerce_environment }}"
- name: install bower dependencies
shell: >
chdir={{ ecommerce_code_dir }}
. {{ ecommerce_nodeenv_bin }}/activate && {{ ecommerce_node_bin }}/bower install --production --config.interactive=false
- name: Install bower dependencies
shell: ". {{ ecommerce_nodeenv_bin }}/activate && {{ ecommerce_node_bin }}/bower install --production --config.interactive=false"
args:
chdir: "{{ ecommerce_code_dir }}"
become_user: "{{ ecommerce_user }}"
- name: migrate
- name: Migrate
shell: >
chdir={{ ecommerce_code_dir }}
DB_MIGRATION_USER='{{ COMMON_MYSQL_MIGRATE_USER }}'
DB_MIGRATION_PASS='{{ COMMON_MYSQL_MIGRATE_PASS }}'
{{ ecommerce_venv_dir }}/bin/python ./manage.py migrate --noinput
args:
chdir: "{{ ecommerce_code_dir }}"
become_user: "{{ ecommerce_user }}"
environment: "{{ ecommerce_environment }}"
when: migrate_db is defined and migrate_db|lower == "yes"
- name: populate countries
- name: Populate countries
shell: >
chdir={{ ecommerce_code_dir }}
DB_MIGRATION_USER={{ COMMON_MYSQL_MIGRATE_USER }}
......@@ -79,26 +83,26 @@
- "command_result.rc != 0"
- name: compile sass
shell: >
chdir={{ ecommerce_code_dir }}
{{ ecommerce_venv_dir }}/bin/python manage.py {{ item }}
shell: "{{ ecommerce_venv_dir }}/bin/python manage.py {{ item }}"
args:
chdir: "{{ ecommerce_code_dir }}"
become_user: "{{ ecommerce_user }}"
environment: "{{ ecommerce_environment }}"
with_items:
- "update_assets --skip-collect"
when: not devstack
- name: run r.js optimizer
shell: >
chdir={{ ecommerce_code_dir }}
. {{ ecommerce_nodeenv_bin }}/activate && {{ ecommerce_node_bin }}/r.js -o build.js
- name: Run r.js optimizer
shell: ". {{ ecommerce_nodeenv_bin }}/activate && {{ ecommerce_node_bin }}/r.js -o build.js"
args:
chdir: "{{ ecommerce_code_dir }}"
become_user: "{{ ecommerce_user }}"
when: not devstack
- name: run collectstatic
shell: >
chdir={{ ecommerce_code_dir }}
{{ ecommerce_venv_dir }}/bin/python manage.py {{ item }}
- name: Run collectstatic
shell: "{{ ecommerce_venv_dir }}/bin/python manage.py {{ item }}"
args:
chdir: "{{ ecommerce_code_dir }}"
become_user: "{{ ecommerce_user }}"
environment: "{{ ecommerce_environment }}"
with_items:
......@@ -106,61 +110,65 @@
- "compress"
when: not devstack
- name: write out the supervisor wrapper
template: >
src=edx/app/ecommerce/ecommerce.sh.j2
dest={{ ecommerce_home }}/{{ ecommerce_service_name }}.sh
mode=0650 owner={{ supervisor_user }} group={{ common_web_user }}
- name: write supervisord config
template: >
src=edx/app/supervisor/conf.d.available/ecommerce.conf.j2
dest="{{ supervisor_available_dir }}/{{ ecommerce_service_name }}.conf"
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
- name: setup the ecommence env file
template: >
src="./{{ ecommerce_home }}/{{ ecommerce_service_name }}_env.j2"
dest="{{ ecommerce_home }}/ecommerce_env"
owner={{ ecommerce_user }}
group={{ ecommerce_user }}
mode=0644
- name: enable supervisor script
file: >
src={{ supervisor_available_dir }}/{{ ecommerce_service_name }}.conf
dest={{ supervisor_cfg_dir }}/{{ ecommerce_service_name }}.conf
state=link
force=yes
- name: Write out the supervisor wrapper
template:
src: "edx/app/ecommerce/ecommerce.sh.j2"
dest: "{{ ecommerce_home }}/{{ ecommerce_service_name }}.sh"
mode: "0650"
owner: "{{ supervisor_user }}"
group: "{{ common_web_user }}"
- name: Write supervisord config
template:
src: "edx/app/supervisor/conf.d.available/ecommerce.conf.j2"
dest: "{{ supervisor_available_dir }}/{{ ecommerce_service_name }}.conf"
owner: "{{ supervisor_user }}"
group: "{{ common_web_user }}"
mode: "0644"
- name: Setup the ecommence env file
template:
src: "./{{ ecommerce_home }}/{{ ecommerce_service_name }}_env.j2"
dest: "{{ ecommerce_home }}/ecommerce_env"
owner: "{{ ecommerce_user }}"
group: "{{ ecommerce_user }}"
mode: "0644"
- name: Enable supervisor script
file:
src: "{{ supervisor_available_dir }}/{{ ecommerce_service_name }}.conf"
dest: "{{ supervisor_cfg_dir }}/{{ ecommerce_service_name }}.conf"
state: link
force: yes
when: not disable_edx_services
- name: update supervisor configuration
- name: Update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
when: not disable_edx_services
- name: create symlinks from the-er venv bin dir
file: >
src="{{ ecommerce_venv_dir }}/bin/{{ item }}"
dest="{{ COMMON_BIN_DIR }}/{{ item.split('.')[0] }}.ecommerce"
state=link
- name: Create symlinks from the-er venv bin dir
file:
src: "{{ ecommerce_venv_dir }}/bin/{{ item }}"
dest: "{{ COMMON_BIN_DIR }}/{{ item..split('.', 1) | first }}.ecommerce"
state: link
with_items:
- python
- pip
- django-admin.py
- name: create symlinks from the repo dir
file: >
src="{{ ecommerce_code_dir }}/{{ item }}"
dest="{{ COMMON_BIN_DIR }}/{{ item.split('.')[0] }}.ecommerce"
state=link
- python
- pip
- django-admin.py
- name: Create symlinks from the repo dir
file:
src: "{{ ecommerce_code_dir }}/{{ item }}"
dest: "{{ COMMON_BIN_DIR }}/{{ item..split('.', 1) | first }}.ecommerce"
state: link
with_items:
- manage.py
- name: restart the applicaton
supervisorctl: >
state=restarted
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
name={{ ecommerce_service_name }}
- manage.py
- name: Restart the applicaton
supervisorctl:
name: "{{ ecommerce_service_name }}"
state: restarted
supervisorctl_path: "{{ supervisor_ctl }}"
config: "{{ supervisor_cfg }}"
when: not disable_edx_services
become_user: "{{ supervisor_service_user }}"
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