---
- name: install tftp server package
  package: state=present name=tftp-server
  tags:
  - packages
  - tftp_server

- name: install syslinux package
  package: state=present name=syslinux
  tags:
  - packages
  - tftp_server

- name: setup pxelinux.cfg dir
  file: path=/var/lib/tftpboot/pxelinux.cfg mode=755 state=directory
  tags:
  - config
  - tftp_server

- name: setup pxelinux.cfg default file
  copy: src=default.{{ inventory_hostname }} dest=/var/lib/tftpboot/pxelinux.cfg/default mode=644
  tags:
  - config
  - tftp_server

- name: setup highbank default file
  copy: src=highbank.{{ inventory_hostname }} dest=/var/lib/tftpboot/pxelinux.cfg/default-arm-highbank mode=644
  tags:
  - config
  - tftp_server

- name: enable tftp socket service
  service: state=started enabled=true name=tftp.socket
  tags:
  - service
  - config
  - tftp_server

- name: fill up the tftpboot directory
  synchronize: src="{{ bigfiles }}/tftpboot/" dest=/var/lib/tftpboot/
  tags:
  - tftp_server

- name: generate custom configs
  template: src=grubhost.cfg.j2 dest="/var/lib/tftpboot/uefi/{{ hostvars[item].install_mac }}"
  with_items: "{{ groups['all'] }}"
  when: "hostvars[item].install_noc == inventory_hostname"
  tags:
  - tftp_server
