Adds in DHCPD role - Ubuntu 16.04
Building on from the previous commit https://review.openstack.org/427869 this adds in DHCPD role to provide DHCP to the virtual machines which are booting up and point them towards our TFTP server. Change-Id: I73649562096a659dee7227b0cfb84f2c4a4f5ec4
This commit is contained in:
parent
e0381502e3
commit
088d941d22
23
multi-node-aio-xenial-ansible/roles/dhcpd_install/README.md
Normal file
23
multi-node-aio-xenial-ansible/roles/dhcpd_install/README.md
Normal file
@ -0,0 +1,23 @@
|
||||
dhcpd_install
|
||||
=========
|
||||
|
||||
This module installs dhcpd
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
This module requires Ansible 2.x
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
See defaults for variables and descriptions
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
Example to call:
|
||||
|
||||
- hosts: all
|
||||
roles:
|
||||
- { role: dhcpd_install }
|
@ -0,0 +1,45 @@
|
||||
---
|
||||
# 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: dhcpd_install/defaults
|
||||
# description: ALL our default variables for dhcpd_install go in here
|
||||
#------------------------------------------------------------------------------
|
||||
# Packages - All our required packages we need installing
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# - pre-requisites -
|
||||
packages: # Packages required for dhcpd
|
||||
- isc-dhcp-server
|
||||
|
||||
# - general variables -
|
||||
dhcp_default_lease_time: 21600 # Default lease time
|
||||
dhcp_max_lease_time: 43200 # Max lease time
|
||||
tftp_server: 10.0.2.100 # The server hosting the TFTP server
|
||||
tftp_boot_path: /pxelinux.0 # Path of where to boot from first
|
||||
|
||||
# - List of DHCP Subnets - These are iterated though and each will be created
|
||||
dhcp_list:
|
||||
- netmask: 255.255.255.0 # Netmask
|
||||
gateway: 10.0.2.1 # Gateway
|
||||
dns: 8.8.8.8 # DNS
|
||||
subnet: 10.0.2.0 # Subnet mask
|
||||
default_lease_time: 21600 # Subnet Default lease time - The default is used if this is not defined
|
||||
max_lease_time: 43200 # Subnet Max lease time - The default is used if this is not defined
|
||||
tftp_boot_path: /pxelinux.0 # Path for tftp of where to boot from first - The default is used if this is not defined
|
||||
tftp_server: 10.0.2.100 # The server hosting the TFTP server - The default is used if this is not defined
|
||||
|
||||
# - List of static DHCP hosts - These are iterated though and each will be created
|
||||
server_list:
|
||||
- name: host # Server hostname
|
||||
hwaddr: "aa:aa:aa:aa:aa:aa" # Server MAC
|
||||
ip: "10.0.2.2" # Server IP
|
@ -0,0 +1,21 @@
|
||||
---
|
||||
# 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: dhcpd_install/handlers
|
||||
# description: All our handlers for dhcpd_install go in here
|
||||
|
||||
- name: restart dhcpd
|
||||
service:
|
||||
name: "{{ item }}"
|
||||
state: restarted
|
||||
with_items: "{{ packages }}"
|
@ -0,0 +1,22 @@
|
||||
---
|
||||
# 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.
|
||||
#
|
||||
galaxy_info:
|
||||
author: "Rick Box - BBC R&D"
|
||||
license: Apache2
|
||||
min_ansible_version: 2.0
|
||||
platforms:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- xenial
|
||||
dependencies: []
|
@ -0,0 +1,24 @@
|
||||
---
|
||||
# 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.
|
||||
#
|
||||
# module: dhcpd_install/tasks/configure
|
||||
# description: Configure dhcpd_install
|
||||
|
||||
- name: Create a template in /etc/dhcp/dhcpd.conf
|
||||
template:
|
||||
src: dhcpd.conf.j2
|
||||
dest: /etc/dhcp/dhcpd.conf
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
notify: restart dhcpd
|
@ -0,0 +1,26 @@
|
||||
---
|
||||
# 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.
|
||||
#
|
||||
# module: dhcpd_install/tasks/install
|
||||
# description: Install our required packages for dhcpd_install
|
||||
|
||||
- name: Install all required packages for dhcpd_install
|
||||
apt:
|
||||
pkg: "{{ packages }}"
|
||||
state: latest
|
||||
|
||||
- name: Make sure -{{ packages }}- are enabled
|
||||
service:
|
||||
name: "{{ item }}"
|
||||
enabled: yes
|
||||
with_items: "{{ packages }}"
|
@ -0,0 +1,18 @@
|
||||
---
|
||||
# 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.
|
||||
#
|
||||
# module: dhcpd_install/tasks
|
||||
# description: Install dhcpd_install onto an Ubuntu 16.xx server
|
||||
|
||||
- include: install.yml
|
||||
- include: configure.yml
|
@ -0,0 +1,53 @@
|
||||
#jinja2: lstrip_blocks: True
|
||||
### MANAGED BY {{ role_path|basename }} ANSIBLE ROLE ###
|
||||
|
||||
ddns-update-style none;
|
||||
|
||||
allow booting;
|
||||
allow bootp;
|
||||
|
||||
log-facility local7;
|
||||
authoritative;
|
||||
|
||||
shared-network all-networks {
|
||||
{% for dhcp in dhcp_list %}
|
||||
subnet {{ dhcp.subnet }} netmask {{ dhcp.netmask }} {
|
||||
option routers {{ dhcp.gateway }};
|
||||
option domain-name-servers {{ dhcp.dns }};
|
||||
option subnet-mask {{ dhcp.netmask }};
|
||||
{% if dhcp.default_lease_time is defined and dhcp.default_lease_time > 0 %}
|
||||
default-lease-time {{ dhcp.default_lease_time }};
|
||||
{% else %}
|
||||
default-lease-time {{ dhcp_default_lease_time }};
|
||||
{% endif %}
|
||||
{% if dhcp.max_lease_time is defined and dhcp.max_lease_time > 0 %}
|
||||
max-lease-time {{ dhcp.max_lease_time }};
|
||||
{% else %}
|
||||
max-lease-time {{ dhcp_max_lease_time }};
|
||||
{% endif %}
|
||||
{% if dhcp.tftp_server is defined and dhcp.tftp_server|ipaddr %}
|
||||
next-server {{ dhcp.tftp_server }};
|
||||
{% elif tftp_server is defined and tftp_server|length > 0 %}
|
||||
next-server {{ tftp_server }};
|
||||
{% endif %}
|
||||
{% if dhcp.tftp_boot_path is defined and dhcp.tftp_boot_path|ipaddr %}
|
||||
filename "{{ dhcp.tftp_boot_path }}";
|
||||
{% elif tftp_boot_path is defined and tftp_boot_path|length > 0 %}
|
||||
filename "{{ tftp_boot_path }}";
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% if server_list.0.name != "blank" %}
|
||||
group {
|
||||
{% for host in server_list %}
|
||||
host {{ host.name }} {
|
||||
hardware ethernet {{ host.hwaddr }};
|
||||
fixed-address {{ host.ip }};
|
||||
option host-name "{{ host.name }}";
|
||||
}
|
||||
{% endfor %}
|
||||
}
|
||||
{% endif %}
|
||||
}
|
Loading…
Reference in New Issue
Block a user