ansible-role-borgbackup/tasks/ssh.yml

37 lines
995 B
YAML
Raw Normal View History

2023-04-08 22:33:17 +02:00
---
2023-04-09 10:05:37 +02:00
- name: "SSH | Ensure directory exist"
ansible.builtin.file:
path: "{{ borg_user }}/.ssh/"
state: directory
mode: "0700"
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
2023-04-08 22:33:17 +02:00
- name: "SSH | Generate an OpenSSH keypair"
community.crypto.openssh_keypair:
path: "{{ borg_ssh_key_file_path }}"
type: "{{ borg_ssh_key_type }}"
2023-04-09 10:05:37 +02:00
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
2023-05-08 15:29:17 +02:00
comment: "{{ inventory_hostname }}"
2023-04-08 22:33:17 +02:00
- name: "SSH | Ensure configuration file is present"
ansible.builtin.file:
2023-04-09 10:05:37 +02:00
path: "{{ borg_user_ssh_config_path }}"
2023-04-08 22:33:17 +02:00
state: touch
mode: "644"
2023-04-09 10:05:37 +02:00
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
2023-04-08 22:33:17 +02:00
2023-05-08 11:21:21 +02:00
- name: "SSH | Ensure configuration exists"
ansible.builtin.file:
2023-05-08 11:54:10 +02:00
path: ~/.ssh/config
2023-05-08 11:21:21 +02:00
state: touch
mode: "0644"
- name: "SSH | Create SSH configuration"
2023-04-08 22:33:17 +02:00
ansible.builtin.blockinfile:
2023-05-08 11:54:10 +02:00
path: ~/.ssh/config
2023-04-08 22:33:17 +02:00
marker: "### {mark} ANSIBLE MANAGED BLOCK"
2023-05-08 11:21:21 +02:00
block: "{{ lookup('template', 'ssh_config.j2') }}"