diff --git a/ansible/roles/ironic/tasks/bootstrap.yml b/ansible/roles/ironic/tasks/bootstrap.yml index d33859fae1..7217c4f29c 100644 --- a/ansible/roles/ironic/tasks/bootstrap.yml +++ b/ansible/roles/ironic/tasks/bootstrap.yml @@ -52,3 +52,20 @@ run_once: True delegate_to: "{{ groups['ironic-api'][0] }}" when: database_created + +- name: Running Ironic-PXE bootstrap container + kolla_docker: + action: "start_container" + common_options: "{{ docker_common_options }}" + detach: False + environment: + KOLLA_BOOTSTRAP: + KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" + image: "{{ ironic_pxe_image_full }}" + name: "bootstrap_ironic_pxe" + restart_policy: "never" + volumes: + - "{{ node_config_directory }}/ironic-pxe/:{{ container_config_directory }}/:ro" + - "ironic-pxe:/tftpboot/" + run_once: True + delegate_to: "{{ groups['ironic-pxe'][0] }}" diff --git a/docker/ironic/ironic-pxe/Dockerfile.j2 b/docker/ironic/ironic-pxe/Dockerfile.j2 index da2adbe5e5..bda9a9bdd7 100644 --- a/docker/ironic/ironic-pxe/Dockerfile.j2 +++ b/docker/ironic/ironic-pxe/Dockerfile.j2 @@ -6,9 +6,7 @@ MAINTAINER {{ maintainer }} RUN yum -y install \ tftp-server \ syslinux-tftpboot \ - && yum clean all \ - && mkdir -p /tftpboot \ - && cp /var/lib/tftpboot/chain.c32 /tftpboot + && yum clean all {% elif base_distro in ['ubuntu', 'debian'] %} @@ -16,13 +14,12 @@ RUN apt-get install -y --no-install-recommends \ tftpd-hpa \ syslinux-common \ syslinux \ - && apt-get clean \ - && mkdir -p /tftpboot \ - && chown -R ironic: /tftpboot \ - && cp /usr/lib/syslinux/pxelinux.0 /usr/lib/syslinux/chain.c32 /tftpboot + && apt-get clean {% endif %} COPY tftp-map-file /map-file +COPY extend_start.sh /usr/local/bin/kolla_extend_start +RUN chmod 755 /usr/local/bin/kolla_extend_start {{ include_footer }} diff --git a/docker/ironic/ironic-pxe/extend_start.sh b/docker/ironic/ironic-pxe/extend_start.sh new file mode 100644 index 0000000000..0f5fcd679b --- /dev/null +++ b/docker/ironic/ironic-pxe/extend_start.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases +# of the KOLLA_BOOTSTRAP variable being set, including empty. +if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then + chown -R ironic: /tftpboot + for pxe_file in /var/lib/tftpboot/chain.c32 /usr/lib/syslinux/pxelinux.0 /usr/lib/syslinux/chain.c32; do + if [[ -e "$pxe_file" ]]; then + cp "$pxe_file" /tftpboot + fi + done + exit 0 +fi +