This repository has been archived on 2023-12-26. You can view files and clone it, but cannot push or open issues or pull requests.
lewis/roles/system/tasks/main.yml

60 lines
1.7 KiB
YAML
Raw Normal View History

2023-04-11 20:20:57 +00:00
- name: Install sshfs
apt:
name: sshfs
2023-02-25 14:35:35 +00:00
- name: Add admins' authorized keys
authorized_key:
key: "{{ item }}"
user: "{{ ansible_user_id }}"
loop: "{{ admin_public_keys }}"
- name: Copy host public key
copy:
2023-02-25 14:35:35 +00:00
dest: "/etc/ssh/ssh_host_ed25519_key.pub"
content: "{{ dataserver_public_key }}"
2023-02-25 14:35:35 +00:00
mode: 0644
- name: Copy host private key
copy:
src: "{{ role_path }}/files/ssh_host_ed25519_key"
dest: "/etc/ssh/ssh_host_ed25519_key"
mode: 0600
- name: Copy user public key
copy:
dest: "/etc/ssh/ssh_user_ed25519_key.pub"
content: "{{ user_public_key }}"
mode: 0644
- name: Copy user private key
copy:
src: "{{ role_path }}/files/ssh_user_ed25519_key"
dest: "/etc/ssh/ssh_user_ed25519_key"
mode: 0600
- name: Copy ssh config
copy:
src: "{{ role_path }}/files/ssh.conf"
dest: "/etc/ssh/ssh_config.d/custom.conf"
- name: Check certificate existance
stat:
path: "/etc/ssh/ssh_user_ed25519_key-cert.pub"
register: cert_stat
- name: Generate user certificate
command:
2023-04-11 06:45:28 +00:00
cmd: "ssh -o ConnectTimeout=3 -o ConnectionAttempts=1 root@hermes.dmz '/root/ca.sh user \"{{ user_public_key }}\" lewis.lan \"backup\"'"
register: cert
delegate_to: localhost
when: not cert_stat.stat.exists
- name: Place user certificate
copy:
dest: "/etc/ssh/ssh_user_ed25519_key-cert.pub"
content: "{{ cert.stdout }}"
2023-04-11 06:45:28 +00:00
mode: 0600
when: not cert_stat.stat.exists
2023-04-11 15:27:21 +00:00
- name: Create point mount for atlas data
file:
path: /mnt/atlas
state: directory
- name: Mount atlas data
mount:
2023-04-11 20:10:57 +00:00
src: "backup-share@atlas.lan:"
2023-04-11 15:27:21 +00:00
path: "/mnt/atlas"
state: mounted
fstype: fuse.sshfs
2023-04-21 07:29:28 +00:00
opts: "x-systemd.automount,_netdev,idmap=user,allow_other,reconnect,ro,ServerAliveInterval=15,ServerAliveCountMax=3"