summaryrefslogtreecommitdiff
path: root/roles/approx/tasks/main.yml
blob: 5896dcaba84681a3bfe41d7ed80bfe302affbd50 (plain) (blame)
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
---
- name: prepare storage volume for approx
  when: approx_storage is defined
  vars:
    storage_volume: "{{ approx_storage | combine({'dest': approx_basepath}) }}"
  include_role:
    name: "storage/{{ approx_storage.type }}/volume"

- name: install approx
  apt:
    name: approx
    state: present

- name: make sure cache and tmp directories exist
  loop:
  - cache
  - tmp
  file:
    state: directory
    path: "{{ approx_basepath }}/{{ item }}"
    mode: 0700
    owner: approx
    group: approx

- name: generate approx config
  copy:
    content: |
      # ansible managed

      {% for name, remote in approx_backends.items() %}
      {{ name }} {{ remote }}
      {% endfor %}

      $cache {{ approx_basepath }}/cache
    dest: /etc/approx/approx.conf

- name: create override directories for approx systemd units
  loop:
  - approx@.service
  - approx.socket
  file:
    state: directory
    path: "/etc/systemd/system/{{ item }}.d"

- name: create appprox service override
  copy:
    content: |
      # ansible managed
      [Unit]
      CollectMode=inactive-or-failed

      [Service]
      Environment=TMPDIR="{{ approx_basepath }}/tmp"
    dest: /etc/systemd/system/approx@.service.d/ansible.conf
  notify: restart approx socket

- name: create appprox socket override
  copy:
    content: |
      # ansible managed
      [Socket]
      ListenStream=
      ListenStream=127.0.0.1:19999
    dest: /etc/systemd/system/approx.socket.d/ansible.conf
  notify: restart approx socket

- name: make sure approx socket is started
  systemd:
    daemon_reload: yes
    name: approx.socket
    state: started

- name: configure nginx vhost
  vars:
    nginx_vhost:
      default: yes
      name: approx
      template: generic
      hostnames:
      - "{{ approx_hostname }}"
      locations:
        '/':
          proxy_pass: http://127.0.0.1:19999
  include_role:
    name: nginx/vhost