infobloxopen / infoblox-ansible

Ansible modules for interfacing to Infoblox systems
GNU General Public License v3.0
54 stars 61 forks source link

nios_network router and ntp-servers (42) option can not have a use_option flag #221

Open ggeronimo-github opened 4 months ago

ggeronimo-github commented 4 months ago

Summary When using the infoblox.nios_modules.nios_network, for certain DHCP options router and 42, I am getting the errors:

Option router can not have a use_option flag

Option ntp-servers can not have a use_option flag

Issue Type Bug Report

Component Name nios_network

Ansible Version ansible [core 2.16.4]

Configuration

# tasks for dhcp_network
- name: Set DHCP network and options for multiple networks IPv4
  loop: "{{ dhcp_networks }}"
  loop_control:
    loop_var: dhcp_network
  infoblox.nios_modules.nios_network:
    network_view: "{{ dhcp_network.network_view }}"
    network: "{{ dhcp_network.network }}"
    comment: "{{ dhcp_network.comment }}"
    options:
      - name: domain-name-servers
        value: "{{ dhcp_network.dns_server }}"
      - name: router
        value: "{{ dhcp_network.router }}"

    members:
      - name: "{{ dhcp_network.dhcp_member }}"
    state: present
    provider: "{{ nios_provider }}"

and

# tasks for dhcp_network
- name: Set DHCP network and options for multiple networks IPv4
  loop: "{{ dhcp_networks }}"
  loop_control:
    loop_var: dhcp_network
  infoblox.nios_modules.nios_network:
    network_view: "{{ dhcp_network.network_view }}"
    network: "{{ dhcp_network.network }}"
    comment: "{{ dhcp_network.comment }}"
    options:
      - name: domain-name-servers
        value: "{{ dhcp_network.dns_server }}"
      - num: 42
        value: "{{ dhcp_network.ntp_server }}"

    members:
      - name: "{{ dhcp_network.dhcp_member }}"
    state: present
    provider: "{{ nios_provider }}"

Expected Results Since router and option 42 can not have a use_option flag, it should not be included when using the module, and task should be ok, not failed.

Actual Results

"msg": "Option router can not have a use_option flag",
    "operation": "update_object",
    "type": "AdmConProtoError"

and 

    "msg": "Option ntp-servers can not have a use_option flag",
    "operation": "update_object",
    "type": "AdmConProtoError"
badnetmask commented 4 months ago

This is a relatively simple patch (I've done it before), I just don't have the availability to do it right now, but you can probably try it on your side first to prove the point.

Look for wherever your collections are landed on your system, edit this line on nios_network.py, then add the numbers 3 and 42 (options "router" and "ntp-server" respectively).

If it works, you can even submit your own PR. :wink: