Add inventory_dns feature to bifrost

This will allow to configure addressing based on inventory

Change-Id: I71517146a197e39ed8ff2205e4234685d95331ad
This commit is contained in:
Yolanda Robla 2016-01-10 12:17:34 +01:00
parent 2a370dd08a
commit 5553ccab81
9 changed files with 48 additions and 7 deletions

View File

@ -66,3 +66,15 @@ You can set up a static DHCP reservation using the ``ipv4_address`` parameter
and setting the ``inventory_dhcp`` setting to a value of ``true``. This will and setting the ``inventory_dhcp`` setting to a value of ``true``. This will
result in the first MAC address defined in the list of hardware MAC addresses result in the first MAC address defined in the list of hardware MAC addresses
to receive a static address assignment in dnsmasq. to receive a static address assignment in dnsmasq.
======================================
Forcing DNS to resolve to ipv4_address
======================================
dnsmasq will resolve all entries to the IP assigned to each server in
the leases file. However, this IP will not always be the desired one, if you
are working with multiple networks.
To force DNS to always resolve to ``ipv4_address`` please set the
``inventory_dns`` setting to a value of ``true``. This will result in each
server to resolve to ``ipv4_address`` by explicitly using address capabilities
of dnsmasq.

View File

@ -56,7 +56,6 @@ instance_info: A dictionary containing the information to define an instance.
expected are image_source, image_checksum, root_gb, however, expected are image_source, image_checksum, root_gb, however,
any supported key/value can be submitted to the API. any supported key/value can be submitted to the API.
inventory_dhcp: A boolean value, defaulted to false, which allows dnsmasq inventory_dhcp: A boolean value, defaulted to false, which allows dnsmasq
to configure the IP of the machines, rather than putting to configure the IP of the machines, rather than putting
the IP configuration of the machine in the config drive. the IP configuration of the machine in the config drive.
@ -85,6 +84,12 @@ noauth_mode: Controls if the module is called in noauth mode.
which expects a clouds.yml file. More information about which expects a clouds.yml file. More information about
this file format can be found at: this file format can be found at:
http://docs.openstack.org/developer/os-client-config/ http://docs.openstack.org/developer/os-client-config/
inventory_dns: A boolean value, defaulted to false, which causes the role
to update a template file and reload dnsmasq upon each update
in order to perform static dns addressing utilizing the
ipv4_address parameter.
Dependencies Dependencies
------------ ------------

View File

@ -9,5 +9,6 @@ deploy_image_filename: "deployment_image.qcow2"
deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}" deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}"
inventory_dhcp: false inventory_dhcp: false
inventory_dhcp_static_ip: true inventory_dhcp_static_ip: true
inventory_dns: false
deploy_url_protocol: "http" deploy_url_protocol: "http"
noauth_mode: true noauth_mode: true

View File

@ -27,13 +27,18 @@
delegate_to: localhost delegate_to: localhost
when: inventory_dhcp | bool when: inventory_dhcp | bool
become: yes become: yes
- name: "Setup DNS address for nodes."
template: src=dns-address.j2 dest=/etc/dnsmasq.d/host_record_{{ inventory_hostname }} owner=root group=root mode=0644
delegate_to: localhost
when: inventory_dns | bool
become: yes
- name: "Sending dnsmasq HUP" - name: "Sending dnsmasq HUP"
# Note(TheJulia): We need to actually to send a hup signal directly as # Note(TheJulia): We need to actually to send a hup signal directly as
# Ansible's reloaded state does not pass through to the init script. # Ansible's reloaded state does not pass through to the init script.
command: killall -HUP dnsmasq command: killall -HUP dnsmasq
become: yes become: yes
when: inventory_dhcp | bool when: (inventory_dhcp | bool) or (inventory_dns | bool)
- name: "Deploy to hardware - Using custom instance_info" - name: "Deploy to hardware - Using custom instance_info."
os_ironic_node: os_ironic_node:
auth_type: "{{ auth_type | default(omit) }}" auth_type: "{{ auth_type | default(omit) }}"
auth: "{{ auth | default(omit) }}" auth: "{{ auth | default(omit) }}"

View File

@ -0,0 +1,2 @@
# This file is managed by bifrost
host-record={{ inventory_hostname }},{{ ipv4_address }}

View File

@ -77,6 +77,9 @@ In the case of static inventory, please also consider to set the
``dhcp_lease_time`` setting to infinite, to avoid unnecessary refreshes ``dhcp_lease_time`` setting to infinite, to avoid unnecessary refreshes
of ips. of ips.
If you want to force all hostnames to resolve to ``ipv4_address`` set on
the inventory, please set the ``inventory_dns`` setting to ``true``.
In case your HW needs a kernel option to boot, set the following variable: In case your HW needs a kernel option to boot, set the following variable:
extra_kernel_options: Default undefined. extra_kernel_options: Default undefined.

View File

@ -86,6 +86,10 @@ enable_cors_credential_support: false
# hosts in your dynamic inventory. # hosts in your dynamic inventory.
inventory_dhcp: False inventory_dhcp: False
# Set this to true to configure dnsmasq to resolv to ipv4_address from the
# hosts in your dynamic inventory.
inventory_dns: False
# Settings to enable the use of inspector # Settings to enable the use of inspector
enable_inspector: false enable_inspector: false
inspector_auth: "noauth" inspector_auth: "noauth"

View File

@ -119,6 +119,10 @@ interface={{ network_interface }}
# running another nameserver on the same machine. # running another nameserver on the same machine.
bind-interfaces bind-interfaces
# Include another lot of configuration options.
#conf-file=/etc/dnsmasq.more.conf
conf-dir=/etc/dnsmasq.d
# If you don't want dnsmasq to read /etc/hosts, uncomment the # If you don't want dnsmasq to read /etc/hosts, uncomment the
# following line. # following line.
#no-hosts #no-hosts
@ -653,10 +657,6 @@ dhcp-boot=http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interf
# Log lots of extra information about DHCP transactions. # Log lots of extra information about DHCP transactions.
#log-dhcp #log-dhcp
# Include another lot of configuration options.
#conf-file=/etc/dnsmasq.more.conf
#conf-dir=/etc/dnsmasq.d
{% if testing %} {% if testing %}
log-queries log-queries
log-dhcp log-dhcp

View File

@ -0,0 +1,9 @@
---
features:
- Adds new feature to manage DNS with the settings
on the inventory. When ``inventory_dns`` setting is
True, it will populate a set of record-host entries,
for each of the hostnames present on the inventory,
matching the ``ipv4_address``. This will override
the default dnsmasq behaviour, that will associate
hostnames with IP present on the leases file.