---
- hosts: all 
  vars_files:
    - massive_var/main.yml
  vars:
    x509_ca_server: "{{ groups['ManagementNodes'][0] }}"
    openvpn_servers: "{{ groups['ManagementNodes'] }}"
    slurmctrl: "{{ groups['ManagementNodes'][0] }}"
    slurmqueues:
      - {name: batch, group: ComputeNodes, default: true}
  roles:
    - { role: etcHosts,  domain: "{{ ldapDomain }}" }

- hosts: 'ManagementNodes'
  vars_files:
    - massive_var/main.yml
    - massive_var/package.yml
    - massive_var/passwords.yml
  vars:
    x509_ca_server: "{{ groups['ManagementNodes'][0] }}"
    openvpn_servers: "{{ groups['ManagementNodes'] }}"
    slurmctrl: "{{ groups['ManagementNodes'][0] }}"
    slurmqueues:
      - {name: batch, group: ComputeNodes, default: true}
      - {name: dev, group: ComputeNodesDev, default: false}
      - {name: multicore, group: ComputeNodesLarge, default: false}
    mkFileSystems:
        - {fstype : 'ext4', dev: '/dev/vdc1', opts: ''}
        - {fstype : 'ext4', dev: '/dev/vdc2', opts: ''}
        - {fstype : 'ext4', dev: '/dev/vdc3', opts: ''}
    mountFileSystems:
        - {fstype : 'ext4', dev: '/dev/vdc1', opts: 'defaults,nofail', name: '/cvl/scratch'}
        - {fstype : 'ext4', dev: '/dev/vdc2', opts: 'defaults,nofail', name: '/cvl/home'}
        - {fstype : 'ext4', dev: '/dev/vdc3', opts: 'defaults,nofail', name: '/cvl/local'}
  roles:
    - { role: easy-rsa-CA }
    - { role: OpenVPN-Server }
    - { role: ntp }
    - { role: openLdapClient }
    - { role: slurm-build }
    - { role: nfs-server, configDiskDevice: true }
    - { role: slurm, slurm_use_vpn: true}
    - { role: installPackage, yumGroupPackageList: ['CVL Pre-installation', 'CVL Base Packages'], cliCopy: {'run': 'cp -r /usr/local/Modules/modulefiles/cvl /usr/local/Modules/modulefiles/massive', 'check': '/usr/local/Modules/modulefiles/massive'} }

- hosts: all 
  vars_files:
    - massive_var/main.yml
  vars:
    x509_ca_server: "{{ groups['ManagementNodes'][0] }}"
    openvpn_servers: "{{ groups['ManagementNodes'] }}"
  roles:
    - { role: etcHosts, domain: "{{ ldapDomain }}" }

- hosts: 'ComputeNodes*'
  vars_files:
    - massive_var/main.yml
    - massive_var/passwords.yml
    - massive_var/package.yml
  vars:
    x509_ca_server: "{{ groups['ManagementNodes'][0] }}"
    openvpn_servers: "{{ groups['ManagementNodes'] }}"
  roles:
    - { role: OpenVPN-Client }

- hosts: 'LoginNodes'
  vars_files:
    - massive_var/main.yml
    - massive_var/passwords.yml
    - massive_var/package.yml
  vars:
    x509_ca_server: "{{ groups['ManagementNodes'][0] }}"
    openvpn_servers: "{{ groups['ManagementNodes'] }}"
  roles:
    - { role: OpenVPN-Client }

- hosts: all 
  vars_files:
    - massive_var/main.yml
    - massive_var/passwords.yml
    - massive_var/package.yml
  vars:
    x509_ca_server: "{{ groups['ManagementNodes'][0] }}"
    nfs_server: "{{ groups['ManagementNodes'][0] }}"
    openvpn_servers: "{{ groups['ManagementNodes'] }}"
    groupList:
      - { name : 'ComputeNodes', interface : 'tun0' }
      - { name : 'ComputeNodesDev', interface : 'tun0' }
      - { name : 'ComputeNodesLarge', interface : 'tun0' }
      - { name : 'LoginNodes', interface : 'tun0' }
    exportList:
      - { name: '/usr/local', src: '/cvl/local', fstype: 'nfs4', opts: 'defaults,ro,nofail', interface : 'tun0', srvopts: 'ro,sync' }
      - { name: '/home', src: '/cvl/home', fstype: 'nfs4', opts: 'defaults,nofail', interface : 'tun0', srvopts: 'rw,root_squash,sync' }
      - { name: '/scratch', src: '/cvl/scratch', fstype: 'nfs4', opts: 'defaults,nofail', interface : 'tun0', srvopts: 'rw,root_squash,sync' }
  roles:
    - { role: etcHosts, domain: "{{ ldapDomain }}" }
    - { role: syncExports }

