generate_disks.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. ---
  2. - name: Adds python packages if python is not present
  3. raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-yaml)
  4. - name: Gathering facts
  5. setup:
  6. - name: Gather variables for each operating system
  7. include_vars: "{{ item }}"
  8. with_first_found:
  9. - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
  10. - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
  11. - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
  12. - "{{ ansible_distribution | lower }}.yml"
  13. - "{{ ansible_os_family | lower }}.yml"
  14. - name: Install required packages
  15. package:
  16. name: "{{ item }}"
  17. state: latest
  18. with_items: "{{ netbootxyz_packages }}"
  19. - name: Check out latest iPXE sources
  20. git:
  21. repo: "{{ ipxe_repo }}"
  22. dest: /usr/src/ipxe
  23. version: "{{ ipxe_branch }}"
  24. - name: Check out latest netboot.xyz sources
  25. git:
  26. repo: "{{ netbootxyz_repo }}"
  27. dest: /usr/src/netboot.xyz
  28. version: "{{ netbootxyz_branch }}"
  29. - name: Copy iPXE Bootloader template to iPXE source directory
  30. template:
  31. src: disks/ipxe-bootloader.j2
  32. dest: /usr/src/ipxe/src/ipxe-bootloader
  33. - name: Copy netboot.xyz colour.h iPXE config
  34. file:
  35. src: /usr/src/netboot.xyz/ipxe/local/colour.h
  36. dest: /usr/src/ipxe/src/config/local/colour.h
  37. state: link
  38. - name: Copy netboot.xyz general.h iPXE config
  39. file:
  40. src: /usr/src/netboot.xyz/ipxe/local/general.h
  41. dest: /usr/src/ipxe/src/config/local/general.h
  42. state: link
  43. - name: Touch iPXE config local files
  44. file:
  45. path: "{{ item }}"
  46. state: touch
  47. with_items:
  48. - /usr/src/ipxe/src/config/local/console.h
  49. - /usr/src/ipxe/src/config/local/umalloc.h
  50. - /usr/src/ipxe/src/config/local/nap.h
  51. - /usr/src/ipxe/src/config/local/timer.h
  52. - /usr/src/ipxe/src/config/local/branding.h
  53. - /usr/src/ipxe/src/config/local/serial.h
  54. - /usr/src/ipxe/src/config/local/reboot.h
  55. - /usr/src/ipxe/src/config/local/sanboot.h
  56. - /usr/src/ipxe/src/config/local/fault.h
  57. - /usr/src/ipxe/src/config/local/dhcp.h
  58. - /usr/src/ipxe/src/config/local/sideband.h
  59. - /usr/src/ipxe/src/config/local/entropy.h
  60. - /usr/src/ipxe/src/config/local/crypto.h
  61. - /usr/src/ipxe/src/config/local/usb.h
  62. - /usr/src/ipxe/src/config/local/settings.h
  63. - name: Create iPXE file directory
  64. file:
  65. path: /var/www/html/ipxe
  66. state: directory
  67. - name: Compile iPXE bootloader for Legacy BIOS
  68. shell: "{{ item }}"
  69. with_items:
  70. - make EMBED=ipxe-bootloader bin/ipxe.dsk bin/ipxe.iso bin/ipxe.lkrn bin/ipxe.usb bin/ipxe.kpxe bin/undionly.kpxe
  71. args:
  72. chdir: /usr/src/ipxe/src
  73. - name: Copy iPXE files for Legacy BIOS to http directory
  74. copy:
  75. src: /usr/src/ipxe/src/bin/{{ item }}
  76. dest: /var/www/html/ipxe/{{ boot_domain }}-{{ item }}
  77. remote_src: True
  78. with_items:
  79. - ipxe.dsk
  80. - ipxe.iso
  81. - ipxe.lkrn
  82. - ipxe.usb
  83. - ipxe.kpxe
  84. - undionly.kpxe
  85. - name: Copy netboot.xyz general.h.efi iPXE config
  86. file:
  87. src: /usr/src/netboot.xyz/ipxe/local/general.h.efi
  88. dest: /usr/src/ipxe/src/config/local/general.h
  89. state: link
  90. - name: Compile iPXE bootloader for EFI
  91. shell: "{{ item }}"
  92. with_items:
  93. - make clean
  94. - make EMBED=ipxe-bootloader bin-x86_64-efi/ipxe.efi
  95. args:
  96. chdir: /usr/src/ipxe/src
  97. - name: Generate iPXE EFI ISO Disk
  98. shell: "{{ item }}"
  99. with_items:
  100. - mkdir -p efi_tmp/EFI/BOOT/
  101. - cp bin-x86_64-efi/ipxe.efi efi_tmp/EFI/BOOT/bootx64.efi
  102. - genisoimage -o ipxe-efi.iso efi_tmp
  103. args:
  104. chdir: /usr/src/ipxe/src
  105. - name: Copy iPXE EFI builds to http directory
  106. copy:
  107. src: "{{ ipxe_source_dir }}/src/{{ item.src }}"
  108. dest: "{{ netbootxyz_root }}/ipxe/{{ item.dest }}"
  109. remote_src: True
  110. with_items:
  111. - { src: "bin-x86_64-efi/ipxe.efi", dest: "{{ boot_domain }}-ipxe.efi" }
  112. - { src: "ipxe-efi.iso", dest: "{{ boot_domain }}-ipxe-efi.iso" }