f00c6bf215
Adds support for iPXE scripting. Allows for the operator to specify a remote iPXE kernel to pull in newer iPXE kernel features and specify a remote default iPXE script for customizing the multi node for other types of deployments. Switches the installations to use netboot installer kernels instead of ISO retrival and extraction. Restructures directory to allow for future multi node configs instead of just debian based installs. Change-Id: Ie97f021dbd33ad3d852132b0b2850f54d4e13476
232 lines
6.9 KiB
YAML
232 lines
6.9 KiB
YAML
---
|
|
# Copyright 2017, Rackspace US, Inc.
|
|
#
|
|
# 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 witing, 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: Gather facts
|
|
hosts: pxe_hosts
|
|
gather_facts: "{{ gather_facts | default(true) }}"
|
|
pre_tasks:
|
|
- name: Gather variables for each operating system
|
|
include_vars: "{{ item }}"
|
|
with_first_found:
|
|
- "{{ playbook_dir }}/vars/{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
|
|
- "{{ playbook_dir }}/vars/{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
|
- "{{ playbook_dir }}/vars/{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
|
- "{{ playbook_dir }}/vars/{{ ansible_distribution | lower }}.yml"
|
|
- "{{ playbook_dir }}/vars/{{ ansible_os_family | lower }}.yml"
|
|
tags:
|
|
- always
|
|
|
|
- name: Install host distro packages
|
|
package:
|
|
pkg: "{{ item }}"
|
|
state: "latest"
|
|
update_cache: yes
|
|
cache_valid_time: 600
|
|
with_items: "{{ mnaio_pxe_distro_packages }}"
|
|
|
|
- name: Create base directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "root"
|
|
group: "root"
|
|
mode: "0755"
|
|
with_items:
|
|
- /var/www/pxe
|
|
- /var/www/pxe/configs
|
|
- /var/www/pxe/images
|
|
- /var/www/pxe/networking
|
|
- /var/www/pxe/scripts
|
|
- /var/www/pxe/templates
|
|
- /var/lib/tftpboot
|
|
- /var/lib/tftpboot/ipxe
|
|
|
|
- name: Get root public key
|
|
command: cat /root/.ssh/id_rsa.pub
|
|
register: public_key_get
|
|
changed_when: false
|
|
when:
|
|
- tftp_ssh_key is undefined
|
|
|
|
- name: Set key facts
|
|
set_fact:
|
|
tftp_ssh_key: "{{ public_key_get.stdout }}"
|
|
when:
|
|
- tftp_ssh_key is undefined
|
|
|
|
tasks:
|
|
- name: Drop NGINX config
|
|
copy:
|
|
src: "pxe/sites-enabled.default"
|
|
dest: /etc/nginx/sites-enabled/default
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
notify:
|
|
- restart nginx
|
|
|
|
- name: Drop tftp-hpa configs
|
|
template:
|
|
src: "pxe/tftp/tftp-hpa"
|
|
dest: /etc/default/tftpd-hpa
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
notify:
|
|
- restart tftp-hpa
|
|
|
|
- name: Download iPXE
|
|
get_url:
|
|
url: "{{ ipxe_kernel_url }}"
|
|
dest: "/var/lib/tftpboot/ipxe.lkrn"
|
|
tmp_dest: /tmp/
|
|
|
|
- name: Drop ipxe default menu
|
|
template:
|
|
src: "pxe/tftp/boot.ipxe.j2"
|
|
dest: "/var/lib/tftpboot/boot.ipxe"
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
|
|
- name: network scripts for pxe
|
|
template:
|
|
src: "pxe/configs/{{ ansible_os_family | lower }}/{{ item.src }}"
|
|
dest: /var/www/pxe/{{ item.dir }}/{{ item.dest }}
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
with_items:
|
|
- src: basic-interface.cfg
|
|
dest: "basic-{{ ansible_os_family | lower }}-interface.cfg"
|
|
dir: networking
|
|
- src: vm-post-install-script.sh.j2
|
|
dest: "vm-post-install-{{ ansible_os_family | lower }}-script.sh"
|
|
dir: scripts
|
|
- src: general-post-install-script.sh.j2
|
|
dest: "general-post-install-{{ ansible_os_family | lower }}-script.sh"
|
|
dir: scripts
|
|
|
|
- name: network scripts for an MNAIO
|
|
template:
|
|
src: "pxe/configs/{{ ansible_os_family | lower }}/{{ item.src }}"
|
|
dest: /var/www/pxe/{{ item.dir }}/{{ item.dest }}
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
when:
|
|
- groups['mnaio_hosts'] | default([]) | length > 0
|
|
with_items:
|
|
- src: mnaio-bridges.cfg.j2
|
|
dest: mnaio-bridges.cfg
|
|
dir: networking
|
|
- src: mnaio-post-install-script.sh.j2
|
|
dest: mnaio-post-install-{{ ansible_os_family | lower }}-script.sh
|
|
dir: scripts
|
|
|
|
- name: network scripts for servers
|
|
template:
|
|
src: "pxe/configs/{{ ansible_os_family | lower }}/vm-bridges.cfg.j2"
|
|
dest: /var/www/pxe/networking/{{ hostvars[item]['server_hostname'] }}-bridges.cfg
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
with_items: "{{ groups['pxe_servers'] }}"
|
|
|
|
- name: tftp configs for servers
|
|
template:
|
|
src: "pxe/tftp/boot.ipxe.macaddr.j2"
|
|
dest: "/var/lib/tftpboot/ipxe/{{ hostvars[item]['server_mac_address'] | replace(':', '-') | lower }}"
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
with_items: "{{ groups['pxe_servers'] }}"
|
|
|
|
- name: Preseeds for pxe mnaio
|
|
template:
|
|
src: "pxe/configs/{{ ansible_os_family | lower }}/mnaio.config.j2"
|
|
dest: /var/www/pxe/configs/mnaio.config
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
with_dict: "{{ images }}"
|
|
|
|
- name: Preseeds for pxe vm
|
|
template:
|
|
src: "pxe/configs/{{ ansible_os_family | lower }}/vm.config.j2"
|
|
dest: /var/www/pxe/configs/vm.config
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
with_dict: "{{ images }}"
|
|
|
|
- name: Preseeds for pxe vm-compute
|
|
template:
|
|
src: "pxe/configs/{{ ansible_os_family | lower }}/vm-compute.config.j2"
|
|
dest: /var/www/pxe/configs/vm-compute.config
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
with_dict: "{{ images }}"
|
|
|
|
- name: Preseeds for pxe compute
|
|
template:
|
|
src: "pxe/configs/{{ ansible_os_family | lower }}/compute.config.j2"
|
|
dest: /var/www/pxe/configs/compute.config
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
with_dict: "{{ images }}"
|
|
|
|
- name: Preseeds for pxe infra
|
|
template:
|
|
src: "pxe/configs/{{ ansible_os_family | lower }}/infra.config.j2"
|
|
dest: /var/www/pxe/configs/infra.config
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
with_dict: "{{ images }}"
|
|
|
|
- name: Ensure permissions are correct
|
|
shell: |
|
|
# Fix perms if needed
|
|
find /var/lib/tftpboot -type d -exec chmod 0755 {} \;
|
|
find /var/lib/tftpboot -type f -exec chmod 0644 {} \;
|
|
find /var/www/pxe -type d -exec chmod 0755 {} \;
|
|
|
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
|
|
handlers:
|
|
- name: restart nginx
|
|
service:
|
|
name: "nginx"
|
|
state: restarted
|
|
enabled: yes
|
|
|
|
- name: restart tftp-hpa
|
|
service:
|
|
name: "tftpd-hpa"
|
|
state: restarted
|
|
enabled: yes
|
|
|
|
- name: restart inetd
|
|
service:
|
|
name: "inetutils-inetd"
|
|
state: restarted
|
|
enabled: yes
|
|
|
|
tags:
|
|
- deploy-pxe
|