diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml index 5a42b059c..49ea90569 100644 --- a/playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml @@ -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 diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml index 9736532f1..15a838fa9 100644 --- a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml @@ -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 == {} diff --git a/playbooks/roles/bifrost-dhcp-record/defaults/main.yml b/playbooks/roles/bifrost-dhcp-record/defaults/main.yml new file mode 100644 index 000000000..dae936780 --- /dev/null +++ b/playbooks/roles/bifrost-dhcp-record/defaults/main.yml @@ -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 diff --git a/playbooks/roles/bifrost-dhcp-record/tasks/main.yml b/playbooks/roles/bifrost-dhcp-record/tasks/main.yml new file mode 100644 index 000000000..97877e1e8 --- /dev/null +++ b/playbooks/roles/bifrost-dhcp-record/tasks/main.yml @@ -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 diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/templates/dhcp-host.j2 b/playbooks/roles/bifrost-dhcp-record/templates/dhcp-host.j2 similarity index 100% rename from playbooks/roles/bifrost-deploy-nodes-dynamic/templates/dhcp-host.j2 rename to playbooks/roles/bifrost-dhcp-record/templates/dhcp-host.j2 diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/templates/dns-address.j2 b/playbooks/roles/bifrost-dhcp-record/templates/dns-address.j2 similarity index 100% rename from playbooks/roles/bifrost-deploy-nodes-dynamic/templates/dns-address.j2 rename to playbooks/roles/bifrost-dhcp-record/templates/dns-address.j2 diff --git a/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml b/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml index 907a4ee9a..f24242968 100644 --- a/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml +++ b/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml @@ -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) }}" diff --git a/playbooks/roles/ironic-inspect-node/defaults/main.yml b/playbooks/roles/ironic-inspect-node/defaults/main.yml index 7f005d7e5..f106556ec 100644 --- a/playbooks/roles/ironic-inspect-node/defaults/main.yml +++ b/playbooks/roles/ironic-inspect-node/defaults/main.yml @@ -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) }}" diff --git a/playbooks/roles/ironic-inspect-node/tasks/main.yml b/playbooks/roles/ironic-inspect-node/tasks/main.yml index c34af4f6a..c2edae4ea 100644 --- a/playbooks/roles/ironic-inspect-node/tasks/main.yml +++ b/playbooks/roles/ironic-inspect-node/tasks/main.yml @@ -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: diff --git a/playbooks/roles/ironic-inspect-node/templates/dhcp-host.j2 b/playbooks/roles/ironic-inspect-node/templates/dhcp-host.j2 deleted file mode 100644 index d9f11f1fb..000000000 --- a/playbooks/roles/ironic-inspect-node/templates/dhcp-host.j2 +++ /dev/null @@ -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 %} diff --git a/playbooks/roles/ironic-inspect-node/templates/dns-address.j2 b/playbooks/roles/ironic-inspect-node/templates/dns-address.j2 deleted file mode 100644 index 4792c23cd..000000000 --- a/playbooks/roles/ironic-inspect-node/templates/dns-address.j2 +++ /dev/null @@ -1,2 +0,0 @@ -# This file is managed by bifrost -host-record={{ inventory_hostname }},{{ ipv4_address }} diff --git a/releasenotes/notes/cleaning-dhcp-config-e693799a88f32a4e.yaml b/releasenotes/notes/cleaning-dhcp-config-e693799a88f32a4e.yaml new file mode 100644 index 000000000..b21c05676 --- /dev/null +++ b/releasenotes/notes/cleaning-dhcp-config-e693799a88f32a4e.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Makes sure the static DHCP configuration runs before automated cleaning.