Skip to content

Instantly share code, notes, and snippets.

@grahamoregan
Last active July 22, 2016 10:22
Show Gist options
  • Save grahamoregan/6b0e799089a993f535c5959f2e73f598 to your computer and use it in GitHub Desktop.
Save grahamoregan/6b0e799089a993f535c5959f2e73f598 to your computer and use it in GitHub Desktop.
simple ansible deploy script
- name: Sample deploy
hosts: backend
sudo: yes
remote_user: ubuntu
gather_facts: no
vars:
- build_dir: "/tmp/build"
- deploy_dir: "/opt/deploy"
tasks:
- synchronize:
src="./"
dest="{{ build_dir }}"
recursive=yes
delete=yes
owner=no
group=no
tags:
- deploy
- build
- shell: /opt/apache-maven-3.3.3/bin/mvn package -DskipTests chdir="{{ build_dir }}"
tags:
- build
- shell: cp {{ deploy_dir }}/backend.jar {{ deploy_dir }}/backend.jar.$(date +%Y-%m-%d-%H-%m-%S)
- shell: cp {{ build_dir}}/target/backend-0.1.jar {{ deploy_dir }}/backend.jar
- shell: cp {{ build_dir}}/config.yml {{ deploy_dir }}/config.yml
- copy:
src="./upstart.conf"
dest="/etc/init/backend.conf"
- service:
name="backend"
state="restarted"
tags:
- deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment