Permalink
Switch branches/tags
Nothing to show
Find file Copy path
5adebdc Jul 6, 2016
1 contributor

Users who have contributed to this file

72 lines (64 sloc) 2.22 KB
---
- hosts: localhost
connection: local
gather_facts: False
vars:
aws_region: eu-west-1
app_name: "semaphore-cd"
prereq_stack_name: "{{ app_name }}-prereqs"
app_stack_name: "{{ app_name }}-main"
bucket_name: "{{ app_name }}-releases"
environment_name: production
tasks:
- name: Provision Pre-req stack
cloudformation:
state: present
stack_name: "{{ prereq_stack_name }}"
region: "{{ aws_region }}"
disable_rollback: true
template: "cloudformation/prereqs.json"
template_parameters:
BucketName: "{{ bucket_name }}"
RepositoryName: "{{ app_name }}"
register: prereqs
- name: Generate artifact hash
command: "./script/release-tag"
changed_when: False
register: artifact_hash
- name: Push Image to ECR
command: "make push UPSTREAM={{ prereqs.stack_outputs.Repository }}:{{ artifact_hash.stdout }}"
changed_when: False
- name: Create scratch dir for release artifact
command: "mktemp -d"
register: tmp_dir
changed_when: False
- name: Create Dockerrun.aws.json for release artifact
template:
src: files/Dockerrun.aws.json
dest: "{{ tmp_dir.stdout }}/Dockerrun.aws.json"
vars:
image: "{{ prereqs.stack_outputs.Repository }}:{{ artifact_hash.stdout }}"
- name: Create release zip file
command: "zip -r {{ tmp_dir.stdout }}/release.zip ."
args:
chdir: "{{ tmp_dir.stdout }}"
changed_when: False
- name: Upload release zip to S3
s3:
region: "{{ aws_region }}"
mode: put
src: "{{ tmp_dir.stdout }}/release.zip"
bucket: "{{ prereqs.stack_outputs.S3Bucket }}"
object: "{{ app_name }}-{{ artifact_hash.stdout }}.zip"
- name: Deploy application stack
cloudformation:
state: present
stack_name: "{{ app_stack_name }}"
region: "{{ aws_region }}"
disable_rollback: true
template: "cloudformation/app.json"
template_parameters:
S3Bucket: "{{ prereqs.stack_outputs.S3Bucket }}"
S3ZipKey: "{{ app_name }}-{{ artifact_hash.stdout }}.zip"
RackEnv: "{{ environment_name }}"
HealthCheckPath: "/ping"