- name: Fetch dotfiles git: repo: "{{ dots_repo }}" dest: "/srv/dots/" register: dotfiles - name: Create list of users to configure set_fact: users: - "{{ ansible_user }}" - "{{ username }}" - name: Remove existing dotfiles file: path: "/home/{{ item }}/.bashrc" state: absent with_items: "{{ users }}" when: dotfiles.changed - name: Copy dotfiles copy: remote_src: yes src: /srv/dots/ dest: "/home/{{ item }}/dots/" owner: "{{ item }}" group: "{{ item }}" with_items: "{{ users }}" when: dotfiles.changed - name: Deploy dotfiles on login template: src: templates/.bash_profile.j2 dest: "/home/{{ item }}/.bash_profile" owner: "{{ item }}" group: "{{ item }}" force: yes with_items: "{{ users }}" when: dotfiles.changed