Zsh
The zsh shell role, counterpart to bash. You don't list it in a playbook directly — unix includes it when the host's login shell is zsh (unix_shell == zsh, the default on macOS), as the last step of the os -> unix -> shell chain.
What it does
- Initializes zsh's completion system (
compinit) via a~/.profile.d/zsh.shfragment
unix already creates the ~/.profile.d/ framework and wires it into the zsh login files (~/.zprofile and ~/.zshrc), so this role only adds what is specific to zsh.
Shells and completions
The framework's aliases and functions are POSIX, so they run identically under bash and zsh. The one shell-specific output is completions: the shared generator reads the bare shell variable, and on a zsh host it registers the same completions through zsh's bashcompinit compatibility layer instead of emitting plain bash complete -F directives (see bash). Those registrations are guarded on compdef existing — which is what this role's compinit fragment provides.
Selecting the shell
unix_shell resolves from the bare, host-level shell variable, defaulting from the OS (zsh on macOS, bash elsewhere). Set shell: zsh in host_vars to run zsh on a non-macOS host:
# host_vars/linux-box.yaml
shell: zsh