Skip to content

Commit

Permalink
fix(storage): install play
Browse files Browse the repository at this point in the history
Signed-off-by: unusualpseudo <[email protected]>
  • Loading branch information
unusualpseudo committed Aug 25, 2024
1 parent 45cc14a commit cb7d9ab
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 105 deletions.
1 change: 1 addition & 0 deletions ansible/main/inventory/group_vars/kubernetes/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ apt_install_packages:
- iputils-ping
- python3-kubernetes
- python3-yaml
- rsync

apt_remove_packages:
- ufw
Expand Down
5 changes: 0 additions & 5 deletions ansible/main/inventory/group_vars/storage/rift.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions ansible/main/inventory/host_vars/apex.sops.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
pool_name: "oasis"
disk_device_id: "usb-Micron_CT1000X9PROSSD9_2409E8C145DD-0:0"
datasets:
- name: "oasis/Media"
- name: "oasis/Media/Movies"
- name: "oasis/Media/TvShows"
- name: "oasis/Media/Music"
- name: "oasis/Media/YouTube"
22 changes: 0 additions & 22 deletions ansible/main/inventory/host_vars/horizon.sops.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions ansible/main/inventory/host_vars/rift.sops.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions ansible/main/inventory/host_vars/rift.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
pool_name: "backups"
disk_device_id: "usb-WD_Elements_25A1_575834314442384E39444131-0:0"
datasets:
- name: "backups/Apps"
- name: "backups/Apps/Minio"
- name: "backups/Apps/Postgres"
22 changes: 0 additions & 22 deletions ansible/main/inventory/host_vars/titan.sops.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions ansible/main/inventory/hosts.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
all:
vars:
ansible_user: "{{ lookup('env', 'ANSIBLE_USER') }}"
children:
kubernetes:
children:
Expand All @@ -17,6 +19,4 @@ all:
storage:
hosts:
apex:
disk_device_id: "usb-Micron_CT1000X9PROSSD9_2409E8C145DD-0:0"
rift:
disk_device_id: "usb-WD_Elements_25A1_575834314442384E39444131-0:0"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
address=/{{lookup('env', 'CLOUDFLARE_DOMAIN')}}/{{lookup('env', 'NGINX_INTERNAL_ADDR')}}
address=/{{lookup('env', 'CLUSTER_DOMAIN')}}/{{lookup('env', 'NGINX_INTERNAL_ADDR')}}
dns-forward-max=5096
min-cache-ttl=300
rebind-domain-ok=
3 changes: 1 addition & 2 deletions ansible/main/playbooks/os/reboot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
- name: Reboot all kubernetes nodes
hosts: all
become: true
gather_facts: true
any_errors_fatal: true
any_errors_fatal: false
pre_tasks:
- name: Pausing for 5 seconds...
ansible.builtin.pause:
Expand Down
27 changes: 20 additions & 7 deletions ansible/main/playbooks/storage/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,30 @@
failed_when: false
changed_when: false

- name: Fail if ZFS pool already exists
fail:
msg: "The ZFS pool {{ pool_name }} already exists."
when: zpool_check.rc == 0

tasks:
- name: Create ZFS pool
- name: Create ZFS pool (only if it does not exist)
shell: "zpool create -o ashift=12 -f {{ pool_name }} /dev/disk/by-id/{{ disk_device_id }}"
when: zpool_check.rc != 0

- name: Set ZFS property atime
shell: "zfs set atime=off {{ pool_name }}"
when: zpool_check.rc != 0

- name: Set ZFS property compression
shell: "zfs set compression=lz4 {{ pool_name }}"
when: zpool_check.rc != 0

- name: Get existing datasets
shell: "zfs list -H -o name"
register: existing_datasets
changed_when: false

- name: Create ZFS datasets
- name: Create ZFS datasets (only if they do not exist)
shell: "zfs create {{ dataset.name }}"
loop: "{{ datasets }}"
loop_control:
loop_var: dataset
when: dataset.name not in existing_datasets.stdout_lines

- name: Set NFS share properties for datasets
shell: "zfs set sharenfs={{ nfs_options }} {{ dataset.name }}"
Expand All @@ -71,6 +75,15 @@
debug:
msg: "{{ zpool_status.stdout }}"

- name: Get existing datasets
shell: "zfs list -H -o name"
register: existing_datasets
changed_when: false

- name: Show existing datasets
debug:
msg: "{{ existing_datasets.stdout }}"

- name: Restart NFS service
ansible.builtin.systemd:
name: nfs-kernel-server
Expand Down

0 comments on commit cb7d9ab

Please sign in to comment.