system/ansible/deployment_poc/tasks/configure_dhcp.yml
Georg 7bb88aaa66 Init Ansible NetBox DHCP POC deployment
Signed-off-by: Georg <georg@lysergic.dev>
2022-01-05 23:59:13 +01:00

32 lines
1.1 KiB
YAML

---
- 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 }}"