blob: 9802b0e61fdb099a7dc23cd98558a404d21e08ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
---
- name: Configure DHCP
block:
- name: Query DHCP server
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: 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 }}"
|