openstack-ansible-ops/pxelinux-provisioning/playbooks/deploy-dhcp.yml
Kevin Carter 743b939640 Add basic provisioning using pxelinux
The basic provisioning tools we had in the MNAIO could long be used on a
set of physical machines however doing so required a healthy
understanding of everything going on under the hood. This change
extracts the PXE components out of our older MNAIO tooling and
will allow operators to easily deploy operating systems on machines in
the most compatible way possible.

Change-Id: I2188f0f0de7f8be331a35b5f22cf5114ea9b6718
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2018-05-01 15:42:04 +00:00

73 lines
2.4 KiB
YAML

---
# 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: Deploy DHCP
hosts: dhcp_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 all required packages for dhcpd_install
package:
pkg: "{{ item }}"
state: "latest"
update_cache: yes
cache_valid_time: 600
with_items: "{{ default_dhcp_distro_packages }}"
- name: Enable services
systemd:
name: "{{ item }}"
enabled: yes
with_items: "{{ default_dhcp_distro_packages }}"
tasks:
- name: Create a template in /etc/dhcp/dhcpd.conf
template:
src: templates/dhcp/dhcpd.conf.j2
dest: /etc/dhcp/dhcpd.conf
mode: 0644
owner: root
group: root
notify: restart dhcpd
- name: Create a template in /etc/dhcp/dhcpd.conf
template:
src: templates/dhcp/isc-dhcp-server.j2
dest: /etc/default/isc-dhcp-server
mode: 0644
owner: root
group: root
notify: restart dhcpd
environment: "{{ deployment_environment_variables | default({}) }}"
handlers:
- name: restart dhcpd
systemd:
name: "{{ item }}"
state: restarted
with_items: "{{ default_dhcp_distro_packages }}"
tags:
- deploy-dhcpd