diff --git a/tasks/main.yml b/tasks/main.yml index 3ae0d4b..009d52c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -20,18 +20,20 @@ user: name: "{{ item.key }}" shell: /bin/zsh - with_dict: "{{ __users__ | default({}) }}" - when: > + loop: "{{ __users__ | default({}) | dict2items }}" + when: >- (ansible_os_family == 'RedHat' or ansible_os_family == 'Debian') and - (item.value.has_key('zsh_default_shell') and item.value.zsh_default_shell) + ("zsh_default_shell" in item.value and item.value.zsh_default_shell) -- name: Generate ~.zshrc. +- name: Generate ~/.zshrc. template: mode: 0644 src: zshrc.j2 owner: "{{ item.key }}" dest: "~{{ item.key }}/.zshrc" - with_dict: "{{ __users__ | default({}) }}" + loop: "{{ __users__ | default({}) | dict2items }}" + # loop_control: + # loop_var: user_shell - name: Check for .zfunctions directory. file: @@ -39,7 +41,7 @@ mode: 0755 owner: "{{ item.key }}" dest: "~{{ item.key }}/.zfunctions" - with_dict: "{{ __users__ | default({}) }}" + loop: "{{ __users__ | default({}) | dict2items }}" - name: Upload zfunctions files copy: @@ -49,9 +51,9 @@ directory_mode: yes force: yes mode: 0755 - with_dict: "{{ __users__ | default({}) }}" - when: > - item.value.has_key('zsh_zfunctions_directory') + loop: "{{ __users__ | default({}) | dict2items }}" + when: >- + "zsh_zfunctions_directory" in item.value - name: Download zsh prompt file. get_url: @@ -60,8 +62,9 @@ url: "{{ item.value.zsh_prompt_download_url | default(zsh_default_prompt_download_url) }}" checksum: "{{ item.value.zsh_prompt_download_md5 | default(zsh_default_prompt_download_md5) }}" dest: "~{{ item.key }}/.zfunctions/prompt_{{ item.value.zsh_prompt_name | default(zsh_default_prompt_name) }}_setup" - with_dict: "{{ __users__ | default({}) }}" - when: item.value.has_key('zsh_prompt_install') and item.value.zsh_prompt_install + loop: "{{ __users__ | default({}) | dict2items }}" + when: >- + "zsh_prompt_install" in item.value and item.value.zsh_prompt_install - name: Download zsh prompt additional file. get_url: @@ -70,10 +73,10 @@ url: "{{ item.value.zsh_prompt_additional_url }}" checksum: "{{ item.value.zsh_prompt_additional_md5 | default(omit) }}" dest: "~{{ item.key }}/.zfunctions/{{ zsh_prompt_additional_url | basename | replace('.zsh', '') }}" - with_dict: "{{ __users__ | default({}) }}" - when: > - item.value.has_key('zsh_prompt_install') and item.value.zsh_prompt_install and - item.value.has_key('zsh_prompt_additional_url') and item.value.zsh_prompt_additional_url + loop: "{{ __users__ | default({}) | dict2items }}" + when: >- + "zsh_prompt_install" in item.value and item.value.zsh_prompt_install and + "zsh_prompt_additional_url" in item.value and item.value.zsh_prompt_additional_url - name: Download zsh additional file if install default prompt. get_url: @@ -82,7 +85,7 @@ url: "{{ zsh_default_prompt_additional_url }}" checksum: "{{ zsh_default_prompt_additional_md5 | default(omit) }}" dest: "~{{ item.key }}/.zfunctions/{{ zsh_default_prompt_additional_url | basename | replace('.zsh', '') }}" - with_dict: "{{ __users__ | default({}) }}" - when: > - item.value.has_key('zsh_prompt_install') and item.value.zsh_prompt_install and not - item.value.has_key('zsh_prompt_name') + loop: "{{ __users__ | default({}) | dict2items }}" + when: >- + "zsh_prompt_install" in item.value and item.value.zsh_prompt_install and not + "zsh_prompt_name" in item.value