--- - name: Install zsh apt: name: zsh state: present - name: Set zsh as the default shell shell: chsh -s $(which zsh) {{ ansible_user }} become: true when: ansible_user != "root" register: chsh_result failed_when: chsh_result.rc != 0 changed_when: false