Skip to content

Commit 947279b

Browse files
committed
feat(roles.zfs): migrate zfs role to collection
1 parent 1713f82 commit 947279b

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed

roles/zfs/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# ZFS
2+
3+
An Ansible role to install [OpenZFS](https://openzfs.org/wiki/Main_Page) ([GitHub](https://github.com/openzfs/zfs))
4+
5+
## Requirements
6+
7+
None.
8+
9+
## Role Variables
10+
11+
`zfs_kabi:` - Use kABI instead of DKMS
12+
13+
## Dependencies
14+
15+
## Example Playbook
16+
17+
```yaml
18+
- hosts: zfs
19+
roles:
20+
- syaghoubi00.homelab.zfs
21+
```
22+
23+
## License
24+
25+
GPL-3.0-or-later
26+
27+
## Author Information
28+
29+
Created by Sebastian Yaghoubi

roles/zfs/meta/main.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
dependencies: []
2+
galaxy_info:
3+
author: syaghoubi00
4+
description: Installs ZFS
5+
galaxy_tags:
6+
- zfs
7+
- storage
8+
- infra
9+
license: GPL-3.0-or-later
10+
min_ansible_version: "2.1"
11+
role_name: zfs

roles/zfs/tasks/RedHat-9.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# TODO: Check if repo is installed before calling the role
2+
- name: Add EPEL
3+
ansible.builtin.include_role: syaghoubi00.homelab.epel
4+
5+
- name: Add ZFS Repo GPG Key
6+
become: true
7+
ansible.builtin.rpm_key:
8+
key: https://raw.githubusercontent.com/zfsonlinux/zfsonlinux.github.com/master/zfs-release/RPM-GPG-KEY-openzfs-key2
9+
fingerprint: 7DC7 299D CF7C 7FD9 CD87 701B A599 FD5E 9DB8 4141
10+
state: present
11+
12+
- name: Add ZFS Repo for EL9
13+
ansible.builtin.dnf:
14+
name: https://zfsonlinux.org/epel/zfs-release-2-3.el9.noarch.rpm
15+
state: present
16+
17+
- name: Install ZFS for EL9 - DKMS
18+
ansible.builtin.dnf:
19+
name:
20+
- kernel-devel
21+
- zfs
22+
state: present
23+
when: zfs_kabi is undefined
24+
25+
- name: Install ZFS for EL9 - kABI
26+
when: zfs_kabi
27+
block:
28+
- name: Disable zfs-dkms
29+
community.general.dnf_config_manager:
30+
name: zfs
31+
state: disabled
32+
33+
- name: Enable zfs-kmod
34+
community.general.dnf_config_manager:
35+
name: zfs-kmod
36+
state: enabled
37+
38+
- name: Install zfs-kmod
39+
ansible.builtin.package:
40+
name: zfs
41+
state: present

roles/zfs/tasks/Ubuntu-24.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- name: Enable Universe Repo for ZFS
2+
become: true
3+
ansible.builtin.apt_repository:
4+
repo: "deb http://archive.ubuntu.com/ubuntu {{ ansible_lsb.codename }} main universe"
5+
state: present
6+
filename: universe
7+
8+
- name: Install ZFS
9+
become: true
10+
ansible.builtin.package:
11+
name: zfsutils-linux

roles/zfs/tasks/main.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# HACK: Set EL distros to group them all as RedHat
2+
# - otherwise would need separate files for every derivative
3+
- name: Define OS distributions
4+
ansible.builtin.set_fact:
5+
el_distros:
6+
- AlmaLinux
7+
8+
- name: Install ZFS
9+
ansible.builtin.include_tasks: "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
10+
when: ansible_distribution not in el_distros
11+
12+
- name: Install ZFS - (EL)
13+
ansible.builtin.include_tasks: "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yaml"
14+
when: ansible_distribution in el_distros

0 commit comments

Comments
 (0)