diff --git a/doc/source/deploy/dhcp.rst b/doc/source/deploy/dhcp.rst index e171c6b98..d8bfd5519 100644 --- a/doc/source/deploy/dhcp.rst +++ b/doc/source/deploy/dhcp.rst @@ -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 result in the first MAC address defined in the list of hardware MAC addresses 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. diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/README.md b/playbooks/roles/bifrost-deploy-nodes-dynamic/README.md index dee5a0816..93c96c1d9 100644 --- a/playbooks/roles/bifrost-deploy-nodes-dynamic/README.md +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/README.md @@ -56,7 +56,6 @@ instance_info: A dictionary containing the information to define an instance. expected are image_source, image_checksum, root_gb, however, any supported key/value can be submitted to the API. - inventory_dhcp: A boolean value, defaulted to false, which allows dnsmasq to configure the IP of the machines, rather than putting 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 this file format can be found at: 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 ------------ diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml index 2e6d89579..3283f44f3 100644 --- a/playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml @@ -9,5 +9,6 @@ deploy_image_filename: "deployment_image.qcow2" deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}" inventory_dhcp: false inventory_dhcp_static_ip: true +inventory_dns: false deploy_url_protocol: "http" noauth_mode: true diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml index 8161869aa..9b7a79fea 100644 --- a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml @@ -27,13 +27,18 @@ delegate_to: localhost when: inventory_dhcp | bool 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" # 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. command: killall -HUP dnsmasq become: yes - when: inventory_dhcp | bool -- name: "Deploy to hardware - Using custom instance_info" + when: (inventory_dhcp | bool) or (inventory_dns | bool) +- name: "Deploy to hardware - Using custom instance_info." os_ironic_node: auth_type: "{{ auth_type | default(omit) }}" auth: "{{ auth | default(omit) }}" diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/templates/dns-address.j2 b/playbooks/roles/bifrost-deploy-nodes-dynamic/templates/dns-address.j2 new file mode 100644 index 000000000..4792c23cd --- /dev/null +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/templates/dns-address.j2 @@ -0,0 +1,2 @@ +# This file is managed by bifrost +host-record={{ inventory_hostname }},{{ ipv4_address }} diff --git a/playbooks/roles/bifrost-ironic-install/README.md b/playbooks/roles/bifrost-ironic-install/README.md index 9d18c28ca..088acecd1 100644 --- a/playbooks/roles/bifrost-ironic-install/README.md +++ b/playbooks/roles/bifrost-ironic-install/README.md @@ -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 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: extra_kernel_options: Default undefined. diff --git a/playbooks/roles/bifrost-ironic-install/defaults/main.yml b/playbooks/roles/bifrost-ironic-install/defaults/main.yml index e78330e65..fe492db8c 100644 --- a/playbooks/roles/bifrost-ironic-install/defaults/main.yml +++ b/playbooks/roles/bifrost-ironic-install/defaults/main.yml @@ -86,6 +86,10 @@ enable_cors_credential_support: false # hosts in your dynamic inventory. 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 enable_inspector: false inspector_auth: "noauth" diff --git a/playbooks/roles/bifrost-ironic-install/templates/dnsmasq.conf.j2 b/playbooks/roles/bifrost-ironic-install/templates/dnsmasq.conf.j2 index 18b1c6626..359f4c2a9 100644 --- a/playbooks/roles/bifrost-ironic-install/templates/dnsmasq.conf.j2 +++ b/playbooks/roles/bifrost-ironic-install/templates/dnsmasq.conf.j2 @@ -119,6 +119,10 @@ interface={{ network_interface }} # running another nameserver on the same machine. 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 # following line. #no-hosts @@ -656,10 +660,6 @@ dhcp-boot=http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interf # Log lots of extra information about DHCP transactions. #log-dhcp -# Include another lot of configuration options. -#conf-file=/etc/dnsmasq.more.conf -#conf-dir=/etc/dnsmasq.d - {% if testing %} log-queries log-dhcp diff --git a/releasenotes/notes/inventory_dns-921195abbc5e65ef.yaml b/releasenotes/notes/inventory_dns-921195abbc5e65ef.yaml new file mode 100644 index 000000000..0a25fd956 --- /dev/null +++ b/releasenotes/notes/inventory_dns-921195abbc5e65ef.yaml @@ -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.