Skip to content

User defined config file

Patrick edited this page May 9, 2024 · 1 revision

Distribute a custom .zshrc file for a list of users.

  • Install the zsh package.
  • Set zsh as default shell for the specified users.
  • Distribute a custom .zshrc for each user.

main.yml file in your project folder:

- name: zsh
  hosts: all
  vars:
    zsh_config_backup: false
    zsh_config_overwrite: true

    zsh_users:
      - lorem
      - ipsum

    zsh_users_config:
      - template: "zshrc.j2"
        filename: ".zshrc"

  roles:
    - bec.shell.zsh
  tasks:
    - ansible.builtin.debug:
        msg: "ZSH was installed and a custom file was distributed."

zshrc.j2 file in your templates folder:

{% if zsh_config_overwrite is true %}
#
# {{ ansible_managed }}
#
{% endif %}

# Add your content here.
Clone this wiki locally