-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
|
||
- name: Update all nodes | ||
hosts: nodes | ||
become: true | ||
tasks: | ||
- name: Update nodes using DNF # noqa: package-latest | ||
ansible.builtin.dnf: | ||
name: "*" | ||
update_cache: true | ||
update_only: true | ||
state: latest | ||
|
||
- name: Update all routers | ||
hosts: routers | ||
become: true | ||
tasks: | ||
- name: Update nodes using APT | ||
ansible.builtin.apt: | ||
name: "*" | ||
update_cache: true | ||
only_upgrade: true | ||
state: latest |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
- name: Add zfs to storage nodes | ||
hosts: all | ||
become: true | ||
vars: | ||
zfs_pool_name: "niployments-hard-storage" | ||
zfs_pool_mountpoint: "/mnt/hard-storage" | ||
zfs_pool_state: present | ||
zfs_pool_mode: "raidz" | ||
|
||
tasks: | ||
- name: Only run play if storage is not enabled | ||
when: hostvars[inventory_hostname]['storage'] is defined and hostvars[inventory_hostname]['storage'] == "true" | ||
block: | ||
- name: Get stoarge definitions | ||
ansible.builtin.include_vars: | ||
file: storage-defs.json | ||
name: storage_definitions | ||
- name: Use storage definition for node | ||
ansible.builtin.set_fact: | ||
zfs_pool_devices: "{{ storage_definitions[inventory_hostname] }}" | ||
- name: Enable EPEL repository | ||
Check failure on line 22 in node/add-zfs-to-storage-node.yaml GitHub Actions / Ansible Lintfqcn[action-core]
Check failure Code scanning / Ansible-lint Use FQCN for builtin module actions (ansible.builtin.yum). Error
Use ansible.builtin.dnf or ansible.legacy.dnf instead.
|
||
ansible.builtin.yum: | ||
name: epel-release | ||
state: present | ||
- name: Add ZFS GPG key | ||
ansible.builtin.rpm_key: | ||
state: present | ||
key: https://raw.githubusercontent.com/zfsonlinux/zfsonlinux.github.com/master/zfs-release/RPM-GPG-KEY-openzfs-key2 | ||
- name: Install DKMS manually | ||
Check failure on line 30 in node/add-zfs-to-storage-node.yaml GitHub Actions / Ansible Lintfqcn[action-core]
Check failure Code scanning / Ansible-lint Use FQCN for builtin module actions (ansible.builtin.yum). Error
Use ansible.builtin.dnf or ansible.legacy.dnf instead.
|
||
ansible.builtin.yum: | ||
name: dkms | ||
state: present | ||
- name: Install zfs repo | ||
Check failure on line 34 in node/add-zfs-to-storage-node.yaml GitHub Actions / Ansible Lintfqcn[action-core]
Check failure Code scanning / Ansible-lint Use FQCN for builtin module actions (ansible.builtin.yum). Error
Use ansible.builtin.dnf or ansible.legacy.dnf instead.
|
||
ansible.builtin.yum: | ||
name: "https://zfsonlinux.org/epel/zfs-release-2-3.el9.noarch.rpm" | ||
state: present | ||
- name: Install ZFS | ||
ansible.builtin.dnf: | ||
name: | ||
- zfs | ||
- zfs-dkms | ||
- kernel-devel | ||
state: present | ||
- name: Install dkms modules | ||
ansible.builtin.command: dkms autoinstall | ||
changed_when: true | ||
- name: Load ZFS kernel module | ||
Check failure on line 48 in node/add-zfs-to-storage-node.yaml GitHub Actions / Ansible Lintignore-errors
Check failure Code scanning / Ansible-lint Use failed_when and specify error conditions instead of using ignore_errors. Error
Task/Handler: Load ZFS kernel module
|
||
ansible.builtin.command: modprobe zfs | ||
changed_when: true | ||
ignore_errors: yes | ||
Check failure on line 51 in node/add-zfs-to-storage-node.yaml GitHub Actions / Ansible Lintyaml[truthy]
Check failure Code scanning / Ansible-lint Truthy value should be one of [false, true] Error
Truthy value should be one of [false, true]
|
||
- name: Check ZFS pool existance | ||
Check failure on line 52 in node/add-zfs-to-storage-node.yaml GitHub Actions / Ansible Lintfqcn[action-core]
Check failure Code scanning / Ansible-lint Use FQCN for builtin module actions (ansible.builtin.yum). Error
Use ansible.builtin.command or ansible.legacy.command instead.
|
||
command: zpool list -Ho name {{ zfs_pool_name }} | ||
register: result_pool_list | ||
ignore_errors: yes | ||
Check failure on line 55 in node/add-zfs-to-storage-node.yaml GitHub Actions / Ansible Lintyaml[truthy]
Check failure Code scanning / Ansible-lint Truthy value should be one of [false, true] Error
Truthy value should be one of [false, true]
|
||
changed_when: false | ||
|
||
- name: Create ZFS pool | ||
Check failure on line 58 in node/add-zfs-to-storage-node.yaml GitHub Actions / Ansible Lintfqcn[action-core]
Check failure on line 58 in node/add-zfs-to-storage-node.yaml GitHub Actions / Ansible Lintno-changed-when
Check failure Code scanning / Ansible-lint Use FQCN for builtin module actions (ansible.builtin.yum). Error
Use ansible.builtin.command or ansible.legacy.command instead.
Check failure Code scanning / Ansible-lint Commands should not change things if nothing needs doing. Error
Task/Handler: Create ZFS pool
|
||
command: >- | ||
zpool create | ||
{{ '-m ' + zfs_pool_mountpoint if zfs_pool_mountpoint else '' }} | ||
{{ zfs_pool_name }} | ||
{{ zfs_pool_mode if zfs_pool_mode else '' }} | ||
{{ zfs_pool_devices | join(' ') }} | ||
when: | ||
- zfs_pool_state | default('present') == 'present' | ||
- result_pool_list.rc == 1 | ||
- name: Install NFS utilities | ||
Check failure on line 68 in node/add-zfs-to-storage-node.yaml GitHub Actions / Ansible Lintfqcn[action-core]
Check failure Code scanning / Ansible-lint Use FQCN for builtin module actions (ansible.builtin.yum). Error
Use ansible.builtin.dnf or ansible.legacy.dnf instead.
|
||
dnf: | ||
name: nfs-utils | ||
state: present | ||
|
||
- name: Force nfs version 4 | ||
Check failure Code scanning / Ansible-lint Trailing spaces Error
Trailing spaces
|
||
ansible.builtin.lineinfile: | ||
path: /etc/nfsmount.conf | ||
regexp: "^# Nfsvers=4" | ||
line: "Nfsvers=4" | ||
- name: Enable and start the NFS server service | ||
ansible.builtin.systemd: | ||
name: nfs-server | ||
enabled: true | ||
state: started | ||
|
||
- name: Create export directory | ||
ansible.builtin.file: | ||
path: "{{ zfs_pool_mountpoint }}/shared_dir" | ||
state: directory | ||
mode: '0755' | ||
|
||
- name: Set SELinux context for the export directory | ||
ansible.builtin.command: chcon -t nfs_t {{ zfs_pool_mountpoint }}/shared_dir | ||
args: | ||
creates: /export/shared_dir | ||
|
||
- name: Configure NFS exports | ||
Check failure Code scanning / Ansible-lint `mode: 644` should have a string value with leading zero `mode: "01204"` or use symbolic mode. Error
Task/Handler: Configure NFS exports
|
||
ansible.builtin.copy: | ||
dest: /etc/exports | ||
content: "{{ zfs_pool_mountpoint }}/shared_dir *(rw,sync,no_root_squash,no_subtree_check)\n" | ||
mode: 644 | ||
|
||
- name: Export NFS shares | ||
ansible.builtin.command: exportfs -r | ||
changed_when: true | ||
Check failure Code scanning / Ansible-lint No new line character at the end of file Error
No new line character at the end of file
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"cluster2": [ | ||
"/dev/disk/by-id/ata-ST2000DM008-2UB102_WFL7F5R8", | ||
"/dev/disk/by-id/ata-ST2000DM008-2UB102_WFL7F74S", | ||
"/dev/disk/by-id/ata-ST2000DM008-2UB102_WFL7HRE3" | ||
] | ||
} |