Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add variables for each deployment #38

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions provisioners/deploy-backend.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
---
- name: Deploy code on machine and configure cron and services
- name: Deploy code on the backend machine and configure cron and services
hosts: default
become: true
vars:
repos:
- api
- daemon
- library
- mdot
- task-runner
- uploader
- upload-service
- website
temp_dir: /data/tmp/www
deploy_dir: /data/www
tasks:
- name: Create minute cron dir
file:
Expand All @@ -16,40 +28,31 @@
job: "cd / && run-parts --report /etc/cron.minute"
- name: Copy packages from S3
become_user: deployer
command: "aws s3 cp s3://permanent-repos/{{ perm_env }}/{{ item }}.tar.gz /data/tmp/{{ item }}.tar.gz"
loop:
- api
- daemon
- library
- mdot
- task-runner
- uploader
- upload-service
- website
command: "aws s3 cp s3://permanent-repos/{{ perm_env }}/{{ item }}.tar.gz {{ temp_dir }}/{{ item }}.tar.gz"
loop: "{{ repos }}"
- name: Untar packages
unarchive:
src: "/data/tmp/{{ item }}.tar.gz"
dest: /data/www/
src: "{{ temp_dir }}/{{ item }}.tar.gz"
dest: "{{ temp_dir }}"
remote_src: yes
loop:
- api
- daemon
- library
- mdot
- task-runner
- uploader
- upload-service
- website
loop: "{{ repos }}"
- name: Rsync temprorary directory to deployment directory
command: "rsync -azh {{ temp_dir }}/{{ item }} {{ deploy_dir }} --delete"
loop: "{{ repos }}"
- name: Remove temporary directory
file:
path: "{{ temp_dir }}"
state: absent
- name: Change file permissions
file:
path: /data/www
path: "{{ deploy_dir }}"
state: directory
recurse: yes
owner: www-data
group: deployer
- name: Create cronjobs
copy:
src: "/data/www/task-runner/scripts/{{ item }}"
src: "{{ deploy_dir }}/task-runner/scripts/{{ item }}"
dest: "/etc/cron.{{ item }}"
owner: www-data
group: deployer
Expand All @@ -61,7 +64,7 @@
- hourly/system-check
- name: Create daemon service files
copy:
src: "/data/www/daemon/scripts/{{ item }}"
src: "{{ deploy_dir }}/daemon/scripts/{{ item }}"
dest: "/etc/systemd/system/{{ item }}"
owner: www-data
group: deployer
Expand All @@ -72,7 +75,7 @@
- sqs-daemon.service
- name: Create uploader service
copy:
src: /data/www/uploader/scripts/uploader.service
src: "{{ deploy_dir }}/uploader/scripts/uploader.service"
dest: /etc/systemd/system/uploader.service
owner: www-data
group: deployer
Expand Down
34 changes: 21 additions & 13 deletions provisioners/deploy-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
- name: Deploy code on machine and configure cron
hosts: default
become: true
vars:
repos:
- api
- library
- task-runner
temp_dir: /data/tmp/www
deploy_dir: /data/www
tasks:
- name: Create minute cron dir
file:
Expand All @@ -16,30 +23,31 @@
job: "cd / && run-parts --report /etc/cron.minute"
- name: Copy packages from S3
become_user: deployer
command: "aws s3 cp s3://permanent-repos/{{ perm_env }}/{{ item }}.tar.gz /data/tmp/{{ item }}.tar.gz"
loop:
- api
- library
- task-runner
command: "aws s3 cp s3://permanent-repos/{{ perm_env }}/{{ item }}.tar.gz {{ temp_dir }}/{{ item }}.tar.gz"
loop: "{{ repos }}"
- name: Untar packages
unarchive:
src: "/data/tmp/{{ item }}.tar.gz"
dest: /data/www/
src: "{{ temp_dir }}/{{ item }}.tar.gz"
dest: "{{ temp_dir }}"
remote_src: yes
loop:
- api
- library
- task-runner
loop: "{{ repos }}"
- name: Rsync temprorary directory to deployment directory
command: "rsync -azh {{ temp_dir }}/{{ item }} {{ deploy_dir }} --delete"
loop: "{{ repos }}"
- name: Remove temporary directory
file:
path: "{{ temp_dir }}"
state: "absent"
- name: Change file permissions
file:
path: /data/www
path: "{{ deploy_dir }}"
state: directory
recurse: yes
owner: www-data
group: deployer
- name: Create cronjobs
copy:
src: "/data/www/task-runner/scripts/{{ item }}"
src: "{{ deploy_dir }}/task-runner/scripts/{{ item }}"
dest: "/etc/cron.{{ item }}"
owner: www-data
group: deployer
Expand Down
39 changes: 23 additions & 16 deletions provisioners/deploy-taskrunner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
- name: Perform taskrunner deployment steps
hosts: default
become: true
vars:
repos:
- api
- daemon
- library
- task-runner
temp_dir: /data/tmp/www
deploy_dir: /data/www
tasks:
- name: Create minute cron dir
file:
Expand All @@ -16,32 +24,31 @@
job: "cd / && run-parts --report /etc/cron.minute"
- name: Copy packages from S3
become_user: deployer
command: "aws s3 cp s3://permanent-repos/{{ perm_env }}/{{ item }}.tar.gz /data/tmp/{{ item }}.tar.gz"
loop:
- api
- daemon
- library
- task-runner
command: "aws s3 cp s3://permanent-repos/{{ perm_env }}/{{ item }}.tar.gz {{ temp_dir }}/{{ item }}.tar.gz"
loop: "{{ repos }}"
- name: Untar packages
unarchive:
src: "/data/tmp/{{ item }}.tar.gz"
dest: /data/www/
src: "{{ temp_dir }}/{{ item }}.tar.gz"
dest: "{{ temp_dir }}"
remote_src: yes
loop:
- api
- daemon
- library
- task-runner
loop: "{{ repos }}"
- name: Rsync temprorary directory to deployment directory
command: "rsync -azh {{ temp_dir }}/{{ item }} {{ deploy_dir }} --delete"
loop: "{{ repos }}"
- name: Remove temporary directory
file:
path: "{{ temp_dir }}"
state: absent
- name: Change file permissions
file:
path: /data/www
path: "{{ deploy_dir }}"
state: directory
recurse: yes
owner: www-data
group: deployer
- name: Create cronjobs
copy:
src: "/data/www/task-runner/scripts/{{ item }}"
src: "{{ deploy_dir }}/task-runner/scripts/{{ item }}"
dest: "/etc/cron.{{ item }}"
owner: www-data
group: deployer
Expand All @@ -52,7 +59,7 @@
- hourly/system-check
- name: Create daemon service files
copy:
src: "/data/www/daemon/scripts/{{ item }}"
src: "{{ deploy_dir }}/daemon/scripts/{{ item }}"
dest: "/etc/systemd/system/{{ item }}"
owner: www-data
group: deployer
Expand Down
9 changes: 9 additions & 0 deletions provisioners/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
state: mounted
fstype: ext4

- name: Install required packages
hosts: default
become: true
tasks:
- name: Install rsync
apt:
name: rsync
update_cache: yes

- name: Perform system configuration
hosts: default
become: true
Expand Down