deploy.yml 2.42 KB
Newer Older
bow's avatar
bow committed
1
2
3
4
5
---

- name: create required directories
  file: path={{ item }} owner={{ sentinel_user }} group={{ sentinel_group }} state=directory mode=0755
  with_items:
bow's avatar
bow committed
6
    - "{{ sentinel_checkout_dir|dirname }}"
bow's avatar
bow committed
7
    - "{{ sentinel_deployment_dir }}"
8
    - "{{ sentinel_nginx_dir }}"
bow's avatar
bow committed
9
10
11
12
13
14
15
16

- name: clone git repository
  git:
    repo: "{{ sentinel_git_repo }}"
    dest: "{{ sentinel_checkout_dir }}"
    version: "{{ sentinel_git_checkout }}"
    update: yes
  become_user: "{{ sentinel_user }}"
bow's avatar
bow committed
17
  register: gitclone
bow's avatar
bow committed
18

bow's avatar
bow committed
19
- name: install pip
bow's avatar
bow committed
20
21
22
23
24
25
  apt: pkg={{ item }} state=present
  with_items:
    - python-dev
    - python-pip

- name: ensure requirements file exists
26
  stat: path={{ sentinel_checkout_dir }}/requirements-dev.txt
bow's avatar
bow committed
27
28
29

- name: install python dependencies
  pip:
30
    chdir: "{{ sentinel_checkout_dir }}"
bow's avatar
bow committed
31
32
    requirements: "requirements-dev.txt"

33
- name: install dependencies via sbt (first run may take a while)
bow's avatar
bow committed
34
  shell: "./sbt -batch -no-colors update"
bow's avatar
bow committed
35
  args:
36
    chdir: "{{ sentinel_checkout_dir }}"
bow's avatar
bow committed
37
38
39
  become_user: "{{ sentinel_user }}"
  register: sbt_update
  changed_when: "'ownloading' in sbt_update.stdout"
bow's avatar
bow committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

- name: capture scala series
  shell: "./sbt -batch -no-colors 'show sentinel/scalaSeries'"
  args:
    chdir: "{{ sentinel_checkout_dir }}"
  become_user: "{{ sentinel_user }}"
  register: cmd_scala_series
  changed_when: false

- name: capture sentinel version
  shell: "./sbt -batch -no-colors 'show sentinel/version'"
  args:
    chdir: "{{ sentinel_checkout_dir }}"
  become_user: "{{ sentinel_user }}"
  register: cmd_sentinel_version
  changed_when: false

- name: store scala series
  set_fact: scala_series="{{ cmd_scala_series.stdout_lines|last|replace('[info] ', '') }}"
  when: cmd_scala_series|success

- name: store sentinel version
  set_fact: sentinel_version="{{ cmd_sentinel_version.stdout_lines|last|replace('[info] ', '') }}"
  when: cmd_sentinel_version|success

bow's avatar
bow committed
65
66
67
- include: deploy_jar.yml
  tags: [sentinel, deploy]

68
69
- include: deploy_docs.yml
  tags: [sentinel, deploy]
70
71

- name: set nginx configuration
bow's avatar
bow committed
72
  template: src=sentinel.nginx.j2 dest=/etc/nginx/sites-available/sentinel
73
74
75
76
77
78
79
80
81
82
83
  notify: restart nginx
  register: nginx_config

- name: enable sentinel nginx configuration
  file: path=/etc/nginx/sites-enabled/sentinel src=/etc/nginx/sites-available/sentinel state=link
  notify: restart nginx
  when: nginx_config|changed

- name: disable default nginx configuration
  file: path=/etc/nginx/sites-enabled/default state=absent
  notify: restart nginx