DAJEEEEEE, STA ANDANDO (anche se con nginx e non con xmpp) E GODO UN CASINOOOO. ALLA FINE I PROBLEMI DI SSH ERANO SOLO DOVUTI ALLA FRETTA. E LASCIA UN PO' DI TEMPO A STI POVERI CONTAINER DI AVVIARSI

This commit is contained in:
Freek Kettone 2025-09-03 17:07:10 +02:00
parent 54eeb79ac9
commit 2d5fb2e77b
3 changed files with 24 additions and 45 deletions

View file

@ -6,6 +6,19 @@
become: yes
tasks:
- name: Wait until SSH is fully ready (Ansible login confirms availability)
ansible.builtin.wait_for_connection:
timeout: 300 # fino a 5 minuti (essere generosi per bootstrap lento)
delay: 5 # aspetta 5s prima di cominciare i tentativi
- name: Ensure apt cache is updated (idempotent)
ansible.builtin.apt:
update_cache: yes
# non vogliamo che il primo apt rallenti la connessione dopo wait_for_connection,
# ma questo garantisce che i task successivi usino pacchetti aggiornati.
- name: Ensure SSH is installed
ansible.builtin.apt:
name: openssh-server
@ -27,14 +40,6 @@
line: 'PermitRootLogin yes'
notify: Restart SSH
- name: Disable DNS lookup to speed up SSH login
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?UseDNS'
line: 'UseDNS no'
notify: Restart SSH
- name: Ensure .ssh directory exists
ansible.builtin.file:
@ -53,21 +58,3 @@
owner: root
group: root
- name: Configure SSH for key-only root login
ansible.builtin.blockinfile:
path: /etc/ssh/sshd_config
block: |
PermitRootLogin prohibit-password
PasswrodAuthentication no
UseDNS no
notify: Restart SSH
handlers:
- name: Restart SSH
ansible.builtin.service:
name: ssh
state: restarted