Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api_modify: Some routes shows "changed" when they shouldn't #148

Closed
Igorgro opened this issue Jan 28, 2023 · 5 comments · Fixed by #154
Closed

api_modify: Some routes shows "changed" when they shouldn't #148

Igorgro opened this issue Jan 28, 2023 · 5 comments · Fixed by #154
Labels
bug Something isn't working

Comments

@Igorgro
Copy link

Igorgro commented Jan 28, 2023

SUMMARY

Some routes (I currently experiencing this only in ip dhcp-client, but there can be more) show changed, when there actually no changes. For example when I executing the following task muliple times:

- name: Set DHCP client
  community.routeros.api_modify:
    path: ip dhcp-client
    data:
      - interface: ether1
        add-default-route: True
        default-route-distance: 1
        disabled: false
        use-peer-dns: True
        use-peer-ntp: True
        dhcp-options: ""

it always shows changed status, when no actually changes are performed (it is visible when enabling verbose output and comparing old_data and new_data)

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.routeros.api_modify

ANSIBLE VERSION
ansible [core 2.14.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0] (/usr/bin/python)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
Collection         Version
------------------ -------
community.routeros 2.5.0  
CONFIGURATION

OS / ENVIRONMENT
  • Control host:
    • OS: Arch Linux
    • Python version: 3.10.9
  • Mikrotik RouterOS 7.7
STEPS TO REPRODUCE

Run a playbook with the task that modifies ip dhcp-client path of Mikrotik router

- name: Set DHCP client
  community.routeros.api_modify:
    path: ip dhcp-client
    data:
      - interface: ether1
        add-default-route: True
        default-route-distance: 1
        disabled: false
        use-peer-dns: True
        use-peer-ntp: True
        dhcp-options: ""
EXPECTED RESULTS

The status of task should be ok, not changed when applying the same configuration

ACTUAL RESULTS
PLAY RECAP *************
localhost                  : ok=0    changed=1
@felixfontein
Copy link
Collaborator

Please use --diff to figure out what the module thinks it is changing.

@felixfontein felixfontein added the bug Something isn't working label Jan 29, 2023
@felixfontein felixfontein changed the title Some routes shows "changed" when they shouldn't api_modify: Some routes shows "changed" when they shouldn't Jan 29, 2023
@Igorgro
Copy link
Author

Igorgro commented Jan 29, 2023

When using --diff --check it shows the following:

--- before
+++ after
@@ -15,6 +15,7 @@
             ".id": "*5",
             "add-default-route": true,
             "default-route-distance": 1,
+            "dhcp-options": "",
             "disabled": false,
             "interface": "ether1",
             "use-peer-dns": true,

I need this option to be unset, but it doesn't accept null or empty object/array

@felixfontein
Copy link
Collaborator

Ok, that means we are handling the dhcp-options value wrong. I have to try that out, and I'm also wondering whether the behavior changed between ROS6 and ROS7 for it.

@felixfontein
Copy link
Collaborator

Verified: on both ROS6 and ROS7, dhcp-options's empty value should be '' (similar to comments).

@felixfontein
Copy link
Collaborator

#154 should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants