summaryrefslogtreecommitdiff
path: root/chaos-at-home/ch-epimetheus.yml
blob: 148cda8252982e2a99668c3fe2e60d1e77256375 (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
---
- name: Basic Setup
  hosts: ch-epimetheus
  roles:
  - role: apt-repo/base
  - role: core/base
  - role: core/sshd/base
  - role: core/zsh
  - role: core/ntp
  - role: core/cpu-microcode
  - role: apt-repo/spreadspace
  - role: nginx/base
  - role: monitoring/prometheus/exporter
  - role: network/wakeonlan
  - role: storage/luks/volumes
  - role: storage/zfs/pools
  - role: storage/zfs/sanoid
  - role: storage/zfs/syncoid
  post_tasks:
  - name: install simple suspend script
    copy:
      content: |
        #!/bin/bash

        if [ -z "$1" ]; then
          echo "suspending indefinitely"
          systemctl suspend
        else
          #rtcwake --seconds 300 -m mem
          echo "suspending for $1"
          rtcwake --time $(date -d "$1" +%s) -m mem
        fi
      dest: /root/suspend.sh
      mode: 0755

  - name: install post-boot script
    copy:
      dest: /usr/local/bin/post-boot
      mode: 0755
      content: |
        #!/bin/bash
        set -e

        {% for name, volume in luks_volumes.items() %}
        echo -e "opening crypto volume: \033[1;37m{{ name }}\033[0m"
        cryptsetup luksOpen '{{ volume.device }}' '{{ name }}'
        {% endfor %}

        systemctl restart zfs-import-cache.service
        systemctl restart zfs-mount.service
        systemctl restart zfs-share.service
        systemctl restart zfs-zed.service
        mount -a

  - name: install dstat script
    copy:
      dest: /usr/local/bin/dstat.sh
      mode: 0755
      content: |
        #!/bin/bash
        {% set disk_variables = [] %}
        disk_primary=$(basename $(realpath '{{ install.disks.primary }}'))
        {{ disk_variables.append('$disk_primary') -}}
        {% for name,volume in luks_volumes.items() %}
        disk_{{ name | replace('-', '_') }}=$(basename $(realpath '{{ volume.device }}'))
        {{ disk_variables.append('$disk_'+(name | replace('-', '_'))) -}}
        {% endfor %}
        exec dstat -cnd -N {{ network.primary.name }} -D "{{ disk_variables | join(',') }}"  --disk-util --top-io --top-bio