summaryrefslogtreecommitdiff
path: root/roles/isso/main.yml
blob: b31a4b3671f1f0e68ecc91395e1b5a3e1d3c82e5 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
# Target: alpine3.10
- name: Install Isso Commenting Server
  hosts: isso
  vars:
    username: isso
    deploy_path: "/opt/{{ username }}"
    version: 7eed747e7a94ca1a19c01c67de7ed6b16d2bbe3d
  tasks:
  - name: Ensuring group exists
    group:
      name: "{{ username }}"
      state: present
  - name: Creating user and making home directory
    user:
      system: yes
      state: present
      name: "{{ username }}"
      groups: "{{ username }}"
      home: "{{ deploy_path }}"
  - name: Installing the required dependencies
    apk:
      state: present
      update_cache: yes
      name:
        - sudo
        - git
        - gcc
        - python3-dev
        - musl-dev
        - libffi-dev
        - npm
        - make
        - supervisor
  - block:
    - name: Cloning repository
      git:
        repo: https://github.com/posativ/isso
        dest: "{{ deploy_path }}"
        version: "{{ version }}"
    - name: Setting up python virtual environment
      shell: python3 -m venv .
      args:
        chdir: "{{ deploy_path }}"
        creates: bin/activate
    - name: Setting up build environment
      shell: |
        . bin/activate
        python setup.py develop
      args:
        chdir: "{{ deploy_path }}"
        creates: isso.egg-info
    - name: Installing JavaScript dependencies
      shell: npm install bower requirejs jade
      args:
        chdir: "{{ deploy_path }}"
        creates: node_modules/.bin
    - name: Building JavaScript assets
      shell: |
        PATH=$PATH:"{{ deploy_path }}"/node_modules/.bin
        make init
        make js
      args:
        chdir: "{{ deploy_path }}"
        creates: isso/js/embed.min.js
    - name: Copying config file
      copy:
        src: isso.conf
        dest: "{{ deploy_path }}/isso.conf"
        mode: '0644'
      register: issoConfig
    become: true
    become_user: "{{ username }}"
  - name: Copying supervisord config file
    copy:
      src: supervisord.conf
      dest: /etc/supervisord.conf
      mode: '0644'
    register: supervisorConfig
  - name: Ensuring supervisord has been started and enabled
    service:
      name: supervisord
      state: started
      enabled: yes
  - name: Waiting for supervisor to become active
    wait_for:
      port: 9100
  - name: Restarting supervisord due to config change
    service:
      name: supervisord
      state: restarted
    when: supervisorConfig.changed
  - name: Ensuring isso has been started
    supervisorctl:
      name: isso
      state: started
  - name: Waiting for application to become active
    wait_for:
      port: 8100
  - name: Restarting application due to config change
    supervisorctl:
      name: isso
      state: restarted
    when: issoConfig.changed
  - name: Testing if isso admin page exists
    uri:
      url: http://0.0.0.0:8100/admin
      return_content: yes
  - name: Testing if isso JavaScript exists
    uri:
      url: http://0.0.0.0:8100/js/embed.min.js
      return_content: yes