gantsign / ansible-role-oh-my-zsh

Ansible role for installing and configuring oh-my-zsh
https://galaxy.ansible.com/gantsign/oh-my-zsh
MIT License
165 stars 41 forks source link

Add option to skip default .zshrc file creation #160

Closed DavidGL17 closed 1 year ago

DavidGL17 commented 1 year ago

Hi,

I've been using your role and have had no issue, but I have a possible upgrade that could be made :

A boolean could be added to skip the default .zshrc file creation on install. Currently, when i rerun the playbook I have that uses this role this task is always marked as changed because I put my own custom .zshrc file later, and it would be nice if this small change could be added.

Kind regards,

David

YacineSahli commented 1 year ago

Hi, u should move ur custom config in the ./oh-my-zsh/custom/ folder.

mircsicz commented 1 year ago

Can u please be specific about the path of that folder?

I've been looking in roles/gantsign.oh-my-zsh but can't find it there...

Maybe you're expecting it to be created in that path? Or is it safe to edit roles/gantsign.oh-my-zsh/templates/zshrc.j2?

EDIT: OK I got it: The Path is: ~/.oh-my-zsh/custom/ and there's already an example.zsh

I use this task to copy a template to the Dir:

    - name: Copy Templates for {{remoteuser}}
      ansible.builtin.template:
        src: "{{ item.src }}"
        dest: "{{ item.dst }}"
        owner: "{{ remoteuser }}"
        group: "{{ remoteuser }}"
      with_items:
        - { src: '{{ tmpldir }}zshcustoms.j2', dst: '{{homepath}}{{remoteuser}}/.oh-my-zsh/custom/zshcustoms.zsh' }
Virtlink commented 1 year ago

To add to this, in my case, I am using stow to save my .dotfiles in a Git repository, and unstow them using Ansible. But if I run this role before unstowing, unstowing fails because this role wrote to .zshrc. Alternatively, if I unstow first and then run this rule, it moves my symlinked .zshrc to a different name, which is also incorrect.

The role does not seem to be idempotent, and it would be great if generating .zshrc could be skipped.

freemanjp commented 1 year ago

@DavidGL17 thanks for raising this issue, a flag to control this behavior has been added in version 2.7.0 of this role.

DavidGL17 commented 1 year ago

Thank you very much for your work, sorry for not giving any answers after my question i was a bit occupied these last few weeks ^^