-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path01-dhcp.yaml
More file actions
41 lines (40 loc) · 1.57 KB
/
01-dhcp.yaml
File metadata and controls
41 lines (40 loc) · 1.57 KB
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
32
33
34
35
36
37
38
39
40
41
---
- hosts: pakupi_controller
become: yes
tasks:
# - name: Gather facts from all hosts
# ansible.builtin.setup:
# delegate_to: "{{ item }}"
# delegate_facts: true
# loop: "{{ groups['all'] }}"
# ignore_unreachable: true
- name: Build DHCP host list
set_fact:
dhcp_hosts: "{{ (dhcp_hosts | default([])) + [dhcp_host_template] }}"
loop: "{{ groups['all'] }}"
- name: Build DHCP default range configuration
set_fact:
dhcp_global_routers: "{{ pakupi_dhcp_gateway }}"
dhcp_subnets:
- ip: "{{ pakupi_network }}"
netmask: "{{ pakupi_network_mask }}"
range_begin: "{{ pakupi_dhcp_range.begin }}"
range_end: "{{ pakupi_dhcp_range.end }}"
domain_name_servers: "{{ pakupi_dhcp_dns }}"
# TODO Check and set routers if gateway set
# routers: "{{ pakupi_dhcp_gateway }}"
- name: DBG
debug:
msg: "{{ dhcp_subnets }}"
- name: Setup DHCP server
include_role:
name: bertvv.dhcp
vars:
dhcp_host_template:
name: "{{ item }}"
mac: "{{ hostvars[item].macaddress }}"
ip: "{{ hostvars[item].ansible_host }}"
hostname: "{{ item }}.{{ pakupi_domain }}"
routers: "{{ pakupi_dhcp_gateway }}"
pakupi_net: "{{ pakupi_network }}/{{ pakupi_network_mask }}"
# hostvars[item].ansible_facts[dict(hostvars[item].ansible_facts.interfaces | map('extract', hostvars[item].ansible_facts, ['ipv4', 'address']) | zip(hostvars[item].ansible_facts.interfaces))[hostvars[item].ansible_facts.all_ipv4_addresses | ansible.utils.ipaddr(pakupi_net) | first]].macaddress