---
- name: Common configuration
  hosts: pbs_master:pbs_clients:maui_master
  vars_files:
    - vars/os
  tasks:
    - include: common/tasks/gc3repo.yml
    - 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: common/tasks/iptables.yml trusted_hosts=${groups.all}
  handlers:
    - include: common/handlers/main.yml

- name: PBS masternode Playbook
  hosts: pbs_master
  vars_files:
    - vars/os
  tasks: 
    - include: slurm/tasks/nfs.yml
    - action: nfsexport path=/home dest=/etc/exports clients=${groups.pbs_clients} options=rw,no_root_squash,sync
      notify: reload exports

    - include: pbs+maui/tasks/master.yml
    - include: cluster/tasks/packages.yml
  handlers:
    - include: slurm/handlers/main.yml
    - include: common/handlers/main.yml
    - include: pbs+maui/handlers/main.yml

- name: MAUI masternode Playbook
  hosts: maui_master
  vars_files:
    - vars/os
  tasks: 
    - include: pbs+maui/tasks/maui.yml
  handlers:
    - include: pbs+maui/handlers/main.yml

- name: PBS worker nodes Playbook
  hosts: pbs_clients
  vars_files:
    - vars/os
  tasks: 
    - include: common/tasks/nfs-clients.yml nfsserver=${groups.pbs_master[0]} nfspath=/home nfsmount=/home nfsoptions=rw,sync,nfsvers=3
    - include: pbs+maui/tasks/clients.yml
    - include: cluster/tasks/packages.yml
  handlers:
    - include: pbs+maui/handlers/main.yml

