41 lines
1.3 KiB
YAML
41 lines
1.3 KiB
YAML
---
|
|
- name: Configure DHCP
|
|
block:
|
|
- name: Set DHCP host OS
|
|
set_fact:
|
|
dhcp_os: "{{ hostvars[dhcp_host]['platforms'][0] }}"
|
|
|
|
- name: Insert DHCP host block
|
|
ansible.builtin.blockinfile:
|
|
#backup: yes
|
|
block: "{{ lookup('template', '../templates/dhcpd.conf.j2') }}"
|
|
marker: "### {mark} Ansible managed block for {{ vm_name }} ###"
|
|
path: "/etc/dhcpd.conf"
|
|
#delegate_to: "{{ dhcp_host }}"
|
|
become: yes
|
|
become_method: doas
|
|
when: dhcp_os == 'openbsd-x86_64'
|
|
|
|
- name: Restart dhcpd
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/bin/doas
|
|
- rcctl
|
|
- restart
|
|
- dhcpd
|
|
when: dhcp_os == 'openbsd-x86_64'
|
|
|
|
- name: Insert DHCP static mapping
|
|
vyos.vyos.vyos_config:
|
|
backup: yes
|
|
backup_options:
|
|
dir_path: "/tmp/"
|
|
comment: "Configured as part of {{ vm_name }} deployment"
|
|
lines:
|
|
- "set service dhcp-server shared-network-name LAN subnet {{ prefix_display }} static-mapping {{ vm_name }} mac-address {{ mac_address }}"
|
|
- "set service dhcp-server shared-network-name LAN subnet {{ prefix_display }} static-mapping {{ vm_name }} ip-address {{ ip_address }}"
|
|
save: no # CHANGE BEFORE ROLLOUT
|
|
when: dhcp_os == 'vyos-x86_64'
|
|
delegate_to: "{{ dhcp_host }}"
|
|
|