Configure static DHCP before automated cleaning

After the switch to newer ansible collection, the enrollment workflow
started running automated cleaning (before that, it would use the old
API version resulting in immediate "available"). However, the static
DHCP configuration only happened in the inspect and deploy workflows,
which are run after enrollment.

This change extracts a new small role for the DHCP config and includes
it in all 3 workflows that use DHCP.

While here, make sure that dnsmasq_dhcp_hostsdir is respected.

Change-Id: Idf6f24dde11d600698d45a218812cba8134fb73f
This commit is contained in:
Dmitry Tantsur 2023-12-19 10:58:44 +01:00
parent 35c3d51dc4
commit ab62784f22
No known key found for this signature in database
GPG Key ID: 315B2AF9FD216C60
12 changed files with 66 additions and 64 deletions

View File

@ -12,9 +12,6 @@ deploy_image_filename: "deployment_image.qcow2"
deploy_image_path: "{{ deploy_image | default(http_boot_folder + '/' + deploy_image_filename) }}"
deploy_image_source: "{{ deploy_url_protocol }}://{{ internal_ip }}:{{ file_url_port }}/{{ deploy_image_filename }}"
deploy_root_gb: 10
inventory_dhcp: false
inventory_dhcp_static_ip: true
inventory_dns: false
deploy_url_protocol: "http"
# Under normal circumstances, the os_ironic_node module does not wait for

View File

@ -43,32 +43,8 @@
- uuid is undefined
- name is defined
- name: "Setup DHCP for nodes."
template:
src: dhcp-host.j2
dest: "/etc/dnsmasq.d/bifrost.dhcp-hosts.d/{{ inventory_hostname }}"
owner: root
group: root
mode: "0644"
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"
when: inventory_dns | bool
become: yes
- name: "Restarting dnsmasq"
service:
name: dnsmasq
state: restarted
become: yes
when: inventory_dhcp | bool or inventory_dns | bool
- import_role:
name: bifrost-dhcp-record
- name: "Create instance info"
when: instance_info is not defined or instance_info == {}

View File

@ -0,0 +1,17 @@
# 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.
---
dnsmasq_dhcp_hostsdir: "/etc/dnsmasq.d/bifrost.dhcp-hosts.d"
dnsmasq_host_record_prefix: "/etc/dnsmasq.d/host_record_"
inventory_dhcp: false
inventory_dhcp_static_ip: true
inventory_dns: false

View File

@ -0,0 +1,38 @@
# 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: "Setup DHCP for nodes."
template:
src: dhcp-host.j2
dest: "{{ dnsmasq_dhcp_hostsdir }}/{{ inventory_hostname }}"
owner: root
group: root
mode: "0644"
when: inventory_dhcp | bool
become: yes
- name: "Setup DNS address for nodes."
template:
src: dns-address.j2
dest: "{{ dnsmasq_host_record_prefix }}{{ inventory_hostname }}"
owner: root
group: root
mode: "0644"
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 or inventory_dns | bool

View File

@ -19,6 +19,9 @@
- import_role:
name: bifrost-cloud-config
- import_role:
name: bifrost-dhcp-record
- name: "Dynamic enrollment"
openstack.cloud.baremetal_node:
cloud: "{{ cloud_name | default(omit) }}"

View File

@ -2,9 +2,6 @@
# defaults file for ironic-inspect-node
noauth_mode: false
inspection_wait_timeout: 1800
inventory_dhcp: false
inventory_dhcp_static_ip: true
inventory_dns: false
# Timeout for gathering facts.
fact_gather_timeout: "{{ lookup('config', 'DEFAULT_GATHER_TIMEOUT', on_missing='skip') | default(omit, true) }}"

View File

@ -19,30 +19,8 @@
- import_role:
name: bifrost-cloud-config
- name: "Setup DHCP for nodes."
template:
src: dhcp-host.j2
dest: "/etc/dnsmasq.d/bifrost.dhcp-hosts.d/{{ inventory_hostname }}"
owner: root
group: root
mode: "0644"
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"
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 or inventory_dns | bool
- import_role:
name: bifrost-dhcp-record
- name: "Execute node introspection"
openstack.cloud.baremetal_inspect:

View File

@ -1,6 +0,0 @@
# This file is managed by bifrost
{% if inventory_dhcp_static_ip | bool == true %}
{{ nics[0]['mac'] }},{{provisioning_ipv4_address}},{{name}},12h
{% else %}
{{ nics[0]['mac'] }},{{name}},12h
{% endif %}

View File

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

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Makes sure the static DHCP configuration runs before automated cleaning.