summaryrefslogtreecommitdiff
path: root/taskd.yaml
blob: 3d107117de5c7c47630c5329a06469f0ff3adb16 (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
---
- name: Install taskd
  hosts: raspberry
  gather_facts: false
  tasks:
  # Installation
     - name: Install build tools
       tags:
       - slow
       apt:
         pkg:
         - gcc
         - make
         - cmake
         - gnutls-dev
         - uuid-dev

     - name: Create user
       become: true
       user:
         name: taskd

     - name: Add public key to authorized_keys
       become: true
       tags:
       - test
       authorized_key:
         user: taskd
         state: present
         key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"

     - name: Build taskd from source
       remote_user: taskd
       tags:
       - slow
       shell: |
         cd /tmp
         git clone --recursive https://github.com/GothenburgBitFactory/taskserver.git
         cd taskserver
         cmake -DCMAKE_BUILD_TYPE=release .
         make

     - name: Install taskd
       become: true
       shell: |
         cd /tmp/taskserver
         make install

    # Configuration
     - name: Setup initial config
       remote_user: taskd
       environment:
         TASKDDATA: /home/taskd/data
       shell: |
         mkdir -p ~/data/orgs
         taskd init
         taskd config server taskd.eug-vs.xyz:53589

     - name: Push vars for generating keys
       remote_user: taskd
       copy:
         src: ./files/taskd/vars
         dest: /tmp/taskserver/pki

     - name: Generate keys & certificates
       remote_user: taskd
       environment:
         TASKDDATA: /home/taskd/data
       shell: |
         cd /tmp/taskserver/pki
         ./generate
         cp server.*.pem ~/data
         cp ca.cert.pem ~/data
         taskd config --force server.cert ~/data/server.cert.pem
         taskd config --force server.key ~/data/server.key.pem
         taskd config --force server.crl ~/data/server.crl.pem
         taskd config --force ca.cert ~/data/ca.cert.pem

     - name: Add hostname
       become: true
       shell: echo "192.168.0.131 taskd.eug-vs.xyz" >> /etc/hosts

     - name: Create systemd unit
       become: true
       copy:
         src: ./files/taskd/taskd.service
         dest: /etc/systemd/system

     - name: Enable and start the service
       become: true
       systemd:
         name: taskd
         state: restarted