feat: restructure Ansible playbook and add SSH service handlers
Some checks failed
Nix Format Check / check-format (push) Failing after 37s

This commit is contained in:
Menno van Leeuwen 2025-03-11 16:02:49 +01:00
parent d787b25917
commit 822704cd1d
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
4 changed files with 23 additions and 7 deletions

View File

@ -262,7 +262,7 @@ def main():
"/usr/bin/env", "/usr/bin/env",
"ansible-playbook", "ansible-playbook",
"-i", f"{dotfiles_path}/config/ansible/inventory.ini", "-i", f"{dotfiles_path}/config/ansible/inventory.ini",
f"{dotfiles_path}/config/ansible/main.yml", f"{dotfiles_path}/config/ansible/playbook.yml",
"--extra-vars", f"hostname={hostname}", "--extra-vars", f"hostname={hostname}",
"--extra-vars", f"ansible_user={username}", "--extra-vars", f"ansible_user={username}",
"--limit", hostname, "--limit", hostname,

View File

@ -0,0 +1,12 @@
---
- name: Systemctl daemon-reload
become: true
ansible.builtin.systemd:
daemon_reload: true
- name: Restart SSH service
become: true
ansible.builtin.service:
name: ssh
state: restarted
enabled: true

View File

@ -1,5 +1,8 @@
- name: Configure all hosts - name: Configure all hosts
hosts: all hosts: all
handlers:
- name: Import handler tasks
ansible.builtin.import_tasks: handlers/main.yml
gather_facts: true gather_facts: true
tasks: tasks:

View File

@ -3,6 +3,12 @@
name: openssh-server name: openssh-server
state: present state: present
- name: Ensure SSH service is enabled and running
ansible.builtin.service:
name: ssh
state: started
enabled: true
- name: Ensure SSH server configuration is proper - name: Ensure SSH server configuration is proper
ansible.builtin.template: ansible.builtin.template:
src: templates/sshd_config.j2 src: templates/sshd_config.j2
@ -11,9 +17,4 @@
group: root group: root
mode: '0644' mode: '0644'
validate: '/usr/sbin/sshd -t -f %s' validate: '/usr/sbin/sshd -t -f %s'
notify: Restart SSH service
- name: Ensure SSH service is enabled and running
ansible.builtin.service:
name: ssh
state: started
enabled: true