The README and the comments of tasks/bootstrap.yml, tasks/handback.yml and tasks/lock_root.yml named mortis.kamino.sshd, which the role-independence test refuses in a role's docs. They now name the sshd role (of this Collection), as the ufw role does for system_baseline. The role's own FQCN in its README and scenario stays, as in sshd and ufw. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
29 lines
1.5 KiB
YAML
29 lines
1.5 KiB
YAML
---
|
|
- name: Test connection as configured user
|
|
ansible.builtin.wait_for_connection:
|
|
timeout: 5
|
|
register: user_management_connection
|
|
# Failure is the signal to fall back to root below; the "Verify root access" ping
|
|
# fails the play if root is unreachable too.
|
|
ignore_errors: true
|
|
|
|
# Key only, never a password: the root fallback uses the same deploy key as every other
|
|
# connection (ansible_ssh_private_key_file). It is for a new LXC: the provisioning step gives root
|
|
# that key and stock Ubuntu sshd (PermitRootLogin prohibit-password) admits root by key on first
|
|
# boot. A new VM never needs it (cloud-init creates the configured user with the key; root does not
|
|
# get it), and a fresh Proxmox node gets the key from the operator. Once the sshd role has run
|
|
# (PermitRootLogin no on ubuntu_lxc/ubuntu_vm), root is refused: a host whose configured user broke
|
|
# later is recovered from its Proxmox node (pct enter, qm terminal or the console), not here.
|
|
# tasks/handback.yml switches the connection back to the configured user after it is created.
|
|
- name: Fallback to root if user connection failed
|
|
when: user_management_connection is failed
|
|
block:
|
|
- name: Switch to root with the deploy key
|
|
# Connection var on purpose: as a fact it overrides the connection for the rest of the run,
|
|
# until tasks/handback.yml switches it back.
|
|
ansible.builtin.set_fact: # noqa: var-naming[no-role-prefix]
|
|
ansible_ssh_user: root
|
|
|
|
- name: Verify root access
|
|
ansible.builtin.ping:
|