Skip to content

Instantly share code, notes, and snippets.

@hlassiege
Last active August 29, 2015 14:10
Show Gist options
  • Save hlassiege/ac20ada7400c1d7dda31 to your computer and use it in GitHub Desktop.
Save hlassiege/ac20ada7400c1d7dda31 to your computer and use it in GitHub Desktop.
Deployment file(s)
- hosts: analytics
sudo: true
vars_files:
- ../target/classes/version.yml
tasks:
- name: Ensure hopwork log folder exist
file: path=/var/log/hopwork/analytics/ state=directory group=www-data owner=www-data
- name: Ensure hopwork folder exist
file: path=/opt/hopwork/ state=directory group=www-data owner=www-data
- name: Ensure analytics folder exist
file: path=/opt/hopwork/analytics state=directory group=www-data owner=www-data
- name: Configure monitoring
copy: src=analytics.monit dest=/etc/monit/conf.d/analytics
- name: Copy starter/sh
template: src=starter.sh dest=/opt/hopwork/analytics/starter.sh mode=0755 group=www-data owner=www-data
- name: Configure stopper.sh
copy: src=stopper.sh dest=/opt/hopwork/analytics/stopper.sh mode=0755 group=www-data owner=www-data
- name: Stop monitoring
service: name=monit state=stopped
- name: Stop application
command: /opt/hopwork/analytics/stopper.sh
sudo: yes
sudo_user: www-data
- name: Copy application
copy: src=../target/analytics-{{appversion}}.jar dest=/opt/hopwork/analytics/analytics.jar group=www-data owner=www-data mode=0755
- name: Start monitoring
service: name=monit state=started
- name: Start analytics
monit: name=analytics state=started
- name: Configure iptables
template: src=hopjobs.iptables.rules dest=/etc/iptables/include.d/hopjobs.rules
register: iptables
- name: Reconfigure iptables
service: name=firewall state=restarted
when: iptables.changed
- name: Configure nginx basic authentication
template: src=htpasswd dest=/etc/nginx/sites-available/hopsearch.htpasswd owner=nginx group=nginx mode=755
register: basicauth
- name: Configure Nginx virtual host
template: src=hopsearch.nginx dest=/etc/nginx/sites-available/hopsearch
register: virtualhost
- file: src=/etc/nginx/sites-available/hopsearch dest=/etc/nginx/sites-enabled/hopsearch state=link
register: link
- service: name=nginx state=restarted
when: virtualhost.changed or link.changed or basicauth.changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment