---

- name: Create needed directories
  file: path={{ nomad_root_dir }}/{{ item.dir }} state=directory owner={{ item.owner | default(omit) }} group={{ item.group | default(omit) }} mode={{ item.mode | default(omit) }}
  loop:
    - dir: /
      owner: root
      group: root
      mode: 755
    - dir: backup
      owner: root
      group: root
      mode: 700
    - dir: meta
      owner: root
      group: root
      mode: 700
    - dir: bin
    - dir: tmp
      owner: "{{ nomad_user }}"
      group: "{{ nomad_user }}"
    - dir: data
      owner: "{{ nomad_user }}"
      group: "{{ nomad_user }}"
      mode: 700
    - dir: plugins
      owner: "{{ nomad_user }}"
      group: "{{ nomad_user }}"
    - dir: etc
      owner: root
      mode: 755
    - dir: docker
      owner: root
      mode: 755
    - dir: tls
  tags: nomad

- name: Create host_volume directories
  file: path={{ item.path }} state=directory owner={{ item.owner | default(omit) }} group={{ item.group | default(omit) }} mode={{ item.mode | default(omit) }}
  loop: "{{ nomad_conf.client.host_volumes | default([]) }}"
  when: item.create | default(False)
  tags: nomad

