infobloxopen / infoblox-ansible

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

nios_host_record always shows result is "changed" when alias is present #160

Open fostermi opened 1 year ago

fostermi commented 1 year ago

When using the nios_host_record module with a host record that contains an alias parameter, the module, when run, always shows the resulting play/task as changed. If no alias is present, then the module will correctly show that the result hasn't changed.

Task in playbook with two records: one with aliases and another without.

---
- hosts: localhost
  vars:
    nios_provider:
      host: {{ infobloxhost }}
      username: {{ username }}
      password: {{ password }}
      wapi_version: '2.12'
    host_records:
      - name: infobloxhosttest.example.com
        ipv4addrs:
          - address: 172.16.23.4
        aliases:
          - infobloxctest3
      - name: infobloxhosttest2.example.com
        ipv4addrs:
           - address: 172.16.23.5
  connection: local
  tasks:

  - name: Configure an ipv4 host record
    infoblox.nios_modules.nios_host_record:
      name: "{{ item.name }}"
      ipv4: "{{ item.ipv4addrs }}"
      aliases: "{{ item.aliases | default(omit, true) }}"
      state: "{{ item.state | default('present', true) }}"
      view: "Internal"
      comment: "Managed by Ansible"
      provider:
        host: "{{ nios_provider.host }}"
        username: "{{ nios_provider.username }}"
        password: "{{ nios_provider.password }}"
    with_items:
      - "{{ host_records }}"
    when: item.state == "present"

ansible-playbook output:

PLAY [localhost] *****************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Configure an ipv4 host record] *********************************************************************************************************************************************************************************************************
changed: [localhost] => (item={'name': 'infobloxhosttest.example.com', 'ipv4addrs': [{'address': '172.16.23.4'}], 'aliases': ['infobloxctest3'], 'state': 'present'})
ok: [localhost] => (item={'name': 'infobloxhosttest2.example.com', 'ipv4addrs': [{'address': '172.16.23.5'}], 'state': 'present'})

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 

Environment

ansible [core 2.11.12] 
  config file = /Users/me/git/ansible/ansible.cfg
  configured module search path = ['/Users/me/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/me/venvs/ansible-2.12.13-nios/lib/python3.7/site-packages/ansible
  ansible collection location = /Users/me/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/me/venvs/ansible-2.12.13-nios/bin/ansible
  python version = 3.7.4 (default, Sep  7 2019, 18:31:37) [Clang 9.0.0 (clang-900.0.39.2)]
  jinja version = 3.1.2
  libyaml = True

infoblox-client    0.5.2

Infoblox.Nios_Modules v1.4.0