tftp: start on boot & fix tftp paths

This fixes the tftp service name on CentOS and makes sure that
the service is running on boot.  It also makes sure that the
tftp_root is setup correctly for the default configuration
on CentOS.

Change-Id: I56944ea905b5ea908cf1e93d5ae1325e68788562
This commit is contained in:
Mohammed Naser 2019-07-31 16:39:23 -04:00 committed by Jean-Philippe Evrard
parent 5d74ab936a
commit 0a2092a087
9 changed files with 59 additions and 18 deletions

View File

@ -1,4 +0,0 @@
re ^(/tftpboot/) /tftpboot/\2
re ^/tftpboot/ /tftpboot/
re ^(^/) /tftpboot/\1
re ^([^/]) /tftpboot/\1

View File

@ -23,10 +23,22 @@
listen:
- "venv changed"
- name: Restart tftpd-hpa
- name: Restart tftpd socket
service:
name: "tftpd-hpa"
name: "{{ ironic_tftpd_service_name }}.socket"
state: restarted
enabled: yes
daemon_reload: yes
failed_when: false
when:
- "ansible_pkg_mgr in ['zypper']"
- name: Restart tftpd
service:
name: "{{ ironic_tftpd_service_name }}"
state: restarted
enabled: yes
daemon_reload: yes
failed_when: false
- name: Restart isc-dhcp-server

View File

@ -21,9 +21,9 @@
notify:
- Restart isc-dhcp-server
- name: Create /tftpboot
- name: Create tftpboot path
file:
path: "/tftpboot"
path: "{{ ironic_tftpd_root }}"
state: directory
owner: "{{ ironic_system_user_name }}"
group: "{{ ironic_system_group_name }}"
@ -33,19 +33,37 @@
template:
src: "tftpd-hpa.j2"
dest: "/etc/default/tftpd-hpa"
when:
- ansible_os_family == 'Debian'
notify:
- Restart tftpd-hpa
- Restart tftpd
- name: Copy in tftpd-hpa map file
copy:
- name: Copy in tftpd map file
template:
src: "map-file"
dest: "/tftpboot/map-file"
dest: "{{ ironic_tftpd_root }}/map-file"
notify:
- Restart tftpd-hpa
- Restart tftpd
- name: Copy library modules into /tftpboot
- name: Copy library modules into tftpboot
copy:
src: "{{ item }}"
dest: "/tftpboot/"
dest: "{{ ironic_tftpd_root }}/"
remote_src: True
with_items: "{{ ironic_library_modules_paths }}"
# Add 'yum' in condition if tftp socket required to be started for centos.
- name: Start up tftp socket
when:
- "ansible_pkg_mgr in ['zypper']"
systemd:
daemon_reload: yes
name: "{{ ironic_tftpd_service_name }}.socket"
state: started
enabled: true
- name: Start up tftp
service:
name: "{{ ironic_tftpd_service_name }}"
state: started
enabled: true

View File

@ -176,6 +176,8 @@ pool_max_size = {{ ironic_wsgi_processes }}
[pxe]
tftp_server = {{ ironic_tftp_server_address }}
pxe_append_params = {{ ironic_pxe_append_params }}
tftp_root = {{ ironic_tftpd_root }}
tftp_master_path = {{ ironic_tftpd_root }}/master_images
[seamicro]

4
templates/map-file Normal file
View File

@ -0,0 +1,4 @@
re ^({{ ironic_tftpd_root }}/) {{ ironic_tftpd_root }}/\2
re ^{{ ironic_tftpd_root }}/ {{ ironic_tftpd_root }}/
re ^(^/) {{ ironic_tftpd_root }}/\1
re ^([^/]) {{ ironic_tftpd_root }}/\1

View File

@ -1,4 +1,4 @@
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"
TFTP_DIRECTORY="{{ ironic_tftpd_root }}"
TFTP_ADDRESS="{{ ironic_tftp_server_address }}:69"
TFTP_OPTIONS="-vvvv --map-file /tftpboot/map-file"
TFTP_OPTIONS="-vvvv --map-file {{ ironic_tftpd_root }}/map-file"

View File

@ -44,3 +44,6 @@ ironic_library_modules_paths:
- "/usr/lib/PXELINUX/pxelinux.0"
- "/usr/lib/syslinux/modules/efi64/chain.c32"
- "/usr/lib/syslinux/modules/bios/ldlinux.c32"
ironic_tftpd_service_name: tftpd-hpa
ironic_tftpd_root: /tftpboot

View File

@ -43,4 +43,7 @@ ironic_conductor_standalone_distro_packages:
ironic_library_modules_paths:
- "/usr/share/syslinux/pxelinux.0"
- "/usr/share/syslinux/chain.c32"
- "/usr/share/syslinux/linux.c32"
- "/usr/share/syslinux/linux.c32"
ironic_tftpd_service_name: tftp
ironic_tftpd_root: /var/lib/tftpboot

View File

@ -43,3 +43,6 @@ ironic_library_modules_paths:
- "/usr/share/syslinux/pxelinux.0"
- "/usr/share/syslinux/chain.c32"
- "/usr/share/syslinux/linux.c32"
ironic_tftpd_service_name: tftp
ironic_tftpd_root: /srv/tftpboot