- name: Create root directory for websites
  file:
    path: "{{ www_root }}"
    state: directory
- name: Create root directory for each website
  file:
    path: "{{ www_root }}/{{ item.domain }}"
    state: directory
  with_items: "{{ www_sites }}"
- name: Create public directory for each website
  file:
    path: "{{ www_root }}/{{ item.domain }}/public"
    state: directory
  with_items: "{{ www_sites }}"
- name: Create log directory for each website and give caddy write permissions
  file:
    path: "{{ www_root }}/{{ item.domain }}/logs"
    state: directory
    owner: caddy
    group: caddy
    mode: '0755'
  with_items: "{{ www_sites }}"