alliance-boreale/infrastructure/ansible2/roles/common/tasks/ssh.yml
Dan Allaire ef98fd8a3f Refonte
2026-03-09 18:23:06 -04:00

32 lines
783 B
YAML

# Alliance Boréale - Rôle Common - SSH Configuration
# Date: 2025-10-31
---
- name: "📦 Ensure OpenSSH server is installed"
ansible.builtin.apt:
name: openssh-server
state: present
- name: "⚙️ Configure SSH daemon"
ansible.builtin.template:
src: sshd_config.j2
dest: /etc/ssh/sshd_config
owner: root
group: root
mode: '0644'
validate: '/usr/sbin/sshd -t -f %s'
notify: restart sshd
- name: "🔑 Add authorized keys for ansible user"
ansible.posix.authorized_key:
user: "{{ users.ansible.name }}"
key: "{{ item }}"
state: present
loop: "{{ ssh.authorized_keys }}"
when: ssh.authorized_keys is defined
- name: "✅ Start and enable SSH"
ansible.builtin.systemd:
name: sshd
state: started
enabled: true