---

- name: create node data dir
  become: yes
  file:
    path: "{{item}}"
    state: "directory"
    owner: "{{node_user}}"
    group: "{{node_user}}"
    mode: "0770"
  with_items:
    - "{{node_data_dir}}"
    - "{{node_log_dir}}"
    - "{{node_conf_dir}}"

- name: install conf
  become: yes
  template:
    src: "{{node_conf_template}}"
    dest: "{{node_conf_dir}}/{{node_type}}.conf"
    owner: "{{node_user}}"
    group: "{{node_user}}"
    mode: "0644"
  notify: restart node

- name: install node service
  become: yes
  template:
    src: "{{node_service_template}}"
    dest: "/lib/systemd/system/{{node_type}}.service"
    mode: "0644"
  notify: restart node

- name: ensure node is started
  become: yes
  systemd: service="{{node_type}}.service" enabled="yes" state="started" daemon_reload="yes"
