# Need to check because we don't want to overwrite user content
# with symlinks in the name of idempotence :D
- name: webserver-multisite-check
  stat:
    path: "/home/{{ user.name }}/public/html"
    # In case it's a symlink to elsewhere
    follow: yes
  register: publichtml

- name: webserver-multisite-folder
  file:
    path: "/home/{{ user.name }}/public/html"
    state: directory
    owner: "{{ user.name }}"
    group: "{{ user.name }}"
    mode: 0755
  when: not publichtml.stat.exists

- name: webserver-multisite-symlink
  file:
    path: "/home/{{ user.name }}/public/html/{{ item }}"
    src: "/home/{{ user.name }}/public_html"
    state: link
    owner: "{{ user.name }}"
    group: "{{ user.name }}"
    mode: 0755
  loop:
    - onion
    - domain
    - tilde
  when: not publichtml.stat.exists
