---
- name: Common configuration
  hosts: gridengine_master:gridengine_clients
  vars_files:
    - vars/os
  tasks:
    - include: common/tasks/ssh_host_based_authentication.yml hosts={{groups.all}}
    - include: cluster/tasks/packages.yml
    - include: common/tasks/iptables.yml trusted_hosts={{groups.all}}
  handlers:
    - include: common/handlers/main.yml

- name: GridEngine masternode Playbook
  hosts: gridengine_master
  vars_files:
    - vars/os
  tasks: 
    - include: common/tasks/nfs.yml
    - include: gridengine/tasks/master.yml
    - nfsexport: path=/home dest=/etc/exports clients="{{groups.gridengine_clients}}" options=rw,no_root_squash,sync
      notify: 
        - ensure nfs service is running
        - reload exports
  handlers:
    - include: common/handlers/main.yml
    - include: slurm/handlers/main.yml
    - include: gridengine/handlers/main.yml

- name: GridEngine worker nodes Playbook
  hosts: gridengine_clients
  vars_files:
    - vars/os
  tasks: 
    - include: common/tasks/nfs-clients.yml nfsserver={{groups.gridengine_master[0]}} nfspath=/home nfsmount=/home
    - include: common/tasks/nfs-clients.yml nfsserver={{groups.gridengine_master[0]}} nfspath=/usr/share/gridengine/default/common nfsmount=/usr/share/gridengine/default/common
      when: is_centos
    - include: gridengine/tasks/clients.yml
  handlers:
    - include: common/handlers/main.yml
    - include: gridengine/handlers/main.yml

