feat: systemd service for mount

This commit is contained in:
Matthieu Bessat 2024-06-11 17:22:00 +02:00
parent 3ec8b1d1e7
commit b8e71be310
14 changed files with 91 additions and 39 deletions

1
ansible/.gitignore vendored
View file

@ -1,2 +1,3 @@
arch_packages.json arch_packages.json
pip_packages.json pip_packages.json
vm_files

View file

@ -198,7 +198,7 @@ categories:
- gopls - gopls
- rust-analyzer - rust-analyzer
- typst-lsp - typst-lsp
- vscode-css-language - vscode-css-languageserver
- pyright - pyright
- typescript-language-server - typescript-language-server
- svelte-language-server - svelte-language-server
@ -299,6 +299,7 @@ categories:
audio: audio:
- tenacity - tenacity
- songrec - songrec
- aur/clementine
video: video:
- cheese - cheese
- celluloid - celluloid

View file

@ -22,9 +22,8 @@ ln -s $workdir $base/vm_files
ansible-playbook $base/workstation.yaml \ ansible-playbook $base/workstation.yaml \
-v \ -v \
--ask-become-pass \ --ask-become-pass \
-u "mbess" \
-i "inventory.yaml" \ -i "inventory.yaml" \
--ssh-extra-args "-o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 22 -i ./master_sshkey" \ --ssh-extra-args "-o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 22 -i ./master_sshkey" \
--extra-vars "@$workdir/vars.yaml" \ --extra-vars "@$workdir/vars.yaml" \
--start-at-task "Install pip packages" $@

View file

@ -1,4 +1,6 @@
IdentityFile "~/.ssh/{{ device_name }}_perso_generic_ed25519"
Host forge.lefuturiste.fr Host forge.lefuturiste.fr
user git user git
IdentitiesOnly yes IdentitiesOnly yes
IdentityFile ~/.ssh/{{ device_name }}_perso_generic_ed25519 IdentityFile "~/.ssh/{{ device_name }}_perso_generic_ed25519"

View file

@ -0,0 +1,14 @@
[Unit]
Description=SSHFS Daemon to mount a remote directory
StartLimitInterval=200
StartLimitBurst=8
[Service]
Type=simple
ExecStart=/usr/bin/sshfs -f {{ service_params.ssh_uri }} {{ service_params.mount_path }} -o reconnect,ServerAliveInterval=30,ServerAliveCountMax=5
Restart=always
StandardOutput=journal
RestartSec=20
[Install]
WantedBy=default.target

View file

@ -1,15 +0,0 @@
[Unit]
Description=SSHFS Daemon to mount srv06 warmd as a volume
StartLimitInterval=200
StartLimitBurst=8
[Service]
Type=simple
ExecStart=/usr/bin/sshfs -f {{ user }}@srv06.rem:/warmd/mbess {{ home }}/.mnt/srv06/warmd/mbess -o reconnect,ServerAliveInterval=30,ServerAliveCountMax=5
Restart=always
StandardOutput=journal
RestartSec=20
[Install]
WantedBy=default.target

View file

@ -0,0 +1,11 @@
[Unit]
Description=SwayBg
PartOf=graphical-session.target
[Service]
Type=simple
ExecStart=swaybg -i {{ home }}/.dots/wallpapers/jupiter.jpg -m fill
[Install]
WantedBy=sway-session.target

View file

