---

# First we need hostname -f to return the correct domain

- hosts: '*'
  roles:
  - {role: etcHosts, domain: 'test.massive.org.au' }

# Create an x509 CA. Certificates are used for the VPN, the ldap server and the web server (karaage)

- hosts: ManagmentNodes[0]
  vars:
  roles:
  - { role: easy-rsa-CA }

- hosts: 'ManagmentNodes'
  vars:
    x509_ca_server: "{{ groups['ManagmentNodes'][0] }}"
    ldapDomain: "dc=test,dc=massive,dc=org,dc=au"
  roles:
  - { role: OpenVPN-Server }
  - { role: ldapserver }

- hosts: 'karaage'
  vars:
    x509_ca_server: "{{ groups['ManagmentNodes'][0] }}"
    smtp_smarthost: "does_not_exist.massive.org.au"
    ldapDomain: "dc=test,dc=massive,dc=org,dc=au"
    ldapURL: "ldaps://{{ hostvars[groups['ManagmentNodes'][0]]['ansible_fqdn'] }}"
  roles:
  - { role: karaage2.7 }

# The next two tasks, apply the VPN and recalcuate /etc/hosts. Comment them if you are on a secure network

- hosts: ComputeNodes
  vars:
    x509_ca_server: "{{ groups['ManagmentNodes'][0] }}"
    openvpn_servers: "{{ groups['ManagmentNodes'] }}"
  roles:
    - { role: OpenVPN-Client }

- hosts: '*'
  roles:
  - {role: etcHosts, domain: 'test.massive.org.au' }

# These tasks build some software (slurm, munge and openmpi) and copy them back to localhost. Skip if you have some other way of getting 
# copyies of these software

- hosts: ComputeNodes[0]
  vars:
    slurm_version: 14.11.0
    munge_version: 0.5.11
  roles:
    - { role: slurm-build }

# Slurm and openmpi tasks assume copies of the software in /tmp under a very specific directory strucutre (created by the build tasks above) Modifiy 
# the roles if you have a different way of installing the software

- hosts: ComputeNodes:ManagmentNodes:LoginNodes
  vars:
    slurm_version: 14.11.0
    munge_version: 0.5.11
    slurmqueues: 
      - {name: batch, group: ComputeNodes}
    slurmctrl: "{{ groups['ManagmentNodes'][0] }}"
  roles:
      - { role: slurm, slurm_use_vpn: true} # change to false if you are on a secure network
      - { role: test_user }

# These tasks build some software (slurm, munge and openmpi) and copy them back to localhost. Skip if you have some other way of getting 
# copyies of these software

- hosts: ComputeNodes[0]
  vars:
    openmpi_version: 1.8.3
  roles:
    - { role: openmpi-build }

# Slurm and openmpi tasks assume copies of the software in /tmp under a very specific directory strucutre (created by the build tasks above) Modifiy 
# the roles if you have a different way of installing the software

- hosts: ComputeNodes:ManagmentNodes:LoginNodes
  vars:
    openmpi_version: 1.8.3
  roles:
      - { role: openmpi }