- hosts: 'ComputeNodes'
  vars_files:
    - massive_var/main.yml
    - massive_var/passwords.yml
    - massive_var/package.yml
  vars:
    x509_ca_server: "{{ groups['ManagementNodes'][0] }}"
    openvpn_servers: "{{ groups['ManagementNodes'] }}"
    slurmctrl: "{{ groups['ManagementNodes'][0] }}"
    slurmqueues:
      - {name: batch, group: ComputeNodes, default: true}
    nfs_server: "{{ groups['ManagementNodes'][0] }}"
    groupList:
      - { name : 'ComputeNodes', interface : 'tun0' }
    exportList: 
      - { name: '/usr/local', src: '/cvl/local', fstype: 'nfs4', opts: 'defaults,ro,nofail', interface : 'tun0', srvopts: 'ro,sync' } 
      - { name: '/home', src: '/cvl/home', fstype: 'nfs4', opts: 'defaults,nofail', interface : 'tun0', srvopts: 'rw,root_squash,sync' } 
      - { name: '/scratch', src: '/cvl/scratch', fstype: 'nfs4', opts: 'defaults,nofail', interface : 'tun0', srvopts: 'rw,root_squash,sync' }
  roles:
    - { role: ntp }
    - { role: openLdapClient }
    - { role: nfs-client }
    - { role: slurm, slurm_use_vpn: true}
    - { role: installPackage, preInstallation: "umount /usr/local", postInstallation: "mount /usr/local", yumGroupPackageList: ["CVL Pre-installation", "CVL Base Packages"], cliFileCopy: {'src': '/tmp/gconf_path', 'dest': '/etc/gconf/2/path'} }

- hosts: 'ComputeNodesDev'
  vars_files:
    - massive_var/main.yml
    - massive_var/passwords.yml
    - massive_var/package.yml
  vars:
    x509_ca_server: "{{ groups['ManagementNodes'][0] }}"
    openvpn_servers: "{{ groups['ManagementNodes'] }}"
    slurmctrl: "{{ groups['ManagementNodes'][0] }}"
    slurmqueues:
      - {name: dev, group: ComputeNodesDev, default: false}
    nfs_server: "{{ groups['ManagementNodes'][0] }}"
    groupList:
      - { name : 'ComputeNodes', interface : 'tun0' }
    exportList: 
      - { name: '/home', src: '/cvl/home', fstype: 'nfs4', opts: 'defaults,nofail', interface : 'tun0', srvopts: 'rw,root_squash,sync' } 
      - { name: '/scratch', src: '/cvl/scratch', fstype: 'nfs4', opts: 'defaults,nofail', interface : 'tun0', srvopts: 'rw,root_squash,sync' }
  roles:
    - { role: ntp }
    - { role: openLdapClient }
    - { role: nfs-client }
    - { role: slurm, slurm_use_vpn: true}
    - { role: installPackage, preInstallation: "umount /usr/local", postInstallation: "mount /usr/local", yumGroupPackageList: ["CVL Pre-installation", "CVL Base Packages"], cliFileCopy: {'src': '/tmp/gconf_path', 'dest': '/etc/gconf/2/path'} }

- hosts: 'ComputeNodesLarge'
  vars_files:
    - massive_var/main.yml
    - massive_var/passwords.yml
    - massive_var/package.yml
  vars:
    x509_ca_server: "{{ groups['ManagementNodes'][0] }}"
    openvpn_servers: "{{ groups['ManagementNodes'] }}"
    slurmctrl: "{{ groups['ManagementNodes'][0] }}"
    slurmqueues:
      - {name: multicore, group: ComputeNodesLarge, default: false}
    nfs_server: "{{ groups['ManagementNodes'][0] }}"
    groupList:
      - { name : 'ComputeNodes', interface : 'tun0' }
    exportList: 
      - { name: '/usr/local', src: '/cvl/local', fstype: 'nfs4', opts: 'defaults,ro,nofail', interface : 'tun0', srvopts: 'ro,sync' }
      - { name: '/home', src: '/cvl/home', fstype: 'nfs4', opts: 'defaults,nofail', interface : 'tun0', srvopts: 'rw,root_squash,sync' } 
      - { name: '/scratch', src: '/cvl/scratch', fstype: 'nfs4', opts: 'defaults,nofail', interface : 'tun0', srvopts: 'rw,root_squash,sync' }
  roles:
    - { role: ntp }
    - { role: openLdapClient }
    - { role: nfs-client }
    - { role: slurm, slurm_use_vpn: true}
    - { role: installPackage, preInstallation: "umount /usr/local", postInstallation: "mount /usr/local", yumGroupPackageList: ["CVL Pre-installation", "CVL Base Packages"], cliFileCopy: {'src': '/tmp/gconf_path', 'dest': '/etc/gconf/2/path'} }

- hosts: 'LoginNodes'
  vars_files:
    - massive_var/main.yml
    - massive_var/passwords.yml
  vars:
    groupList:
      - { name : 'ComputeNodes', interface : 'tun0' }
    x509_ca_server: "{{ groups['ManagementNodes'][0] }}"
    openvpn_servers: "{{ groups['ManagementNodes'] }}"
    slurmctrl: "{{ groups['ManagementNodes'][0] }}"
    slurmqueues:
      - {name: batch, group: ComputeNodes, default: true}
    exportList: 
      - { name: '/home', src: '/cvl/home', fstype: 'nfs4', opts: 'defaults,nofail', interface : 'tun0', srvopts: 'rw,root_squash,sync' } 
  roles:
    - { role: ntp }
    - { role: openLdapClient }
    - { role: nfs-client }
    - { role: slurm, slurm_use_vpn: true}
    - { role: installPackage, importRepo: { command: "wget http://cvlrepo.massive.org.au/repo/cvl.repo -O", destination: "/etc/yum.repos.d/cvl.repo" }, yumGroupPackageList: ['CVL Pre-installation', 'CVL Base Packages'], cliCopy: {'run': 'cp -r /usr/local/Modules/modulefiles/cvl /usr/local/Modules/modulefiles/massive', 'check': '/usr/local/Modules/modulefiles/massive'} }

