Commit f4f1306c by Arbab Nazar Committed by GitHub

Merge pull request #3141 from edx/arbab/alton-rewrite

write ansible tasks with proper YAML syntax
parents ce3d9d68 d02435b1
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
# #
# #
- name: restart alton - name: restart alton
supervisorctl: > supervisorctl:
name=alton name: alton
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path: "{{ supervisor_ctl }}"
config={{ supervisor_cfg }} config: "{{ supervisor_cfg }}"
state=restarted state: restarted
when: not disable_edx_services when: not disable_edx_services
- name: setup the alton env ---
template: > - name: Setup the env and configure the boto profiles for alton
src="alton_env.j2" dest="{{ alton_app_dir }}/alton_env" template:
owner="{{ alton_user }}" group="{{ common_web_user }}" src: "{{ item.src }}"
mode=0644 dest: "{{ alton_app_dir }}/{{ item.dest }}"
owner: "{{ alton_user }}"
group: "{{ common_web_user }}"
mode: "0640"
with_items:
- { src: 'alton_env.j2', dest: 'alton_env' }
- { src: 'boto.j2', dest: '.boto' }
notify: restart alton notify: restart alton
- name: configure the boto profiles for alton - name: Checkout the code
template: > git_2_0_1:
src="boto.j2" dest: "{{ alton_code_dir }}"
dest="{{ alton_app_dir }}/.boto" repo: "{{ alton_source_repo }}"
owner="{{ alton_user }}" version: "{{ alton_version }}"
group="{{ common_web_user }}" accept_hostkey: yes
mode="0640"
notify: restart alton
- name: checkout the code
git_2_0_1: >
dest="{{ alton_code_dir }}" repo="{{ alton_source_repo }}"
version="{{ alton_version }}" accept_hostkey=yes
become_user: "{{ alton_user }}" become_user: "{{ alton_user }}"
register: alton_checkout register: alton_checkout
notify: restart alton notify: restart alton
- name: install the requirements - name: Install the requirements
pip: > pip:
requirements="{{ alton_requirements_file }}" requirements: "{{ alton_requirements_file }}"
virtualenv="{{ alton_venv_dir }}" virtualenv: "{{ alton_venv_dir }}"
state=present state: present
extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}" extra_args: "-i {{ COMMON_PYPI_MIRROR_URL }}"
become_user: "{{ alton_user }}" become_user: "{{ alton_user }}"
notify: restart alton notify: restart alton
- name: create the supervisor wrapper - name: Create the supervisor wrapper
template: > template:
src="{{ alton_supervisor_wrapper|basename }}.j2" src: "{{ alton_supervisor_wrapper | basename }}.j2"
dest="{{ alton_supervisor_wrapper }}" dest: "{{ alton_supervisor_wrapper }}"
mode=0755 mode: "0755"
sudo_user: "{{ alton_user }}" sudo_user: "{{ alton_user }}"
notify: restart alton notify: restart alton
- name: create a supervisor config - name: Create a supervisor config
template: > template:
src=alton.conf.j2 dest="{{ supervisor_available_dir }}/alton.conf" src: alton.conf.j2
owner="{{ supervisor_user }}" dest: "{{ supervisor_available_dir }}/alton.conf"
group="{{ supervisor_user }}" owner: "{{ supervisor_user }}"
group: "{{ supervisor_user }}"
become_user: "{{ supervisor_user }}" become_user: "{{ supervisor_user }}"
notify: restart alton notify: restart alton
- name: enable the supervisor config - name: Enable the supervisor config
file: > file:
src="{{ supervisor_available_dir }}/alton.conf" src: "{{ supervisor_available_dir }}/alton.conf"
dest="{{ supervisor_cfg_dir }}/alton.conf" dest: "{{ supervisor_cfg_dir }}/alton.conf"
state=link state: link
force=yes force: yes
mode=0644 mode: "0644"
become_user: "{{ supervisor_user }}" become_user: "{{ supervisor_user }}"
when: not disable_edx_services when: not disable_edx_services
notify: restart alton notify: restart alton
- name: update supervisor configuration - name: Update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update" shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update register: supervisor_update
changed_when: supervisor_update.stdout is defined and supervisor_update.stdout != "" changed_when: supervisor_update.stdout is defined and supervisor_update.stdout != ""
when: not disable_edx_services when: not disable_edx_services
- name: ensure alton is started - name: Ensure alton is started
supervisorctl: > supervisorctl:
name=alton name: alton
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path: "{{ supervisor_ctl }}"
config={{ supervisor_cfg }} config: "{{ supervisor_cfg }}"
state=started state: started
when: not disable_edx_services when: not disable_edx_services
- include: tag_ec2.yml tags=deploy - include: tag_ec2.yml
when: COMMON_TAG_EC2_INSTANCE when: COMMON_TAG_EC2_INSTANCE
tags:
- deploy
...@@ -21,17 +21,23 @@ ...@@ -21,17 +21,23 @@
# #
# #
- name: create application user - name: Create application user
user: > user:
name="{{ alton_user }}" home="{{ alton_app_dir }}" name: "{{ alton_user }}"
createhome=no shell=/bin/false home: "{{ alton_app_dir }}"
createhome: no
shell: /bin/false
- name: create alton user dirs - name: Create alton user dirs
file: > file:
path="{{ item }}" state=directory path: "{{ item }}"
owner="{{ alton_user }}" group="{{ common_web_group }}" state: directory
owner: "{{ alton_user }}"
group: "{{ common_web_group }}"
with_items: with_items:
- "{{ alton_app_dir }}" - "{{ alton_app_dir }}"
- "{{ alton_venvs_dir }}" - "{{ alton_venvs_dir }}"
- include: deploy.yml tags=deploy - include: deploy.yml
tags:
- deploy
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
- name: get instance information - name: get instance information
action: ec2_facts action: ec2_facts
tags: tags:
- deploy - deploy
- name: tag instance - name: tag instance
ec2_tag: resource={{ ansible_ec2_instance_id }} region={{ ansible_ec2_placement_region }} ec2_tag:
args: resource: "{{ ansible_ec2_instance_id }}"
region: "{{ ansible_ec2_placement_region }}"
tags: tags:
"version:alton" : "{{ alton_source_repo }} {{ alton_checkout.after |truncate(7,True,'')}}" "version:alton" : "{{ alton_source_repo }} {{ alton_checkout.after |truncate(7,True,'')}}"
when: alton_checkout.after is defined when: alton_checkout.after is defined
......
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