@ -5,8 +5,18 @@
systemd_services: systemd_services:
system: [] system: []
user: user:
- name: "sshfs_srv06_warmd" - from: "mount_sshfs"
name: "mount_sshfs_srv06_warmd_mbess"
enabled: true enabled: true
params:
ssh_uri: "mbess@srv06.mbess.net:/warmd/mbess"
mount_path: "{{ home }}/.mnt/srv06/warmd/mbess"
- from: "mount_sshfs"
name: "mount_sshfs_srv06_warmd_etb"
enabled: true
params:
ssh_uri: "mbess@srv06.mbess.net:/warmd/etoiledebethleem"
mount_path: "{{ home }}/.mnt/srv06/warmd/etb"
- name: "popequer_gitwatch@" - name: "popequer_gitwatch@"
- name: "hourly_remainder" - name: "hourly_remainder"
enabled: true enabled: true
@ -15,6 +25,8 @@
enabled: true enabled: true
- name: "gammastep" - name: "gammastep"
enabled: true enabled: true
- name: "swaybg"
enabled: true
config_files: config_files:
- dir: fish - dir: fish
name: config.fish name: config.fish
@ -194,7 +206,7 @@
vars: vars:
packages: "{{ (lookup('file', 'arch_packages.json') | from_json)['aur'] }}" packages: "{{ (lookup('file', 'arch_packages.json') | from_json)['aur'] }}"
# SYSTEMD # SYSTEMD user services
- name: Setup systemd user services folder - name: Setup systemd user services folder
file: file:
path: "{{ home }}/.config/systemd/user" path: "{{ home }}/.config/systemd/user"
@ -202,14 +214,26 @@
recurse: true recurse: true
- name: Setup user units - name: Setup user units
loop: "{{ systemd_services.user }}"
when: "item.from is not defined"
template: template:
src: "systemd/user/{{ item.name }}.service" src: "systemd/user/{{ item.name }}.service"
dest: "{{ home }}/.config/systemd/user/{{ item.name }}.service" dest: "{{ home }}/.config/systemd/user/{{ item.name }}.service"
vars:
service_params: "{{ item.params }}"
- name: Setup user unit with from
loop: "{{ systemd_services.user }}" loop: "{{ systemd_services.user }}"
when: "item.from is defined"
template:
src: "systemd/user/{{ item.from }}.service"
dest: "{{ home }}/.config/systemd/user/{{ item.name }}.service"
vars:
service_params: "{{ item.params }}"
- name: Setup user timers - name: Setup user timers
when: "item.timer is defined and item.timer"
loop: "{{ systemd_services.user }}" loop: "{{ systemd_services.user }}"
when: "item.timer is defined and item.timer"
template: template:
src: "systemd/user/{{ item.name }}.timer" src: "systemd/user/{{ item.name }}.timer"
dest: "{{ home }}/.config/systemd/user/{{ item.name }}.timer" dest: "{{ home }}/.config/systemd/user/{{ item.name }}.timer"
@ -234,21 +258,15 @@
enabled: true enabled: true
# OTHERS # OTHERS
- name: Setup mount point folder - name: Setup mount point folders
file: file:
path: "{{ home }}/.mnt" path: "{{ home }}/.mnt/{{ item }}"
state: directory
recurse: true
- name: Setup mount point folder for srv06
file:
path: "{{ home }}/.mnt/srv06/warmd/mbess"
state: directory
recurse: true
- name: Setup mount point folder
file:
path: "{{ home }}/.mnt/etb"
state: directory state: directory
recurse: true recurse: true
loop:
- srv06/warmd/mbess
- srv06/coldd/mbess
- srv06/warmd/etb
- name: Setup triage folder - name: Setup triage folder
file: file:
path: "{{ home }}/triage" path: "{{ home }}/triage"
@ -297,14 +315,16 @@
repo: "git@forge.lefuturiste.fr:mbess/books-sources.git" repo: "git@forge.lefuturiste.fr:mbess/books-sources.git"
dest: /home/mbess/workspace/books_sources dest: /home/mbess/workspace/books_sources
- name: Clone monakhos
ansible.builtin.git:
repo: "git@forge.lefuturiste.fr:mbess/monakhos.git"
dest: /home/mbess/workspace/monakhos
- name: Setup wofi link - name: Setup wofi link
become: true become: true
file: file:
src: "/usr/bin/wofi" src: "/usr/bin/wofi"
dest: "/usr/bin/rofi" dest: "/usr/bin/rofi"
state: link state: link
# Final workspaces
- name: Clone monakhos
ansible.builtin.git:
repo: "git@forge.lefuturiste.fr:mbess/monakhos.git"
dest: /home/mbess/workspace/monakhos

2
target/.gitignore vendored
View file

@ -1,3 +1,5 @@
* *
!.gitignore !.gitignore
!.gitkeep !.gitkeep
!example_host/
!example_host/*

View file

@ -0,0 +1,3 @@
workstation:
hosts:
localhost: {}

View file

@ -0,0 +1,7 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACCzLJSUEp7ZgIhKgBe3KS9VxD1kVoL+1rteNDUTwrF+DwAAAJBi/5tQYv+b
UAAAAAtzc2gtZWQyNTUxOQAAACCzLJSUEp7ZgIhKgBe3KS9VxD1kVoL+1rteNDUTwrF+Dw
AAAED4FA6R3uUYxh3xbBzpejFO71FKa/COcMq6tdiwdyDn/rMslJQSntmAiEqAF7cpL1XE
PWRWgv7Wu140NRPCsX4PAAAADW1hc3Rlcl9zc2hrZXk=
-----END OPENSSH PRIVATE KEY-----

View file

@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILMslJQSntmAiEqAF7cpL1XEPWRWgv7Wu140NRPCsX4P master_sshkey

2
target/example_host/run.sh Executable file
View file

@ -0,0 +1,2 @@
#!/usr/bin/sh
../../ansible/run_ansible_playbook.sh -u mbess

View file

@ -0,0 +1,4 @@
device_name: example_host
user: mbess
target_is_real: true