init commit
This commit is contained in:
164
tasks/config_pxe.yaml
Normal file
164
tasks/config_pxe.yaml
Normal file
@ -0,0 +1,164 @@
|
||||
---
|
||||
|
||||
|
||||
###############################################
|
||||
# Install packages needed for PXE
|
||||
###############################################
|
||||
- name: APT - Install Packages
|
||||
apt:
|
||||
name:
|
||||
- "{{ item }}"
|
||||
state: present
|
||||
loop: "{{ pxe_packages }}"
|
||||
when: not refresh_only | bool
|
||||
|
||||
###############################################
|
||||
# DHCP Server
|
||||
###############################################
|
||||
# Stop DHCP server
|
||||
- name: DHCP - Stop DHCP
|
||||
service:
|
||||
name: isc-dhcp-server
|
||||
state: stopped
|
||||
enabled: yes
|
||||
|
||||
# Copy DHCP config file 1
|
||||
- name: DHCP - Copy dhcpd.conf
|
||||
template:
|
||||
src: dhcpd.conf.j2
|
||||
dest: /etc/dhcp/dhcpd.conf
|
||||
mode: 0644
|
||||
|
||||
# Copy DHCP config file 2
|
||||
- name: DHCP - Copy isc-dhcp-server
|
||||
template:
|
||||
src: isc-dhcp-server.j2
|
||||
dest: /etc/default/isc-dhcp-server
|
||||
mode: 0644
|
||||
|
||||
# Start DHCP server
|
||||
- name: DHCP - Start DHCP
|
||||
service:
|
||||
name: isc-dhcp-server
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
# Download vendor list for dhcp-lease-list
|
||||
- name: DHCP - Download vendor list for dhcp-lease-list
|
||||
get_url:
|
||||
url: "http://standards-oui.ieee.org/oui.txt"
|
||||
dest: /usr/local/etc/oui.txt
|
||||
mode: '0644'
|
||||
|
||||
###############################################
|
||||
# TFTP Server
|
||||
###############################################
|
||||
|
||||
# Stop TFTP Server
|
||||
- name: TFTP - Stop TFTP
|
||||
service:
|
||||
name: tftpd-hpa
|
||||
state: stopped
|
||||
enabled: yes
|
||||
|
||||
# Create TFTP server folder structure
|
||||
- name: TFTP - Create tftp directory
|
||||
file:
|
||||
path: /srv/tftp
|
||||
state: directory
|
||||
mode: '0755'
|
||||
owner: tftp
|
||||
group: tftp
|
||||
|
||||
# Copy TFTP Config File
|
||||
- name: TFTP - Copy tftpd-hpa
|
||||
template:
|
||||
src: tftpd-hpa.j2
|
||||
dest: /etc/default/tftpd-hpa
|
||||
mode: 0644
|
||||
|
||||
# Start TFTP Server
|
||||
- name: TFTP - Start TFTP
|
||||
service:
|
||||
name: tftpd-hpa
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
###############################################
|
||||
# Copy necessary files
|
||||
###############################################
|
||||
|
||||
# Create destination folder for all the next stuff
|
||||
- name: Files - Create debian-installer directory
|
||||
file:
|
||||
path: /var/www/html/debian-installer/amd64
|
||||
state: directory
|
||||
mode: '0755'
|
||||
owner: www-data
|
||||
group: www-data
|
||||
|
||||
## Old comments:
|
||||
## Extract trixie debian netboot files
|
||||
## These are from the syslinux-common package
|
||||
## Some of the files from the trixie netboot archive
|
||||
## are needed for this voodoo to all work
|
||||
## This is one of the two files called in the grub bootloader
|
||||
## This is the other file called in the grub bootloader
|
||||
## Changing from bookworm to trixie, bookworm curl command:
|
||||
## curl -L https://deb.debian.org/debian/dists/bookworm/main/installer-amd64/current/images/netboot/netboot.tar.gz | \
|
||||
- name: Files - copy static files
|
||||
shell: |
|
||||
curl -L https://deb.debian.org/debian/dists/trixie/main/installer-amd64/current/images/netboot/netboot.tar.gz | \
|
||||
tar xz -C /var/www/html/debian-installer/amd64
|
||||
cp /usr/lib/syslinux/modules/bios/* /srv/tftp/
|
||||
cp -R /var/www/html/debian-installer/amd64/debian-installer /srv/tftp/
|
||||
cp /var/www/html/debian-installer/amd64/debian-installer/amd64/linux /srv/tftp/debian-installer/amd64/linux
|
||||
cp /var/www/html/debian-installer/amd64/debian-installer/amd64/initrd.gz /srv/tftp/debian-installer/amd64/initrd.gz
|
||||
register: static_files_output
|
||||
|
||||
# Oh Hai grub bootloader, I was just talking about you
|
||||
- name: Files - copy the grub
|
||||
block:
|
||||
- name: Files - Copy grub.cfg to tftp
|
||||
when: not deploy_iso | bool
|
||||
template:
|
||||
src: grub.cfg.j2
|
||||
dest: /srv/tftp/debian-installer/amd64/grub/grub.cfg
|
||||
mode: 0644
|
||||
|
||||
- name: Files - Copy grub-iso.cfg to tftp
|
||||
when: deploy_iso | bool
|
||||
template:
|
||||
src: grub-iso.cfg.j2
|
||||
dest: /srv/tftp/debian-installer/amd64/grub/grub.cfg
|
||||
mode: 0644
|
||||
|
||||
# This is the preseed file for unattended server installation
|
||||
# It's served from HTTP now because bollocks to weird TFTP foolishness
|
||||
- name: Files - Copy server preseed to http
|
||||
template:
|
||||
src: preseed-server-v2.cfg.j2
|
||||
dest: /var/www/html/preseed-server.cfg
|
||||
mode: 0644
|
||||
|
||||
# Build Fresh Init Archive
|
||||
- name: Files - Cosmos Init
|
||||
ansible.builtin.archive:
|
||||
path: "/var/jenkins_home/ansible/roles/pxe_server/files/init"
|
||||
dest: "/var/jenkins_home/ansible/roles/pxe_server/files/cosmos-init.tar"
|
||||
format: "tar"
|
||||
delegate_to: localhost
|
||||
|
||||
# update archive_fresh
|
||||
- name: update archive_fresh
|
||||
set_fact:
|
||||
archive_fresh: true
|
||||
|
||||
# Copy Archive to Target
|
||||
- name: Files - Copy cosmos-init.tar to target
|
||||
copy:
|
||||
src: /var/jenkins_home/ansible/roles/pxe_server/files/cosmos-init.tar
|
||||
dest: /var/www/html/cosmos-init.tar
|
||||
mode: 0644
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user