--- - name: 'Install git' become: true package: name: 'git' state: 'present' - name: 'Remove domain level dir' file: path: '{{ sites_data_root }}/{{ item.name }}/html' state: 'absent' when: 'item.git_url is defined' loop: '{{ websites }}' - name: 'Create domain level dir' file: path: '{{ sites_data_root }}/{{ item.name }}/html' state: 'directory' mode: '0755' loop: '{{ websites }}' - name: 'Clone all the website project repos' git: repo: '{{ item.git_url }}' dest: '/home/{{ ansible_user }}/{{ item.name }}' depth: 1 update: true force: true version: '{{ item.git_version }}' umask: '002' when: 'item.git_url is defined' loop: '{{ websites }}' - name: 'Move all the html bases to data root' copy: src: '/home/{{ ansible_user }}/{{ item.name }}/{{ item.html_root }}/' dest: '{{ sites_data_root }}/{{ item.name }}/html/' remote_src: true when: 'item.git_url is defined' loop: '{{ websites }}' - name: 'Remove git checkout' file: path: '/home/{{ ansible_user }}/{{ item.name }}' state: 'absent' when: 'item.git_url is defined' loop: '{{ websites }}'