---
  - name: Create exemONE Agent Directory
    ansible.builtin.file:
      path: "{{ EXEM_HOME }}"
      state: directory
      mode: '0755'

  - name: Copy exemONE NDM-Agent File
#    ansible.posix.synchronize:
    ansible.builtin.copy:
      src: "{{ role_path }}/files/ndm"
      dest: "{{ EXEM_HOME }}"

  - name: Create Agent Script
    ansible.builtin.template:
      src: "{{ item }}.j2"
      dest: "{{ EXEM_HOME }}/ndm/bin/{{ item }}"
      mode: '0740'
    with_items: 
      - ndm-ctl
      - ndm-svc
      - reg.env
      - start
      - stop

  - name: Create Agent Conf
    ansible.builtin.template:
      src: "{{ item }}.j2"
      dest: "{{ EXEM_HOME }}/ndm/conf/{{ item }}"
      mode: '0755'
    with_items: 
      - ndm.conf

  - name: chmod change
    ansible.builtin.shell: "chmod -R 740 {{ EXEM_HOME }}/ndm"

  - name: exem-ndm-agent start
    ansible.builtin.shell: "nohup {{ EXEM_HOME }}/ndm/bin/start"