infrastructure/ansible/roles/base/tasks/ssh.yml
Jake Howard d5a7a61171
All checks were successful
/ terraform (push) Successful in 38s
/ ansible (push) Successful in 1m30s
Remove unnecessary use of become from some roles
This should make execution much faster
2024-09-09 17:09:03 +01:00

43 lines
841 B
YAML

- name: Install OpenSSH for Debian
package:
name: openssh-server
when: ansible_os_family == 'Debian'
- name: Install OpenSSH for Arch
package:
name: openssh
when: ansible_os_family == 'Archlinux'
- name: Define context
set_fact:
user: jake
enable_root: false
- name: SSH config
template:
src: files/sshd_config
dest: /etc/ssh/sshd_config
validate: /usr/sbin/sshd -t -f %s
backup: true
mode: "644"
register: sshd_config
- name: Set up authorized keys
ansible.posix.authorized_key:
user: "{{ me.user }}"
state: present
key: "{{ lookup('file', item) }}"
loop:
- ssh-keys/ps.pub
- ssh-keys/mobile.pub
- name: Enable SSH
service:
name: sshd
enabled: true
- name: Restart SSH Daemon
service:
name: sshd
state: reloaded
when: sshd_config.changed