---
- name: Common configuration
  hosts: gridengine_master:gridengine_clients
  vars_files:
    - vars/os
  tasks:
    - include: common/tasks/hosts.yml hosts=${groups.all}
    - include: common/tasks/hostname.yml
    - 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: gridengine/tasks/master.yml
    - include: slurm/tasks/nfs.yml
    - action: nfsexport path=/home dest=/etc/exports clients=${groups.gridengine_clients} options=rw,no_root_squash,sync
      notify: reload exports
  handlers:
    - 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
      only_if: $is_centos
    - include: gridengine/tasks/clients.yml
  handlers:
    - include: gridengine/handlers/main.yml

