diff --git a/files/map-file b/files/map-file deleted file mode 100644 index 812abe0c..00000000 --- a/files/map-file +++ /dev/null @@ -1,4 +0,0 @@ -re ^(/tftpboot/) /tftpboot/\2 -re ^/tftpboot/ /tftpboot/ -re ^(^/) /tftpboot/\1 -re ^([^/]) /tftpboot/\1 diff --git a/handlers/main.yml b/handlers/main.yml index 57d35e13..cd6f2c0a 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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 diff --git a/tasks/ironic_conductor_post_install.yml b/tasks/ironic_conductor_post_install.yml index 74a23ef7..484d6756 100644 --- a/tasks/ironic_conductor_post_install.yml +++ b/tasks/ironic_conductor_post_install.yml @@ -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 \ No newline at end of file diff --git a/templates/ironic.conf.j2 b/templates/ironic.conf.j2 index 1f24b626..101bc3ae 100644 --- a/templates/ironic.conf.j2 +++ b/templates/ironic.conf.j2 @@ -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] diff --git a/templates/map-file b/templates/map-file new file mode 100644 index 00000000..91fdd713 --- /dev/null +++ b/templates/map-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 diff --git a/templates/tftpd-hpa.j2 b/templates/tftpd-hpa.j2 index b683ea35..cb22c1f2 100644 --- a/templates/tftpd-hpa.j2 +++ b/templates/tftpd-hpa.j2 @@ -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" diff --git a/vars/debian.yml b/vars/debian.yml index 9f01db2f..6760a79d 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -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 \ No newline at end of file diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index 9894ec7a..6168b963 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -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" \ No newline at end of file + - "/usr/share/syslinux/linux.c32" + +ironic_tftpd_service_name: tftp +ironic_tftpd_root: /var/lib/tftpboot \ No newline at end of file diff --git a/vars/suse.yml b/vars/suse.yml index 40d14266..301195de 100644 --- a/vars/suse.yml +++ b/vars/suse.yml @@ -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 \ No newline at end of file