---
  - name: Check if configuration exists already
    stat: path=/etc/re6stnet/re6stnet.conf
    register: re6stnet_conf

  - name: Configure Re6st with re6st-conf
    shell: "re6st-conf --registry {{ re6st_registry_url }} --token {{ re6sttoken }} -r title {{ computer_name }}  -d /etc/re6stnet"
    when: re6stnet_conf.stat.exists == False and "{{ re6sttoken }}" != "notoken" and "{{ computer_name }}" != "noname"

  - name: Check if configuration exists already
    stat: path=/etc/re6stnet/re6stnet.conf
    register: recheck_re6stnet_conf

  - name: stat re6stnet.service
    stat: path=/etc/systemd/re6stnet.service
    register: re6stnet
  
  - name: stat re6st-node.service
    stat: path=/etc/systemd/system/re6st-node.service
    register: re6stnode
  
  - name: set re6st-node.service file
    copy: src=/etc/systemd/re6stnet.service dest=/etc/systemd/system/re6st-node.service
    when: ansible_distribution == 'CentOS' and ansible_distribution_version >= '7' and re6stnet.stat.exists == True and re6stnode.stat.exists == False

  - name: Start re6st-node service
    service: name=re6st-node state=started enabled=yes
    when: recheck_re6stnet_conf.stat.exists == True