---
- action: deployment_facts

- name: create shared directories
  file:
    path: "{{ item }}"
    state: "directory"
    owner: "{{ user }}"
    group: "{{ user }}"
    mode: "0755"
  with_items:
    - "{{ default_directories }}"
    - "{{ directories }}"

- name: create configuration files from templates
  template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    owner: "{{ item.user | default(user) }}"
    group: "{{ item.group | default(user) }}"
    mode: "{{ item.mode | default(0600) }}"
  with_items:
    - "{{ templates }}"

- name: create or update the bare Git repository
  git:
    repo: "{{ repo }}"
    dest: "{{ deploy_to }}/scm"
    version: "{{ branch }}"
    bare: yes
    update: yes
    accept_hostkey: yes

- shell: chdir="{{ deploy_to }}/scm" git archive {{ branch }} | tar -x -C {{ build_path }}

- file:
    path: "{{ build_path }}"
    mode: 0755

- file:
    path: "{{ build_path }}"
    owner: "{{ user }}"
    group: "{{ user }}"
    recurse: yes

- name: symlink shared files to build directory
  file:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    state: link
    force: yes
  with_items:
    - "{{ default_symlinks }}"
    - "{{ symlinks }}"
  when: item is defined

---
- action: deployment_facts

- name: create shared directories
  file:
    path: "{{ item }}"
    state: "directory"
    owner: "{{ user }}"
    group: "{{ group | default(user) }}"
    mode: "0755"
  with_items:
    - "{{ default_directories }}"
    - "{{ directories }}"

- name: create configuration files from templates
  template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    owner: "{{ item.user | default(user) }}"
    group: "{{ item.group | default(user) }}"
    mode: "{{ item.mode | default(0600) }}"
  with_items:
    - "{{ templates }}"

- name: create or update the bare Git repository
  git:
    repo: "{{ repo }}"
    dest: "{{ deploy_to }}/scm"
    version: "{{ branch }}"
    bare: yes
    update: yes
    accept_hostkey: yes

- shell: chdir="{{ deploy_to }}/scm" git archive {{ branch }} | tar -x -C {{ build_path }}

- file:
    path: "{{ build_path }}"
    mode: 0755

- file:
    path: "{{ build_path }}"
    owner: "{{ user }}"
    group: "{{ group | default(user) }}"
    recurse: yes

- name: symlink shared files to build directory
  file:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    state: link
    force: yes
  with_items:
    - "{{ default_symlinks }}"
    - "{{ symlinks }}"
  when: item is defined

Add group variable for directories
Add group variable for directories
