Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install NFS server into skylark #427

Merged
merged 4 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/develop_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ jobs:
- console
- dockerservice
- jenkins
- nfs
- rui
- runner03
- skylark
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/main_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ jobs:
- console
- dockerservice
- jenkins
- nfs
- rui
- runner03
- skylark
Expand Down Expand Up @@ -121,7 +120,6 @@ jobs:
- console
- dockerservice
- jenkins
- nfs
- rui
- runner03
- skylark
Expand Down
5 changes: 0 additions & 5 deletions inventories/host_vars/networks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ network:
ipv4: 192.168.1.102
shortname: origin
sshuser: hayato
- hostname: nfs.hayaworld.home
interface: ens18
ipv4: 192.168.1.103
shortname: nfs
sshuser: hayato
- hostname: console.hayaworld.home
interface: ens18
ipv4: 192.168.1.105
Expand Down
56 changes: 0 additions & 56 deletions inventories/host_vars/nfs.yml

This file was deleted.

43 changes: 43 additions & 0 deletions inventories/host_vars/skylark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,52 @@ drives:
subvol: "/Nullpo"
filesystem: "btrfs"
options: "defaults,users,noatime,compress=zstd"
- uuid: 77af48a6-5a47-4e06-a106-c5c74b6d1449
mountpoint: /backup/nfs
subvol: "/nfs"
filesystem: "btrfs"
options: "defaults,users,noatime,compress=zstd"
- uuid: 77af48a6-5a47-4e06-a106-c5c74b6d1449
mountpoint: /backup/snapshots
subvol: "/snapshots"
filesystem: "btrfs"
options: "defaults,users,noatime,compress=zstd"

nfs:
exports:
- path: "/skylark/nfs"
allowip: "192.168.1.0/24"
options: "rw"
nfs_folders:
- name: "hayato"
uid: 1000
gid: 1000
path: "/skylark/nfs/hayato"

backup_exclude:
home:
- "SparceImages/icloud_photo.sparsebundle/*"

backup_scripts:
dirs:
- name: "Nullpo"
src: "/skylark/Nullpo/"
dest: "/backup/Nullpo"
snapshotdir: "/backup/snapshots/Nullpo"
excludefilepath: "/home/hayato/backupscripts/Nullpo_exclude.txt"
- name: "NFS"
src: "/skylark/nfs/"
dest: "/backup/nfs"
snapshotdir: "/backup/snapshots/nfs"
excludefilepath: "/home/hayato/backupscripts/NFS_exclude.txt"
- name: "Home"
src: "/skylark/hayato/"
dest: "/backup/hayato"
snapshotdir: "/backup/snapshots/hayato"
excludefilepath: "/home/hayato/backupscripts/Home_exclude.txt"

services_start:
- nfs-server
- nmbd
- qemu-guest-agent
- smbd
Expand Down Expand Up @@ -62,3 +97,11 @@ firewall:
proto: "tcp"
src: "172.17.0.0/16"
port: "22"
- name: "NFS service(TCP)"
proto: "tcp"
src: "192.168.1.0/24"
port: "2049"
- name: "NFS service(UDP)"
proto: "udp"
src: "192.168.1.0/24"
port: "2049"
37 changes: 0 additions & 37 deletions nfs.yml

This file was deleted.

6 changes: 6 additions & 0 deletions skylark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
tags:
- samba

- name: Set nfs
ansible.builtin.import_tasks:
file: tasks/skylark/nfs.yml
tags:
- nfs

- name: Install Pre-builded SNS downloaders
ansible.builtin.import_tasks:
file: tasks/sns_dl.yml
Expand Down
27 changes: 0 additions & 27 deletions tasks/nfs/install_nfs.yml

This file was deleted.

30 changes: 0 additions & 30 deletions tasks/nfs/mount.yml

This file was deleted.

13 changes: 7 additions & 6 deletions tasks/skylark/backupscripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
mode: '0755'

- name: Put Backup Script
ansible.builtin.copy:
src: "templates/skylark/{{ item }}"
dest: "{{ item }}"
ansible.builtin.template:
src: "templates/skylark/home/hayato/backupscripts/incrementalBackup.sh.j2"
dest: "/home/hayato/backupscripts/incremental{{ item.name }}Backup.sh"
owner: hayato
group: hayato
mode: '0755'
loop:
- /home/hayato/backupscripts/incrementalHomeBackup.sh
- /home/hayato/backupscripts/incrementalNullpoBackup.sh
loop: "{{ backup_scripts.dirs }}"
vars:
pathinfo: "{{ item }}"

- name: Put Exclude file
ansible.builtin.template:
Expand All @@ -26,6 +26,7 @@
loop:
- /home/hayato/backupscripts/Nullpo_exclude.txt
- /home/hayato/backupscripts/Home_exclude.txt
- /home/hayato/backupscripts/NFS_exclude.txt

- name: "Sudo password passthrough"
ansible.builtin.blockinfile:
Expand Down
45 changes: 45 additions & 0 deletions tasks/skylark/nfs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
- name: "Install NFS modules"
ansible.builtin.apt:
pkg:
- nfs-kernel-server

- name: "Add idmapd.conf"
ansible.builtin.template:
src: templates/skylark/etc/idmapd.conf.j2
dest: /etc/idmapd.conf
owner: root
group: root
mode: '0644'
notify: "Restart nfs-server"
tags:
- nfs_config

- name: "Add exports"
ansible.builtin.template:
src: templates/skylark/etc/exports.j2
dest: /etc/exports
owner: root
group: root
mode: '0644'
notify: "Restart nfs-server"
tags:
- nfs_config

- name: "Mkdir for users root"
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
mode: '0755'
owner: "root"
group: "root"
loop: "{{ nfs.exports }}"

- name: "Mkdir for users"
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
mode: '0755'
owner: "{{ item.uid }}"
group: "{{ item.gid }}"
loop: "{{ nfs.nfs_folders }}"
5 changes: 0 additions & 5 deletions templates/nfs/etc/motd

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% for e in exports %}
{% for e in nfs.exports %}
{{ e.path }} {{ e.allowip }}({{ e.options }})
{% endfor %}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if backup_exclude.nfs is defined %}
{% for path in backup_exclude.nfs %}
{{ path }}
{% endfor %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

SRC='{{ pathinfo.src }}'
DEST='{{ pathinfo.dest }}'
SNAPSHOTSDIR='{{ pathinfo.snapshotdir }}'
EXCLUDEFILE='{{ pathinfo.excludefilepath }}'

TODAY=$(date +%Y%m%d_%H%M%S)

# rsync
echo "rsync -av8 --delete --exclude-from=${EXCLUDEFILE} ${SRC} ${DEST}"
rsync -av8 --delete --exclude-from="${EXCLUDEFILE}" ${SRC} ${DEST}
RETVAL=$?

# Snapshot 作成
sudo btrfs subvolume snapshot -r "${DEST}" "${SNAPSHOTSDIR}/${TODAY}"
Loading
Loading