Windows DHCP Server and HPE ILO5 client identifier

Hello everyone,

I’m currently having a problem with the community.windows.win_dhcp_lease module.

I need to reserve IP addresses for our HPE Gen10 servers on a Windows DHCP server. But HPE is a bit on the other side in terms of standards in my opinion. The ILO 5 presents itself with a client ID that looks like this: ILO_MAC, followed by 6 times 0. For example: “00:B1:8A:D1:5A:1F000000”. This is unusual but normal, I think in view of the ILO5 User Guide

Then when I try to reserve an IP address I get the error: Mac address not formatted correctly.

Does anyone have a solution for this? Or should I create my own plugin for this?
Here is my main.yml

- hosts: localhost
  name: Create reservation in DHCP
  strategy: free
  connection: local
  gather_facts: False
  vars:
    mac_addresses_input: "00:B1:8A:D1:5A:1F,00:AA:BB:CC:DD:EE"
    mac_addresses: "{{ mac_addresses_input.split(',') }}"
    ilo_names_input: "tobi-test,marie-test"
    ilo_names: "{{ ilo_names_input.split(',') }}"
    gen: "ilo5"
    ip_reserved: false

  tasks:
    - name: Combine MAC and ILO-Names
      set_fact:
        combined_list: "{{ mac_addresses | zip(ilo_names) | list }}"

    - name: Start IP Reservation.
      ansible.builtin.include_tasks: ip_reservation_task.yml
      loop: "{{ combined_list }}"
      loop_control:
        loop_var: combined_item
      when: not ip_reserved

    - name: Display Reserved IPs
      debug:
        var: reserved_ips

and here is the ip_reservation_task.yml:

---
- name: Set mac address for ILO5
  ansible.builtin.set_fact:
    current_mac: "{{ combined_item[0] }}000000"
    current_ilo_name: "{{ combined_item[1] }}"
  when: gen == "ilo5"

- name: Display DHCP result
  debug:
    msg: "{{ current_mac }} und der name dazu {{ current_ilo_name }}"

- name: Get a free DHCP IP
  community.windows.win_dhcp_lease:
    type: lease
    scope_id: "{{ dhcp_scope_id }}"
    mac: "{{ current_mac }}"
    state: present
  register: dhcp_lease

- name: Check IP reachability via win_ping
  ansible.windows.win_ping:
    data: "{{ ip_to_check }}"
  register: ping_result

- name: Create DHCP lease with "Not Free - Check" comment if IP is reachable
  community.windows.win_dhcp_lease:
    type: lease
    ip: "{{ ip_to_check }}"
    scope_id: "{{ dhcp_scope_id }}"
    mac: "{{ current_mac }}"
    dns_hostname: "{{ current_ilo_name }}"
    description: "Not Free - Please Check"
  when: ping_result.ping == "pong"

- name: Save IP address with "Not Free - Please Check" comment
  set_fact:
    allready_reserved: "{{ allready_reserved | default([]) + [ip_to_check] }}"
  when: ping_result.ping == "pong"

- name: Create DHCP reservation if IP is free and not reachable
  community.windows.win_dhcp_lease:
    type: reservation
    ip: "{{ ip_to_check }}"
    scope_id: "{{ dhcp_scope_id }}"
    mac: "{{ current_mac }}"
    dns_hostname: "{{ current_ilo_name }}"
    description: "Reserved with Ansible"

- name: Save reserved IP address and hostname
  set_fact:
    reserved_ips: "{{ reserved_ips | default([]) + [ { 'ip': ip_to_check, 'hostname': current_ilo_name } ] }}"
 
- name: Set ip_reserved flag
  set_fact:
    ip_reserved: true

Hi,

Yeah, it looks like module only accepts a mac parameter 12 or 17 chars long (resulting in a single format), as module doc states that:

Linux and other operating systems can use other types of identifiers.

which is misleading IMO, and I don’t see any other way to define client identifier.

If you try to manually create the reservation using the long ILO client identifier, does it work ?

Also, does it work if you use ILO NIC mac address instead, without adding the trailing zeros ?

Hey, thanks for your advice.

I can do it manually in the DHCP Console and windows warns me because it is unusal to do that. But it works. If i only set the mac then the DHCP lease wont work… i tried it.

I see. Then your best bet would be to rewrite module’s function to your needs IMO, or write a custom script to execute with script module.

Just so you know, there was apparently an attempt to circumvent this issue, though changes weren’t merged, not sure why.