From 2577caad017664dd9a3a7cf3692f4d914205c3ec Mon Sep 17 00:00:00 2001 From: stephane Date: Wed, 1 Jul 2015 11:37:46 -0700 Subject: [PATCH] Break install role into logical chunks The ironic-install role is getting a little unwieldy. Break out the /tftpboot setup and IPA CoreOS download into tasks to be included. Remove the Ubuntu download as it is not currently in use. Change-Id: I5043995e7f950aaea1b8ccfea362a89613efa31c --- .../ironic-install/tasks/create_tftpboot.yml | 46 ++++++++++++++++ .../tasks/download_ipa_coreos.yml | 29 ++++++++++ playbooks/roles/ironic-install/tasks/main.yml | 55 ++----------------- 3 files changed, 80 insertions(+), 50 deletions(-) create mode 100644 playbooks/roles/ironic-install/tasks/create_tftpboot.yml create mode 100644 playbooks/roles/ironic-install/tasks/download_ipa_coreos.yml diff --git a/playbooks/roles/ironic-install/tasks/create_tftpboot.yml b/playbooks/roles/ironic-install/tasks/create_tftpboot.yml new file mode 100644 index 000000000..f6da95a2e --- /dev/null +++ b/playbooks/roles/ironic-install/tasks/create_tftpboot.yml @@ -0,0 +1,46 @@ +# Copyright (c) 2015 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +--- +- name: "Setting up PXE and iPXE folders" + file: name={{item}} owner=ironic group=ironic state=directory + with_items: + - /tftpboot + - /tftpboot/pxelinux.cfg + - "{{ http_boot_folder }}" +- name: "Placing tftpd map-file" + copy: src=tftpboot-map-file dest=/tftpboot/map-file owner=ironic group=ironic +- name: "Disable service tftpd-hpa" + service: name=tftpd-hpa state=stopped enabled=no +# NOTE(cinerama) See https://bugs.launchpad.net/bifrost/+bug/1471973 +# with regard to the next two tasks. +- name: "Placing pxelinux.0 (pre-14.10)" + copy: src={{ syslinux_tftp_dir }}/pxelinux.0 dest=/tftpboot + when: ansible_distribution_version|version_compare('14.10', '<') +- name: "Placing pxelinux.0 (>=14.10)" + copy: src=/usr/lib/PXELINUX/pxelinux.0 dest=/tftpboot + when: ansible_distribution_version|version_compare('14.10', '>=') +- name: "Place boot.ipxe helper script to HTTP root" + copy: src=boot.ipxe dest=/httpboot/boot.ipxe +- name: "Place tftp config file" + copy: src=xinetd.tftp dest=/etc/xinetd.d/tftp +- name: "Copy iPXE image into place" + copy: src={{ ipxe_dir }}/undionly.kpxe dest=/tftpboot/ +# Similar logic to below can be utilized to retrieve files +- name: "Determine if folder exists, else create and populate folder." + stat: path=/tftpboot/master_images + register: test_master_images +- name: "Create master_images folder" + file: name=/tftpboot/master_images state=directory owner=ironic group=ironic + when: test_master_images.stat.exists == false diff --git a/playbooks/roles/ironic-install/tasks/download_ipa_coreos.yml b/playbooks/roles/ironic-install/tasks/download_ipa_coreos.yml new file mode 100644 index 000000000..1159f5a39 --- /dev/null +++ b/playbooks/roles/ironic-install/tasks/download_ipa_coreos.yml @@ -0,0 +1,29 @@ +# Copyright (c) 2015 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +--- +# This is overly complex, however get_url will always re-retrieve the file +# if it already exists, and this is to prevent that behavior. +- name: "Test if CoreOS kernel is present" + stat: path={{ http_boot_folder }}/coreos_production_pxe.vmlinuz + register: test_core_os_kernel_present +- name: "Download CoreOS kernel" + get_url: url={{ deploy_kernel_upstream_url }} dest={{ http_boot_folder }}/coreos_production_pxe.vmlinuz + when: test_core_os_kernel_present.stat.exists == false +- name: "Test if CoreOS image is present" + stat: path={{ http_boot_folder }}/coreos_production_pxe_image-oem.cpio.gz + register: test_core_os_image_present +- name: "Download CoreOS image" + get_url: url={{ deploy_ramdisk_upstream_url }} dest={{ http_boot_folder }}/coreos_production_pxe_image-oem.cpio.gz + when: test_core_os_image_present.stat.exists == false diff --git a/playbooks/roles/ironic-install/tasks/main.yml b/playbooks/roles/ironic-install/tasks/main.yml index a923825d5..9e2a93239 100644 --- a/playbooks/roles/ironic-install/tasks/main.yml +++ b/playbooks/roles/ironic-install/tasks/main.yml @@ -150,28 +150,8 @@ service: name=ironic-conductor state=restarted - name: "Start ironic-api" service: name=ironic-api state=restarted -- name: "Setting up PXE and iPXE folders" - file: name={{item}} owner=ironic group=ironic state=directory - with_items: - - /tftpboot - - /tftpboot/pxelinux.cfg - - "{{ http_boot_folder }}" -- name: "Placing tftpd map-file" - copy: src=tftpboot-map-file dest=/tftpboot/map-file owner=ironic group=ironic -- name: "Disable service tftpd-hpa" - service: name=tftpd-hpa state=stopped enabled=no -- name: "Placing pxelinux.0 (pre-14.10)" - copy: src={{ syslinux_tftp_dir }}/pxelinux.0 dest=/tftpboot - when: ansible_distribution_version|version_compare('14.10', '<') -- name: "Placing pxelinux.0 (>=14.10)" - copy: src=/usr/lib/PXELINUX/pxelinux.0 dest=/tftpboot - when: ansible_distribution_version|version_compare('14.10', '>=') -- name: "Place boot.ipxe helper script to HTTP root" - copy: src=boot.ipxe dest=/httpboot/boot.ipxe -- name: "Place tftp config file" - copy: src=xinetd.tftp dest=/etc/xinetd.d/tftp -- name: "Copy iPXE image into place" - copy: src={{ ipxe_dir }}/undionly.kpxe dest=/tftpboot/ +- name: "Create and populate /tftpboot" + include: create_tftpboot.yml - name: "Deploy dnsmasq configuration file" template: src=dnsmasq.conf.j2 dest=/etc/dnsmasq.conf when: "{{include_dhcp_server|bool}}" @@ -224,39 +204,14 @@ - name: "Sending services a force-reload signal" service: name=dnsmasq state=restarted when: "{{include_dhcp_server|bool}}" -# Similar logic to below can be utilized to retrieve files -- name: "Determine if folder exists, else create and populate folder." - stat: path=/tftpboot/master_images - register: test_master_images -- name: "Create master_images folder" - file: name=/tftpboot/master_images state=directory owner=ironic group=ironic - when: test_master_images.stat.exists == false -# This is overly complex, however get_url will always re-retrieve the file -# if it already exists, and this is to prevent that behavior. -- name: "Test if CoreOS kernel is present" - stat: path={{ http_boot_folder }}/coreos_production_pxe.vmlinuz - register: test_core_os_kernel_present -- name: "Download CoreOS kernel" - get_url: url={{ deploy_kernel_upstream_url }} dest={{ http_boot_folder }}/coreos_production_pxe.vmlinuz - when: test_core_os_kernel_present.stat.exists == false -- name: "Test if CoreOS image is present" - stat: path={{ http_boot_folder }}/coreos_production_pxe_image-oem.cpio.gz - register: test_core_os_image_present -- name: "Download CoreOS image" - get_url: url={{ deploy_ramdisk_upstream_url }} dest={{ http_boot_folder }}/coreos_production_pxe_image-oem.cpio.gz - when: test_core_os_image_present.stat.exists == false +- name: "Download Ironic Python Agent CoreOS kernel & image" + include: download_ipa_coreos.yml - name: "Download cirros to use for deployment if requested" get_url: url={{ cirros_deploy_image_upstream_url }} dest="{{ deploy_image }}" when: "{{use_cirros|bool}}" -- name: "Test if Ubuntu 14.04 server cloud amd64 is present" +- name: "Test if deploy image is present" stat: path={{ deploy_image }} register: test_os_image_present -- name: "Download Ubuntu image" - get_url: url={{ deploy_image_upstream_url }} dest=/httpboot/ubuntu-14.04-server-cloudimg-amd64.tar.gz - when: test_os_image_present.stat.exists == false and create_image_via_dib == false -- name: "Extract Ubuntu image" - unarchive: src=/httpboot/ubuntu-14.04-server-cloudimg-amd64.tar.gz dest=/httpboot/ creates=/httpboot/trusty-server-cloudimg-amd64.img - when: test_os_image_present.stat.exists == false and create_image_via_dib == false # Create bootable image takes a partition image, prepends space for a # bootloader, partition table, and then installs the bootloader. #