# Windows DHCP Server and HPE ILO5 client identifier

**URL:** <https://forum.ansible.com/t/windows-dhcp-server-and-hpe-ilo5-client-identifier/2060>\
**Category:** Get Help\
**Tags:** windows, playbook, collections, ee\
**Created:** [October 31, 2023, 5:56pm UTC](https://forum.ansible.com/t/windows-dhcp-server-and-hpe-ilo5-client-identifier/2060 "2023-10-31T17:56:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torie-Coding](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/torie-coding/32/1248_2.png) [@Torie-Coding](https://forum.ansible.com/u/Torie-Coding)\
**Post date:** [October 31, 2023, 5:56pm UTC](https://forum.ansible.com/t/windows-dhcp-server-and-hpe-ilo5-client-identifier/2060/1 "2023-10-31T17:56:31Z")

</div>

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](https://support.hpe.com/hpesc/public/docDisplay?docId=a00105236en_us&docLocale=en_US&page=GUID-A5D87AA3-9E2D-435C-B866-6056EB224DDB.html#:~:text=WINS%20Server%20boxes.-,NOTE%3A,BB%2DCC%2C%20then%20the%20associated%20DHCP%20client%20identifier%20is%20005300AABBCC000000.,-Static%20IPv4%20Address)

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

```auto
- 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:

```auto
---
- 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

```

---

<div class="post-metadata">

**Author:** ![ptn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ptn/32/481_2.png) [@ptn](https://forum.ansible.com/u/ptn)\
**Post date:** [October 31, 2023, 6:35pm UTC](https://forum.ansible.com/t/windows-dhcp-server-and-hpe-ilo5-client-identifier/2060/2 "2023-10-31T18:35:03Z")

</div>

Hi,

Yeah, it looks like module [only accepts a mac parameter 12 or 17 chars long](https://github.com/ansible-collections/community.windows/blob/6b7254c2679dad9ca91d2891df5bc0aa3d4c4345/plugins/modules/win_dhcp_lease.ps1#L43) (resulting in a single format), as [module doc](https://docs.ansible.com/ansible/latest/collections/community/windows/win_dhcp_lease_module.html#parameter-mac) 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 ?

---

<div class="post-metadata">

**Author:** ![Torie-Coding](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/torie-coding/32/1248_2.png) [@Torie-Coding](https://forum.ansible.com/u/Torie-Coding)\
**Post date:** [October 31, 2023, 6:59pm UTC](https://forum.ansible.com/t/windows-dhcp-server-and-hpe-ilo5-client-identifier/2060/3 "2023-10-31T18:59:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ptn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ptn/32/481_2.png) [@ptn](https://forum.ansible.com/u/ptn)\
**Post date:** [November 1, 2023, 4:48pm UTC](https://forum.ansible.com/t/windows-dhcp-server-and-hpe-ilo5-client-identifier/2060/4 "2023-11-01T16:48:12Z")

</div>

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](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/script_module.html).

Just so you know, there was apparently an [attempt to circumvent this issue](https://github.com/ansible-collections/community.windows/pull/428), though changes weren’t merged, not sure why.
