Review of #122. - A failed attach no longer closes the connection: the snippet does not exec tmux, it prints a line and leaves the plain shell (a client TERM without terminfo made every login fail). A clean detach still ends the connection. - The snippet acts only for an interactive shell (case $-): a login shell that is not interactive, such as `ssh -t host 'bash -lc cmd'`, is left alone. Docs corrected. - Validation anchors with \Z, so a trailing newline from a YAML block scalar is refused. It moves to validate.yml (tag always); argument_specs already covers types. - Install keys on tmux being in the resolved package list, not a second profile list. - verify.yml: the snippet does nothing without a terminal, the trailing-newline refusals, and the removal path. The vacuous pve assert is gone. - README and argument_specs: window commands start with a minimal environment (use absolute paths), zsh and fish do not read /etc/profile.d, detach ends the connection.
28 lines
1.5 KiB
YAML
28 lines
1.5 KiB
YAML
---
|
|
# Attach an interactive SSH login to a tmux session, created with the configured windows when it does not exist.
|
|
# /etc/profile.d is read by every login shell: the snippet itself acts only for an interactive one with a terminal and an SSH
|
|
# connection, so scp, sftp, `ssh host command` and automation never trigger it.
|
|
# sshd's ForceCommand is deliberately not used: it applies to every session type and a broken tmux would lock out all of them.
|
|
#
|
|
# Installed when autostart is on and the resolved package list holds tmux (the ubuntu_lxc and ubuntu_vm profiles); the inputs are
|
|
# checked in validate.yml. Security: the session name, window names and commands are role inputs (inventory), never read from a user
|
|
# or a fact. They are validated and shell-quoted in the template. The script is root-owned and not writable by the users it runs for.
|
|
# It is world-readable and the commands show in `ps`, so a command must hold no secret. Commands run as the user who logs in.
|
|
- name: Install the tmux auto-start snippet
|
|
ansible.builtin.template:
|
|
src: tmux-autostart.sh.j2
|
|
dest: /etc/profile.d/tmux-autostart.sh
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
validate: /bin/sh -n %s
|
|
when: system_baseline_tmux_autostart | bool and 'tmux' in system_baseline_essential_packages
|
|
become: true
|
|
|
|
- name: Remove the tmux auto-start snippet
|
|
ansible.builtin.file:
|
|
path: /etc/profile.d/tmux-autostart.sh
|
|
state: absent
|
|
when: not (system_baseline_tmux_autostart | bool and 'tmux' in system_baseline_essential_packages)
|
|
become: true
|