summaryrefslogtreecommitdiff
path: root/baserock_webserver/instance-hastebin-config.yml
blob: 2adc8ca6c9c287fc3521d769818e942f65bfcbc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
65
66
67
68
69
# Instance-specific configuration for paste.baserock.org
---
- hosts: webserver
  vars:
  - haste_server_url: https://github.com/palvarez89/haste-server
  - haste_server_branch: baserock
  - haste_server_install_location: /home/hastebin/haste-server
  - haste_server_service_name: haste-server
  tasks:
  - name: Install Git
    apt:
      name: git
      state: latest
    become: yes

  - name: Install Redis
    apt:
      name: redis
      state: latest
    become: yes

  - name: Start Redis service
    service:
        name: redis
        enabled: yes
        state: started
    become: yes

  - name: Install Node.js
    apt:
      pkg:
        - nodejs
        - npm
      state: latest
    become: yes

  - name: hastebin user
    user: name=hastebin
    become: yes
    become_user: root

  - name: Download hastebin sources
    git:
      repo: "{{ haste_server_url }}"
      version: "{{ haste_server_branch }}"
      dest: "{{ haste_server_install_location }}"
    become: yes
    become_user: hastebin

  - name: Update packages based on package.json to their latest version.
    npm:
      path: "{{ haste_server_install_location }}"
      state: latest
    become: yes
    become_user: hastebin

  - name: Install service for the haste server
    template:
      src: hastebin/haste-server.service.in
      dest: /etc/systemd/system/{{ haste_server_service_name }}.service
    become: yes

  - name: Restart haste service
    service:
        name: "{{ haste_server_service_name }}"
        enabled: yes
        state: restarted
        daemon_reload: yes
    become: yes