2022-01-05 23:59:13 +01:00
|
|
|
---
|
|
|
|
- name: Configure DHCP
|
|
|
|
block:
|
2022-02-13 01:37:39 +01:00
|
|
|
- name: Set DHCP host OS
|
2022-01-05 23:59:13 +01:00
|
|
|
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'
|
2022-02-13 01:37:39 +01:00
|
|
|
|
|
|
|
- name: Restart dhcpd
|
|
|
|
ansible.builtin.command:
|
|
|
|
argv:
|
|
|
|
- /usr/bin/doas
|
|
|
|
- rcctl
|
|
|
|
- restart
|
|
|
|
- dhcpd
|
|
|
|
when: dhcp_os == 'openbsd-x86_64'
|
|
|
|
|
2022-01-05 23:59:13 +01:00
|
|
|
- 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 }}"
|
|
|
|
|