-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnas.yaml
More file actions
105 lines (96 loc) · 3.08 KB
/
nas.yaml
File metadata and controls
105 lines (96 loc) · 3.08 KB
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
---
- name: Setup nas
hosts: nas
become: true
roles:
- role: nftables
- role: bridge
- role: exim4_mail_relay
- role: auto-upgrade
- role: dlna-server
- role: file-server
- role: pi-pxe-boot
- role: offline-backup
- role: offsite-backup
- role: nspawn-host
- role: cloudflare_dns
- role: certbot_dns
- role: container-proxy
- role: node_exporter
- role: debian_backports
vars:
# contrib is require for zfs
debian_backports_archives: main contrib
handlers:
tasks:
- name: Configure zfs package pinning
ansible.builtin.copy:
dest: /etc/apt/preferences.d/90zfs
content: |
Package: src:zfs-linux
Pin: release n={{ ansible_facts.lsb.codename }}-backports
Pin-Priority: 990
tags: ['zfs']
- name: Install ZFS
ansible.builtin.package:
name:
- linux-headers-amd64
- zfsutils-linux
- zfs-dkms
tags: ['zfs']
- name: Create ZFS pools
ansible.builtin.command:
cmd: zpool create {{ item.name }} {{ item.members }} -f
creates: /{{ item.name }}
loop: "{{ zfs_pools }}"
when: zfs_pools is defined
tags: ['zfs']
- name: Create ZFS volumes
community.general.zfs:
name: "{{ item.name }}"
state: present
extra_zfs_properties: "{{ item.extra_zfs_properties }}"
loop: "{{ zfs_volumes }}"
when: zfs_volumes is defined
tags: ['zfs']
- name: Make sure machines bind mount target directory exists
ansible.builtin.file:
dest: "{{ nas_bind_mount_machines_folder }}"
owner: root
group: root
mode: "0700"
state: directory
when: nas_bind_mount_machines_folder is defined
tags: ['nspawn']
- name: Bind mount machines directory
ansible.posix.mount:
path: /var/lib/machines
src: "{{ nas_bind_mount_machines_folder }}"
# we need to tell systemdd that this mount requires the zfs mount service.
# There is a way to let zfs generate information about the volumes and pools so that systemd can figure
# it out by itself. I was unable to find an easy to understand piece of documentation 🙃
# Keywords: zfs-mount-generator filesystem mount ordering
# So for now this is good enough!
opts: bind,x-systemd.required-by=machines.target,x-systemd.requires=zfs-mount.service
fstype: none
state: mounted
when: nas_bind_mount_machines_folder is defined
tags: ['nspawn']
- name: Install git-backup util
ansible.builtin.copy:
src: utils/git-backup
dest: /usr/local/bin/git-backup
owner: root
group: root
mode: '0755'
tags: ['git-backup']
- name: Create daily git-backup cron
ansible.builtin.copy:
dest: /etc/cron.daily/git-backup
content: |
#!/bin/bash
/usr/bin/chronic -ve /usr/local/bin/git-backup "/ssd-pool1/backup/git-repos/"
owner: root
group: root
mode: '0744'
tags: ['git-backup']