From 513f56604a130c45fb94a88fedcf16024063c5ef Mon Sep 17 00:00:00 2001 From: jbisabel <87313000+jbisabel@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:27:41 +0100 Subject: [PATCH 01/29] fix: Add topology option to dtc:lbdn (#191) * fix: Add topology option to dtc:lbdn * feat: allow to specify toppology name instead of reference * fix: correct object type for topology * fix: remove trailing whitespace * fix: better error handling --- plugins/modules/nios_dtc_lbdn.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/modules/nios_dtc_lbdn.py b/plugins/modules/nios_dtc_lbdn.py index e1868903..eebdcf2c 100644 --- a/plugins/modules/nios_dtc_lbdn.py +++ b/plugins/modules/nios_dtc_lbdn.py @@ -37,6 +37,12 @@ - RATIO - ROUND_ROBIN - TOPOLOGY + topology: + description: + - Configures the topology rules for the C(TOPOLOGY) load balancing method. + - Required only when I(lb_method) is set to C(TOPOLOGY). + required: false + type: str auth_zones: description: - List of linked authoritative zones. @@ -195,6 +201,16 @@ def pools_transform(module): module.fail_json(msg='pool %s cannot be found.' % pool) return pool_list + def topology_transform(module): + topology = module.params['topology'] + if topology: + topo_obj = wapi.get_object('dtc:topology', {'name': topology}) + if topo_obj: + return topo_obj[0]['_ref'] + else: + module.fail_json( + msg='topology %s cannot be found.' % topology) + auth_zones_spec = dict() pools_spec = dict( @@ -207,6 +223,7 @@ def pools_transform(module): lb_method=dict(required=True, choices=['GLOBAL_AVAILABILITY', 'RATIO', 'ROUND_ROBIN', 'TOPOLOGY']), + topology=dict(type='str', transform=topology_transform), auth_zones=dict(type='list', elements='str', options=auth_zones_spec, transform=auth_zones_transform), patterns=dict(type='list', elements='str'), From bd5df2d0ed16d1077a23e719de0d489d66e3c16a Mon Sep 17 00:00:00 2001 From: jbisabel <87313000+jbisabel@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:28:07 +0100 Subject: [PATCH 02/29] fix: workflow (#192) * fix: removed unsupported ansible versions and added new required python versions * fix: check if quoting python version works * fix: quote all python versions * fix: deprecated features + remove python 3.12 + coverage version * fix: dependencies * fix: pin coverage dependency to 6.5.0 --- .github/workflows/ansible-test.yml | 52 +++++++++++-------- .../targets/nios_a_record/tasks/main.yml | 2 +- .../targets/nios_aaaa_record/tasks/main.yml | 2 +- .../targets/nios_cname_record/tasks/main.yml | 2 +- .../targets/nios_dns_view/tasks/main.yml | 2 +- .../targets/nios_host_record/tasks/main.yml | 2 +- .../targets/nios_mx_record/tasks/main.yml | 2 +- .../targets/nios_naptr_record/tasks/main.yml | 2 +- .../targets/nios_network/tasks/main.yml | 2 +- .../targets/nios_network_view/tasks/main.yml | 2 +- .../targets/nios_ptr_record/tasks/main.yml | 2 +- .../targets/nios_srv_record/tasks/main.yml | 2 +- .../targets/nios_txt_record/tasks/main.yml | 2 +- .../targets/nios_zone/tasks/main.yml | 2 +- .../targets/prepare_nios_tests/tasks/main.yml | 2 +- tests/unit/requirements.txt | 2 +- 16 files changed, 45 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 85a80f91..7ccd9f66 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -18,10 +18,10 @@ jobs: - name: Check out code uses: actions/checkout@v2 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v1 with: - python-version: 3.9 + python-version: '3.10' - name: Install ansible (${{ matrix.ansible-version }}) run: pip install pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check @@ -48,19 +48,19 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.9] - ansible-version: [stable-2.9, stable-2.10, stable-2.11, stable-2.12, stable-2.13, devel] + python-version: ['3.8', '3.9', '3.10', '3.11'] + ansible-version: [stable-2.13, stable-2.14, stable-2.15, devel] exclude: - ansible-version: devel - python-version: 2.7 + python-version: '3.8' - ansible-version: devel - python-version: 3.8 - - ansible-version: stable-2.12 - python-version: 2.7 + python-version: '3.9' + - ansible-version: stable-2.15 + python-version: '3.8' + - ansible-version: stable-2.14 + python-version: '3.8' - ansible-version: stable-2.13 - python-version: 2.7 - - ansible-version: stable-2.9 - python-version: 3.9 + python-version: '3.11' steps: - name: Set up Python ${{ matrix.python-version }} @@ -91,7 +91,7 @@ jobs: - name: Generate coverage report run: | - if [ "${{ matrix.ansible-version }}" == "devel" ]; then pip install coverage==6.5.0; fi + if [ "${{ matrix.ansible-version }}" == "stable-2.13" ]; then pip install coverage==4.5.4; fi ansible-test coverage xml -v --group-by command --group-by version working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ @@ -108,21 +108,29 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.9] - ansible-version: [stable-2.9, stable-2.10, stable-2.11, stable-2.12, stable-2.13, devel] + python-version: ['3.8', '3.9', '3.10', '3.11'] + ansible-version: [stable-2.13, stable-2.14, stable-2.15, devel] exclude: - - ansible-version: stable-2.9 - python-version: 3.9 + - ansible-version: devel + python-version: '3.8' + - ansible-version: devel + python-version: '3.9' + - ansible-version: stable-2.15 + python-version: '3.8' + - ansible-version: stable-2.14 + python-version: '3.8' + - ansible-version: stable-2.13 + python-version: '3.11' steps: - - name: Set up Python 3.9 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v1 with: - python-version: 3.9 + python-version: ${{ matrix.python-version }} - name: Check out code uses: actions/checkout@v2 - - name: Install ansible-base (${{ matrix.ansible }}) + - name: Install ansible-base (${{ matrix.ansible-version }}) run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check - name: Download migrated collection artifacts @@ -170,15 +178,15 @@ jobs: strategy: fail-fast: false matrix: - ansible-version: [stable-2.9, stable-2.10, stable-2.11, stable-2.12, stable-2.13, devel] + ansible-version: [stable-2.13, stable-2.14, stable-2.15, devel] steps: - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v1 with: # it is just required to run that once as "ansible-test sanity" in the docker image # will run on all python versions it supports. - python-version: 3.9 + python-version: '3.10' - name: Install ansible (${{ matrix.ansible-version }}) version run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check diff --git a/tests/integration/targets/nios_a_record/tasks/main.yml b/tests/integration/targets/nios_a_record/tasks/main.yml index b3fa8014..0955a39f 100644 --- a/tests/integration/targets/nios_a_record/tasks/main.yml +++ b/tests/integration/targets/nios_a_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_a_record_idempotence.yml +- include_tasks: nios_a_record_idempotence.yml diff --git a/tests/integration/targets/nios_aaaa_record/tasks/main.yml b/tests/integration/targets/nios_aaaa_record/tasks/main.yml index 2fec2adb..9096b63d 100644 --- a/tests/integration/targets/nios_aaaa_record/tasks/main.yml +++ b/tests/integration/targets/nios_aaaa_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_aaaa_record_idempotence.yml +- include_tasks: nios_aaaa_record_idempotence.yml diff --git a/tests/integration/targets/nios_cname_record/tasks/main.yml b/tests/integration/targets/nios_cname_record/tasks/main.yml index b30f250a..df8ff758 100644 --- a/tests/integration/targets/nios_cname_record/tasks/main.yml +++ b/tests/integration/targets/nios_cname_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_cname_record_idempotence.yml +- include_tasks: nios_cname_record_idempotence.yml diff --git a/tests/integration/targets/nios_dns_view/tasks/main.yml b/tests/integration/targets/nios_dns_view/tasks/main.yml index 1eb9c07a..2b9ca3a0 100644 --- a/tests/integration/targets/nios_dns_view/tasks/main.yml +++ b/tests/integration/targets/nios_dns_view/tasks/main.yml @@ -1 +1 @@ -- include: nios_dns_view_idempotence.yml +- include_tasks: nios_dns_view_idempotence.yml diff --git a/tests/integration/targets/nios_host_record/tasks/main.yml b/tests/integration/targets/nios_host_record/tasks/main.yml index 2f1dcc55..3c626f55 100644 --- a/tests/integration/targets/nios_host_record/tasks/main.yml +++ b/tests/integration/targets/nios_host_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_host_record_idempotence.yml +- include_tasks: nios_host_record_idempotence.yml diff --git a/tests/integration/targets/nios_mx_record/tasks/main.yml b/tests/integration/targets/nios_mx_record/tasks/main.yml index fe687173..ebffb41a 100644 --- a/tests/integration/targets/nios_mx_record/tasks/main.yml +++ b/tests/integration/targets/nios_mx_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_mx_record_idempotence.yml +- include_tasks: nios_mx_record_idempotence.yml diff --git a/tests/integration/targets/nios_naptr_record/tasks/main.yml b/tests/integration/targets/nios_naptr_record/tasks/main.yml index a22a8018..ed94e8a3 100644 --- a/tests/integration/targets/nios_naptr_record/tasks/main.yml +++ b/tests/integration/targets/nios_naptr_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_naptr_record_idempotence.yml +- include_tasks: nios_naptr_record_idempotence.yml diff --git a/tests/integration/targets/nios_network/tasks/main.yml b/tests/integration/targets/nios_network/tasks/main.yml index c147af8f..040cb8a8 100644 --- a/tests/integration/targets/nios_network/tasks/main.yml +++ b/tests/integration/targets/nios_network/tasks/main.yml @@ -1 +1 @@ -- include: nios_network_idempotence.yml +- include_tasks: nios_network_idempotence.yml diff --git a/tests/integration/targets/nios_network_view/tasks/main.yml b/tests/integration/targets/nios_network_view/tasks/main.yml index 97e87148..0acf4a4c 100644 --- a/tests/integration/targets/nios_network_view/tasks/main.yml +++ b/tests/integration/targets/nios_network_view/tasks/main.yml @@ -1 +1 @@ -- include: nios_network_view_idempotence.yml +- include_tasks: nios_network_view_idempotence.yml diff --git a/tests/integration/targets/nios_ptr_record/tasks/main.yml b/tests/integration/targets/nios_ptr_record/tasks/main.yml index ec33e8f5..29fbb5fe 100644 --- a/tests/integration/targets/nios_ptr_record/tasks/main.yml +++ b/tests/integration/targets/nios_ptr_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_ptr_record_idempotence.yml +- include_tasks: nios_ptr_record_idempotence.yml diff --git a/tests/integration/targets/nios_srv_record/tasks/main.yml b/tests/integration/targets/nios_srv_record/tasks/main.yml index 1c847673..4e4dd166 100644 --- a/tests/integration/targets/nios_srv_record/tasks/main.yml +++ b/tests/integration/targets/nios_srv_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_srv_record_idempotence.yml +- include_tasks: nios_srv_record_idempotence.yml diff --git a/tests/integration/targets/nios_txt_record/tasks/main.yml b/tests/integration/targets/nios_txt_record/tasks/main.yml index e15b4c55..0acbc091 100644 --- a/tests/integration/targets/nios_txt_record/tasks/main.yml +++ b/tests/integration/targets/nios_txt_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_txt_record_idempotence.yml +- include_tasks: nios_txt_record_idempotence.yml diff --git a/tests/integration/targets/nios_zone/tasks/main.yml b/tests/integration/targets/nios_zone/tasks/main.yml index f066edcd..cb335970 100644 --- a/tests/integration/targets/nios_zone/tasks/main.yml +++ b/tests/integration/targets/nios_zone/tasks/main.yml @@ -1 +1 @@ -- include: nios_zone_idempotence.yml +- include_tasks: nios_zone_idempotence.yml diff --git a/tests/integration/targets/prepare_nios_tests/tasks/main.yml b/tests/integration/targets/prepare_nios_tests/tasks/main.yml index 2a3092f3..e3c03fb3 100644 --- a/tests/integration/targets/prepare_nios_tests/tasks/main.yml +++ b/tests/integration/targets/prepare_nios_tests/tasks/main.yml @@ -1 +1 @@ -- include: prepare_nios_tests_idempotence.yml +- include_tasks: prepare_nios_tests_idempotence.yml diff --git a/tests/unit/requirements.txt b/tests/unit/requirements.txt index a0a2eb7e..883f6010 100644 --- a/tests/unit/requirements.txt +++ b/tests/unit/requirements.txt @@ -5,4 +5,4 @@ pytest-xdist mock pytest-mock pytest-cov -coverage==4.5.4 +coverage==6.5.0 From 0195dd8f5c538bad7b24ba9c10982ea8fead36b2 Mon Sep 17 00:00:00 2001 From: jbisabel <87313000+jbisabel@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:28:28 +0100 Subject: [PATCH 03/29] fix: Add lb_preferred_topology option to dtc:pools (#193) * fix: topology for dtc pools * fix: trailing whitespace * fix: better error handling --- plugins/modules/nios_dtc_pool.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/modules/nios_dtc_pool.py b/plugins/modules/nios_dtc_pool.py index 422d76f1..17401987 100644 --- a/plugins/modules/nios_dtc_pool.py +++ b/plugins/modules/nios_dtc_pool.py @@ -41,6 +41,12 @@ - TOPOLOGY required: true type: str + lb_preferred_topology: + description: + - Configures the topology rules for the C(TOPOLOGY) load balancing method. + - Required only when I(lb_preferred_method) is set to C(TOPOLOGY). + required: false + type: str servers: description: - Configure the DTC Servers related to the pool @@ -185,6 +191,16 @@ def monitors_transform(module): monitor_list.append(monitor_obj[0]['_ref']) return monitor_list + def topology_transform(module): + topology = module.params['lb_preferred_topology'] + if topology: + topo_obj = wapi.get_object('dtc:topology', {'name': topology}) + if topo_obj: + return topo_obj[0]['_ref'] + else: + module.fail_json( + msg='topology %s cannot be found.' % topology) + servers_spec = dict( server=dict(required=True), ratio=dict(type='int', default=1) @@ -203,6 +219,7 @@ def monitors_transform(module): 'RATIO', 'ROUND_ROBIN', 'TOPOLOGY']), + lb_preferred_topology=dict(type='str', transform=topology_transform), servers=dict(type='list', elements='dict', options=servers_spec, transform=servers_transform), From 6440c52b0dfff20eb2fc2735d76078b8376beab3 Mon Sep 17 00:00:00 2001 From: jbisabel <87313000+jbisabel@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:30:27 +0100 Subject: [PATCH 04/29] Feat/monitors (#194) * feat: DTC TCP monitor * fix: linting+sanity tests * fix: remove test * fix: wrongly named integration test directory * fix: more linting fun * fix: attempt at fixing integration test by not using cannonical name for new module * fix: roll back previous commit * feat: add ICMP monitor * feat: add example playbooks for ICMP monitor * fix: icmp unit test * feat: DTC PDP monitor support * fix: default for PDP port * feat: HTTP monitor * fix: forgot to declare constant * fix: small copy-paste error in docs * feat: add support for SIP DTC monitors * feat: Add support for DTC SNMP monitors * fix: unit test * feat: first stab at topology support * fix: unit test * fix: unit test * fix: unit test * chore: typos * chore: linting * fix: topology rule transform * feat: add new modules to README * fix: integration tests * fix: topology integration test --- CHANGELOG.rst | 20 ++ README.md | 14 + changelogs/.plugin-cache.yaml | 35 +++ changelogs/changelog.yaml | 26 ++ galaxy.yml | 2 +- playbooks/create_dtc_monitor_http.yaml | 19 ++ playbooks/create_dtc_monitor_icmp.yaml | 17 ++ playbooks/create_dtc_monitor_pdp.yaml | 17 ++ playbooks/create_dtc_monitor_sip.yaml | 17 ++ playbooks/create_dtc_monitor_snmp.yaml | 17 ++ playbooks/create_dtc_monitor_tcp.yaml | 18 ++ playbooks/create_dtc_topology.yml | 31 ++ playbooks/delete_dtc_monitor_http.yaml | 16 + playbooks/delete_dtc_monitor_icmp.yaml | 16 + playbooks/delete_dtc_monitor_pdp.yaml | 16 + playbooks/delete_dtc_monitor_sip.yaml | 16 + playbooks/delete_dtc_monitor_snmp.yaml | 16 + playbooks/delete_dtc_monitor_tcp.yaml | 16 + playbooks/delete_dtc_topology.yml | 16 + plugins/module_utils/api.py | 7 + plugins/modules/nios_dtc_monitor_http.py | 272 +++++++++++++++++ plugins/modules/nios_dtc_monitor_icmp.py | 154 ++++++++++ plugins/modules/nios_dtc_monitor_pdp.py | 159 ++++++++++ plugins/modules/nios_dtc_monitor_sip.py | 209 +++++++++++++ plugins/modules/nios_dtc_monitor_snmp.py | 279 ++++++++++++++++++ plugins/modules/nios_dtc_monitor_tcp.py | 160 ++++++++++ plugins/modules/nios_dtc_topology.py | 250 ++++++++++++++++ .../targets/nios_dtc_monitor_http/aliases | 3 + .../nios_dtc_monitor_http/defaults/main.yaml | 3 + .../nios_dtc_monitor_http/meta/main.yaml | 2 + .../nios_dtc_monitor_http/tasks/main.yaml | 1 + .../nios_dtc_monitor_http_idempotence.yaml | 75 +++++ .../targets/nios_dtc_monitor_icmp/aliases | 3 + .../nios_dtc_monitor_icmp/defaults/main.yaml | 3 + .../nios_dtc_monitor_icmp/meta/main.yaml | 2 + .../nios_dtc_monitor_icmp/tasks/main.yaml | 1 + .../nios_dtc_monitor_icmp_idempotence.yaml | 71 +++++ .../targets/nios_dtc_monitor_pdp/aliases | 3 + .../nios_dtc_monitor_pdp/defaults/main.yaml | 3 + .../nios_dtc_monitor_pdp/meta/main.yaml | 2 + .../nios_dtc_monitor_pdp/tasks/main.yaml | 1 + .../nios_dtc_monitor_pdp_idempotence.yaml | 71 +++++ .../targets/nios_dtc_monitor_sip/aliases | 3 + .../nios_dtc_monitor_sip/defaults/main.yaml | 3 + .../nios_dtc_monitor_sip/meta/main.yaml | 2 + .../nios_dtc_monitor_sip/tasks/main.yaml | 1 + .../nios_dtc_monitor_sip_idempotence.yaml | 71 +++++ .../targets/nios_dtc_monitor_snmp/aliases | 3 + .../nios_dtc_monitor_snmp/defaults/main.yaml | 3 + .../nios_dtc_monitor_snmp/meta/main.yaml | 2 + .../nios_dtc_monitor_snmp/tasks/main.yaml | 1 + .../nios_dtc_monitor_snmp_idempotence.yaml | 71 +++++ .../targets/nios_dtc_monitor_tcp/aliases | 3 + .../nios_dtc_monitor_tcp/defaults/main.yaml | 3 + .../nios_dtc_monitor_tcp/meta/main.yaml | 2 + .../nios_dtc_monitor_tcp/tasks/main.yaml | 1 + .../nios_dtc_monitor_tcp_idempotence.yaml | 73 +++++ .../targets/nios_dtc_topology/aliases | 3 + .../nios_dtc_topology/defaults/main.yaml | 3 + .../targets/nios_dtc_topology/meta/main.yaml | 2 + .../targets/nios_dtc_topology/tasks/main.yaml | 1 + .../tasks/nios_dtc_topology_idempotence.yaml | 122 ++++++++ .../modules/test_nios_dtc_monitor_http.py | 136 +++++++++ .../modules/test_nios_dtc_monitor_icmp.py | 129 ++++++++ .../modules/test_nios_dtc_monitor_pdp.py | 131 ++++++++ .../modules/test_nios_dtc_monitor_sip.py | 129 ++++++++ .../modules/test_nios_dtc_monitor_snmp.py | 143 +++++++++ .../modules/test_nios_dtc_monitor_tcp.py | 133 +++++++++ .../plugins/modules/test_nios_dtc_topology.py | 156 ++++++++++ 69 files changed, 3408 insertions(+), 1 deletion(-) create mode 100644 playbooks/create_dtc_monitor_http.yaml create mode 100644 playbooks/create_dtc_monitor_icmp.yaml create mode 100644 playbooks/create_dtc_monitor_pdp.yaml create mode 100644 playbooks/create_dtc_monitor_sip.yaml create mode 100644 playbooks/create_dtc_monitor_snmp.yaml create mode 100644 playbooks/create_dtc_monitor_tcp.yaml create mode 100644 playbooks/create_dtc_topology.yml create mode 100644 playbooks/delete_dtc_monitor_http.yaml create mode 100644 playbooks/delete_dtc_monitor_icmp.yaml create mode 100644 playbooks/delete_dtc_monitor_pdp.yaml create mode 100644 playbooks/delete_dtc_monitor_sip.yaml create mode 100644 playbooks/delete_dtc_monitor_snmp.yaml create mode 100644 playbooks/delete_dtc_monitor_tcp.yaml create mode 100644 playbooks/delete_dtc_topology.yml create mode 100644 plugins/modules/nios_dtc_monitor_http.py create mode 100644 plugins/modules/nios_dtc_monitor_icmp.py create mode 100644 plugins/modules/nios_dtc_monitor_pdp.py create mode 100644 plugins/modules/nios_dtc_monitor_sip.py create mode 100644 plugins/modules/nios_dtc_monitor_snmp.py create mode 100644 plugins/modules/nios_dtc_monitor_tcp.py create mode 100644 plugins/modules/nios_dtc_topology.py create mode 100644 tests/integration/targets/nios_dtc_monitor_http/aliases create mode 100644 tests/integration/targets/nios_dtc_monitor_http/defaults/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_http/meta/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_http/tasks/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_http/tasks/nios_dtc_monitor_http_idempotence.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_icmp/aliases create mode 100644 tests/integration/targets/nios_dtc_monitor_icmp/defaults/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_icmp/meta/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_icmp/tasks/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_icmp/tasks/nios_dtc_monitor_icmp_idempotence.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_pdp/aliases create mode 100644 tests/integration/targets/nios_dtc_monitor_pdp/defaults/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_pdp/meta/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_pdp/tasks/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_pdp/tasks/nios_dtc_monitor_pdp_idempotence.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_sip/aliases create mode 100644 tests/integration/targets/nios_dtc_monitor_sip/defaults/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_sip/meta/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_sip/tasks/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_sip/tasks/nios_dtc_monitor_sip_idempotence.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_snmp/aliases create mode 100644 tests/integration/targets/nios_dtc_monitor_snmp/defaults/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_snmp/meta/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_snmp/tasks/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_snmp/tasks/nios_dtc_monitor_snmp_idempotence.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_tcp/aliases create mode 100644 tests/integration/targets/nios_dtc_monitor_tcp/defaults/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_tcp/meta/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_tcp/tasks/main.yaml create mode 100644 tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml create mode 100644 tests/integration/targets/nios_dtc_topology/aliases create mode 100644 tests/integration/targets/nios_dtc_topology/defaults/main.yaml create mode 100644 tests/integration/targets/nios_dtc_topology/meta/main.yaml create mode 100644 tests/integration/targets/nios_dtc_topology/tasks/main.yaml create mode 100644 tests/integration/targets/nios_dtc_topology/tasks/nios_dtc_topology_idempotence.yaml create mode 100644 tests/unit/plugins/modules/test_nios_dtc_monitor_http.py create mode 100644 tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py create mode 100644 tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py create mode 100644 tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py create mode 100644 tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py create mode 100644 tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py create mode 100644 tests/unit/plugins/modules/test_nios_dtc_topology.py diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a0094f6e..67f8e10e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,26 @@ Infoblox.Nios_Modules Release Notes .. contents:: Topics +v1.6.0 +====== + +Release Summary +--------------- + +This release provides plugins for NIOS DTC monitoring and topology + +New Modules +----------- + +- infoblox.nios_modules.nios_dtc_monitor_http - Configure Infoblox NIOS DTC HTTP monitor +- infoblox.nios_modules.nios_dtc_monitor_icmp - Configure Infoblox NIOS DTC ICMP monitor +- infoblox.nios_modules.nios_dtc_monitor_pdp - Configure Infoblox NIOS DTC PDP monitor +- infoblox.nios_modules.nios_dtc_monitor_sip - Configure Infoblox NIOS DTC SIP monitor +- infoblox.nios_modules.nios_dtc_monitor_snmp - Configure Infoblox NIOS DTC SNMP monitor +- infoblox.nios_modules.nios_dtc_monitor_tcp - Configure Infoblox NIOS DTC TCP monitor +- infoblox.nios_modules.nios_dtc_topology - Configure Infoblox NIOS DTC Topology + + v1.5.0 ====== diff --git a/README.md b/README.md index a5b72d0b..bc00c1d6 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,24 @@ Modules - `nios_dtc_lbdn` – Configure Infoblox NIOS DTC LBDN records +- `nios_dtc_monitor_http` – Configure Infoblox NIOS DTC HTTP monitors + +- `nios_dtc_monitor_icmp` – Configure Infoblox NIOS DTC ICMP monitors + +- `nios_dtc_monitor_pdp` – Configure Infoblox NIOS DTC PDP monitors + +- `nios_dtc_monitor_sip` – Configure Infoblox NIOS DTC SIP monitors + +- `nios_dtc_monitor_snmp` – Configure Infoblox NIOS DTC SNMP monitors + +- `nios_dtc_monitor_tcp` – Configure Infoblox NIOS DTC TCP monitors + - `nios_dtc_pool` – Configure Infoblox NIOS DTC pools - `nios_dtc_server` – Configure Infoblox NIOS DTC server records +- `nios_dtc_topology` – Configure Infoblox NIOS DTC topologies + - `nios_fixed_address` – Configure Infoblox NIOS DHCP Fixed Address - `nios_host_record` – Configure Infoblox NIOS host records diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index f7b27505..f36ee335 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -59,6 +59,41 @@ plugins: name: nios_dtc_server namespace: '' version_added: 1.1.0 + nios_dtc_monitor_http: + description: Configure Infoblox NIOS DTC HTTP monitor + name: nios_dtc_monitor_http + namespace: '' + version_added: 1.6.0 + nios_dtc_monitor_tcp: + description: Configure Infoblox NIOS DTC TCP monitor + name: nios_dtc_monitor_tcp + namespace: '' + version_added: 1.6.0 + nios_dtc_monitor_icmp: + description: Configure Infoblox NIOS DTC ICMP monitor + name: nios_dtc_monitor_icmp + namespace: '' + version_added: 1.6.0 + nios_dtc_monitor_pdp: + description: Configure Infoblox NIOS DTC PDP monitor + name: nios_dtc_monitor_pdp + namespace: '' + version_added: 1.6.0 + nios_dtc_monitor_sip: + description: Configure Infoblox NIOS DTC SIP monitor + name: nios_dtc_monitor_sip + namespace: '' + version_added: 1.6.0 + nios_dtc_monitor_snmp: + description: Configure Infoblox NIOS DTC SNMP monitor + name: nios_dtc_monitor_snmp + namespace: '' + version_added: 1.6.0 + nios_dtc_topology: + description: Configure Infoblox NIOS DTC Topology + name: nios_dtc_topology + namespace: '' + version_added: 1.6.0 nios_fixed_address: description: Configure Infoblox NIOS DHCP Fixed Address name: nios_fixed_address diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index ac91562e..3e822d3b 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -217,3 +217,29 @@ releases: Updates default WAPI version to `2.9`, Added Grid Master Candidate feature' release_date: '2023-05-11' + 1.6.0: + changes: + release_summary: This release provides plugins for NIOS DTC monitoring + modules: + - description: Configure Infoblox NIOS DTC HTTP monitor + name: nios_dtc_monitor_http + namespace: '' + - description: Configure Infoblox NIOS DTC ICMP monitor + name: nios_dtc_monitor_icmp + namespace: '' + - description: Configure Infoblox NIOS DTC PDP monitor + name: nios_dtc_monitor_pdp + namespace: '' + - description: Configure Infoblox NIOS DTC SIP monitor + name: nios_dtc_monitor_sip + namespace: '' + - description: Configure Infoblox NIOS DTC SNMP monitor + name: nios_dtc_monitor_snpp + namespace: '' + - description: Configure Infoblox NIOS DTC TCP monitor + name: nios_dtc_monitor_tcp + namespace: '' + - description: Configure Infoblox NIOS DTC Topology + name: nios_dtc_topology + namespace: '' + release_date: 'tbd' diff --git a/galaxy.yml b/galaxy.yml index 717fbe6b..043d7d86 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -9,7 +9,7 @@ namespace: infoblox name: nios_modules # The version of the collection. Must be compatible with semantic versioning -version: 1.5.0 +version: 1.6.0 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/playbooks/create_dtc_monitor_http.yaml b/playbooks/create_dtc_monitor_http.yaml new file mode 100644 index 00000000..2d2afc3e --- /dev/null +++ b/playbooks/create_dtc_monitor_http.yaml @@ -0,0 +1,19 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Create Nios DTC HTTPS monitor Test + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + port: 443 + secure: true + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_dtc_monitor_icmp.yaml b/playbooks/create_dtc_monitor_icmp.yaml new file mode 100644 index 00000000..f792cfa6 --- /dev/null +++ b/playbooks/create_dtc_monitor_icmp.yaml @@ -0,0 +1,17 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Create Nios DTC ICMP monitor Test + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_dtc_monitor_pdp.yaml b/playbooks/create_dtc_monitor_pdp.yaml new file mode 100644 index 00000000..ea2bc9b9 --- /dev/null +++ b/playbooks/create_dtc_monitor_pdp.yaml @@ -0,0 +1,17 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Create Nios DTC PDP monitor Test + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_dtc_monitor_sip.yaml b/playbooks/create_dtc_monitor_sip.yaml new file mode 100644 index 00000000..4caa32ea --- /dev/null +++ b/playbooks/create_dtc_monitor_sip.yaml @@ -0,0 +1,17 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Create Nios DTC SIP monitor Test + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_dtc_monitor_snmp.yaml b/playbooks/create_dtc_monitor_snmp.yaml new file mode 100644 index 00000000..b8b796ee --- /dev/null +++ b/playbooks/create_dtc_monitor_snmp.yaml @@ -0,0 +1,17 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Create Nios DTC SNMP monitor Test + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_dtc_monitor_tcp.yaml b/playbooks/create_dtc_monitor_tcp.yaml new file mode 100644 index 00000000..95a824a1 --- /dev/null +++ b/playbooks/create_dtc_monitor_tcp.yaml @@ -0,0 +1,18 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Create Nios DTC TCP monitor Test + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + port: 8080 + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_dtc_topology.yml b/playbooks/create_dtc_topology.yml new file mode 100644 index 00000000..01c50bd4 --- /dev/null +++ b/playbooks/create_dtc_topology.yml @@ -0,0 +1,31 @@ +--- +- hosts: localhost + vars: + nios_provider: + host: 10.196.205.10 + username: cloudadmin + password: infoblox + wapi_version: "2.12" + + connection: local + tasks: + - name: Create a DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + rules: + - dest_type: POOL + destination_link: web_pool1 + return_type: REGULAR + sources: + - source_op: IS + source_type: EA0 + source_value: DC1 + - dest_type: POOL + destination_link: web_pool2 + return_type: REGULAR + sources: + - source_op: IS + source_type: EA0 + source_value: DC2 + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_dtc_monitor_http.yaml b/playbooks/delete_dtc_monitor_http.yaml new file mode 100644 index 00000000..29427ebd --- /dev/null +++ b/playbooks/delete_dtc_monitor_http.yaml @@ -0,0 +1,16 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Delete Nios DTC HTTPS monitor Test + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_dtc_monitor_icmp.yaml b/playbooks/delete_dtc_monitor_icmp.yaml new file mode 100644 index 00000000..eca2975f --- /dev/null +++ b/playbooks/delete_dtc_monitor_icmp.yaml @@ -0,0 +1,16 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Delete Nios DTC ICMP monitor Test + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_dtc_monitor_pdp.yaml b/playbooks/delete_dtc_monitor_pdp.yaml new file mode 100644 index 00000000..b69fb462 --- /dev/null +++ b/playbooks/delete_dtc_monitor_pdp.yaml @@ -0,0 +1,16 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Delete Nios DTC PDP monitor Test + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_dtc_monitor_sip.yaml b/playbooks/delete_dtc_monitor_sip.yaml new file mode 100644 index 00000000..10cc49dd --- /dev/null +++ b/playbooks/delete_dtc_monitor_sip.yaml @@ -0,0 +1,16 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Delete Nios DTC SIP monitor Test + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_dtc_monitor_snmp.yaml b/playbooks/delete_dtc_monitor_snmp.yaml new file mode 100644 index 00000000..972751a6 --- /dev/null +++ b/playbooks/delete_dtc_monitor_snmp.yaml @@ -0,0 +1,16 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Delete Nios DTC SNMP monitor Test + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_dtc_monitor_tcp.yaml b/playbooks/delete_dtc_monitor_tcp.yaml new file mode 100644 index 00000000..662df448 --- /dev/null +++ b/playbooks/delete_dtc_monitor_tcp.yaml @@ -0,0 +1,16 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: Delete Nios DTC TCP monitor Test + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_dtc_topology.yml b/playbooks/delete_dtc_topology.yml new file mode 100644 index 00000000..c80fa117 --- /dev/null +++ b/playbooks/delete_dtc_topology.yml @@ -0,0 +1,16 @@ +--- +- hosts: localhost + vars: + nios_provider: + host: 10.196.205.10 + username: cloudadmin + password: infoblox + wapi_version: "2.12" + + connection: local + tasks: + - name: Delete a DTC Topology + nios_dtc_topology: + name: a_topology + state: absent + provider: "{{ nios_provider }}" diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 51c51257..e1616ad9 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -71,6 +71,13 @@ NIOS_DTC_SERVER = 'dtc:server' NIOS_DTC_POOL = 'dtc:pool' NIOS_DTC_LBDN = 'dtc:lbdn' +NIOS_DTC_MONITOR_HTTP = 'dtc:monitor:http' +NIOS_DTC_MONITOR_ICMP = 'dtc:monitor:icmp' +NIOS_DTC_MONITOR_PDP = 'dtc:monitor:pdp' +NIOS_DTC_MONITOR_SIP = 'dtc:monitor:sip' +NIOS_DTC_MONITOR_SNMP = 'dtc:monitor:snmp' +NIOS_DTC_MONITOR_TCP = 'dtc:monitor:tcp' +NIOS_DTC_TOPOLOGY = 'dtc:topology' NIOS_PROVIDER_SPEC = { 'host': dict(fallback=(env_fallback, ['INFOBLOX_HOST'])), diff --git a/plugins/modules/nios_dtc_monitor_http.py b/plugins/modules/nios_dtc_monitor_http.py new file mode 100644 index 00000000..b90e98a0 --- /dev/null +++ b/plugins/modules/nios_dtc_monitor_http.py @@ -0,0 +1,272 @@ +#!/usr/bin/python +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_dtc_monitor_http +author: "Joachim Buyse (@jbisabel)" +version_added: "1.6.0" +short_description: Configure Infoblox NIOS DTC HTTP monitors +description: + - Adds and/or removes instances of DTC HTTP monitor objects from Infoblox NIOS + servers. This module manages C(dtc:monitor:http) objects using the Infoblox + WAPI interface over REST. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + name: + description: + - Configures the display name for this DTC monitor. Values with leading + or trailing white space are not valid for this field. + required: true + type: str + port: + description: + - Configures the port value for HTTP requests. + type: int + default: 80 + ciphers: + description: + - Configures an optional cipher list for the secure HTTP/S connection. + type: str + client_cert: + description: + - Configures an optional client certificate, supplied in a secure HTTP/S + mode if present. + type: str + content_check: + description: + - Configures the content check type + type: str + choices: + - EXTRACT + - MATCH + - NONE + default: NONE + content_check_input: + description: + - Configures the portion of the response to use as input for content check. + type: str + choices: + - ALL + - BODY + - HEADERS + default: ALL + content_check_op: + description: + - Configures the content check success criteria operator. + type: str + choices: + - EQ + - GEQ + - LEQ + - NEQ + content_check_regex: + description: + - Configures the content check regular expression. Values with leading + or trailing white space are not valid for this field. + type: str + content_extract_group: + description: + - Configures the content extraction sub-expression to extract. + type: int + default: 0 + content_extract_type: + description: + - Configures the content extraction expected type for the extracted data. + type: str + choices: + - INTEGER + - STRING + default: STRING + content_extract_value: + description: + - Configures the content extraction value to compare with the extracted + result. Values with leading or trailing white space are not valid for + this field. + type: str + request: + description: + - Configures the HTTP request to send + type: str + default: GET / + result: + description: + - Configures the type of the expected result + type: str + choices: + - ANY + - CODE_IS + - CODE_IS_NOT + default: ANY + result_code: + description: + - Configures the expected return code + type: int + default: 200 + enable_sni: + description: + - Configures whether or not Server Name Indication (SNI) for the HTTPS + monitor is enabled. + type: bool + default: false + secure: + description: + - Configures the security status of the connection. + type: bool + default: false + validate_cert: + description: + - Configures whether the validation of the remote server's certificate is + enabled. + type: bool + default: true + interval: + description: + - Configures the interval for HTTP health check. + type: int + default: 5 + retry_down: + description: + - Configures the value of how many times the server should appear as + down to be treated as dead after it was alive. + type: int + default: 1 + retry_up: + description: + - Configures the value of how many times the server should appear as up + to be treated as alive after it was dead. + type: int + default: 1 + timeout: + description: + - Configures the timeout for HTTP health check in seconds. + type: int + default: 15 + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + default: present + choices: + - present + - absent + type: str +''' + +EXAMPLES = ''' +- name: Configure a DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + port: 443 + secure: true + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to an existing DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a DTC HTTPS monitor from the system + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_DTC_MONITOR_HTTP +from ..module_utils.api import normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + + ib_spec = dict( + name=dict(required=True, ib_req=True), + + port=dict(type='int', default=80), + ciphers=dict(type='str'), + client_cert=dict(type='str'), + content_check=dict(default='NONE', choices=['EXTRACT', 'MATCH', 'NONE']), + content_check_input=dict(default='ALL', choices=['ALL', 'BODY', 'HEADERS']), + content_check_op=dict(choices=['EQ', 'GEQ', 'LEQ', 'NEQ']), + content_check_regex=dict(type='str'), + content_extract_group=dict(type='int', default=0), + content_extract_type=dict(default='STRING', choices=['INTEGER', 'STRING']), + content_extract_value=dict(type='str'), + request=dict(type='str', default='GET /'), + result=dict(default='ANY', choices=['ANY', 'CODE_IS', 'CODE_IS_NOT']), + result_code=dict(type='int', default=200), + enable_sni=dict(type='bool', default=False), + secure=dict(type='bool', default=False), + validate_cert=dict(type='bool', default=True), + interval=dict(type='int', default=5), + retry_down=dict(type='int', default=1), + retry_up=dict(type='int', default=1), + timeout=dict(type='int', default=15), + + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']) + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_DTC_MONITOR_HTTP, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_dtc_monitor_icmp.py b/plugins/modules/nios_dtc_monitor_icmp.py new file mode 100644 index 00000000..e133954e --- /dev/null +++ b/plugins/modules/nios_dtc_monitor_icmp.py @@ -0,0 +1,154 @@ +#!/usr/bin/python +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_dtc_monitor_icmp +author: "Joachim Buyse (@jbisabel)" +version_added: "1.6.0" +short_description: Configure Infoblox NIOS DTC ICMP monitors +description: + - Adds and/or removes instances of DTC ICMP monitor objects from Infoblox NIOS + servers. This module manages C(dtc:monitor:icmp) objects using the Infoblox + WAPI interface over REST. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + name: + description: + - Configures the display name for this DTC monitor. Values with leading + or trailing white space are not valid for this field. + required: true + type: str + interval: + description: + - Configures the interval for ICMP health check. + type: int + default: 5 + retry_down: + description: + - Configures the value of how many times the server should appear as + down to be treated as dead after it was alive. + type: int + default: 1 + retry_up: + description: + - Configures the value of how many times the server should appear as up + to be treated as alive after it was dead. + type: int + default: 1 + timeout: + description: + - Configures the timeout for ICMP health check in seconds. + type: int + default: 15 + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + default: present + choices: + - present + - absent + type: str +''' + +EXAMPLES = ''' +- name: Configure a DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + port: 8080 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to an existing DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a DTC ICMP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_DTC_MONITOR_ICMP +from ..module_utils.api import normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + + ib_spec = dict( + name=dict(required=True, ib_req=True), + + interval=dict(type='int', default=5), + retry_down=dict(type='int', default=1), + retry_up=dict(type='int', default=1), + timeout=dict(type='int', default=15), + + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']) + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_DTC_MONITOR_ICMP, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_dtc_monitor_pdp.py b/plugins/modules/nios_dtc_monitor_pdp.py new file mode 100644 index 00000000..d9cf8e4a --- /dev/null +++ b/plugins/modules/nios_dtc_monitor_pdp.py @@ -0,0 +1,159 @@ +#!/usr/bin/python +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_dtc_monitor_pdp +author: "Joachim Buyse (@jbisabel)" +version_added: "1.6.0" +short_description: Configure Infoblox NIOS DTC PDP monitors +description: + - Adds and/or removes instances of DTC PDP monitor objects from Infoblox NIOS + servers. This module manages C(dtc:monitor:pdp) objects using the Infoblox + WAPI interface over REST. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + name: + description: + - Configures the display name for this DTC monitor. Values with leading + or trailing white space are not valid for this field. + required: true + type: str + port: + description: + - Configures the port value for PDP requests. + type: int + default: 2123 + interval: + description: + - Configures the interval for PDP health check. + type: int + default: 5 + retry_down: + description: + - Configures the value of how many times the server should appear as + down to be treated as dead after it was alive. + type: int + default: 1 + retry_up: + description: + - Configures the value of how many times the server should appear as up + to be treated as alive after it was dead. + type: int + default: 1 + timeout: + description: + - Configures the timeout for PDP health check in seconds. + type: int + default: 15 + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + default: present + choices: + - present + - absent + type: str +''' + +EXAMPLES = ''' +- name: Configure a DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to an existing DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a DTC PDP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_DTC_MONITOR_PDP +from ..module_utils.api import normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + + ib_spec = dict( + name=dict(required=True, ib_req=True), + + port=dict(type='int', default=2123), + interval=dict(type='int', default=5), + retry_down=dict(type='int', default=1), + retry_up=dict(type='int', default=1), + timeout=dict(type='int', default=15), + + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']) + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_DTC_MONITOR_PDP, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_dtc_monitor_sip.py b/plugins/modules/nios_dtc_monitor_sip.py new file mode 100644 index 00000000..c1df0985 --- /dev/null +++ b/plugins/modules/nios_dtc_monitor_sip.py @@ -0,0 +1,209 @@ +#!/usr/bin/python +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_dtc_monitor_sip +author: "Joachim Buyse (@jbisabel)" +version_added: "1.6.0" +short_description: Configure Infoblox NIOS DTC SIP monitors +description: + - Adds and/or removes instances of DTC SIP monitor objects from Infoblox NIOS + servers. This module manages C(dtc:monitor:sip) objects using the Infoblox + WAPI interface over REST. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + name: + description: + - Configures the display name for this DTC monitor. Values with leading + or trailing white space are not valid for this field. + required: true + type: str + port: + description: + - Configures the port value for SIP requests. + type: int + default: 5060 + ciphers: + description: + - Configures an optional cipher list for the secure TLS/SIPS connection. + type: str + client_cert: + description: + - Configures an optional client certificate, supplied in TLS or SIPS mode + if present. + type: str + request: + description: + - Configures the SIP request to send + type: str + result: + description: + - Configures the type of the expected result + type: str + choices: + - ANY + - CODE_IS + - CODE_IS_NOT + default: ANY + result_code: + description: + - Configures the expected return code + type: int + default: 200 + transport: + description: + - Configures the transport layer protocol to use for the SIP check + type: str + choices: + - SIPS + - TCP + - TLS + - UDP + default: TCP + validate_cert: + description: + - Configures whether the validation of the remote server's certificate is + enabled. + type: bool + default: true + interval: + description: + - Configures the interval for SIP health check. + type: int + default: 5 + retry_down: + description: + - Configures the value of how many times the server should appear as + down to be treated as dead after it was alive. + type: int + default: 1 + retry_up: + description: + - Configures the value of how many times the server should appear as up + to be treated as alive after it was dead. + type: int + default: 1 + timeout: + description: + - Configures the timeout for SIP health check in seconds. + type: int + default: 15 + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + default: present + choices: + - present + - absent + type: str +''' + +EXAMPLES = ''' +- name: Configure a DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to an existing DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a DTC SIP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_DTC_MONITOR_SIP +from ..module_utils.api import normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + + ib_spec = dict( + name=dict(required=True, ib_req=True), + + port=dict(type='int', default=5060), + ciphers=dict(type='str'), + client_cert=dict(type='str'), + request=dict(type='str'), + result=dict(default='ANY', choices=['ANY', 'CODE_IS', 'CODE_IS_NOT']), + result_code=dict(type='int', default=200), + transport=dict(default='TCP', choices=['SIPS', 'TCP', 'TLS', 'UDP']), + validate_cert=dict(type='bool', default=True), + interval=dict(type='int', default=5), + retry_down=dict(type='int', default=1), + retry_up=dict(type='int', default=1), + timeout=dict(type='int', default=15), + + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']) + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_DTC_MONITOR_SIP, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_dtc_monitor_snmp.py b/plugins/modules/nios_dtc_monitor_snmp.py new file mode 100644 index 00000000..036580e8 --- /dev/null +++ b/plugins/modules/nios_dtc_monitor_snmp.py @@ -0,0 +1,279 @@ +#!/usr/bin/python +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_dtc_monitor_snmp +author: "Joachim Buyse (@jbisabel)" +version_added: "1.6.0" +short_description: Configure Infoblox NIOS DTC SNMP monitors +description: + - Adds and/or removes instances of DTC SNMP monitor objects from Infoblox NIOS + servers. This module manages C(dtc:monitor:snmp) objects using the Infoblox + WAPI interface over REST. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + name: + description: + - Configures the display name for this DTC monitor. Values with leading + or trailing white space are not valid for this field. + required: true + type: str + port: + description: + - Configures the port value for SNMP requests. + type: int + default: 161 + version: + description: + - Configures the SNMP protocol version for the SNMP health check. + type: str + choices: + - V1 + - V2C + - V3 + default: V2C + community: + description: + - Configures the SNMP community string for SNMP authentication. + type: str + default: public + user: + description: + - Configures the SNMPv3 user setting. + type: str + context: + description: + - Configures the SNMPv3 context. Values with leading or trailing white + space are not valid for this field. + type: str + engine_id: + description: + - Configures the SNMPv3 engine identifier. Values with leading or + trailing white space are not valid for this field. + type: str + oids: + description: + - Configures the list of OIDs for SNMP monitoring. + type: list + elements: dict + suboptions: + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + type: str + condition: + description: + - Configures the condition of the validation result for the SNMP + health check. + type: str + choices: + - ANY + - EXACT + - GEQ + - LEQ + - RANGE + default: ANY + first: + description: + - Configures the condition's first term to match against the SNMP + health check result. + type: str + last: + description: + - Configures the condition's second term to match against the SNMP + health check result with 'RANGE' condition. + type: str + oid: + description: + - Configures the SNMP OID value for DTC SNMP Monitor health checks. + - This field is required on creation + required: true + type: str + type: + description: + - Configures the condition type for DTC SNMP Monitor health checks + results. + type: str + choices: + - INTEGER + - STRING + default: STRING + interval: + description: + - Configures the interval for SNMP health check. + type: int + default: 5 + retry_down: + description: + - Configures the value of how many times the server should appear as + down to be treated as dead after it was alive. + type: int + default: 1 + retry_up: + description: + - Configures the value of how many times the server should appear as up + to be treated as alive after it was dead. + type: int + default: 1 + timeout: + description: + - Configures the timeout for SNMP health check in seconds. + type: int + default: 15 + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + default: present + choices: + - present + - absent + type: str +''' + +EXAMPLES = ''' +- name: Configure a DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + port: 8080 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to an existing DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a DTC SNMP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.six import iteritems +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_DTC_MONITOR_SNMP +from ..module_utils.api import normalize_ib_spec + + +def oids(module): + ''' Transform the module argument into a valid WAPI struct + This function will transform the oids argument into a structure that is a + valid WAPI structure in the format of: + { + comment: , + condition: , + first: , + last: , + oid: , + type: , + } + It will remove any options that are set to None since WAPI will error on + that condition. + The remainder of the value validation is performed by WAPI + ''' + + oids = list() + for item in module.params['oids']: + oid = dict([(k, v) for k, v in iteritems(item) if v is not None]) + if 'oid' not in oid: + module.fail_json(msg='oid is required for oid value') + oids.append(oid) + return oids + + +def main(): + ''' Main entry point for module execution + ''' + + oid_spec = dict( + comment=dict(type='str'), + condition=dict(default='ANY', choices=['ANY', 'EXACT', 'GEQ', 'LEQ', 'RANGE']), + first=dict(type='str'), + last=dict(type='str'), + oid=dict(type='str', required=True), + type=dict(default='STRING', choices=['INTEGER', 'STRING']) + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + + port=dict(type='int', default=161), + version=dict(default='V2C', choices=['V1', 'V2C', 'V3']), + community=dict(type='str', default='public'), + user=dict(type='str'), + context=dict(type='str'), + engine_id=dict(type='str'), + oids=dict(type='list', elements='dict', options=oid_spec, transform=oids), + interval=dict(type='int', default=5), + retry_down=dict(type='int', default=1), + retry_up=dict(type='int', default=1), + timeout=dict(type='int', default=15), + + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']) + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_DTC_MONITOR_SNMP, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_dtc_monitor_tcp.py b/plugins/modules/nios_dtc_monitor_tcp.py new file mode 100644 index 00000000..f06b5cac --- /dev/null +++ b/plugins/modules/nios_dtc_monitor_tcp.py @@ -0,0 +1,160 @@ +#!/usr/bin/python +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_dtc_monitor_tcp +author: "Joachim Buyse (@jbisabel)" +version_added: "1.6.0" +short_description: Configure Infoblox NIOS DTC TCP monitors +description: + - Adds and/or removes instances of DTC TCP monitor objects from Infoblox NIOS + servers. This module manages C(dtc:monitor:tcp) objects using the Infoblox + WAPI interface over REST. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + name: + description: + - Configures the display name for this DTC monitor. Values with leading + or trailing white space are not valid for this field. + required: true + type: str + port: + description: + - Configures the port value for TCP requests. The field is required on + creation. + type: int + interval: + description: + - Configures the interval for TCP health check. + type: int + default: 5 + retry_down: + description: + - Configures the value of how many times the server should appear as + down to be treated as dead after it was alive. + type: int + default: 1 + retry_up: + description: + - Configures the value of how many times the server should appear as up + to be treated as alive after it was dead. + type: int + default: 1 + timeout: + description: + - Configures the timeout for TCP health check in seconds. + type: int + default: 15 + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + default: present + choices: + - present + - absent + type: str +''' + +EXAMPLES = ''' +- name: Configure a DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + port: 8080 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to an existing DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a DTC TCP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_DTC_MONITOR_TCP +from ..module_utils.api import normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + + ib_spec = dict( + name=dict(required=True, ib_req=True), + + port=dict(type='int'), + interval=dict(type='int', default=5), + retry_down=dict(type='int', default=1), + retry_up=dict(type='int', default=1), + timeout=dict(type='int', default=15), + + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']) + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_DTC_MONITOR_TCP, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_dtc_topology.py b/plugins/modules/nios_dtc_topology.py new file mode 100644 index 00000000..32a21528 --- /dev/null +++ b/plugins/modules/nios_dtc_topology.py @@ -0,0 +1,250 @@ +#!/usr/bin/python +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_dtc_topology +author: "Joachim Buyse (@jbisabel)" +short_description: Configure Infoblox NIOS DTC Topology +version_added: "1.6.0" +description: + - Adds and/or removes instances of DTC Topology objects from + Infoblox NIOS topologies. This module manages NIOS C(dtc:topology) objects + using the Infoblox WAPI interface over REST. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + name: + description: + - Specifies the DTC Topology display name. + required: true + type: str + rules: + description: + - Configures the topology rules + type: list + elements: dict + suboptions: + dest_type: + description: + - Configures the type of the destination for this DTC Topology Rule. + type: str + choices: + - POOL + - SERVER + required: true + destination_link: + description: + - Configures the name of the destination DTC pool or DTC server. + type: str + return_type: + description: + - Configures the type of the DNS response for the rule. + type: str + choices: + - NOERR + - NXDOMAIN + - REGULAR + default: REGULAR + sources: + description: + - Configures the conditions for matching sources. Should be empty to + set the rule as default destination. + type: list + elements: dict + suboptions: + source_op: + description: + - Configures the operation used to match the value. + type: str + choices: + - IS + - IS_NOT + source_type: + description: + - Configures the source type. + type: str + choices: + - CITY + - CONTINENT + - COUNTRY + - EA0 + - EA1 + - EA2 + - EA3 + - SUBDIVISION + - SUBNET + required: true + source_value: + description: + - Configures the source value. + type: str + required: true + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS topology. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + default: present + choices: + - present + - absent + type: str +''' + +EXAMPLES = ''' +- name: Configure a DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + rules: + - dest_type: POOL + destination_link: web_pool1 + return_type: REGULAR + sources: + - source_op: IS + source_type: EA0 + source_value: DC1 + - dest_type: POOL + destination_link: web_pool2 + return_type: REGULAR + sources: + - source_op: IS + source_type: EA0 + source_value: DC2 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to a DTC topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a DTC Topology from the system + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.six import iteritems +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_DTC_TOPOLOGY +from ..module_utils.api import normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + + def sources_transform(sources, module): + source_list = list() + for source in sources: + src = dict([(k, v) for k, v in iteritems(source) if v is not None]) + if 'source_type' not in src or 'source_value' not in src: + module.fail_json(msg='source_type and source_value are required for source') + source_list.append(src) + return source_list + + def rules_transform(module): + rule_list = list() + if not module.params['rules']: + return rule_list + for rule in module.params['rules']: + if rule['dest_type'] == 'POOL': + dest_obj = wapi.get_object('dtc:pool', {'name': rule['destination_link']}) + else: + dest_obj = wapi.get_object('dtc:server', {'name': rule['destination_link']}) + if not dest_obj: + module.fail_json(msg='destination_link %s does not exist' % rule['destination_link']) + + tf_rule = dict( + dest_type=rule['dest_type'], + destination_link=dest_obj[0]['_ref'], + return_type=rule['return_type'] + ) + + if rule['sources']: + tf_rule['sources'] = sources_transform(rule['sources'], module) + + rule_list.append(tf_rule) + return rule_list + + source_spec = dict( + source_op=dict(choices=['IS', 'IS_NOT']), + source_type=dict(required=True, choices=['CITY', 'CONTINENT', 'COUNTRY', 'EA0', 'EA1', 'EA2', 'EA3', 'SUBDIVISION', 'SUBNET']), + source_value=dict(required=True, type='str') + ) + + rule_spec = dict( + dest_type=dict(required=True, choices=['POOL', 'SERVER']), + destination_link=dict(type='str'), + return_type=dict(default='REGULAR', choices=['NOERR', 'NXDOMAIN', 'REGULAR']), + sources=dict(type='list', elements='dict', options=source_spec) + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + + rules=dict(type='list', elements='dict', options=rule_spec, transform=rules_transform), + + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']) + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_DTC_TOPOLOGY, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/tests/integration/targets/nios_dtc_monitor_http/aliases b/tests/integration/targets/nios_dtc_monitor_http/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_http/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_dtc_monitor_http/defaults/main.yaml b/tests/integration/targets/nios_dtc_monitor_http/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_http/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/tests/integration/targets/nios_dtc_monitor_http/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_http/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_http/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_http/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_http/tasks/main.yaml new file mode 100644 index 00000000..f774bfbf --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_http/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_http_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_http/tasks/nios_dtc_monitor_http_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_http/tasks/nios_dtc_monitor_http_idempotence.yaml new file mode 100644 index 00000000..8b3a4f40 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_http/tasks/nios_dtc_monitor_http_idempotence.yaml @@ -0,0 +1,75 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + port: 443 + secure: true + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_http_create1 + +- name: Recreate a DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + port: 443 + secure: true + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_http_create2 + +- name: Add a comment to an existing DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_http_update1 + +- name: Readd a comment to an existing DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_http_update2 + +- name: Remove a DTC HTTPS monitor from the system + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_http_delete1 + +- name: Reremove a DTC HTTPS monitor from the system + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_http_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_http_create1.changed" + - "not dtc_monitor_http_create2.changed" + - "dtc_monitor_http_update1.changed" + - "not dtc_monitor_http_update2.changed" + - "dtc_monitor_http_delete1.changed" + - "not dtc_monitor_http_delete2.changed" diff --git a/tests/integration/targets/nios_dtc_monitor_icmp/aliases b/tests/integration/targets/nios_dtc_monitor_icmp/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_icmp/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_dtc_monitor_icmp/defaults/main.yaml b/tests/integration/targets/nios_dtc_monitor_icmp/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_icmp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/tests/integration/targets/nios_dtc_monitor_icmp/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_icmp/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_icmp/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_icmp/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_icmp/tasks/main.yaml new file mode 100644 index 00000000..28bf85bd --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_icmp/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_icmp_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_icmp/tasks/nios_dtc_monitor_icmp_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_icmp/tasks/nios_dtc_monitor_icmp_idempotence.yaml new file mode 100644 index 00000000..984aa59a --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_icmp/tasks/nios_dtc_monitor_icmp_idempotence.yaml @@ -0,0 +1,71 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_create1 + +- name: Recreate a DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_create2 + +- name: Add a comment to an existing DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_update1 + +- name: Readd a comment to an existing DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_update2 + +- name: Remove a DTC ICMP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_delete1 + +- name: Reremove a DTC ICMP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_icmp_create1.changed" + - "not dtc_monitor_icmp_create2.changed" + - "dtc_monitor_icmp_update1.changed" + - "not dtc_monitor_icmp_update2.changed" + - "dtc_monitor_icmp_delete1.changed" + - "not dtc_monitor_icmp_delete2.changed" diff --git a/tests/integration/targets/nios_dtc_monitor_pdp/aliases b/tests/integration/targets/nios_dtc_monitor_pdp/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_pdp/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_dtc_monitor_pdp/defaults/main.yaml b/tests/integration/targets/nios_dtc_monitor_pdp/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_pdp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/tests/integration/targets/nios_dtc_monitor_pdp/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_pdp/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_pdp/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_pdp/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_pdp/tasks/main.yaml new file mode 100644 index 00000000..55829c8d --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_pdp/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_pdp_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_pdp/tasks/nios_dtc_monitor_pdp_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_pdp/tasks/nios_dtc_monitor_pdp_idempotence.yaml new file mode 100644 index 00000000..022f12d7 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_pdp/tasks/nios_dtc_monitor_pdp_idempotence.yaml @@ -0,0 +1,71 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_create1 + +- name: Recreate a DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_create2 + +- name: Add a comment to an existing DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_update1 + +- name: Readd a comment to an existing DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_update2 + +- name: Remove a DTC PDP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_delete1 + +- name: Reremove a DTC PDP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_pdp_create1.changed" + - "not dtc_monitor_pdp_create2.changed" + - "dtc_monitor_pdp_update1.changed" + - "not dtc_monitor_pdp_update2.changed" + - "dtc_monitor_pdp_delete1.changed" + - "not dtc_monitor_pdp_delete2.changed" diff --git a/tests/integration/targets/nios_dtc_monitor_sip/aliases b/tests/integration/targets/nios_dtc_monitor_sip/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_sip/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_dtc_monitor_sip/defaults/main.yaml b/tests/integration/targets/nios_dtc_monitor_sip/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_sip/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/tests/integration/targets/nios_dtc_monitor_sip/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_sip/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_sip/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_sip/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_sip/tasks/main.yaml new file mode 100644 index 00000000..e5e1b33f --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_sip/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_sip_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_sip/tasks/nios_dtc_monitor_sip_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_sip/tasks/nios_dtc_monitor_sip_idempotence.yaml new file mode 100644 index 00000000..68187a12 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_sip/tasks/nios_dtc_monitor_sip_idempotence.yaml @@ -0,0 +1,71 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_create1 + +- name: Recreate a DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_create2 + +- name: Add a comment to an existing DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_update1 + +- name: Readd a comment to an existing DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_update2 + +- name: Remove a DTC SIP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_delete1 + +- name: Reremove a DTC SIP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_sip_create1.changed" + - "not dtc_monitor_sip_create2.changed" + - "dtc_monitor_sip_update1.changed" + - "not dtc_monitor_sip_update2.changed" + - "dtc_monitor_sip_delete1.changed" + - "not dtc_monitor_sip_delete2.changed" diff --git a/tests/integration/targets/nios_dtc_monitor_snmp/aliases b/tests/integration/targets/nios_dtc_monitor_snmp/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_snmp/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_dtc_monitor_snmp/defaults/main.yaml b/tests/integration/targets/nios_dtc_monitor_snmp/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_snmp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/tests/integration/targets/nios_dtc_monitor_snmp/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_snmp/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_snmp/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_snmp/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_snmp/tasks/main.yaml new file mode 100644 index 00000000..02c852d3 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_snmp/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_snmp_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_snmp/tasks/nios_dtc_monitor_snmp_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_snmp/tasks/nios_dtc_monitor_snmp_idempotence.yaml new file mode 100644 index 00000000..12b56047 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_snmp/tasks/nios_dtc_monitor_snmp_idempotence.yaml @@ -0,0 +1,71 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_create1 + +- name: Recreate a DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_create2 + +- name: Add a comment to an existing DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_update1 + +- name: Readd a comment to an existing DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_update2 + +- name: Remove a DTC SNMP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_delete1 + +- name: Reremove a DTC SNMP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_snmp_create1.changed" + - "not dtc_monitor_snmp_create2.changed" + - "dtc_monitor_snmp_update1.changed" + - "not dtc_monitor_snmp_update2.changed" + - "dtc_monitor_snmp_delete1.changed" + - "not dtc_monitor_snmp_delete2.changed" diff --git a/tests/integration/targets/nios_dtc_monitor_tcp/aliases b/tests/integration/targets/nios_dtc_monitor_tcp/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_tcp/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_dtc_monitor_tcp/defaults/main.yaml b/tests/integration/targets/nios_dtc_monitor_tcp/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_tcp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/tests/integration/targets/nios_dtc_monitor_tcp/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_tcp/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_tcp/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_tcp/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_tcp/tasks/main.yaml new file mode 100644 index 00000000..e24c8265 --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_tcp/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_tcp_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml new file mode 100644 index 00000000..89b4431d --- /dev/null +++ b/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml @@ -0,0 +1,73 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + port: 8080 + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_create1 + +- name: Recreate a DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + port: 8080 + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_create2 + +- name: Add a comment to an existing DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_update1 + +- name: Readd a comment to an existing DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_update2 + +- name: Remove a DTC TCP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_delete1 + +- name: Reremove a DTC TCP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_tcp_create1.changed" + - "not dtc_monitor_tcp_create2.changed" + - "dtc_monitor_tcp_update1.changed" + - "not dtc_monitor_tcp_update2.changed" + - "dtc_monitor_tcp_delete1.changed" + - "not dtc_monitor_tcp_delete2.changed" diff --git a/tests/integration/targets/nios_dtc_topology/aliases b/tests/integration/targets/nios_dtc_topology/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_dtc_topology/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_dtc_topology/defaults/main.yaml b/tests/integration/targets/nios_dtc_topology/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/tests/integration/targets/nios_dtc_topology/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/tests/integration/targets/nios_dtc_topology/meta/main.yaml b/tests/integration/targets/nios_dtc_topology/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/tests/integration/targets/nios_dtc_topology/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_topology/tasks/main.yaml b/tests/integration/targets/nios_dtc_topology/tasks/main.yaml new file mode 100644 index 00000000..8873ef55 --- /dev/null +++ b/tests/integration/targets/nios_dtc_topology/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_topology_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_topology/tasks/nios_dtc_topology_idempotence.yaml b/tests/integration/targets/nios_dtc_topology/tasks/nios_dtc_topology_idempotence.yaml new file mode 100644 index 00000000..a24a9c31 --- /dev/null +++ b/tests/integration/targets/nios_dtc_topology/tasks/nios_dtc_topology_idempotence.yaml @@ -0,0 +1,122 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + state: absent + provider: "{{ nios_provider }}" + +- name: Clean up the DTC pool + infoblox.nios_modules.nios_dtc_pool: + name: web_pool + lb_preferred_method: ROUND_ROBIN + state: absent + provider: "{{ nios_provider }}" + +- name: Clean up the DTC server + infoblox.nios_modules.nios_dtc_server: + name: Server1 + host: 192.168.10.1 + state: absent + provider: "{{ nios_provider }}" + +- name: Create DTC server + infoblox.nios_modules.nios_dtc_server: + name: Server1 + host: 192.168.10.1 + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" + +- name: Create DTC Pool + infoblox.nios_modules.nios_dtc_pool: + name: web_pool + lb_preferred_method: ROUND_ROBIN + servers: + - server: Server1 + ratio: 1 + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" + +- name: Create a DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + rules: + - dest_type: POOL + destination_link: web_pool + return_type: REGULAR + state: present + provider: "{{ nios_provider }}" + register: dtc_topology_create1 + +- name: Recreate a DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + state: present + provider: "{{ nios_provider }}" + register: dtc_topology_create2 + +- name: Add a comment to an existing DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_topology_update1 + +- name: Readd a comment to an existing DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_topology_update2 + +- name: Remove a DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + state: absent + provider: "{{ nios_provider }}" + register: dtc_topology_delete1 + +- name: Reremove a DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + state: absent + provider: "{{ nios_provider }}" + register: dtc_topology_delete2 + +- name: Remove the DTC pool + infoblox.nios_modules.nios_dtc_pool: + name: web_pool + lb_preferred_method: ROUND_ROBIN + state: absent + provider: "{{ nios_provider }}" + +- name: Remove the DTC server + infoblox.nios_modules.nios_dtc_server: + name: Server1 + host: 192.168.10.1 + state: absent + provider: "{{ nios_provider }}" + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_topology_create1.changed" + - "not dtc_topology_create2.changed" + - "dtc_topology_update1.changed" + - "not dtc_topology_update2.changed" + - "dtc_topology_delete1.changed" + - "not dtc_topology_delete2.changed" diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py new file mode 100644 index 00000000..d053f0bf --- /dev/null +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py @@ -0,0 +1,136 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_http +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcHttpMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_http + + def setUp(self): + super(TestNiosDtcHttpMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_http.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_http.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_http.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcHttpMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_http_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'https_monitor', + 'port': 443, 'secure': True, 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "port": {}, + "secure": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'https_monitor', + 'port': 443, 'secure': True}) + + def test_nios_dtc_monitor_http_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'https_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:http/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "https_monitor", + "port": 443, + "secure": True, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_http_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'https_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:http/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "https_monitor", + "port": 443, + "secure": True, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py new file mode 100644 index 00000000..fb4b300d --- /dev/null +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py @@ -0,0 +1,129 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_icmp +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcIcmpMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_icmp + + def setUp(self): + super(TestNiosDtcIcmpMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_icmp.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_icmp.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_icmp.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcIcmpMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_icmp_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'icmp_monitor', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'icmp_monitor'}) + + def test_nios_dtc_monitor_icmp_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'icmp_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:icmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "icmp_monitor", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_icmp_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'icmp_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:icmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "icmp_monitor", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py new file mode 100644 index 00000000..80263784 --- /dev/null +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py @@ -0,0 +1,131 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_pdp +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcTcpMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_pdp + + def setUp(self): + super(TestNiosDtcTcpMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_pdp.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_pdp.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_pdp.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcTcpMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_pdp_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'pdp_monitor', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'pdp_monitor'}) + + def test_nios_dtc_monitor_pdp_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'pdp_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:pdp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "pdp_monitor", + "port": 2123, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_pdp_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'pdp_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:pdp/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "pdp_monitor", + "port": 2123, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py new file mode 100644 index 00000000..90b86bfa --- /dev/null +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py @@ -0,0 +1,129 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_sip +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcSipMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_sip + + def setUp(self): + super(TestNiosDtcSipMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_sip.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_sip.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_sip.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcSipMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_sip_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'sip_monitor', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'sip_monitor'}) + + def test_nios_dtc_monitor_sip_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'sip_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:sip/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "sip_monitor", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_sip_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'sip_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:sip/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "sip_monitor", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py new file mode 100644 index 00000000..838a35eb --- /dev/null +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py @@ -0,0 +1,143 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_snmp +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcSnmpMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_snmp + + def setUp(self): + super(TestNiosDtcSnmpMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_snmp.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_snmp.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_snmp.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcSnmpMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_snmp_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'snmp_monitor', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'snmp_monitor'}) + + def test_nios_dtc_monitor_snmp_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'snmp_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:snmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "snmp_monitor", + "port": 161, + "version": "V2C", + "community": "public", + "interval": 5, + "retry_down": 1, + "retry_up": 1, + "timeout": 15, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_snmp_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'snmp_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:snmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "snmp_monitor", + "port": 161, + "version": "V2C", + "community": "public", + "interval": 5, + "retry_down": 1, + "retry_up": 1, + "timeout": 15, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py new file mode 100644 index 00000000..072ba1a3 --- /dev/null +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py @@ -0,0 +1,133 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_tcp +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcTcpMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_tcp + + def setUp(self): + super(TestNiosDtcTcpMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_tcp.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_tcp.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_tcp.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcTcpMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_tcp_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'tcp_monitor', + 'port': 8080, 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "port": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'tcp_monitor', + 'port': 8080}) + + def test_nios_dtc_monitor_tcp_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'tcp_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:tcp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "tcp_monitor", + "port": 8080, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_tcp_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'tcp_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:tcp/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "tcp_monitor", + "port": 8080, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/tests/unit/plugins/modules/test_nios_dtc_topology.py b/tests/unit/plugins/modules/test_nios_dtc_topology.py new file mode 100644 index 00000000..d0ee4c69 --- /dev/null +++ b/tests/unit/plugins/modules/test_nios_dtc_topology.py @@ -0,0 +1,156 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_topology +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcTopologyModule(TestNiosModule): + + module = nios_dtc_topology + + def setUp(self): + super(TestNiosDtcTopologyModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_topology.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_topology.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_topology.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcTopologyModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_topology_create(self): + self.module.params = { + 'provider': None, + 'state': 'present', + 'name': 'a_topology', + 'rules': [{ + 'dest_type': 'POOL', + 'destination_link': 'web_pool', + 'return_type': 'REGULAR' + }], + 'comment': None, + 'extattrs': None + } + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "rules": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with( + 'testobject', + { + 'name': 'a_topology', + 'rules': [{ + 'dest_type': 'POOL', + 'destination_link': 'web_pool', + 'return_type': 'REGULAR' + }] + } + ) + + def test_nios_dtc_topology_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'a_topology', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + '_ref': 'dtc:topology/ZG5zLm5ldHdvcmtfdmlldyQw:default/true', + 'name': 'a_topology', + 'rules': [{ + '_ref': 'dtc:topology:rule/ZG5zLm5ldHdvcmtfdmlldyQw:a_topology/web_pool' + }], + 'comment': "test comment", + 'extattrs': {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_topology_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'a_topology', + 'comment': None, 'extattrs': None} + + ref = "dtc:topology/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": {}, + "_ref": ref, + "name": "a_topology", + 'rules': [{ + '_ref': 'dtc:topology:rule/ZG5zLm5ldHdvcmtfdmlldyQw:a_topology/web_pool' + }], + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) From e26d3e03e5ddc3d6066a20a76401d636376aab4d Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Mon, 4 Dec 2023 14:36:51 +0530 Subject: [PATCH 05/29] [FIX] CI-RUN and Unit test (#204) --- .github/workflows/ansible-test.yml | 28 +++++++++++++++------ tests/unit/plugins/module_utils/test_api.py | 6 +++-- tests/unit/plugins/modules/utils.py | 6 +++-- tests/unit/requirements.txt | 2 +- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 7ccd9f66..cf8353b8 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -49,12 +49,16 @@ jobs: fail-fast: false matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] - ansible-version: [stable-2.13, stable-2.14, stable-2.15, devel] + ansible-version: [stable-2.13, stable-2.14, stable-2.15, stable-2.16, devel] exclude: - ansible-version: devel python-version: '3.8' - ansible-version: devel python-version: '3.9' + - ansible-version: stable-2.16 + python-version: '3.8' + - ansible-version: stable-2.16 + python-version: '3.9' - ansible-version: stable-2.15 python-version: '3.8' - ansible-version: stable-2.14 @@ -80,8 +84,8 @@ jobs: - name: Setup Unit test Pre-requisites run: | ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz - git clone https://github.com/ansible/ansible.git - cp -rf ansible/test/units/compat /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/ + git clone https://github.com/ansible/ansible.git -b ${{ matrix.ansible-version }} + if [ "${{ matrix.ansible-version }}" != "devel" ]; then cp -rf ansible/test/units/compat /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/; fi cp -rf ansible/test/units/modules/utils.py /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/ sed -i 's/units/ansible_collections.infoblox.nios_modules.tests.unit/' /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py if [ -f /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt ]; then pip install -r /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt; fi @@ -91,7 +95,13 @@ jobs: - name: Generate coverage report run: | - if [ "${{ matrix.ansible-version }}" == "stable-2.13" ]; then pip install coverage==4.5.4; fi + if [ "${{ matrix.ansible-version }}" == "stable-2.13" ]; then + pip install coverage==4.5.4; + elif [ "${{ matrix.ansible-version }}" == "stable-2.14" ]; then + pip install coverage==6.5.0; + elif [ "${{ matrix.ansible-version }}" == "stable-2.15" ]; then + pip install coverage==6.5.0; + fi ansible-test coverage xml -v --group-by command --group-by version working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ @@ -109,12 +119,16 @@ jobs: fail-fast: false matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] - ansible-version: [stable-2.13, stable-2.14, stable-2.15, devel] + ansible-version: [stable-2.13, stable-2.14, stable-2.15, stable-2.16, devel] exclude: - ansible-version: devel python-version: '3.8' - ansible-version: devel python-version: '3.9' + - ansible-version: stable-2.16 + python-version: '3.8' + - ansible-version: stable-2.16 + python-version: '3.9' - ansible-version: stable-2.15 python-version: '3.8' - ansible-version: stable-2.14 @@ -153,7 +167,7 @@ jobs: echo $ANSIBLE_NIOSSIM_CONTAINER ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python-version }} --docker --coverage env: - ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:2.0.0 + ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:3.0.0 working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ # ansible-test support producing code coverage date @@ -178,7 +192,7 @@ jobs: strategy: fail-fast: false matrix: - ansible-version: [stable-2.13, stable-2.14, stable-2.15, devel] + ansible-version: [stable-2.13, stable-2.14, stable-2.15, stable-2.16, devel] steps: - name: Set up Python 3.10 diff --git a/tests/unit/plugins/module_utils/test_api.py b/tests/unit/plugins/module_utils/test_api.py index 9636c05b..18d02faf 100644 --- a/tests/unit/plugins/module_utils/test_api.py +++ b/tests/unit/plugins/module_utils/test_api.py @@ -5,8 +5,10 @@ __metaclass__ = type import copy - -from ansible_collections.infoblox.nios_modules.tests.unit.compat import unittest +try: + from ansible_collections.infoblox.nios_modules.tests.unit.compat import unittest +except ImportError: + import unittest from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock from ansible_collections.infoblox.nios_modules.plugins.module_utils import api diff --git a/tests/unit/plugins/modules/utils.py b/tests/unit/plugins/modules/utils.py index 6a00fd25..15e7ec14 100644 --- a/tests/unit/plugins/modules/utils.py +++ b/tests/unit/plugins/modules/utils.py @@ -4,8 +4,10 @@ __metaclass__ = type import json - -from ansible_collections.community.general.tests.unit.compat import unittest +try: + from ansible_collections.community.general.tests.unit.compat import unittest +except ImportError: + import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible.module_utils import basic from ansible.module_utils.common.text.converters import to_bytes diff --git a/tests/unit/requirements.txt b/tests/unit/requirements.txt index 883f6010..9fc06457 100644 --- a/tests/unit/requirements.txt +++ b/tests/unit/requirements.txt @@ -5,4 +5,4 @@ pytest-xdist mock pytest-mock pytest-cov -coverage==6.5.0 +coverage From 5a7577babc08251ec50056625d9e8d278c833a5b Mon Sep 17 00:00:00 2001 From: Jaykumar Chhatbar <45447272+JchhatbarInfoblox@users.noreply.github.com> Date: Tue, 5 Dec 2023 10:01:24 +0530 Subject: [PATCH 06/29] [Fix] TCP Monitor and topology (#205) * [Fix] TCP Monitor and topology * [Fix] Sanity test for TCP Monitor * [Fix] Integration test for TCP Monitor --- plugins/module_utils/api.py | 5 +++++ plugins/modules/nios_dtc_monitor_tcp.py | 3 ++- plugins/modules/nios_dtc_topology.py | 7 +++++-- .../tasks/nios_dtc_monitor_tcp_idempotence.yaml | 5 +++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index e1616ad9..8962703c 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -753,6 +753,11 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): except TypeError: txt = obj_filter['text'] test_obj_filter['text'] = txt + + # removing Port param from get params for NIOS_DTC_MONITOR_TCP + if (ib_obj_type == NIOS_DTC_MONITOR_TCP): + test_obj_filter = dict([('name', obj_filter['name'])]) + # check if test_obj_filter is empty copy passed obj_filter else: test_obj_filter = obj_filter diff --git a/plugins/modules/nios_dtc_monitor_tcp.py b/plugins/modules/nios_dtc_monitor_tcp.py index f06b5cac..7708baea 100644 --- a/plugins/modules/nios_dtc_monitor_tcp.py +++ b/plugins/modules/nios_dtc_monitor_tcp.py @@ -32,6 +32,7 @@ description: - Configures the port value for TCP requests. The field is required on creation. + required: true type: int interval: description: @@ -128,8 +129,8 @@ def main(): ib_spec = dict( name=dict(required=True, ib_req=True), + port=dict(type='int', required=True, ib_req=True), - port=dict(type='int'), interval=dict(type='int', default=5), retry_down=dict(type='int', default=1), retry_up=dict(type='int', default=1), diff --git a/plugins/modules/nios_dtc_topology.py b/plugins/modules/nios_dtc_topology.py index 32a21528..eec85725 100644 --- a/plugins/modules/nios_dtc_topology.py +++ b/plugins/modules/nios_dtc_topology.py @@ -185,19 +185,22 @@ def sources_transform(sources, module): def rules_transform(module): rule_list = list() + dest_obj = None + if not module.params['rules']: return rule_list + for rule in module.params['rules']: if rule['dest_type'] == 'POOL': dest_obj = wapi.get_object('dtc:pool', {'name': rule['destination_link']}) else: dest_obj = wapi.get_object('dtc:server', {'name': rule['destination_link']}) - if not dest_obj: + if not dest_obj and rule['return_type'] == 'REGULAR': module.fail_json(msg='destination_link %s does not exist' % rule['destination_link']) tf_rule = dict( dest_type=rule['dest_type'], - destination_link=dest_obj[0]['_ref'], + destination_link=dest_obj[0]['_ref'] if dest_obj else None, return_type=rule['return_type'] ) diff --git a/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml index 89b4431d..1c025b93 100644 --- a/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml +++ b/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml @@ -13,6 +13,7 @@ - name: Clean up the DTC TCP monitor infoblox.nios_modules.nios_dtc_monitor_tcp: name: tcp_monitor + port: 8080 state: absent provider: "{{ nios_provider }}" @@ -35,6 +36,7 @@ - name: Add a comment to an existing DTC TCP monitor infoblox.nios_modules.nios_dtc_monitor_tcp: name: tcp_monitor + port: 8080 comment: this is a test comment state: present provider: "{{ nios_provider }}" @@ -43,6 +45,7 @@ - name: Readd a comment to an existing DTC TCP monitor infoblox.nios_modules.nios_dtc_monitor_tcp: name: tcp_monitor + port: 8080 comment: this is a test comment state: present provider: "{{ nios_provider }}" @@ -51,6 +54,7 @@ - name: Remove a DTC TCP monitor from the system infoblox.nios_modules.nios_dtc_monitor_tcp: name: tcp_monitor + port: 8080 state: absent provider: "{{ nios_provider }}" register: dtc_monitor_tcp_delete1 @@ -58,6 +62,7 @@ - name: Reremove a DTC TCP monitor from the system infoblox.nios_modules.nios_dtc_monitor_tcp: name: tcp_monitor + port: 8080 state: absent provider: "{{ nios_provider }}" register: dtc_monitor_tcp_delete2 From 02fda4ec0b6b52cd2010adc3769cd4e27551b4eb Mon Sep 17 00:00:00 2001 From: Jaykumar Chhatbar <45447272+JchhatbarInfoblox@users.noreply.github.com> Date: Tue, 12 Dec 2023 12:07:42 +0530 Subject: [PATCH 07/29] added required param port in example for TCP monitor (#207) --- playbooks/delete_dtc_monitor_sip.yaml | 1 + plugins/modules/nios_dtc_monitor_tcp.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/playbooks/delete_dtc_monitor_sip.yaml b/playbooks/delete_dtc_monitor_sip.yaml index 10cc49dd..1fbc0e29 100644 --- a/playbooks/delete_dtc_monitor_sip.yaml +++ b/playbooks/delete_dtc_monitor_sip.yaml @@ -12,5 +12,6 @@ - name: Delete Nios DTC SIP monitor Test infoblox.nios_modules.nios_dtc_monitor_sip: name: sip_monitor + port: 8080 state: absent provider: "{{ nios_provider }}" diff --git a/plugins/modules/nios_dtc_monitor_tcp.py b/plugins/modules/nios_dtc_monitor_tcp.py index 7708baea..e812f13c 100644 --- a/plugins/modules/nios_dtc_monitor_tcp.py +++ b/plugins/modules/nios_dtc_monitor_tcp.py @@ -96,6 +96,7 @@ - name: Add a comment to an existing DTC TCP monitor infoblox.nios_modules.nios_dtc_monitor_tcp: name: tcp_monitor + port: 8080 comment: this is a test comment state: present provider: @@ -107,6 +108,7 @@ - name: Remove a DTC TCP monitor from the system infoblox.nios_modules.nios_dtc_monitor_tcp: name: tcp_monitor + port: 8080 state: absent provider: host: "{{ inventory_hostname_short }}" From eca5194e0600cabfd80e0ed8ffcd15628f6df6e4 Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Tue, 12 Dec 2023 17:56:10 +0530 Subject: [PATCH 08/29] Fix/dtc objects (#209) * Fixed LBDN and Pool Object for transform fields [FIX] LBDN: auth_zone and pool field [FIX] POOL: servers and monitors field * Fixed BUGS for ENV Variables wapi_version and max_results BUG #198 BUG #185 * Resolve Issue #116 [ADD] Version to infoblox-client in requirement.txt --- plugins/doc_fragments/nios.py | 2 +- plugins/module_utils/api.py | 16 +++++++++------- plugins/modules/nios_dtc_lbdn.py | 4 ++-- plugins/modules/nios_dtc_pool.py | 9 +++++++-- requirements.txt | 2 +- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/plugins/doc_fragments/nios.py b/plugins/doc_fragments/nios.py index bd1f02ea..bbecf7a6 100644 --- a/plugins/doc_fragments/nios.py +++ b/plugins/doc_fragments/nios.py @@ -77,7 +77,7 @@ class ModuleDocFragment(object): wapi_version: description: - Specifies the version of WAPI to use - - Value can also be specified using C(INFOBLOX_WAP_VERSION) environment + - Value can also be specified using C(INFOBLOX_WAPI_VERSION) environment variable. - Until ansible 2.8 the default WAPI was 1.4 type: str diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 8962703c..3a586193 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -91,8 +91,8 @@ 'http_pool_connections': dict(type='int', default=10), 'http_pool_maxsize': dict(type='int', default=10), 'max_retries': dict(type='int', default=3, fallback=(env_fallback, ['INFOBLOX_MAX_RETRIES'])), - 'wapi_version': dict(default='2.9', fallback=(env_fallback, ['INFOBLOX_WAP_VERSION'])), - 'max_results': dict(type='int', default=1000, fallback=(env_fallback, ['INFOBLOX_MAX_RETRIES'])) + 'wapi_version': dict(default='2.9', fallback=(env_fallback, ['INFOBLOX_WAPI_VERSION'])), + 'max_results': dict(type='int', default=1000, fallback=(env_fallback, ['INFOBLOX_MAX_RESULTS'])) } @@ -120,7 +120,12 @@ def get_connector(*args, **kwargs): # explicitly set env = ('INFOBLOX_%s' % key).upper() if env in os.environ: - kwargs[key] = os.environ.get(env) + if NIOS_PROVIDER_SPEC[key].get('type') == 'bool': + kwargs[key] = eval(os.environ.get(env).title()) + elif NIOS_PROVIDER_SPEC[key].get('type') == 'int': + kwargs[key] = eval(os.environ.get(env)) + else: + kwargs[key] = os.environ.get(env) if 'validate_certs' in kwargs.keys(): kwargs['ssl_verify'] = kwargs['validate_certs'] @@ -755,7 +760,7 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): test_obj_filter['text'] = txt # removing Port param from get params for NIOS_DTC_MONITOR_TCP - if (ib_obj_type == NIOS_DTC_MONITOR_TCP): + elif (ib_obj_type == NIOS_DTC_MONITOR_TCP): test_obj_filter = dict([('name', obj_filter['name'])]) # check if test_obj_filter is empty copy passed obj_filter @@ -779,9 +784,6 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): except TypeError: ipaddr = obj_filter['ipv4addr'] test_obj_filter['ipv4addr'] = ipaddr - # prevents creation of a new A record with 'new_ipv4addr' when A record with a particular 'old_ipv4addr' is not found - if old_ipv4addr_exists and ib_obj is None: - raise Exception("A Record with ipv4addr: '%s' is not found" % (ipaddr)) ib_obj = self.get_object(ib_obj_type, test_obj_filter.copy(), return_fields=list(ib_spec.keys())) # prevents creation of a new A record with 'new_ipv4addr' when A record with a particular 'old_ipv4addr' is not found if old_ipv4addr_exists and ib_obj is None: diff --git a/plugins/modules/nios_dtc_lbdn.py b/plugins/modules/nios_dtc_lbdn.py index eebdcf2c..bc5a79c1 100644 --- a/plugins/modules/nios_dtc_lbdn.py +++ b/plugins/modules/nios_dtc_lbdn.py @@ -178,7 +178,7 @@ def auth_zones_transform(module): for zone in module.params['auth_zones']: zone_obj = wapi.get_object('zone_auth', {'fqdn': zone}) - if zone_obj is not None: + if zone_obj: zone_list.append(zone_obj[0]['_ref']) else: module.fail_json( @@ -194,7 +194,7 @@ def pools_transform(module): {'name': pool['pool']}) if 'ratio' not in pool: pool['ratio'] = 1 - if pool_obj is not None: + if pool_obj: pool_list.append({'pool': pool_obj[0]['_ref'], 'ratio': pool['ratio']}) else: diff --git a/plugins/modules/nios_dtc_pool.py b/plugins/modules/nios_dtc_pool.py index 17401987..82491f62 100644 --- a/plugins/modules/nios_dtc_pool.py +++ b/plugins/modules/nios_dtc_pool.py @@ -176,9 +176,11 @@ def servers_transform(module): for server in module.params['servers']: server_obj = wapi.get_object('dtc:server', {'name': server['server']}) - if server_obj is not None: + if server_obj: server_list.append({'server': server_obj[0]['_ref'], 'ratio': server['ratio']}) + else: + module.fail_json(msg='Server %s cannot be found.' % server) return server_list def monitors_transform(module): @@ -187,8 +189,11 @@ def monitors_transform(module): for monitor in module.params['monitors']: monitor_obj = wapi.get_object('dtc:monitor:' + monitor['type'], {'name': monitor['name']}) - if monitor_obj is not None: + if monitor_obj: monitor_list.append(monitor_obj[0]['_ref']) + else: + module.fail_json( + msg='monitor %s cannot be found.' % monitor) return monitor_list def topology_transform(module): diff --git a/requirements.txt b/requirements.txt index be611454..886ac909 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -infoblox-client +infoblox-client==0.6.0 \ No newline at end of file From 51f6dca19bfca169cd5c239453d994148095fa16 Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:42:49 +0530 Subject: [PATCH 09/29] Release notes for v1.6.0 (#212) --- CHANGELOG.rst | 29 ++++++++++++++++++++--------- README.md | 12 ++++++++---- changelogs/.plugin-cache.yaml | 2 +- changelogs/changelog.yaml | 30 ++++++++++++++++++++---------- galaxy.yml | 7 +++---- 5 files changed, 52 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 67f8e10e..3586730c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,20 +9,31 @@ v1.6.0 Release Summary --------------- +Added new modules with CRUD features to manage NIOS DTC health check monitors: DTC HTTP Monitor, +DTC ICMP Monitor, DTC PDP Monitor, DTC SIP Monitor, DTC SNMP Monitor, DTC TCP Monitor. +Added a new module with CRUD features to manage topology rulesets in NIOS. +Added a new field to define topology ruleset for the DTC Pool and DTC LBDN modules. -This release provides plugins for NIOS DTC monitoring and topology +Major Changes +------------- +- Upgrade Ansible version support from 2.13 to 2.16. +- Upgrade Python version support from 3.8 to 3.10. New Modules ----------- +- infoblox.nios_modules.nios_dtc_monitor_http - Configures the Infoblox NIOS DTC HTTP monitor +- infoblox.nios_modules.nios_dtc_monitor_icmp - Configures the Infoblox NIOS DTC ICMP monitor +- infoblox.nios_modules.nios_dtc_monitor_pdp - Configures the Infoblox NIOS DTC PDP monitor +- infoblox.nios_modules.nios_dtc_monitor_sip - Configures the Infoblox NIOS DTC SIP monitor +- infoblox.nios_modules.nios_dtc_monitor_snmp - Configures the Infoblox NIOS DTC SNMP monitor +- infoblox.nios_modules.nios_dtc_monitor_tcp - Configures the Infoblox NIOS DTC TCP monitor +- infoblox.nios_modules.nios_dtc_topology - Configures the Infoblox NIOS DTC Topology -- infoblox.nios_modules.nios_dtc_monitor_http - Configure Infoblox NIOS DTC HTTP monitor -- infoblox.nios_modules.nios_dtc_monitor_icmp - Configure Infoblox NIOS DTC ICMP monitor -- infoblox.nios_modules.nios_dtc_monitor_pdp - Configure Infoblox NIOS DTC PDP monitor -- infoblox.nios_modules.nios_dtc_monitor_sip - Configure Infoblox NIOS DTC SIP monitor -- infoblox.nios_modules.nios_dtc_monitor_snmp - Configure Infoblox NIOS DTC SNMP monitor -- infoblox.nios_modules.nios_dtc_monitor_tcp - Configure Infoblox NIOS DTC TCP monitor -- infoblox.nios_modules.nios_dtc_topology - Configure Infoblox NIOS DTC Topology - +Bugfixes +--------- +- Fixes typo for environment variable INFOBLOX_WAPI_VERSION `#209 `_ +- Fixes environment variable max_results using INFOBLOX_MAX_RESULTS `#209 `_ +- Fixes index error for transform fields in DTC LBDN (auth_zone and Pool) and DTC POOL (servers and monitors) `#209 `_ v1.5.0 ====== diff --git a/README.md b/README.md index bc00c1d6..f6071d47 100644 --- a/README.md +++ b/README.md @@ -93,11 +93,15 @@ Installation Dependencies ------------ -- Python version 3.8 or later +- Python version 3.10 or later -- Ansible version 2.12 or later +- Ansible version 2.16 or later -- NIOS 8.5.x or later +- NIOS 8.6.x and 9.0.x + +- Infoblox WAPI version 2.9 or later + +Note: For modules of DTC objects to function properly, Infoblox recommends WAPI version 2.12 or later. Prerequisites ------------- @@ -180,7 +184,7 @@ Dates TBD Current release --------------- -1.5.0 on 11 May 2023 +1.6.0 on 14 Dec 2023 Versioning ========= diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index f36ee335..68f4bff5 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -163,4 +163,4 @@ plugins: shell: {} strategy: {} vars: {} -version: 1.5.0 +version: 1.6.0 diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 3e822d3b..4aac3e0b 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -219,27 +219,37 @@ releases: release_date: '2023-05-11' 1.6.0: changes: - release_summary: This release provides plugins for NIOS DTC monitoring + major_changes: + - Upgrade Ansible version support from 2.13 to 2.16. + - Upgrade Python version support from 3.8 to 3.10. + release_summary: 'Added new modules with CRUD features to manage NIOS DTC health check monitors: DTC HTTP Monitor, + DTC ICMP Monitor, DTC PDP Monitor, DTC SIP Monitor, DTC SNMP Monitor, DTC TCP Monitor. + Added a new module with CRUD features to manage topology rulesets in NIOS. + Added a new field to define topology ruleset for the DTC Pool and DTC LBDN modules.' + bugfixes: + - Fixes typo for environment variable INFOBLOX_WAPI_VERSION `#209 `_ + - Fixes environment variable max_results using INFOBLOX_MAX_RESULTS `#209 `_ + - Fixes index error for transform fields in DTC LBDN (auth_zone and Pool) and DTC POOL (servers and monitors) `#209 `_ modules: - - description: Configure Infoblox NIOS DTC HTTP monitor + - description: Configures the Infoblox NIOS DTC HTTP monitor. name: nios_dtc_monitor_http namespace: '' - - description: Configure Infoblox NIOS DTC ICMP monitor + - description: Configures the Infoblox NIOS DTC ICMP monitor name: nios_dtc_monitor_icmp namespace: '' - - description: Configure Infoblox NIOS DTC PDP monitor + - description: Configures the Infoblox NIOS DTC PDP monitor name: nios_dtc_monitor_pdp namespace: '' - - description: Configure Infoblox NIOS DTC SIP monitor + - description: Configures the Infoblox NIOS DTC SIP monitor name: nios_dtc_monitor_sip namespace: '' - - description: Configure Infoblox NIOS DTC SNMP monitor - name: nios_dtc_monitor_snpp + - description: Configures the Infoblox NIOS DTC SNMP monitor + name: nios_dtc_monitor_snmp namespace: '' - - description: Configure Infoblox NIOS DTC TCP monitor + - description: Configures the Infoblox NIOS DTC TCP monitor name: nios_dtc_monitor_tcp namespace: '' - - description: Configure Infoblox NIOS DTC Topology + - description: Configures the Infoblox NIOS DTC Topology name: nios_dtc_topology namespace: '' - release_date: 'tbd' + release_date: '2023-12-14' diff --git a/galaxy.yml b/galaxy.yml index 043d7d86..f6ae74fc 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -17,10 +17,9 @@ readme: README.md # A list of the collection's content authors. Can be just the name or in the format 'Full Name (url) # @nicks:irc/im.site#channel' authors: -- Sailesh Giri (sgiri@infoblox.com) -- Vaishnavi TR (vtr@infoblox.com) -- Anagha KH (akh@infoblox.com) -- Shankar Ganesh (sganesh@infoblox.com) +- Hemanth Kumar (hkumar3@infoblox.com) +- Jeenitkumar Khatri (jkhatri@infoblox.com) +- Jaykumar Chhatbar (jchhatbar@infoblox.com) ### OPTIONAL but strongly recommended From 8bf75a19067e6753b96a6d2a83b805d88432fc6c Mon Sep 17 00:00:00 2001 From: Jaykumar Chhatbar <45447272+JchhatbarInfoblox@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:54:32 +0530 Subject: [PATCH 10/29] Release notes for v1.6.1 (#213) * [FIX] Unit test fix for 2.16 and devel * [FIX] Example playbooks. * Release notes for v1.6.1 --- .github/workflows/ansible-test.yml | 16 +++++----------- CHANGELOG.rst | 11 +++++++++++ README.md | 4 ++-- changelogs/.plugin-cache.yaml | 2 +- changelogs/changelog.yaml | 7 +++++++ galaxy.yml | 2 +- meta/runtime.yml | 2 +- playbooks/delete_cname_record.yaml | 2 +- playbooks/delete_dtc_topology.yml | 4 ++-- playbooks/delete_mx_record.yaml | 2 +- playbooks/delete_txt_record.yaml | 2 +- playbooks/restart_services.yml | 2 +- playbooks/update_member.yml | 2 +- tests/requirements.txt | 2 +- tests/unit/requirements.txt | 3 ++- 15 files changed, 38 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index cf8353b8..0d14379b 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - ansible-version: [stable-2.10] + ansible-version: [stable-2.14] steps: - name: Check out code uses: actions/checkout@v2 @@ -49,7 +49,7 @@ jobs: fail-fast: false matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] - ansible-version: [stable-2.13, stable-2.14, stable-2.15, stable-2.16, devel] + ansible-version: [stable-2.14, stable-2.15, stable-2.16, devel] exclude: - ansible-version: devel python-version: '3.8' @@ -63,8 +63,6 @@ jobs: python-version: '3.8' - ansible-version: stable-2.14 python-version: '3.8' - - ansible-version: stable-2.13 - python-version: '3.11' steps: - name: Set up Python ${{ matrix.python-version }} @@ -95,9 +93,7 @@ jobs: - name: Generate coverage report run: | - if [ "${{ matrix.ansible-version }}" == "stable-2.13" ]; then - pip install coverage==4.5.4; - elif [ "${{ matrix.ansible-version }}" == "stable-2.14" ]; then + if [ "${{ matrix.ansible-version }}" == "stable-2.14" ]; then pip install coverage==6.5.0; elif [ "${{ matrix.ansible-version }}" == "stable-2.15" ]; then pip install coverage==6.5.0; @@ -119,7 +115,7 @@ jobs: fail-fast: false matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] - ansible-version: [stable-2.13, stable-2.14, stable-2.15, stable-2.16, devel] + ansible-version: [stable-2.14, stable-2.15, stable-2.16, devel] exclude: - ansible-version: devel python-version: '3.8' @@ -133,8 +129,6 @@ jobs: python-version: '3.8' - ansible-version: stable-2.14 python-version: '3.8' - - ansible-version: stable-2.13 - python-version: '3.11' steps: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v1 @@ -192,7 +186,7 @@ jobs: strategy: fail-fast: false matrix: - ansible-version: [stable-2.13, stable-2.14, stable-2.15, stable-2.16, devel] + ansible-version: [stable-2.14, stable-2.15, stable-2.16, devel] steps: - name: Set up Python 3.10 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3586730c..b4941d31 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,17 @@ Infoblox.Nios_Modules Release Notes =================================== .. contents:: Topics +v1.6.1 +====== + +Release Summary +--------------- +This release includes the updates of plug-in version 1.6.0 and the following documentation changes: +Ansible core version in the dependencies updated to 2.14 or later. + +Minor Changes +------------- +Ansible core version in the dependencies updated to 2.14 or later. v1.6.0 ====== diff --git a/README.md b/README.md index f6071d47..b7665d50 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ Dependencies - Python version 3.10 or later -- Ansible version 2.16 or later +- Ansible Core version 2.14 or later - NIOS 8.6.x and 9.0.x @@ -184,7 +184,7 @@ Dates TBD Current release --------------- -1.6.0 on 14 Dec 2023 +1.6.1 on 19 Dec 2023 Versioning ========= diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index 68f4bff5..3ed1f4b5 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -163,4 +163,4 @@ plugins: shell: {} strategy: {} vars: {} -version: 1.6.0 +version: 1.6.1 diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 4aac3e0b..ec67aff0 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -253,3 +253,10 @@ releases: name: nios_dtc_topology namespace: '' release_date: '2023-12-14' + 1.6.1: + changes: + minor_changes: + - Ansible core version in the dependencies updated to 2.14 or later. + release_summary: 'This release includes the updates of plug-in version 1.6.0 and the following documentation changes: + Ansible core version in the dependencies updated to 2.14 or later.' + release_date: '2023-12-19' diff --git a/galaxy.yml b/galaxy.yml index f6ae74fc..787065d8 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -9,7 +9,7 @@ namespace: infoblox name: nios_modules # The version of the collection. Must be compatible with semantic versioning -version: 1.6.0 +version: 1.6.1 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/meta/runtime.yml b/meta/runtime.yml index 2ee3c9fa..be99ccf4 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,2 +1,2 @@ --- -requires_ansible: '>=2.9.10' +requires_ansible: '>=2.14.0' diff --git a/playbooks/delete_cname_record.yaml b/playbooks/delete_cname_record.yaml index 50c55105..f7f753a7 100644 --- a/playbooks/delete_cname_record.yaml +++ b/playbooks/delete_cname_record.yaml @@ -9,7 +9,7 @@ connection: local tasks: - - name: Create Nios CNAME record + - name: Delete Nios CNAME record infoblox.nios_modules.nios_cname_record: name: cname.ansible.com canonical: realhost.ansible.com diff --git a/playbooks/delete_dtc_topology.yml b/playbooks/delete_dtc_topology.yml index c80fa117..1782aa67 100644 --- a/playbooks/delete_dtc_topology.yml +++ b/playbooks/delete_dtc_topology.yml @@ -9,8 +9,8 @@ connection: local tasks: - - name: Delete a DTC Topology - nios_dtc_topology: + - name: delete a DTC Topology + infoblox.nios_modules.nios_dtc_topology: name: a_topology state: absent provider: "{{ nios_provider }}" diff --git a/playbooks/delete_mx_record.yaml b/playbooks/delete_mx_record.yaml index 3b269a25..9a4475ec 100644 --- a/playbooks/delete_mx_record.yaml +++ b/playbooks/delete_mx_record.yaml @@ -9,7 +9,7 @@ connection: local tasks: - - name: Create Nios MX record + - name: delete Nios MX record infoblox.nios_modules.nios_mx_record: name: ansible.com mx: mailhost.ansible.com diff --git a/playbooks/delete_txt_record.yaml b/playbooks/delete_txt_record.yaml index 376e2973..ea9269af 100644 --- a/playbooks/delete_txt_record.yaml +++ b/playbooks/delete_txt_record.yaml @@ -9,7 +9,7 @@ connection: local tasks: - - name: Create Nios TXT record + - name: delete Nios TXT record infoblox.nios_modules.nios_txt_record: name: fqdn.txt.ansible.com text: example_text diff --git a/playbooks/restart_services.yml b/playbooks/restart_services.yml index 23bbe590..b8b8fe61 100644 --- a/playbooks/restart_services.yml +++ b/playbooks/restart_services.yml @@ -10,6 +10,6 @@ connection: local tasks: - name: Restart Services - nios_restartservices: + infoblox.nios_modules.nios_restartservices: provider: "{{ nios_provider }}" ... diff --git a/playbooks/update_member.yml b/playbooks/update_member.yml index 0d860321..39156913 100644 --- a/playbooks/update_member.yml +++ b/playbooks/update_member.yml @@ -8,7 +8,7 @@ password: cloudadmin connection: local tasks: - - name: create member + - name: update member host name infoblox.nios_modules.nios_member: host_name: {old_name: block1.localdomain, new_name: member01.localdomain} master_candidate: false diff --git a/tests/requirements.txt b/tests/requirements.txt index 7f835e9f..708b417d 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -4,6 +4,6 @@ pytest-xdist mock pytest-mock pytest-cov==2.8.0 -coverage +coverage==7.3.2 pygobject launchpadlib diff --git a/tests/unit/requirements.txt b/tests/unit/requirements.txt index 9fc06457..fc67ca9e 100644 --- a/tests/unit/requirements.txt +++ b/tests/unit/requirements.txt @@ -5,4 +5,5 @@ pytest-xdist mock pytest-mock pytest-cov -coverage +coverage==7.3.2 + From 8b4f2d050135610c0ecf87adf018843ef6f60996 Mon Sep 17 00:00:00 2001 From: Ondra Machacek Date: Wed, 29 May 2024 09:50:30 +0200 Subject: [PATCH 11/29] Add use_range parameter to nios_next_ip (#200) This parameter add use_range parameter to nios_next_ip lookup plugin. With this parameter set to true, the plugin will return first available IP from the network range, assigned to the network. Signed-off-by: Ondra Machacek --- plugins/lookup/nios_next_ip.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/lookup/nios_next_ip.py b/plugins/lookup/nios_next_ip.py index e2fa076d..9b5d243f 100644 --- a/plugins/lookup/nios_next_ip.py +++ b/plugins/lookup/nios_next_ip.py @@ -23,6 +23,11 @@ description: The CIDR network to retrieve the next address(es) from. required: True type: str + use_range: + description: Use DHCP range to retrieve the next available IP address(es). + required: false + default: no + type: bool num: description: The number of IP address(es) to return. required: false @@ -45,6 +50,10 @@ ansible.builtin.set_fact: ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" +- name: return next available IP address for network 192.168.10.0/24 from DHCP range + ansible.builtin.set_fact: + ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', use_range=true, provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + - name: return next available IP address for network 192.168.10.0/24 in a non-default network view ansible.builtin.set_fact: ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', network_view='ansible', \ @@ -91,7 +100,9 @@ def run(self, terms, variables=None, **kwargs): provider = kwargs.pop('provider', {}) wapi = WapiLookup(provider) - if isinstance(ipaddress.ip_network(network), ipaddress.IPv6Network): + if kwargs.get('use_range', False): + network_obj = wapi.get_object('range', {'network': network}) + elif isinstance(ipaddress.ip_network(network), ipaddress.IPv6Network): network_obj = wapi.get_object('ipv6network', {'network': network}) else: network_obj = wapi.get_object('network', {'network': network}) From 85df85e9336f20337469802039d17f1b6750ce65 Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:59:43 +0530 Subject: [PATCH 12/29] Ea definition support (#235) * Attributes (#4) * Add extensible attribute module * added choices to IB_spec * doco * Add the struct creation to api * doco * pep and lint * fix pep issues * Add flags for extensible attributes (#5) (#6) * Extensible attributes module - support flags infobloxopen/infoblox-ansible/#186 add support for flags to the extensible attributes module * Extensible attributes - fix linting reported by the ansible sanity tests --------- Co-authored-by: Hugues Malphettes * Documentation update fix doco line length fix line length PEP issue pep issue * [FIX] CI execution for unit test * [FIX] Github workflows for CI Run Updated workflow file to support ansible-stable 2.17 and removed 2.14 [FIX] coverage report for stable-2.16 [FIX] changed called_once_with to assert_called_once_with for unit tests [FIX] compact file deprication for ansible-2.17 * [FIX] Updated unit test case by replacing called_once_with to assert_called_once_with for python3.12 * Updated data type for Min and Max from str to int --------- Co-authored-by: matthewdennett <52452990+matthewdennett@users.noreply.github.com> Co-authored-by: matt Co-authored-by: Hugues Malphettes --- .github/workflows/ansible-test.yml | 58 ++--- plugins/lookup/nios_next_ip.py | 15 +- plugins/module_utils/api.py | 12 + plugins/modules/nios_extensible_attribute.py | 226 ++++++++++++++++++ tests/unit/compat/mock.py | 6 +- tests/unit/plugins/module_utils/test_api.py | 18 +- .../plugins/modules/test_nios_a_record.py | 15 +- .../plugins/modules/test_nios_aaaa_record.py | 19 +- .../plugins/modules/test_nios_cname_record.py | 8 +- .../plugins/modules/test_nios_dns_view.py | 7 +- .../modules/test_nios_dtc_monitor_http.py | 4 +- .../modules/test_nios_dtc_monitor_icmp.py | 4 +- .../modules/test_nios_dtc_monitor_pdp.py | 4 +- .../modules/test_nios_dtc_monitor_sip.py | 5 +- .../modules/test_nios_dtc_monitor_snmp.py | 5 +- .../modules/test_nios_dtc_monitor_tcp.py | 4 +- .../plugins/modules/test_nios_dtc_topology.py | 5 +- .../modules/test_nios_fixed_address.py | 13 +- .../plugins/modules/test_nios_host_record.py | 17 +- .../unit/plugins/modules/test_nios_member.py | 10 +- .../plugins/modules/test_nios_mx_record.py | 6 +- .../plugins/modules/test_nios_naptr_record.py | 5 +- .../unit/plugins/modules/test_nios_network.py | 8 +- .../plugins/modules/test_nios_network_view.py | 21 +- .../unit/plugins/modules/test_nios_nsgroup.py | 7 +- .../plugins/modules/test_nios_ptr_record.py | 16 +- .../plugins/modules/test_nios_srv_record.py | 6 +- tests/unit/plugins/modules/test_nios_zone.py | 5 +- tests/unit/requirements.txt | 1 - 29 files changed, 424 insertions(+), 106 deletions(-) create mode 100644 plugins/modules/nios_extensible_attribute.py diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 0d14379b..893d066c 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -13,15 +13,15 @@ jobs: strategy: fail-fast: false matrix: - ansible-version: [stable-2.14] + ansible-version: [stable-2.15] steps: - name: Check out code uses: actions/checkout@v2 - - name: Set up Python 3.10 - uses: actions/setup-python@v1 + - name: Set up Python 3.11 + uses: actions/setup-python@v2 with: - python-version: '3.10' + python-version: '3.11' - name: Install ansible (${{ matrix.ansible-version }}) run: pip install pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check @@ -48,25 +48,25 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] - ansible-version: [stable-2.14, stable-2.15, stable-2.16, devel] + python-version: ['3.9', '3.10', '3.11', '3.12'] + ansible-version: [stable-2.15, stable-2.16, stable-2.17, devel] exclude: - ansible-version: devel - python-version: '3.8' + python-version: '3.11' + - ansible-version: devel + python-version: '3.10' - ansible-version: devel python-version: '3.9' - - ansible-version: stable-2.16 - python-version: '3.8' + - ansible-version: stable-2.17 + python-version: '3.9' - ansible-version: stable-2.16 python-version: '3.9' - ansible-version: stable-2.15 - python-version: '3.8' - - ansible-version: stable-2.14 - python-version: '3.8' + python-version: '3.12' steps: - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} @@ -83,7 +83,7 @@ jobs: run: | ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz git clone https://github.com/ansible/ansible.git -b ${{ matrix.ansible-version }} - if [ "${{ matrix.ansible-version }}" != "devel" ]; then cp -rf ansible/test/units/compat /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/; fi + if [ "${{ matrix.ansible-version }}" != "devel" ] && [ "${{ matrix.ansible-version }}" != "stable-2.17" ]; then cp -rf ansible/test/units/compat /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/; fi cp -rf ansible/test/units/modules/utils.py /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/ sed -i 's/units/ansible_collections.infoblox.nios_modules.tests.unit/' /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py if [ -f /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt ]; then pip install -r /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt; fi @@ -93,8 +93,8 @@ jobs: - name: Generate coverage report run: | - if [ "${{ matrix.ansible-version }}" == "stable-2.14" ]; then - pip install coverage==6.5.0; + if [ "${{ matrix.ansible-version }}" == "devel" ]; then + pip install coverage==7.5.3; elif [ "${{ matrix.ansible-version }}" == "stable-2.15" ]; then pip install coverage==6.5.0; fi @@ -114,24 +114,24 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] - ansible-version: [stable-2.14, stable-2.15, stable-2.16, devel] + python-version: ['3.9', '3.10', '3.11', '3.12'] + ansible-version: [stable-2.15, stable-2.16, stable-2.17, devel] exclude: - ansible-version: devel - python-version: '3.8' + python-version: '3.11' + - ansible-version: devel + python-version: '3.10' - ansible-version: devel python-version: '3.9' - - ansible-version: stable-2.16 - python-version: '3.8' + - ansible-version: stable-2.17 + python-version: '3.9' - ansible-version: stable-2.16 python-version: '3.9' - ansible-version: stable-2.15 - python-version: '3.8' - - ansible-version: stable-2.14 - python-version: '3.8' + python-version: '3.12' steps: - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} @@ -186,15 +186,15 @@ jobs: strategy: fail-fast: false matrix: - ansible-version: [stable-2.14, stable-2.15, stable-2.16, devel] + ansible-version: [stable-2.15, stable-2.16, stable-2.17, devel] steps: - - name: Set up Python 3.10 - uses: actions/setup-python@v1 + - name: Set up Python 3.11 + uses: actions/setup-python@v2 with: # it is just required to run that once as "ansible-test sanity" in the docker image # will run on all python versions it supports. - python-version: '3.10' + python-version: 3.11 - name: Install ansible (${{ matrix.ansible-version }}) version run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check diff --git a/plugins/lookup/nios_next_ip.py b/plugins/lookup/nios_next_ip.py index 9b5d243f..41a9c6bc 100644 --- a/plugins/lookup/nios_next_ip.py +++ b/plugins/lookup/nios_next_ip.py @@ -48,21 +48,23 @@ EXAMPLES = """ - name: return next available IP address for network 192.168.10.0/24 ansible.builtin.set_fact: - ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" - name: return next available IP address for network 192.168.10.0/24 from DHCP range ansible.builtin.set_fact: - ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', use_range=true, provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', use_range=true, + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" - name: return next available IP address for network 192.168.10.0/24 in a non-default network view ansible.builtin.set_fact: - ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', network_view='ansible', \ + ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', network_view='ansible', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" - name: return the next 3 available IP addresses for network 192.168.10.0/24 ansible.builtin.set_fact: - ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', num=3, - provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', num=3, \ + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" - name: return the next 3 available IP addresses for network 192.168.10.0/24 excluding ip addresses - ['192.168.10.1', '192.168.10.2'] ansible.builtin.set_fact: @@ -71,7 +73,8 @@ - name: return next available IP address for network fd30:f52:2:12::/64 ansible.builtin.set_fact: - ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', 'fd30:f52:2:12::/64', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', 'fd30:f52:2:12::/64', + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" """ RETURN = """ diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 3a586193..a6303369 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -78,6 +78,7 @@ NIOS_DTC_MONITOR_SNMP = 'dtc:monitor:snmp' NIOS_DTC_MONITOR_TCP = 'dtc:monitor:tcp' NIOS_DTC_TOPOLOGY = 'dtc:topology' +NIOS_EXTENSIBLE_ATTRIBUTE = 'extensibleattributedef' NIOS_PROVIDER_SPEC = { 'host': dict(fallback=(env_fallback, ['INFOBLOX_HOST'])), @@ -214,6 +215,14 @@ def convert_members_to_struct(member_spec): return member_spec +def convert_ea_list_to_struct(member_spec): + ''' Transforms the list of the values into a valid WAPI struct. + ''' + if 'list_values' in member_spec.keys(): + member_spec['list_values'] = [{'_struct': 'extensibleattributedef:listvalues', 'value': v} for v in member_spec['list_values']] + return member_spec + + def normalize_ib_spec(ib_spec): result = {} for arg in ib_spec: @@ -381,6 +390,9 @@ def run(self, ib_obj_type, ib_spec): proposed_object['end_addr'] = proposed_object.get('new_end_addr') del proposed_object['new_end_addr'] + if (ib_obj_type == NIOS_EXTENSIBLE_ATTRIBUTE): + proposed_object = convert_ea_list_to_struct(proposed_object) + # checks if the 'text' field has to be updated for the TXT Record if (ib_obj_type == NIOS_TXT_RECORD): text_obj = proposed_object["text"] diff --git a/plugins/modules/nios_extensible_attribute.py b/plugins/modules/nios_extensible_attribute.py new file mode 100644 index 00000000..50e6b9ff --- /dev/null +++ b/plugins/modules/nios_extensible_attribute.py @@ -0,0 +1,226 @@ +#!/usr/bin/python +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_extensible_attribute +author: + - "Matthew Dennett (@matthewdennett)" + - "Hugues Malphettes (@hmalphettes)" +short_description: Configure Infoblox NIOS extensible attribute definition +version_added: "1.7.0" +description: + - Adds and/or removes a extensible attribute definition objects from + Infoblox NIOS servers. This module manages NIOS C(extensibleattributedef) + objects using the Infoblox WAPI interface over REST. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + type: str + default_value: + description: + - Configures the default value which is pre populated in the GUI when + this attribute is used. Email, URL and string types the value is a + with a maximum of 256 characters. + type: str + list_values: + description: + - Configures a list of preset values associated with the instance of this + object. Only applicable when the attribute type is set to ENUM. + type: list + elements: str + max: + description: + - Configures the maximum value to be associated with the instance of + this object. When provided for an extensible attribute of type + STRING the value represents the maximum number of characters the string + can contain. When provided for an extensible attribute of type INTEGER + the value represents the maximum integer value permitted.Not + applicable for other attributes types. + type: int + min: + description: + - Configures the minimum value to be associated with the instance of + this object. When provided for an extensible attribute of type + STRING the value represents the minimum number of characters the string + can contain. When provided for an extensible attribute of type INTEGER + the value represents the minimum integer value permitted. Not + applicable for other attributes types. + type: int + name: + description: + - Configures the intended name of the instance of the object on the + NIOS server. + type: str + required: true + type: + description: + - Configures the intended type for this attribute object definition + on the NIOS server. + type: str + default: STRING + choices: + - DATE + - EMAIL + - ENUM + - INTEGER + - STRING + - URL + flags: + description: + - This field contains extensible attribute flags. + The possible values are (A)udited, (C)loud API, Cloud (G)master, (I)nheritable, (L)isted, (M)andatory value, + MGM (P)rivate, (R)ead Only, (S)ort enum values, Multiple (V)alues. + If there are two or more flags in the field, you must list them according to the order they are listed above. + For example, "CR" is a valid value for the "flags" field because C = Cloud API is listed before R = Read only. + However, the value "RC" is invalid because the order for the "flags" field is broken. + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + type: str + default: present + choices: + - present + - absent +''' + +EXAMPLES = ''' +- name: Configure an extensible attribute + infoblox.nios_modules.nios_extensible_attribute: + name: my_string + type: STRING + comment: Created by ansible + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Update an extensible attribute to accept multiple values + infoblox.nios_modules.nios_extensible_attribute: + name: my_string + type: STRING + flags: V + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a extensible attribute + infoblox.nios_modules.nios_extensible_attribute: + name: my_string + type: INTEGER + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Create INT extensible attribute + infoblox.nios_modules.nios_extensible_attribute: + name: my_int + type: INTEGER + comment: Created by ansible + min: 10 + max: 20 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Update an extensible attribute + infoblox.nios_modules.nios_extensible_attribute: + name: my_int + type: INTEGER + comment: Updated by ansible + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Create an list extensible attribute + infoblox.nios_modules.nios_extensible_attribute: + name: my_list + type: ENUM + state: present + list_values: + - one + - two + - three + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import normalize_ib_spec +from ..module_utils.api import NIOS_EXTENSIBLE_ATTRIBUTE + + +def main(): + ''' Main entry point for module execution + ''' + + ib_spec = dict( + comment=dict(type='str'), + default_value=dict(type='str'), + list_values=dict(type='list', elements='str'), + max=dict(type='int'), + min=dict(type='int'), + flags=dict(type='str'), + name=dict(type='str', required=True, ib_req=True), + type=dict(type='str', default='STRING', + choices=['DATE', 'EMAIL', 'ENUM', 'INTEGER', 'STRING', 'URL']) + ) + + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']) + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True) + + wapi = WapiModule(module) + + result = wapi.run(NIOS_EXTENSIBLE_ATTRIBUTE, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py index ba8455bf..802cf61e 100644 --- a/tests/unit/compat/mock.py +++ b/tests/unit/compat/mock.py @@ -64,8 +64,7 @@ def _iterate_read_data(read_data): # newline that our naive format() added data_as_list[-1] = data_as_list[-1][:-1] - for line in data_as_list: - yield line + yield from data_as_list def mock_open(mock=None, read_data=''): """ @@ -91,8 +90,7 @@ def _readline_side_effect(): if handle.readline.return_value is not None: while True: yield handle.readline.return_value - for line in _data: - yield line + yield from _data global file_spec if file_spec is None: diff --git a/tests/unit/plugins/module_utils/test_api.py b/tests/unit/plugins/module_utils/test_api.py index 18d02faf..73911a8d 100644 --- a/tests/unit/plugins/module_utils/test_api.py +++ b/tests/unit/plugins/module_utils/test_api.py @@ -79,11 +79,11 @@ def test_wapi_no_change(self): def test_wapi_change(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'updated comment', 'extattrs': None} - + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "extattrs": {} } @@ -99,16 +99,16 @@ def test_wapi_change(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.called_once_with(test_object) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'default'}) def test_wapi_change_false(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'updated comment', 'extattrs': None, 'fqdn': 'foo'} - + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "extattrs": {} } @@ -125,7 +125,9 @@ def test_wapi_change_false(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'updated comment', 'name': 'default'} + ) def test_wapi_extattrs_change(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', @@ -161,9 +163,10 @@ def test_wapi_extattrs_nochange(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'test comment', 'extattrs': {'Site': 'test'}} + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [{ "comment": "test comment", - "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "extattrs": {'Site': {'value': 'test'}} }] @@ -178,6 +181,7 @@ def test_wapi_extattrs_nochange(self): res = wapi.run('testobject', test_spec) self.assertFalse(res['changed']) + wapi.update_object.assert_not_called() def test_wapi_create(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible', diff --git a/tests/unit/plugins/modules/test_nios_a_record.py b/tests/unit/plugins/modules/test_nios_a_record.py index 16d81866..9234f9c7 100644 --- a/tests/unit/plugins/modules/test_nios_a_record.py +++ b/tests/unit/plugins/modules/test_nios_a_record.py @@ -86,10 +86,11 @@ def test_nios_a_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'a.ansible.com', 'ipv4': '192.168.10.1', 'comment': 'updated comment', 'extattrs': None} + ref = "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "a.ansible.com", "ipv4": "192.168.10.1", "extattrs": {} @@ -105,8 +106,10 @@ def test_nios_a_record_update_comment(self): wapi = self._get_wapi(test_object) res = wapi.run('testobject', test_spec) - self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'updated comment', 'ipv4': '192.168.10.1', 'name': 'a.ansible.com'} + ) def test_nios_a_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'a.ansible.com', 'ipv4': '192.168.10.1', @@ -139,12 +142,12 @@ def test_nios_a_record_update_record_name(self): self.module.params = {'provider': None, 'state': 'present', 'name': {'new_name': 'a_new.ansible.com', 'old_name': 'a.ansible.com'}, 'comment': 'comment', 'extattrs': None} + ref = "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", - "name": "a_new.ansible.com", - "old_name": "a.ansible.com", + "_ref": ref, + "name": "a.ansible.com", "extattrs": {} } ] @@ -159,4 +162,4 @@ def test_nios_a_record_update_record_name(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.called_once_with(test_object) + wapi.update_object.assert_called_once_with(ref, {'name': 'a_new.ansible.com', 'comment': 'comment'}) diff --git a/tests/unit/plugins/modules/test_nios_aaaa_record.py b/tests/unit/plugins/modules/test_nios_aaaa_record.py index 1b4f96c0..10b6e18d 100644 --- a/tests/unit/plugins/modules/test_nios_aaaa_record.py +++ b/tests/unit/plugins/modules/test_nios_aaaa_record.py @@ -86,10 +86,11 @@ def test_nios_aaaa_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'aaaa.ansible.com', 'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'comment': 'updated comment', 'extattrs': None} + ref = "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "aaaa.ansible.com", "ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", "extattrs": {} @@ -107,6 +108,10 @@ def test_nios_aaaa_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'updated comment', 'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'name': 'aaaa.ansible.com'} + ) def test_nios_aaaa_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'aaaa.ansible.com', @@ -138,13 +143,12 @@ def test_nios_aaaa_record_remove(self): def test_nios_aaaa_record_update_record_name(self): self.module.params = {'provider': None, 'state': 'present', 'name': {'new_name': 'aaaa_new.ansible.com', 'old_name': 'aaaa.ansible.com'}, 'comment': 'comment', 'extattrs': None} - + ref = "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", - "name": "aaaa_new.ansible.com", - "old_name": "aaaa.ansible.com", + "_ref": ref, + "name": "aaaa.ansible.com", "extattrs": {} } ] @@ -159,4 +163,7 @@ def test_nios_aaaa_record_update_record_name(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'comment', 'name': 'aaaa_new.ansible.com'} + ) diff --git a/tests/unit/plugins/modules/test_nios_cname_record.py b/tests/unit/plugins/modules/test_nios_cname_record.py index 360a9cc9..3ad17abd 100644 --- a/tests/unit/plugins/modules/test_nios_cname_record.py +++ b/tests/unit/plugins/modules/test_nios_cname_record.py @@ -85,11 +85,11 @@ def test_nios_cname_record_create(self): def test_nios_cname_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'cname.ansible.com', 'canonical': 'realhost.ansible.com', 'comment': 'updated comment', 'extattrs': None} - + ref = "cnamerecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "cnamerecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "cname.ansible.com", "canonical": "realhost.ansible.com", "extattrs": {} @@ -107,6 +107,10 @@ def test_nios_cname_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'updated comment', 'name': 'cname.ansible.com', 'canonical': 'realhost.ansible.com'} + ) def test_nios_cname_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'cname.ansible.com', diff --git a/tests/unit/plugins/modules/test_nios_dns_view.py b/tests/unit/plugins/modules/test_nios_dns_view.py index b4933b55..ba003c8f 100644 --- a/tests/unit/plugins/modules/test_nios_dns_view.py +++ b/tests/unit/plugins/modules/test_nios_dns_view.py @@ -58,6 +58,9 @@ def _get_wapi(self, test_object): return wapi def load_fixtures(self, commands=None): + """ + Load fixtures for the module + """ self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) self.load_config.return_value = dict(diff=None, session='session') @@ -84,10 +87,11 @@ def test_nios_dns_view_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible-dns', 'comment': 'updated comment', 'extattrs': None} + ref = "dnsview/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/true" test_object = [ { "comment": "test comment", - "_ref": "dnsview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "ansible-dns", "extattrs": {} } @@ -103,6 +107,7 @@ def test_nios_dns_view_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'ansible-dns'}) def test_nios_dns_view_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible-dns', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py index d053f0bf..037ea92b 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py @@ -84,10 +84,11 @@ def test_nios_dtc_monitor_http_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'https_monitor', 'comment': 'updated comment', 'extattrs': None} + ref = "dtc:monitor:http/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:http/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "https_monitor", "port": 443, "secure": True, @@ -105,6 +106,7 @@ def test_nios_dtc_monitor_http_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'https_monitor'}) def test_nios_dtc_monitor_http_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'https_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py index fb4b300d..78f13365 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py @@ -81,10 +81,11 @@ def test_nios_dtc_monitor_icmp_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'icmp_monitor', 'comment': 'updated comment', 'extattrs': None} + ref = "dtc:monitor:icmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:icmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "icmp_monitor", "extattrs": {} } @@ -100,6 +101,7 @@ def test_nios_dtc_monitor_icmp_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'icmp_monitor'}) def test_nios_dtc_monitor_icmp_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'icmp_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py index 80263784..0fb63682 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py @@ -81,10 +81,11 @@ def test_nios_dtc_monitor_pdp_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'pdp_monitor', 'comment': 'updated comment', 'extattrs': None} + ref = "dtc:monitor:pdp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:pdp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "pdp_monitor", "port": 2123, "extattrs": {} @@ -101,6 +102,7 @@ def test_nios_dtc_monitor_pdp_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'pdp_monitor'}) def test_nios_dtc_monitor_pdp_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'pdp_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py index 90b86bfa..6e170d75 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py @@ -80,11 +80,11 @@ def test_nios_dtc_monitor_sip_create(self): def test_nios_dtc_monitor_sip_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'sip_monitor', 'comment': 'updated comment', 'extattrs': None} - + ref = "dtc:monitor:sip/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:sip/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "sip_monitor", "extattrs": {} } @@ -100,6 +100,7 @@ def test_nios_dtc_monitor_sip_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'sip_monitor'}) def test_nios_dtc_monitor_sip_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'sip_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py index 838a35eb..374b5a67 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py @@ -80,11 +80,11 @@ def test_nios_dtc_monitor_snmp_create(self): def test_nios_dtc_monitor_snmp_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'snmp_monitor', 'comment': 'updated comment', 'extattrs': None} - + ref = "dtc:monitor:snmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:snmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "snmp_monitor", "port": 161, "version": "V2C", @@ -107,6 +107,7 @@ def test_nios_dtc_monitor_snmp_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'snmp_monitor'}) def test_nios_dtc_monitor_snmp_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'snmp_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py index 072ba1a3..8de3d25f 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py @@ -83,10 +83,11 @@ def test_nios_dtc_monitor_tcp_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'tcp_monitor', 'comment': 'updated comment', 'extattrs': None} + ref = "dtc:monitor:tcp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:tcp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "tcp_monitor", "port": 8080, "extattrs": {} @@ -103,6 +104,7 @@ def test_nios_dtc_monitor_tcp_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'tcp_monitor'}) def test_nios_dtc_monitor_tcp_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'tcp_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_topology.py b/tests/unit/plugins/modules/test_nios_dtc_topology.py index d0ee4c69..6a11515b 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_topology.py +++ b/tests/unit/plugins/modules/test_nios_dtc_topology.py @@ -101,10 +101,10 @@ def test_nios_dtc_topology_create(self): def test_nios_dtc_topology_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'a_topology', 'comment': 'updated comment', 'extattrs': None} - + ref = "dtc:topology/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { - '_ref': 'dtc:topology/ZG5zLm5ldHdvcmtfdmlldyQw:default/true', + '_ref': ref, 'name': 'a_topology', 'rules': [{ '_ref': 'dtc:topology:rule/ZG5zLm5ldHdvcmtfdmlldyQw:a_topology/web_pool' @@ -124,6 +124,7 @@ def test_nios_dtc_topology_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'a_topology'}) def test_nios_dtc_topology_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'a_topology', diff --git a/tests/unit/plugins/modules/test_nios_fixed_address.py b/tests/unit/plugins/modules/test_nios_fixed_address.py index ae373fd3..ba435b76 100644 --- a/tests/unit/plugins/modules/test_nios_fixed_address.py +++ b/tests/unit/plugins/modules/test_nios_fixed_address.py @@ -82,11 +82,12 @@ def test_nios_fixed_address_ipv4_dhcp_update(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'test_fa', 'ipaddr': '192.168.10.1', 'mac': '08:6d:41:e8:fd:e8', 'network': '192.168.10.0/24', 'network_view': 'default', 'comment': 'updated comment', 'extattrs': None} + ref = "network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", "name": "test_fa", - "_ref": "network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "ipaddr": "192.168.10.1", "mac": "08:6d:41:e8:fd:e8", "network": "192.168.10.0/24", @@ -109,6 +110,16 @@ def test_nios_fixed_address_ipv4_dhcp_update(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with( + ref, + { + 'comment': 'updated comment', + 'name': 'test_fa', + 'ipaddr': '192.168.10.1', + 'mac': '08:6d:41:e8:fd:e8', + 'network': '192.168.10.0/24', + } + ) def test_nios_fixed_address_ipv4_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'test_fa', 'ipaddr': '192.168.10.1', 'mac': '08:6d:41:e8:fd:e8', diff --git a/tests/unit/plugins/modules/test_nios_host_record.py b/tests/unit/plugins/modules/test_nios_host_record.py index 8a5a8e6f..7bc72337 100644 --- a/tests/unit/plugins/modules/test_nios_host_record.py +++ b/tests/unit/plugins/modules/test_nios_host_record.py @@ -107,10 +107,11 @@ def test_nios_host_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'updated comment', 'extattrs': None} + ref = "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "extattrs": {} } @@ -126,18 +127,20 @@ def test_nios_host_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'updated comment', 'name': 'default'} + ) def test_nios_host_record_update_record_name(self): self.module.params = {'provider': None, 'state': 'present', 'name': {'new_name': 'default', 'old_name': 'old_default'}, 'comment': 'comment', 'extattrs': None} + ref = "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", - "name": "default", - "old_name": "old_default", + "_ref": ref, + "name": "old_default", "extattrs": {} } ] @@ -152,4 +155,6 @@ def test_nios_host_record_update_record_name(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'comment', 'name': 'default'} + ) diff --git a/tests/unit/plugins/modules/test_nios_member.py b/tests/unit/plugins/modules/test_nios_member.py index a65b5df1..c8e02ce0 100644 --- a/tests/unit/plugins/modules/test_nios_member.py +++ b/tests/unit/plugins/modules/test_nios_member.py @@ -84,11 +84,11 @@ def test_nios_member_update(self): self.module.params = {'provider': None, 'state': 'present', 'host_name': 'test_member', 'vip_setting': {'address': '192.168.1.110', 'subnet_mask': '255.255.255.0', 'gateway': '192.168.1.1'}, 'config_addr_type': 'IPV4', 'platform': 'VNIOS', 'comment': 'updated comment', 'extattrs': None} - + ref = "member/b25lLnZpcnR1YWxfbm9kZSQ3:member01.ansible-dev.com" test_object = [ { "comment": "Created with Ansible", - "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQ3:member01.ansible-dev.com", + "_ref": ref, "config_addr_type": "IPV4", "host_name": "member01.ansible-dev.com", "platform": "VNIOS", @@ -118,6 +118,12 @@ def test_nios_member_update(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'updated comment', 'host_name': 'test_member', + 'vip_setting': {'address': '192.168.1.110', 'subnet_mask': '255.255.255.0', 'gateway': '192.168.1.1'}, + 'config_addr_type': 'IPV4', 'platform': 'VNIOS'} + ) def test_nios_member_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'host_name': 'test_member', diff --git a/tests/unit/plugins/modules/test_nios_mx_record.py b/tests/unit/plugins/modules/test_nios_mx_record.py index 55524b4d..7f8db39e 100644 --- a/tests/unit/plugins/modules/test_nios_mx_record.py +++ b/tests/unit/plugins/modules/test_nios_mx_record.py @@ -86,11 +86,11 @@ def test_nios_mx_record_create(self): def test_nios_mx_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible.com', 'mx': 'mailhost.ansible.com', 'preference': 0, 'comment': 'updated comment', 'extattrs': None} - + ref = "mxrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "mxrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "ansible.com", "mx": "mailhost.ansible.com", "preference": 0, @@ -110,6 +110,8 @@ def test_nios_mx_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'ansible.com', + 'mx': 'mailhost.ansible.com', 'preference': 0}) def test_nios_mx_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible.com', 'mx': 'mailhost.ansible.com', diff --git a/tests/unit/plugins/modules/test_nios_naptr_record.py b/tests/unit/plugins/modules/test_nios_naptr_record.py index 44c9c349..38c3f059 100644 --- a/tests/unit/plugins/modules/test_nios_naptr_record.py +++ b/tests/unit/plugins/modules/test_nios_naptr_record.py @@ -91,10 +91,11 @@ def test_nios_naptr_record_update_comment(self): 'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com', 'comment': 'updated comment', 'extattrs': None} + ref = "naptrrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "naptrrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "*.subscriber-100.ansiblezone.com", "order": "1000", "preference": "10", @@ -116,6 +117,8 @@ def test_nios_naptr_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': '*.subscriber-100.ansiblezone.com', + 'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com'}) def test_nios_naptr_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': '*.subscriber-100.ansiblezone.com', diff --git a/tests/unit/plugins/modules/test_nios_network.py b/tests/unit/plugins/modules/test_nios_network.py index 0fad5aaa..afc96330 100644 --- a/tests/unit/plugins/modules/test_nios_network.py +++ b/tests/unit/plugins/modules/test_nios_network.py @@ -78,10 +78,11 @@ def test_nios_network_ipv4_dhcp_update(self): self.module.params = {'provider': None, 'state': 'present', 'network': '192.168.10.0/24', 'comment': 'updated comment', 'extattrs': None} + ref = "network/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/true" test_object = [ { "comment": "test comment", - "_ref": "network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "network": "192.168.10.0/24", "extattrs": {'options': {'name': 'test', 'value': 'ansible.com'}} } @@ -97,15 +98,17 @@ def test_nios_network_ipv4_dhcp_update(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'network': '192.168.10.0/24'}) def test_nios_network_ipv6_dhcp_update(self): self.module.params = {'provider': None, 'state': 'present', 'ipv6network': 'fe80::/64', 'comment': 'updated comment', 'extattrs': None} + ref = "ipv6network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "ipv6network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "ipv6network": "fe80::/64", "extattrs": {'options': {'name': 'test', 'value': 'ansible.com'}} } @@ -120,6 +123,7 @@ def test_nios_network_ipv6_dhcp_update(self): wapi = self._get_wapi(test_object) res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'ipv6network': 'fe80::/64'}) def test_nios_network_ipv4_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'network': '192.168.10.0/24', diff --git a/tests/unit/plugins/modules/test_nios_network_view.py b/tests/unit/plugins/modules/test_nios_network_view.py index fc95f180..24ee5fbd 100644 --- a/tests/unit/plugins/modules/test_nios_network_view.py +++ b/tests/unit/plugins/modules/test_nios_network_view.py @@ -83,11 +83,11 @@ def test_nios_network_view_create(self): def test_nios_network_view_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'updated comment', 'extattrs': None, 'network_view': 'default'} - + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "extattrs": {}, "network_view": "default" @@ -104,18 +104,20 @@ def test_nios_network_view_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'updated comment', 'name': 'default'} + ) def test_nios_network_view_update_name(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'old_name': 'old_default', 'comment': 'updated comment', 'extattrs': None, 'network_view': 'default'} - + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", - "name": "default", - "old_name": "old_default", + "_ref": ref, + "name": "old_default", "extattrs": {}, "network_view": "default" } @@ -131,7 +133,10 @@ def test_nios_network_view_update_name(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'updated comment', 'name': 'default'} + ) def test_nios_network_view_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible', diff --git a/tests/unit/plugins/modules/test_nios_nsgroup.py b/tests/unit/plugins/modules/test_nios_nsgroup.py index 60b21dcc..195ea7a7 100644 --- a/tests/unit/plugins/modules/test_nios_nsgroup.py +++ b/tests/unit/plugins/modules/test_nios_nsgroup.py @@ -107,10 +107,11 @@ def test_nios_nsgroup_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'updated comment', 'grid_primary': None} + ref = "nsgroup/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "nsgroup/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "grid_primary": {} } @@ -126,4 +127,6 @@ def test_nios_nsgroup_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'updated comment', 'name': 'default'} + ) diff --git a/tests/unit/plugins/modules/test_nios_ptr_record.py b/tests/unit/plugins/modules/test_nios_ptr_record.py index 5ffd6487..68f69b9c 100644 --- a/tests/unit/plugins/modules/test_nios_ptr_record.py +++ b/tests/unit/plugins/modules/test_nios_ptr_record.py @@ -109,11 +109,11 @@ def test_nios_ptr_record_remove(self): def test_nios_ptr_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.com', 'ipv4addr': '10.36.241.14', 'comment': 'updated comment', 'extattrs': None, 'view': 'default'} - + ref = "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default" test_object = [ { "comment": "test comment", - "_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default", + "_ref": ref, "ptrdname": "ansible.test.com", "ipv4addr": "10.36.241.14", "extattrs": {}, @@ -133,16 +133,18 @@ def test_nios_ptr_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'updated comment', 'ptrdname': 'ansible.test.com', 'ipv4addr': '10.36.241.14', 'view': 'default'} + ) def test_nios_ptr_record_update_record_ptrdname(self): self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.org', 'ipv4addr': '10.36.241.14', 'comment': 'comment', 'extattrs': None, 'view': 'default'} - + ref = "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default" test_object = [ { "comment": "test comment", - "_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default", + "_ref": ref, "ptrdname": "ansible.test.com", "ipv4addr": "10.36.241.14", "extattrs": {}, @@ -162,7 +164,9 @@ def test_nios_ptr_record_update_record_ptrdname(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'comment', 'ptrdname': 'ansible.test.org', 'ipv4addr': '10.36.241.14', 'view': 'default'} + ) def test_nios_ptr6_record_create(self): self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible6.test.com', diff --git a/tests/unit/plugins/modules/test_nios_srv_record.py b/tests/unit/plugins/modules/test_nios_srv_record.py index 9a6f3fb3..5c41cd4c 100644 --- a/tests/unit/plugins/modules/test_nios_srv_record.py +++ b/tests/unit/plugins/modules/test_nios_srv_record.py @@ -90,11 +90,11 @@ def test_nios_srv_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': '_sip._tcp.service.ansible.com', 'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10, 'comment': None, 'extattrs': None} - + ref = "srvrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "srvrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "_sip._tcp.service.ansible.com", 'port': 5080, "target": "mailhost.ansible.com", @@ -118,6 +118,8 @@ def test_nios_srv_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'name': '_sip._tcp.service.ansible.com', + 'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10}) def test_nios_srv_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': '_sip._tcp.service.ansible.com', diff --git a/tests/unit/plugins/modules/test_nios_zone.py b/tests/unit/plugins/modules/test_nios_zone.py index 693ab060..20230c8e 100644 --- a/tests/unit/plugins/modules/test_nios_zone.py +++ b/tests/unit/plugins/modules/test_nios_zone.py @@ -104,11 +104,11 @@ def test_nios_zone_remove(self): def test_nios_zone_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com', 'comment': 'updated comment', 'extattrs': None} - + ref = "zone/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "zone/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "fqdn": "ansible.com", "extattrs": {'Site': {'value': 'test'}} } @@ -124,6 +124,7 @@ def test_nios_zone_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'fqdn': 'ansible.com'}) def test_nios_zone_create_using_grid_primary_secondaries(self): self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com', diff --git a/tests/unit/requirements.txt b/tests/unit/requirements.txt index fc67ca9e..c64045e9 100644 --- a/tests/unit/requirements.txt +++ b/tests/unit/requirements.txt @@ -6,4 +6,3 @@ mock pytest-mock pytest-cov coverage==7.3.2 - From c4c02f32528c2640afefee21ea603e044715b4fb Mon Sep 17 00:00:00 2001 From: Jaykumar Chhatbar <45447272+JchhatbarInfoblox@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:31:47 +0530 Subject: [PATCH 13/29] - Added support for IPv6 next available ips in network ranges. (#225) --- plugins/lookup/nios_next_ip.py | 36 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/plugins/lookup/nios_next_ip.py b/plugins/lookup/nios_next_ip.py index 41a9c6bc..bed0f44a 100644 --- a/plugins/lookup/nios_next_ip.py +++ b/plugins/lookup/nios_next_ip.py @@ -24,7 +24,7 @@ required: True type: str use_range: - description: Use DHCP range to retrieve the next available IP address(es). + description: Use DHCP range to retrieve the next available IP address(es). Requested number of IP Addresses must be between 1 and 20. required: false default: no type: bool @@ -86,7 +86,6 @@ """ from ansible.plugins.lookup import LookupBase -from ansible.module_utils._text import to_text from ansible.errors import AnsibleError from ..module_utils.api import WapiLookup import ipaddress @@ -103,12 +102,12 @@ def run(self, terms, variables=None, **kwargs): provider = kwargs.pop('provider', {}) wapi = WapiLookup(provider) - if kwargs.get('use_range', False): - network_obj = wapi.get_object('range', {'network': network}) - elif isinstance(ipaddress.ip_network(network), ipaddress.IPv6Network): - network_obj = wapi.get_object('ipv6network', {'network': network}) + if isinstance(ipaddress.ip_network(network), ipaddress.IPv6Network): + object_type = 'ipv6range' if kwargs.get('use_range', False) else 'ipv6network' else: - network_obj = wapi.get_object('network', {'network': network}) + object_type = 'range' if kwargs.get('use_range', False) else 'network' + + network_obj = wapi.get_object(object_type, {'network': network}) if network_obj is None: raise AnsibleError('unable to find network object %s' % network) @@ -117,13 +116,16 @@ def run(self, terms, variables=None, **kwargs): exclude_ip = kwargs.get('exclude', []) network_view = kwargs.get('network_view', 'default') - try: - ref_list = [network['_ref'] for network in network_obj if network['network_view'] == network_view] - if not ref_list: - raise AnsibleError('no records found') - else: - ref = ref_list[0] - avail_ips = wapi.call_func('next_available_ip', ref, {'num': num, 'exclude': exclude_ip}) - return [avail_ips['ips']] - except Exception as exc: - raise AnsibleError(to_text(exc)) + ref_list = [network['_ref'] for network in network_obj if network['network_view'] == network_view] + if not ref_list: + raise AnsibleError('no records found') + + for ref in ref_list: + try: + avail_ips = wapi.call_func('next_available_ip', ref, {'num': num, 'exclude': exclude_ip}) + if len(avail_ips['ips']) >= num: + return [avail_ips['ips']] + except Exception: + continue + + raise AnsibleError('unable to find the required number of IPs') From 3f5025ee7735a0d2dfa3399b647b4d29dbf49bc0 Mon Sep 17 00:00:00 2001 From: Jaykumar Chhatbar <45447272+JchhatbarInfoblox@users.noreply.github.com> Date: Tue, 9 Jul 2024 20:03:57 +0530 Subject: [PATCH 14/29] Pull 196: added support for use_logic_filter_rules and sanity fixes. (#233) * [IMP] added support for use_logic_filter_rules [UPD] added use_logic_filter_rules in example. - added use_logic_filter_rules and logic_filter_rules documentation. * [IMP] added unit testcases for logic_filter_rules - corrected sanity test failures. * - Updated unit testcases for logic_filter_rules with assert. * Integration test cases for logic filters * [FIX] Fixed sanity failure for too many blank lines * - Updated NIOS SIM Container version to 4.0.0. * - Updated wapi version to 2.12.3. --------- Co-authored-by: Ubuntu --- .github/workflows/ansible-test.yml | 2 +- plugins/doc_fragments/nios.py | 2 +- plugins/lookup/nios_next_ip.py | 14 ++-- plugins/module_utils/api.py | 2 +- plugins/modules/nios_network.py | 41 ++++++++++- .../tasks/nios_network_idempotence.yml | 53 ++++++++++++++ .../unit/plugins/modules/test_nios_network.py | 70 ++++++++++++++++++- 7 files changed, 171 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 893d066c..24bbfe05 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -161,7 +161,7 @@ jobs: echo $ANSIBLE_NIOSSIM_CONTAINER ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python-version }} --docker --coverage env: - ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:3.0.0 + ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:4.0.0 working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ # ansible-test support producing code coverage date diff --git a/plugins/doc_fragments/nios.py b/plugins/doc_fragments/nios.py index bbecf7a6..17c74fad 100644 --- a/plugins/doc_fragments/nios.py +++ b/plugins/doc_fragments/nios.py @@ -81,7 +81,7 @@ class ModuleDocFragment(object): variable. - Until ansible 2.8 the default WAPI was 1.4 type: str - default: '2.9' + default: '2.12.3' max_results: description: - Specifies the maximum number of objects to be returned, diff --git a/plugins/lookup/nios_next_ip.py b/plugins/lookup/nios_next_ip.py index bed0f44a..9b3dd8cd 100644 --- a/plugins/lookup/nios_next_ip.py +++ b/plugins/lookup/nios_next_ip.py @@ -49,12 +49,12 @@ - name: return next available IP address for network 192.168.10.0/24 ansible.builtin.set_fact: ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', - provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" - name: return next available IP address for network 192.168.10.0/24 from DHCP range ansible.builtin.set_fact: - ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', use_range=true, - provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', + use_range=true, provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" - name: return next available IP address for network 192.168.10.0/24 in a non-default network view ansible.builtin.set_fact: @@ -66,15 +66,17 @@ ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', num=3, \ provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" -- name: return the next 3 available IP addresses for network 192.168.10.0/24 excluding ip addresses - ['192.168.10.1', '192.168.10.2'] +- name: return the next 3 available IP addresses for network 192.168.10.0/24 + excluding ip addresses - ['192.168.10.1', '192.168.10.2'] ansible.builtin.set_fact: - ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', num=3, exclude=['192.168.10.1', '192.168.10.2'], + ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', num=3, + exclude=['192.168.10.1', '192.168.10.2'], provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" - name: return next available IP address for network fd30:f52:2:12::/64 ansible.builtin.set_fact: ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', 'fd30:f52:2:12::/64', - provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" """ RETURN = """ diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index a6303369..c95c8df6 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -92,7 +92,7 @@ 'http_pool_connections': dict(type='int', default=10), 'http_pool_maxsize': dict(type='int', default=10), 'max_retries': dict(type='int', default=3, fallback=(env_fallback, ['INFOBLOX_MAX_RETRIES'])), - 'wapi_version': dict(default='2.9', fallback=(env_fallback, ['INFOBLOX_WAPI_VERSION'])), + 'wapi_version': dict(default='2.12.3', fallback=(env_fallback, ['INFOBLOX_WAPI_VERSION'])), 'max_results': dict(type='int', default=1000, fallback=(env_fallback, ['INFOBLOX_MAX_RESULTS'])) } diff --git a/plugins/modules/nios_network.py b/plugins/modules/nios_network.py index d9f6040a..ee3b9349 100644 --- a/plugins/modules/nios_network.py +++ b/plugins/modules/nios_network.py @@ -111,6 +111,28 @@ description: - The name of the Nios member to be assigned to this network. type: str + use_logic_filter_rules: + description: + - If set to true it'll override the logic filter list applied at an upper level. + type: bool + default: false + logic_filter_rules: + description: + - Configures the logic filter rules to be applied to the network object. + This argument accepts a list of logic filter rules (see suboptions). When omitted + a default value of an empty list is used. + type: list + default: [] + elements: dict + suboptions: + filter: + description: + - The name of the logic filter to apply to the network object. + type: str + type: + description: + - The type of the logic filter to apply to the network object. + type: str state: description: - Configures the intended state of the instance of the object on @@ -186,6 +208,21 @@ password: admin connection: local +- name: Set filters for a network ipv4 + infoblox.nios_modules.nios_network: + network: 192.168.10.0/24 + comment: this is a test comment + use_logic_filter_rules: true + logic_filter_rules: + - filter: PXE-UEFI + type: Option + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + - name: Remove a network ipv4 infoblox.nios_modules.nios_network: network: 192.168.10.0/24 @@ -329,7 +366,9 @@ def main(): extattrs=dict(type='dict'), comment=dict(), container=dict(type='bool', ib_req=True), - members=dict(type='list', elements='dict', default=[]) + members=dict(type='list', elements='dict', default=[]), + use_logic_filter_rules=dict(type='bool', default=False), + logic_filter_rules=dict(type='list', elements='dict', default=[]) ) argument_spec = dict( diff --git a/tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml b/tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml index 3b5dbc4b..95937d1a 100644 --- a/tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml +++ b/tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml @@ -70,6 +70,53 @@ provider: "{{ nios_provider }}" register: nios_ipv6_create1 + +- name: configure a network ipv6 with filter option + nios_network: + network: fe80::/64 + comment: this is a test comment + use_logic_filter_rules: true + state: present + provider: "{{ nios_provider }}" + register: nios_ipv6_update1 + +- name: configure a network ipv4 with filter option + nios_network: + network: 192.168.11.0/24 + comment: this is a test comment + use_logic_filter_rules: true + state: present + provider: "{{ nios_provider }}" + register: nios_ipv4_create3 + +- name: update a network ipv4 with filter option + nios_network: + network: 192.168.11.0/24 + comment: this is a test comment + use_logic_filter_rules: false + state: present + provider: "{{ nios_provider }}" + register: nios_ipv4_update3 + +- name: Re-run with no changes + nios_network: + network: 192.168.11.0/24 + comment: this is a test comment + use_logic_filter_rules: false + state: present + provider: "{{ nios_provider }}" + register: nios_ipv4_update4 + +- name: remove an ipv4 network + nios_network: + network: 192.168.11.0/24 + comment: this is a test comment + use_logic_filter_rules: false + state: absent + provider: "{{ nios_provider }}" + register: nios_ipv4_remove3 + + - assert: that: - "nios_ipv4_create1.changed" @@ -78,3 +125,9 @@ - "not nios_ipv4_update2.changed" - "nios_ipv4_remove1.changed" - "not nios_ipv4_remove2.changed" + - "nios_ipv4_create3.changed" + - "nios_ipv4_update3.changed" + - "nios_ipv6_create1.changed" + - "nios_ipv6_update1.changed" + - "not nios_ipv4_update4.changed" + - "nios_ipv4_remove3.changed" diff --git a/tests/unit/plugins/modules/test_nios_network.py b/tests/unit/plugins/modules/test_nios_network.py index afc96330..df9b0464 100644 --- a/tests/unit/plugins/modules/test_nios_network.py +++ b/tests/unit/plugins/modules/test_nios_network.py @@ -30,12 +30,16 @@ class TestNiosNetworkModule(TestNiosModule): def setUp(self): super(TestNiosNetworkModule, self).setUp() - self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_network.WapiModule') + self.module = MagicMock( + name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_network.WapiModule' + ) self.module.check_mode = False self.module.params = {'provider': None} self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_network.WapiModule') self.exec_command = self.mock_wapi.start() - self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_network.WapiModule.run') + self.mock_wapi_run = patch( + 'ansible_collections.infoblox.nios_modules.plugins.modules.nios_network.WapiModule.run' + ) self.mock_wapi_run.start() self.load_config = self.mock_wapi_run.start() @@ -58,7 +62,8 @@ def _get_wapi(self, test_object): def test_nios_network_ipv4_create(self): self.module.params = {'provider': None, 'state': 'present', 'network': '192.168.10.0/24', - 'comment': None, 'extattrs': None} + 'comment': None, 'extattrs': None, 'use_logic_filter_rules': False, + 'logic_filter_rules': []} test_object = None test_spec = { @@ -250,3 +255,62 @@ def test_nios_networkcontainer_ipv6_create(self): self.assertTrue(res['changed']) wapi.create_object.assert_called_once_with('testobject', {'ipv6networkcontainer': 'fe80::/64'}) + + def test_nios_network_ipv4_create_with_use_logic_filter_rules(self): + self.module.params = {'provider': None, 'state': 'present', 'network': '192.168.10.0/24', + 'comment': None, 'extattrs': None, 'use_logic_filter_rules': True, + 'logic_filter_rules': []} + + test_object = None + test_spec = { + "network": {"ib_req": True}, + "comment": {}, + "extattrs": {}, + "use_logic_filter_rules": {}, + "logic_filter_rules": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'network': '192.168.10.0/24', + 'use_logic_filter_rules': True, + 'logic_filter_rules': [] + } + ) + + def test_nios_network_ipv4_update_with_use_logic_filter_rules(self): + self.module.params = {'provider': None, 'state': 'present', 'network': '192.168.10.0/24', + 'comment': 'updated comment', 'extattrs': None, 'use_logic_filter_rules': True, + 'logic_filter_rules': []} + + ref = "network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "network": "192.168.10.0/24", + "extattrs": {'options': {'name': 'test', 'value': 'ansible.com'}}, + "use_logic_filter_rules": False, + "logic_filter_rules": [] + } + ] + + test_spec = { + "network": {"ib_req": True}, + "comment": {}, + "extattrs": {}, + "use_logic_filter_rules": {}, + "logic_filter_rules": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'network': '192.168.10.0/24', + 'comment': 'updated comment', + 'use_logic_filter_rules': True, + 'logic_filter_rules': []} + ) From 10cb08a0ee23f6cf120265395cbd9761d89f4701 Mon Sep 17 00:00:00 2001 From: Mauricio Teixeira <1847440+badnetmask@users.noreply.github.com> Date: Thu, 22 Aug 2024 00:50:00 -0400 Subject: [PATCH 15/29] Add modules to manipulate additional types of Name Server Groups (#56) * clarify that nios_nsgroup creates authoritative groups * add nios_nsgroup_forwardingmember * add nios_nsgroup_forwardingmember * fix sanity tests * fix module description * add nios_nsgroup_delegation * add nios_nsgroup_stubmember * fix bad merge * remove deprecated files * modify ib_spec to fix sanity errors * add missing import to fix sanity tests * include integration test for nios_nsgroup_delegation (fails on my local system, wanna check what happens on github) * fix incorrect object type for 'extattrs' * correct integration tests for nios_nsgroup_delegation_idempotence.yml NOTE: requires update on 'nios-test-container' which has not been pushed yet * fix typos on nios_nsgroup_delegation_idempotence integration test * add remaining integration tests for all nsgroup types NOTE: automated github tests in this repo will fail until this is merged, and a new image is pushed to quay.io: https://github.com/ansible/nios-test-container/pull/8 * fix sanity tests * retrigger checks * retrigger checks * fix integration and sanity tests * fix sanity tests for ansible devel branch --- README.md | 10 +- plugins/module_utils/api.py | 4 + plugins/modules/nios_nsgroup.py | 4 +- plugins/modules/nios_nsgroup_delegation.py | 128 +++++++++++++ .../modules/nios_nsgroup_forwardingmember.py | 175 ++++++++++++++++++ .../modules/nios_nsgroup_forwardstubserver.py | 128 +++++++++++++ plugins/modules/nios_nsgroup_stubmember.py | 119 ++++++++++++ .../targets/nios_nsgroup_delegation/aliases | 3 + .../defaults/main.yaml | 3 + .../nios_nsgroup_delegation/meta/main.yaml | 2 + .../nios_nsgroup_delegation/tasks/main.yml | 1 + .../nios_nsgroup_delegation_idempotence.yml | 83 +++++++++ .../nios_nsgroup_forwardingmember/aliases | 3 + .../defaults/main.yaml | 3 + .../meta/main.yaml | 2 + .../tasks/main.yml | 1 + ...s_nsgroup_forwardingmember_idempotence.yml | 104 +++++++++++ .../nios_nsgroup_forwardstubserver/aliases | 3 + .../defaults/main.yaml | 3 + .../meta/main.yaml | 2 + .../tasks/main.yml | 1 + ..._nsgroup_forwardstubserver_idempotence.yml | 83 +++++++++ .../targets/nios_nsgroup_stubmember/aliases | 3 + .../defaults/main.yaml | 3 + .../nios_nsgroup_stubmember/meta/main.yaml | 2 + .../nios_nsgroup_stubmember/tasks/main.yml | 1 + .../nios_nsgroup_stubmember_idempotence.yml | 76 ++++++++ 27 files changed, 947 insertions(+), 3 deletions(-) create mode 100644 plugins/modules/nios_nsgroup_delegation.py create mode 100644 plugins/modules/nios_nsgroup_forwardingmember.py create mode 100644 plugins/modules/nios_nsgroup_forwardstubserver.py create mode 100644 plugins/modules/nios_nsgroup_stubmember.py create mode 100644 tests/integration/targets/nios_nsgroup_delegation/aliases create mode 100644 tests/integration/targets/nios_nsgroup_delegation/defaults/main.yaml create mode 100644 tests/integration/targets/nios_nsgroup_delegation/meta/main.yaml create mode 100644 tests/integration/targets/nios_nsgroup_delegation/tasks/main.yml create mode 100644 tests/integration/targets/nios_nsgroup_delegation/tasks/nios_nsgroup_delegation_idempotence.yml create mode 100644 tests/integration/targets/nios_nsgroup_forwardingmember/aliases create mode 100644 tests/integration/targets/nios_nsgroup_forwardingmember/defaults/main.yaml create mode 100644 tests/integration/targets/nios_nsgroup_forwardingmember/meta/main.yaml create mode 100644 tests/integration/targets/nios_nsgroup_forwardingmember/tasks/main.yml create mode 100644 tests/integration/targets/nios_nsgroup_forwardingmember/tasks/nios_nsgroup_forwardingmember_idempotence.yml create mode 100644 tests/integration/targets/nios_nsgroup_forwardstubserver/aliases create mode 100644 tests/integration/targets/nios_nsgroup_forwardstubserver/defaults/main.yaml create mode 100644 tests/integration/targets/nios_nsgroup_forwardstubserver/meta/main.yaml create mode 100644 tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/main.yml create mode 100644 tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/nios_nsgroup_forwardstubserver_idempotence.yml create mode 100644 tests/integration/targets/nios_nsgroup_stubmember/aliases create mode 100644 tests/integration/targets/nios_nsgroup_stubmember/defaults/main.yaml create mode 100644 tests/integration/targets/nios_nsgroup_stubmember/meta/main.yaml create mode 100644 tests/integration/targets/nios_nsgroup_stubmember/tasks/main.yml create mode 100644 tests/integration/targets/nios_nsgroup_stubmember/tasks/nios_nsgroup_stubmember_idempotence.yml diff --git a/README.md b/README.md index b7665d50..17bd1c58 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,15 @@ Modules - `nios_network_view` – Configure Infoblox NIOS network views -- `nios_nsgroup` – Configure Infoblox DNS Nameserver Groups +- `nios_nsgroup` – Configure Infoblox DNS Nameserver Authoritative Groups + +- `nios_nsgroup_delegation` – Configure Infoblox DNS Nameserver Delegation Groups + +- `nios_nsgroup_forwardingmember` – Configure Infoblox DNS Nameserver Forwarding Member Groups + +- `nios_nsgroup_forwardstubserver` – Configure Infoblox DNS Nameserver Forward/Stub Server Groups + +- `nios_nsgroup_stubmember` – Configure Infoblox DNS Nameserver Stub Member Groups - `nios_ptr_record` – Configure Infoblox NIOS PTR records diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index c95c8df6..51d47d33 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -71,6 +71,10 @@ NIOS_DTC_SERVER = 'dtc:server' NIOS_DTC_POOL = 'dtc:pool' NIOS_DTC_LBDN = 'dtc:lbdn' +NIOS_NSGROUP_FORWARDSTUBSERVER = 'nsgroup:forwardstubserver' +NIOS_NSGROUP_FORWARDINGMEMBER = 'nsgroup:forwardingmember' +NIOS_NSGROUP_DELEGATION = 'nsgroup:delegation' +NIOS_NSGROUP_STUBMEMBER = 'nsgroup:stubmember' NIOS_DTC_MONITOR_HTTP = 'dtc:monitor:http' NIOS_DTC_MONITOR_ICMP = 'dtc:monitor:icmp' NIOS_DTC_MONITOR_PDP = 'dtc:monitor:pdp' diff --git a/plugins/modules/nios_nsgroup.py b/plugins/modules/nios_nsgroup.py index 948fe238..91e5d6d4 100644 --- a/plugins/modules/nios_nsgroup.py +++ b/plugins/modules/nios_nsgroup.py @@ -11,14 +11,14 @@ DOCUMENTATION = ''' --- module: nios_nsgroup -short_description: Configure InfoBlox DNS Nameserver Groups +short_description: Configure InfoBlox DNS Nameserver Authoritative Groups version_added: "1.0.0" extends_documentation_fragment: infoblox.nios_modules.nios author: - Erich Birngruber (@ebirn) - Sumit Jaiswal (@sjaiswal) description: - - Adds and/or removes nameserver groups form Infoblox NIOS servers. + - Adds and/or removes nameserver groups of type "Authoritative" form Infoblox NIOS servers. This module manages NIOS C(nsgroup) objects using the Infoblox. WAPI interface over REST. requirements: - infoblox_client diff --git a/plugins/modules/nios_nsgroup_delegation.py b/plugins/modules/nios_nsgroup_delegation.py new file mode 100644 index 00000000..6eec00d1 --- /dev/null +++ b/plugins/modules/nios_nsgroup_delegation.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# Copyright © 2020 Infoblox Inc +# -*- coding: utf-8 -*- +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_nsgroup_delegation +short_description: Configure InfoBlox DNS Nameserver Delegation Groups +extends_documentation_fragment: infoblox.nios_modules.nios +author: + - Mauricio Teixeira (@badnetmask) +description: + - Adds and/or removes nameserver groups of type "Delegation" form Infoblox NIOS servers. + This module manages NIOS C(nsgroup:delegation) objects using the Infoblox. WAPI interface over REST. +requirements: + - infoblox_client +options: + name: + description: + - Specifies the name of the NIOS nameserver group to be managed. + required: true + type: str + delegate_to: + description: + - Specifies the list of name servers to be used + required: true + type: list + elements: dict + suboptions: + name: + description: + - Provide the name of the server + required: true + type: str + address: + description: + - Provide the IP address of the server + required: true + type: str + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + required: false + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + required: false + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + choices: [present, absent] + default: present + type: str +''' + +EXAMPLES = ''' +- name: create infoblox nameserver delegation group + infoblox.nios_modules.nios_nsgroup_delegation: + name: my-delegation-group + comment: "this is a delegation nameserver group" + delegate_to: + - name: first + address: 192.168.0.10 + - name: second + address: 192.168.0.20 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_NSGROUP_DELEGATION +from ..module_utils.api import normalize_ib_spec + + +def main(): + '''entrypoint for module execution.''' + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']), + ) + + delegate_to_spec = dict( + name=dict(required=True), + address=dict(required=True) + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + delegate_to=dict(type='list', elements='dict', required=True, options=delegate_to_spec), + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_NSGROUP_DELEGATION, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_nsgroup_forwardingmember.py b/plugins/modules/nios_nsgroup_forwardingmember.py new file mode 100644 index 00000000..f1fb3507 --- /dev/null +++ b/plugins/modules/nios_nsgroup_forwardingmember.py @@ -0,0 +1,175 @@ +#!/usr/bin/python +# Copyright © 2020 Infoblox Inc +# -*- coding: utf-8 -*- +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_nsgroup_forwardingmember +short_description: Configure InfoBlox DNS Nameserver Forward/Stub Server Groups +extends_documentation_fragment: infoblox.nios_modules.nios +author: + - Mauricio Teixeira (@badnetmask) +description: + - Adds and/or removes nameserver groups of type "Forwarding Member" from Infoblox NIOS servers. + This module manages NIOS C(nsgroup:forwardstubserver) objects using the Infoblox. WAPI interface over REST. +requirements: + - infoblox_client +options: + name: + description: + - Specifies the name of the NIOS nameserver group to be managed. + required: true + type: str + forwarding_servers: + description: + - Specifies the list of forwarding member servers to be used + required: true + type: list + elements: dict + suboptions: + name: + description: + - The name of the forwarding grid member in FQDN format + required: true + type: str + forwarders_only: + description: + - Determines if the appliance sends queries to forwarders only, and not to other internal or Internet root servers. + required: false + type: bool + default: false + use_override_forwarders: + description: + - When using c(forward_to) option, and this is set to C(True), only the defined custom forwarders will be used (no recurse to root nameservers). + required: false + type: bool + default: false + forward_to: + description: + - The information for the remote name server to which you want the Infoblox appliance to forward queries for a specified domain name. + required: false + type: list + default: [] + elements: dict + suboptions: + name: + description: + - Provide the name of the server + required: true + type: str + address: + description: + - Provide the IP address of the server + required: true + type: str + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + required: false + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + required: false + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + choices: [present, absent] + default: present + type: str +''' + +EXAMPLES = ''' +- name: create infoblox nameserver forwarding member group + infoblox.nios_modules.nios_nsgroup_forwardingmember: + name: my-forwardingmember-group + comment: "this is a forwarding member nameserver group" + forwarding_servers: + - name: member.localdomain + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: create infoblox nameserver forwarding member group with external forwarders + infoblox.nios_modules.nios_nsgroup_forwardingmember: + name: my-forwardingmember-group + comment: "this is a forwarding member nameserver group with external forwarders" + forwarding_servers: + - name: member.localdomain + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_NSGROUP_FORWARDINGMEMBER +from ..module_utils.api import normalize_ib_spec + + +def main(): + '''entrypoint for module execution.''' + + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']), + ) + + forward_to_spec = dict( + name=dict(required=True), + address=dict(required=True), + ) + + forwarding_servers_spec = dict( + name=dict(required=True), + forwarders_only=dict(type='bool', default=False), + forward_to=dict(type='list', elements='dict', options=forward_to_spec, default=[], required=False), + use_override_forwarders=dict(type='bool', default=False), + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + forwarding_servers=dict(type='list', elements='dict', required=True, options=forwarding_servers_spec), + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_NSGROUP_FORWARDINGMEMBER, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_nsgroup_forwardstubserver.py b/plugins/modules/nios_nsgroup_forwardstubserver.py new file mode 100644 index 00000000..e7d2b033 --- /dev/null +++ b/plugins/modules/nios_nsgroup_forwardstubserver.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# Copyright © 2020 Infoblox Inc +# -*- coding: utf-8 -*- +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_nsgroup_forwardstubserver +short_description: Configure InfoBlox DNS Nameserver Forwarding Member Groups +extends_documentation_fragment: infoblox.nios_modules.nios +author: + - Mauricio Teixeira (@badnetmask) +description: + - Adds and/or removes nameserver groups of type "Forward/Stub Server" form Infoblox NIOS servers. + This module manages NIOS C(nsgroup:forwardstubserver) objects using the Infoblox. WAPI interface over REST. +requirements: + - infoblox_client +options: + name: + description: + - Specifies the name of the NIOS nameserver group to be managed. + required: true + type: str + external_servers: + description: + - Specifies the list of name servers to be used + required: true + type: list + elements: dict + suboptions: + name: + description: + - Provide the name of the server + required: true + type: str + address: + description: + - Provide the IP address of the server + required: true + type: str + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + required: false + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + required: false + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + choices: [present, absent] + default: present + type: str +''' + +EXAMPLES = ''' +- name: create infoblox nameserver forward/stub group + infoblox.nios_modules.nios_nsgroup_forwardstubserver: + name: my-forwardstub-group + comment: "this is a forward/stub nameserver group" + nameservers: + - name: first + address: 192.168.0.10 + - name: second + address: 192.168.0.20 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_NSGROUP_FORWARDSTUBSERVER +from ..module_utils.api import normalize_ib_spec + + +def main(): + '''entrypoint for module execution.''' + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']), + ) + + external_servers_spec = dict( + name=dict(required=True), + address=dict(required=True) + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + external_servers=dict(type='list', elements='dict', required=True, options=external_servers_spec), + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_NSGROUP_FORWARDSTUBSERVER, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_nsgroup_stubmember.py b/plugins/modules/nios_nsgroup_stubmember.py new file mode 100644 index 00000000..d10fbf50 --- /dev/null +++ b/plugins/modules/nios_nsgroup_stubmember.py @@ -0,0 +1,119 @@ +#!/usr/bin/python +# Copyright © 2020 Infoblox Inc +# -*- coding: utf-8 -*- +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_nsgroup_stubmember +short_description: Configure InfoBlox DNS Nameserver Stub Member Groups +extends_documentation_fragment: infoblox.nios_modules.nios +author: + - Mauricio Teixeira (@badnetmask) +description: + - Adds and/or removes nameserver groups of type "Stub Member" form Infoblox NIOS servers. + This module manages NIOS C(nsgroup:stubmember) objects using the Infoblox. WAPI interface over REST. +requirements: + - infoblox_client +options: + name: + description: + - Specifies the name of the NIOS nameserver group to be managed. + required: true + type: str + stub_members: + description: + - Specifies the list of members to be used + required: true + type: list + elements: dict + suboptions: + name: + description: + - Provide the name of the member + required: true + type: str + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + required: false + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + required: false + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + choices: [present, absent] + default: present + type: str +''' + +EXAMPLES = ''' +- name: create infoblox nameserver stub member group + infoblox.nios_modules.nios_nsgroup_stubmember: + name: my-stubmember-group + comment: "this is a stub member nameserver group" + stub_members: + - name: member.localdomain + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_NSGROUP_STUBMEMBER +from ..module_utils.api import normalize_ib_spec + + +def main(): + '''entrypoint for module execution.''' + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']), + ) + + stub_members_spec = dict( + name=dict(required=True), + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + stub_members=dict(type='list', elements='dict', required=True, options=stub_members_spec), + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_NSGROUP_STUBMEMBER, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/tests/integration/targets/nios_nsgroup_delegation/aliases b/tests/integration/targets/nios_nsgroup_delegation/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_delegation/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_nsgroup_delegation/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_delegation/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_delegation/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_delegation/meta/main.yaml b/tests/integration/targets/nios_nsgroup_delegation/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_delegation/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_delegation/tasks/main.yml b/tests/integration/targets/nios_nsgroup_delegation/tasks/main.yml new file mode 100644 index 00000000..0dd08be4 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_delegation/tasks/main.yml @@ -0,0 +1 @@ +- include_tasks: nios_nsgroup_delegation_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_delegation/tasks/nios_nsgroup_delegation_idempotence.yml b/tests/integration/targets/nios_nsgroup_delegation/tasks/nios_nsgroup_delegation_idempotence.yml new file mode 100644 index 00000000..aad5ae76 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_delegation/tasks/nios_nsgroup_delegation_idempotence.yml @@ -0,0 +1,83 @@ +- name: cleanup nsgroup delegation + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + state: absent + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + +- name: configure a nsgroup delegation on the system + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + state: present + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_create1 + +- name: configure another nsgroup delegation on the system + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + state: present + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_create2 + +- name: update the comment and ext attributes for an existing nsgroup delegation + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_update1 + +- name: update again the comment and ext attributes for an existing nsgroup delegation + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_update2 + +- name: remove the nsgroup delegation + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + state: absent + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_delete1 + +- name: remove again the nsgroup delegation + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + state: absent + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_delete2 + +- assert: + that: + - "nsgroup_delegation_create1.changed" + - "not nsgroup_delegation_create2.changed" + - "nsgroup_delegation_update1.changed" + - "not nsgroup_delegation_update2.changed" + - "nsgroup_delegation_delete1.changed" + - "not nsgroup_delegation_delete2.changed" diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/aliases b/tests/integration/targets/nios_nsgroup_forwardingmember/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_forwardingmember/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/meta/main.yaml b/tests/integration/targets/nios_nsgroup_forwardingmember/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/main.yml b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/main.yml new file mode 100644 index 00000000..32ed6486 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/main.yml @@ -0,0 +1 @@ +- include_tasks: nios_nsgroup_forwardingmember_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/nios_nsgroup_forwardingmember_idempotence.yml b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/nios_nsgroup_forwardingmember_idempotence.yml new file mode 100644 index 00000000..743b1cd9 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/nios_nsgroup_forwardingmember_idempotence.yml @@ -0,0 +1,104 @@ +- name: cleanup nsgroup forwardingmember + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + state: absent + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + +- name: configure a nsgroup forwardingmember on the system + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + state: present + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_create1 + +- name: configure another nsgroup forwardingmember on the system + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + state: present + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_create2 + +- name: update the comment and ext attributes for an existing nsgroup forwardingmember + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_update1 + +- name: update again the comment and ext attributes for an existing nsgroup forwardingmember + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_update2 + +- name: remove the nsgroup forwardingmember + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + state: absent + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_delete1 + +- name: remove again the nsgroup forwardingmember + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + state: absent + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_delete2 + +- assert: + that: + - "nsgroup_forwardingmember_create1.changed" + - "not nsgroup_forwardingmember_create2.changed" + - "nsgroup_forwardingmember_update1.changed" + - "not nsgroup_forwardingmember_update2.changed" + - "nsgroup_forwardingmember_delete1.changed" + - "not nsgroup_forwardingmember_delete2.changed" diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/aliases b/tests/integration/targets/nios_nsgroup_forwardstubserver/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_forwardstubserver/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/meta/main.yaml b/tests/integration/targets/nios_nsgroup_forwardstubserver/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/main.yml b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/main.yml new file mode 100644 index 00000000..e356aa50 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/main.yml @@ -0,0 +1 @@ +- include_tasks: nios_nsgroup_forwardstubserver_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/nios_nsgroup_forwardstubserver_idempotence.yml b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/nios_nsgroup_forwardstubserver_idempotence.yml new file mode 100644 index 00000000..915c1186 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/nios_nsgroup_forwardstubserver_idempotence.yml @@ -0,0 +1,83 @@ +- name: cleanup nsgroup forwardstubserver + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + state: absent + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + +- name: configure a nsgroup forwardstubserver on the system + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + state: present + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_create1 + +- name: configure another nsgroup forwardstubserver on the system + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + state: present + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_create2 + +- name: update the comment and ext attributes for an existing nsgroup forwardstubserver + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_update1 + +- name: update again the comment and ext attributes for an existing nsgroup forwardstubserver + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_update2 + +- name: remove the nsgroup forwardstubserver + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + state: absent + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_delete1 + +- name: remove again the nsgroup forwardstubserver + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + state: absent + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_delete2 + +- assert: + that: + - "nsgroup_forwardstubserver_create1.changed" + - "not nsgroup_forwardstubserver_create2.changed" + - "nsgroup_forwardstubserver_update1.changed" + - "not nsgroup_forwardstubserver_update2.changed" + - "nsgroup_forwardstubserver_delete1.changed" + - "not nsgroup_forwardstubserver_delete2.changed" diff --git a/tests/integration/targets/nios_nsgroup_stubmember/aliases b/tests/integration/targets/nios_nsgroup_stubmember/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_stubmember/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_nsgroup_stubmember/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_stubmember/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_stubmember/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_stubmember/meta/main.yaml b/tests/integration/targets/nios_nsgroup_stubmember/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_stubmember/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_stubmember/tasks/main.yml b/tests/integration/targets/nios_nsgroup_stubmember/tasks/main.yml new file mode 100644 index 00000000..e0cbb36f --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_stubmember/tasks/main.yml @@ -0,0 +1 @@ +- include_tasks: nios_nsgroup_stubmember_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_stubmember/tasks/nios_nsgroup_stubmember_idempotence.yml b/tests/integration/targets/nios_nsgroup_stubmember/tasks/nios_nsgroup_stubmember_idempotence.yml new file mode 100644 index 00000000..b7f97108 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_stubmember/tasks/nios_nsgroup_stubmember_idempotence.yml @@ -0,0 +1,76 @@ +- name: cleanup nsgroup stubmember + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + state: absent + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + +- name: configure a nsgroup stubmember on the system + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + state: present + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_create1 + +- name: configure another nsgroup stubmember on the system + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + state: present + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_create2 + +- name: update the comment and ext attributes for an existing nsgroup stubmember + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_update1 + +- name: update again the comment and ext attributes for an existing nsgroup stubmember + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_update2 + +- name: remove the nsgroup stubmember + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + state: absent + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_delete1 + +- name: remove again the nsgroup stubmember + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + state: absent + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_delete2 + +- assert: + that: + - "nsgroup_stubmember_create1.changed" + - "not nsgroup_stubmember_create2.changed" + - "nsgroup_stubmember_update1.changed" + - "not nsgroup_stubmember_update2.changed" + - "nsgroup_stubmember_delete1.changed" + - "not nsgroup_stubmember_delete2.changed" From b1623bc3a342a769df00782e4ffe3fdb663f678b Mon Sep 17 00:00:00 2001 From: dlehrman Date: Thu, 22 Aug 2024 01:40:27 -0400 Subject: [PATCH 16/29] Exclude DNS View from filter criteria when configure_for_dns is false (#229) * Exclude DNS View from filter criteria when configure_for_dns is false This logic was already applied to scenarios that were not updating a name (lines 715-719). This commit simply applies the same logic to scenarios where names are being updated. Signed-off-by: David Ehrman * Add changelog fragment Signed-off-by: David Ehrman --------- Signed-off-by: David Ehrman --- changelogs/fragments/229-handle-host-rename-without-dns.yml | 4 ++++ plugins/module_utils/api.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/229-handle-host-rename-without-dns.yml diff --git a/changelogs/fragments/229-handle-host-rename-without-dns.yml b/changelogs/fragments/229-handle-host-rename-without-dns.yml new file mode 100644 index 00000000..bf540a20 --- /dev/null +++ b/changelogs/fragments/229-handle-host-rename-without-dns.yml @@ -0,0 +1,4 @@ +--- +bugfixes: + - nios_host_record - rename logic included DNS view in filter critera, even when DNS had been bypassed. Omits DNS view from filter critera when renaming a host object and DNS is bypassed. (https://github.com/infobloxopen/infoblox-ansible/issues/230) +... diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 51d47d33..9e8ff037 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -695,7 +695,11 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): if old_name and new_name: if (ib_obj_type == NIOS_HOST_RECORD): - test_obj_filter = dict([('name', old_name), ('view', obj_filter['view'])]) + # to check only by old_name if dns bypassing is set + if not obj_filter['configure_for_dns']: + test_obj_filter = dict([('name', old_name)]) + else: + test_obj_filter = dict([('name', old_name), ('view', obj_filter['view'])]) # if there are multiple records with same name and different ip elif (ib_obj_type == NIOS_A_RECORD): test_obj_filter = dict([('name', old_name), ('ipv4addr', obj_filter['ipv4addr'])]) From b288ce373b05464f02db2e35643044f11bd5fd15 Mon Sep 17 00:00:00 2001 From: Mohamed Alibi Date: Tue, 3 Sep 2024 12:37:10 +0100 Subject: [PATCH 17/29] Adding the two options to Ipv4 to allow PXE server configuration (#146) * Adding the two options to Ipv4 to allow PXE server configuration --- plugins/modules/nios_host_record.py | 19 +++++++++++++++++++ tests/requirements.txt | 2 ++ tests/unit/requirements.txt | 2 ++ 3 files changed, 23 insertions(+) diff --git a/plugins/modules/nios_host_record.py b/plugins/modules/nios_host_record.py index 31f7f513..66f00549 100644 --- a/plugins/modules/nios_host_record.py +++ b/plugins/modules/nios_host_record.py @@ -92,6 +92,23 @@ required: false aliases: - add + use_nextserver: + version_added: "1.0.0" + description: + - Enable the use of the nextserver option + type: bool + required: false + aliases: + - use_pxe + nextserver: + version_added: "1.0.0" + description: + - Takes as input the name in FQDN format and/or IPv4 Address of + the next server that the host needs to boot from. + type: str + required: false + aliases: + - pxe remove: version_added: "1.0.0" description: @@ -328,6 +345,8 @@ def main(): configure_for_dhcp=dict(type='bool', required=False, aliases=['dhcp']), mac=dict(required=False), add=dict(type='bool', required=False), + use_nextserver=dict(type='bool', required=False, aliases=['use_pxe']), + nextserver=dict(required=False, aliases=['pxe']), remove=dict(type='bool', required=False) ) diff --git a/tests/requirements.txt b/tests/requirements.txt index 708b417d..f0ae0e93 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,3 +1,5 @@ +pip==20.3.4; python_version == '2.6' or python_version=='2.7' +pip==22.2.2; python_version > '3.0' infoblox-client pytest pytest-xdist diff --git a/tests/unit/requirements.txt b/tests/unit/requirements.txt index c64045e9..065df589 100644 --- a/tests/unit/requirements.txt +++ b/tests/unit/requirements.txt @@ -1,3 +1,5 @@ +pip==20.3.4; python_version == '2.6' or python_version=='2.7' +pip==22.2.2; python_version > '3.0' infoblox-client pytest pytest-forked From 1c947713461d0869c7ef44261ad12a0389be9b99 Mon Sep 17 00:00:00 2001 From: Christian-Kolrep <72132031+Christian-Kolrep@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:51:18 +0200 Subject: [PATCH 18/29] ipv6 network container support and more argument validation in nios_next_network lookup plugin (#178) --- plugins/lookup/nios_next_network.py | 50 +++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/plugins/lookup/nios_next_network.py b/plugins/lookup/nios_next_network.py index af3dbf65..9324fe4c 100644 --- a/plugins/lookup/nios_next_network.py +++ b/plugins/lookup/nios_next_network.py @@ -68,6 +68,11 @@ ansible.builtin.set_fact: networkaddr: "{{ lookup('infoblox.nios_modules.nios_next_network', '192.168.10.0/24', cidr=25, exclude=['192.168.10.0/25'], provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + +- name: return the available ipv6 network addresses for network-container 2001:1:111:1::0/64 + set_fact: + networkaddr: "{{ lookup('infoblox.nios_modules.nios_next_network', '2001:1:111:1::0/64', cidr=126, + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" """ RETURN = """ @@ -82,32 +87,63 @@ from ansible.module_utils._text import to_text from ansible.errors import AnsibleError from ..module_utils.api import WapiLookup - +from ..module_utils.api import NIOS_IPV4_NETWORK_CONTAINER, NIOS_IPV6_NETWORK_CONTAINER +import ipaddress class LookupModule(LookupBase): def run(self, terms, variables=None, **kwargs): try: - network = terms[0] + network = ipaddress.ip_network(terms[0], strict=True) except IndexError: - raise AnsibleError('missing network argument in the form of A.B.C.D/E') + raise AnsibleError('network argument is missing') + except (ValueError, TypeError) as error: + raise AnsibleError('network argument is invalid %s' % error) try: cidr = kwargs.get('cidr', 24) + # maybe using network.prefixlen+1 as default except IndexError: raise AnsibleError('missing CIDR argument in the form of xx') + if network.prefixlen >= cidr: + raise AnsibleError('cidr %s must be greater than parent network cidr %s' % (cidr,network.prefixlen)) + + container_type = None + network_objects = None + + # check for ip version 4 or 6 else die + if network.version == 4: + container_type = NIOS_IPV4_NETWORK_CONTAINER + if cidr not in range(1, 32): + raise AnsibleError('cidr %s must be in range 1 to 32' % cidr) + elif network.version == 6: + container_type = NIOS_IPV6_NETWORK_CONTAINER + if cidr not in range(1, 128): + raise AnsibleError('cidr %s must be in range 1 to 128' % cidr) + else: + raise AnsibleError('not a valid ipv4 or ipv6 network definition %s' % terms[0]) + + # check for valid subnetting cidr + if network.prefixlen >= cidr: + raise AnsibleError('cidr %s must be greater than parent network cidr %s' % (cidr,network.prefixlen)) + provider = kwargs.pop('provider', {}) wapi = WapiLookup(provider) - network_obj = wapi.get_object('networkcontainer', {'network': network}) - if network_obj is None: - raise AnsibleError('unable to find network-container object %s' % network) + if container_type is None: + raise AnsibleError('unable to identify network-container type') + + network_objects = wapi.get_object(container_type, {'network': network.with_prefixlen}) + + if network_objects is None: + raise AnsibleError('unable to find network-container object %s' % network.with_prefixlen) + num = kwargs.get('num', 1) exclude_ip = kwargs.get('exclude', []) network_view = kwargs.get('network_view', 'default') try: - ref_list = [network['_ref'] for network in network_obj if network['network_view'] == network_view] + ref_list = [network_obj['_ref'] for network_obj in network_objects if network_obj['network_view'] == network_view] if not ref_list: raise AnsibleError('no records found') else: From 74e785cd9cc6d98a98ab5df522bf71dd44686e3c Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:34:34 +0530 Subject: [PATCH 19/29] [FIX] Removed older PIP added by community PR #146 (#256) * [FIX] Removed older PIP added by community PR #146 * [FIX] Sanity issue on nios_next_network --- .github/workflows/ansible-test.yml | 2 +- plugins/lookup/nios_next_network.py | 15 ++++++++------- tests/requirements.txt | 2 -- tests/unit/requirements.txt | 2 -- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 24bbfe05..b3b0d8f2 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -24,7 +24,7 @@ jobs: python-version: '3.11' - name: Install ansible (${{ matrix.ansible-version }}) - run: pip install pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check - name: Build a collection tarball run: ansible-galaxy collection build --output-path "${GITHUB_WORKSPACE}/.cache/collection-tarballs" diff --git a/plugins/lookup/nios_next_network.py b/plugins/lookup/nios_next_network.py index 9324fe4c..776f63c9 100644 --- a/plugins/lookup/nios_next_network.py +++ b/plugins/lookup/nios_next_network.py @@ -69,10 +69,10 @@ networkaddr: "{{ lookup('infoblox.nios_modules.nios_next_network', '192.168.10.0/24', cidr=25, exclude=['192.168.10.0/25'], provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" -- name: return the available ipv6 network addresses for network-container 2001:1:111:1::0/64 - set_fact: - networkaddr: "{{ lookup('infoblox.nios_modules.nios_next_network', '2001:1:111:1::0/64', cidr=126, - provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" +- name: return the available ipv6 network addresses for network-container 2001:1:111:1::0/64 + set_fact: + networkaddr: "{{ lookup('infoblox.nios_modules.nios_next_network', '2001:1:111:1::0/64', cidr=126, + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" """ RETURN = """ @@ -90,6 +90,7 @@ from ..module_utils.api import NIOS_IPV4_NETWORK_CONTAINER, NIOS_IPV6_NETWORK_CONTAINER import ipaddress + class LookupModule(LookupBase): def run(self, terms, variables=None, **kwargs): @@ -106,7 +107,7 @@ def run(self, terms, variables=None, **kwargs): raise AnsibleError('missing CIDR argument in the form of xx') if network.prefixlen >= cidr: - raise AnsibleError('cidr %s must be greater than parent network cidr %s' % (cidr,network.prefixlen)) + raise AnsibleError('cidr %s must be greater than parent network cidr %s' % (cidr, network.prefixlen)) container_type = None network_objects = None @@ -125,14 +126,14 @@ def run(self, terms, variables=None, **kwargs): # check for valid subnetting cidr if network.prefixlen >= cidr: - raise AnsibleError('cidr %s must be greater than parent network cidr %s' % (cidr,network.prefixlen)) + raise AnsibleError('cidr %s must be greater than parent network cidr %s' % (cidr, network.prefixlen)) provider = kwargs.pop('provider', {}) wapi = WapiLookup(provider) if container_type is None: raise AnsibleError('unable to identify network-container type') - + network_objects = wapi.get_object(container_type, {'network': network.with_prefixlen}) if network_objects is None: diff --git a/tests/requirements.txt b/tests/requirements.txt index f0ae0e93..708b417d 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,5 +1,3 @@ -pip==20.3.4; python_version == '2.6' or python_version=='2.7' -pip==22.2.2; python_version > '3.0' infoblox-client pytest pytest-xdist diff --git a/tests/unit/requirements.txt b/tests/unit/requirements.txt index 065df589..c64045e9 100644 --- a/tests/unit/requirements.txt +++ b/tests/unit/requirements.txt @@ -1,5 +1,3 @@ -pip==20.3.4; python_version == '2.6' or python_version=='2.7' -pip==22.2.2; python_version > '3.0' infoblox-client pytest pytest-forked From fb245f574049f7317b26c5de2ad1f18268e23781 Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:43:10 +0530 Subject: [PATCH 20/29] Develop (#254) * [FIX] added check for list element match. (#239) * [FIX] NPA-73, Re-execution showing change for each execution. (#240) * [FIX] NPA-77, Network container update operation. (#241) * - added network_view in get object search. (#242) * Ansible lint fix (#238) * Rebase from develop branch * anisible-lit fixes after rebase to develop branch. * [FIX] Ansible lint - changelog.yaml - nios_network_idempotence.yml * [FIX] CI job for ansible installation * [NPA-83] Fixed DHCP options for IPv4/v6 network container. (#243) * [NPA-83] Fixed dhcp options for IPv4/v6 network container. * - Added dhcp options supports for ipv4 and ipv6 network container. (#245) * - fixed Re-execution of IPv4/v6 network playbook shows 'changed' status. (#247) - fixed configuring dhcp option using 'num' field for network container is failing. * - [NPA-113] Unable to remove dhcp options from DHCP Range using ansible. (#248) * [ADD]Integration and Unit test cases for extensible attribute. (#246) * [ADD]Integration and Unit test cases for extensible attribute. * [FIX] Sanity Error for Unit testcase * [FIX] Coverage module version upgrade to v7.6.1 for devel branch with python3.12 * [FIX] Sanity Testt for extensible_attribute test. * [IMP] Updated nios-test-container version from 4.0.0 to 5.0.0 * - [NPA-125] unable to configure dhcp options with combination of 'num' and 'name' field. (#250) * [FIX] added check for list element match. (#239) * [FIX] NPA-73, Re-execution showing change for each execution. (#240) * [FIX] NPA-77, Network container update operation. (#241) * - added network_view in get object search. (#242) * Ansible lint fix (#238) * Rebase from develop branch * anisible-lit fixes after rebase to develop branch. * [FIX] Ansible lint - changelog.yaml - nios_network_idempotence.yml * [FIX] CI job for ansible installation * [NPA-83] Fixed DHCP options for IPv4/v6 network container. (#243) * [NPA-83] Fixed dhcp options for IPv4/v6 network container. * - Added dhcp options supports for ipv4 and ipv6 network container. (#245) * - fixed Re-execution of IPv4/v6 network playbook shows 'changed' status. (#247) - fixed configuring dhcp option using 'num' field for network container is failing. * - [NPA-113] Unable to remove dhcp options from DHCP Range using ansible. (#248) * [ADD]Integration and Unit test cases for extensible attribute. (#246) * [ADD]Integration and Unit test cases for extensible attribute. * [FIX] Sanity Error for Unit testcase * [FIX] Coverage module version upgrade to v7.6.1 for devel branch with python3.12 * [FIX] Sanity Testt for extensible_attribute test. * [IMP] Updated nios-test-container version from 4.0.0 to 5.0.0 * - [NPA-125] unable to configure dhcp options with combination of 'num' and 'name' field. (#250) * [IMP] Updated depricated artifact v1 to v4 --------- Co-authored-by: Jaykumar Chhatbar <45447272+JchhatbarInfoblox@users.noreply.github.com> --- .github/workflows/ansible-test.yml | 13 +- changelogs/.plugin-cache.yaml | 55 +-- changelogs/changelog.yaml | 394 +++++++++--------- changelogs/config.yaml | 33 +- galaxy.yml | 21 +- meta/runtime.yml | 2 +- playbooks/create_a_record.yaml | 20 +- playbooks/create_cname_record.yaml | 20 +- playbooks/create_dns_view.yml | 22 +- playbooks/create_dtc_lbdn.yml | 38 +- playbooks/create_dtc_monitor_http.yaml | 4 +- playbooks/create_dtc_monitor_icmp.yaml | 4 +- playbooks/create_dtc_monitor_pdp.yaml | 4 +- playbooks/create_dtc_monitor_sip.yaml | 4 +- playbooks/create_dtc_monitor_snmp.yaml | 4 +- playbooks/create_dtc_monitor_tcp.yaml | 4 +- playbooks/create_dtc_pool.yml | 30 +- playbooks/create_dtc_server.yml | 18 +- playbooks/create_dtc_topology.yml | 3 +- playbooks/create_extensible_attribute.yaml | 20 + playbooks/create_mx_record.yaml | 22 +- playbooks/create_network.yml | 28 +- playbooks/create_network_view.yml | 20 +- playbooks/create_txt_record.yaml | 20 +- playbooks/create_zone.yml | 22 +- playbooks/delete_cname_record.yaml | 18 +- playbooks/delete_dnsview.yml | 16 +- playbooks/delete_dtc_monitor_http.yaml | 4 +- playbooks/delete_dtc_monitor_icmp.yaml | 4 +- playbooks/delete_dtc_monitor_pdp.yaml | 4 +- playbooks/delete_dtc_monitor_sip.yaml | 4 +- playbooks/delete_dtc_monitor_snmp.yaml | 4 +- playbooks/delete_dtc_monitor_tcp.yaml | 4 +- playbooks/delete_dtc_topology.yml | 5 +- playbooks/delete_mx_record.yaml | 22 +- playbooks/delete_network.yml | 16 +- playbooks/delete_network_view.yml | 14 +- playbooks/delete_txt_record.yaml | 20 +- playbooks/delete_zone.yml | 16 +- playbooks/restart_services.yml | 10 +- playbooks/update_a_record.yml | 20 +- playbooks/update_member.yml | 28 +- plugins/lookup/nios_next_ip.py | 6 +- plugins/module_utils/api.py | 28 +- plugins/modules/nios_dtc_lbdn.py | 1 - plugins/modules/nios_extensible_attribute.py | 1 - plugins/modules/nios_member.py | 20 +- plugins/modules/nios_network.py | 4 +- plugins/modules/nios_nsgroup.py | 2 +- plugins/modules/nios_range.py | 7 +- plugins/modules/nios_txt_record.py | 66 +-- .../targets/nios_a_record/meta/main.yaml | 1 + .../targets/nios_a_record/tasks/main.yml | 4 +- .../tasks/nios_a_record_idempotence.yml | 52 +-- .../targets/nios_aaaa_record/meta/main.yaml | 1 + .../targets/nios_aaaa_record/tasks/main.yml | 4 +- .../tasks/nios_aaaa_record_idempotence.yml | 52 +-- .../targets/nios_cname_record/meta/main.yaml | 1 + .../targets/nios_cname_record/tasks/main.yml | 4 +- .../tasks/nios_cname_record_idempotence.yml | 52 +-- .../targets/nios_dns_view/defaults/main.yaml | 2 +- .../targets/nios_dns_view/meta/main.yaml | 3 +- .../targets/nios_dns_view/tasks/main.yml | 4 +- .../tasks/nios_dns_view_idempotence.yml | 44 +- .../nios_dtc_monitor_http/meta/main.yaml | 1 + .../nios_dtc_monitor_http/tasks/main.yaml | 4 +- .../nios_dtc_monitor_http_idempotence.yaml | 13 +- .../nios_dtc_monitor_icmp/meta/main.yaml | 1 + .../nios_dtc_monitor_icmp/tasks/main.yaml | 4 +- .../nios_dtc_monitor_icmp_idempotence.yaml | 13 +- .../nios_dtc_monitor_pdp/meta/main.yaml | 1 + .../nios_dtc_monitor_pdp/tasks/main.yaml | 4 +- .../nios_dtc_monitor_pdp_idempotence.yaml | 13 +- .../nios_dtc_monitor_sip/meta/main.yaml | 1 + .../nios_dtc_monitor_sip/tasks/main.yaml | 4 +- .../nios_dtc_monitor_sip_idempotence.yaml | 13 +- .../nios_dtc_monitor_snmp/meta/main.yaml | 1 + .../nios_dtc_monitor_snmp/tasks/main.yaml | 4 +- .../nios_dtc_monitor_snmp_idempotence.yaml | 13 +- .../nios_dtc_monitor_tcp/meta/main.yaml | 1 + .../nios_dtc_monitor_tcp/tasks/main.yaml | 4 +- .../nios_dtc_monitor_tcp_idempotence.yaml | 13 +- .../targets/nios_dtc_topology/meta/main.yaml | 1 + .../targets/nios_dtc_topology/tasks/main.yaml | 4 +- .../tasks/nios_dtc_topology_idempotence.yaml | 13 +- .../targets/nios_extensible_attribute/aliases | 3 + .../defaults/main.yaml | 3 + .../nios_extensible_attribute/meta/main.yaml | 2 + .../nios_extensible_attribute/tasks/main.yaml | 1 + .../tasks/nios_extensible_attribute.yaml | 147 +++++++ .../nios_host_record/defaults/main.yaml | 2 +- .../targets/nios_host_record/meta/main.yaml | 3 +- .../targets/nios_host_record/tasks/main.yml | 4 +- .../tasks/nios_host_record_idempotence.yml | 76 ++-- .../targets/nios_mx_record/meta/main.yaml | 1 + .../targets/nios_mx_record/tasks/main.yml | 4 +- .../tasks/nios_mx_record_idempotence.yml | 52 +-- .../targets/nios_naptr_record/meta/main.yaml | 1 + .../targets/nios_naptr_record/tasks/main.yml | 4 +- .../tasks/nios_naptr_record_idempotence.yml | 66 +-- .../targets/nios_network/meta/main.yaml | 3 +- .../targets/nios_network/tasks/main.yml | 4 +- .../tasks/nios_network_idempotence.yml | 85 ++-- .../nios_network_view/defaults/main.yaml | 2 +- .../targets/nios_network_view/meta/main.yaml | 3 +- .../targets/nios_network_view/tasks/main.yml | 4 +- .../tasks/nios_network_view_idempotence.yml | 44 +- .../targets/nios_ptr_record/meta/main.yaml | 1 + .../targets/nios_ptr_record/tasks/main.yml | 4 +- .../tasks/nios_ptr_record_idempotence.yml | 48 +-- .../targets/nios_srv_record/meta/main.yaml | 1 + .../targets/nios_srv_record/tasks/main.yml | 4 +- .../tasks/nios_srv_record_idempotence.yml | 52 +-- .../nios_txt_record/defaults/main.yaml | 2 +- .../targets/nios_txt_record/meta/main.yaml | 3 +- .../targets/nios_txt_record/tasks/main.yml | 4 +- .../tasks/nios_txt_record_idempotence.yml | 61 +-- .../targets/nios_zone/defaults/main.yaml | 2 +- .../targets/nios_zone/meta/main.yaml | 3 +- .../targets/nios_zone/tasks/main.yml | 4 +- .../nios_zone/tasks/nios_zone_idempotence.yml | 48 ++- .../targets/prepare_nios_tests/tasks/main.yml | 4 +- .../tasks/prepare_nios_tests_idempotence.yml | 4 +- .../modules/test_extensible_attribute.py | 158 +++++++ 124 files changed, 1440 insertions(+), 996 deletions(-) create mode 100644 playbooks/create_extensible_attribute.yaml create mode 100644 tests/integration/targets/nios_extensible_attribute/aliases create mode 100644 tests/integration/targets/nios_extensible_attribute/defaults/main.yaml create mode 100644 tests/integration/targets/nios_extensible_attribute/meta/main.yaml create mode 100644 tests/integration/targets/nios_extensible_attribute/tasks/main.yaml create mode 100644 tests/integration/targets/nios_extensible_attribute/tasks/nios_extensible_attribute.yaml create mode 100644 tests/unit/plugins/modules/test_extensible_attribute.py diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index b3b0d8f2..28a26681 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -30,7 +30,7 @@ jobs: run: ansible-galaxy collection build --output-path "${GITHUB_WORKSPACE}/.cache/collection-tarballs" - name: Store migrated collection artifacts - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: collection path: .cache/collection-tarballs @@ -74,7 +74,7 @@ jobs: run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check - name: Download migrated collection artifacts - uses: actions/download-artifact@v1 + uses: actions/download-artifact@v4 with: name: collection path: .cache/collection-tarballs @@ -94,7 +94,7 @@ jobs: - name: Generate coverage report run: | if [ "${{ matrix.ansible-version }}" == "devel" ]; then - pip install coverage==7.5.3; + pip install coverage==7.6.1; elif [ "${{ matrix.ansible-version }}" == "stable-2.15" ]; then pip install coverage==6.5.0; fi @@ -142,7 +142,7 @@ jobs: run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check - name: Download migrated collection artifacts - uses: actions/download-artifact@v1 + uses: actions/download-artifact@v4 with: name: collection path: .cache/collection-tarball @@ -152,6 +152,7 @@ jobs: - name: Setup Integration test Pre-requisites run: | + sudo apt-get update sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 pip install -r /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/requirements.txt @@ -161,7 +162,7 @@ jobs: echo $ANSIBLE_NIOSSIM_CONTAINER ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python-version }} --docker --coverage env: - ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:4.0.0 + ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:5.0.0 working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ # ansible-test support producing code coverage date @@ -200,7 +201,7 @@ jobs: run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check - name: Download migrated collection artifacts - uses: actions/download-artifact@v1 + uses: actions/download-artifact@v4 with: name: collection path: .cache/collection-tarballs diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index 3ed1f4b5..8ffcc433 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -1,3 +1,4 @@ +--- plugins: become: {} cache: {} @@ -27,137 +28,137 @@ plugins: nios_a_record: description: Configure Infoblox NIOS A records name: nios_a_record - namespace: '' + namespace: "" version_added: 1.0.0 nios_aaaa_record: description: Configure Infoblox NIOS AAAA records name: nios_aaaa_record - namespace: '' + namespace: "" version_added: 1.0.0 nios_cname_record: description: Configure Infoblox NIOS CNAME records name: nios_cname_record - namespace: '' + namespace: "" version_added: 1.0.0 nios_dns_view: description: Configure Infoblox NIOS DNS views name: nios_dns_view - namespace: '' + namespace: "" version_added: 1.0.0 nios_dtc_lbdn: description: Configure Infoblox NIOS DTC LBDN name: nios_dtc_lbdn - namespace: '' + namespace: "" version_added: 1.1.0 nios_dtc_pool: description: Configure Infoblox NIOS DTC Pool name: nios_dtc_pool - namespace: '' + namespace: "" version_added: 1.1.0 nios_dtc_server: description: Configure Infoblox NIOS DTC Server name: nios_dtc_server - namespace: '' + namespace: "" version_added: 1.1.0 nios_dtc_monitor_http: description: Configure Infoblox NIOS DTC HTTP monitor name: nios_dtc_monitor_http - namespace: '' + namespace: "" version_added: 1.6.0 nios_dtc_monitor_tcp: description: Configure Infoblox NIOS DTC TCP monitor name: nios_dtc_monitor_tcp - namespace: '' + namespace: "" version_added: 1.6.0 nios_dtc_monitor_icmp: description: Configure Infoblox NIOS DTC ICMP monitor name: nios_dtc_monitor_icmp - namespace: '' + namespace: "" version_added: 1.6.0 nios_dtc_monitor_pdp: description: Configure Infoblox NIOS DTC PDP monitor name: nios_dtc_monitor_pdp - namespace: '' + namespace: "" version_added: 1.6.0 nios_dtc_monitor_sip: description: Configure Infoblox NIOS DTC SIP monitor name: nios_dtc_monitor_sip - namespace: '' + namespace: "" version_added: 1.6.0 nios_dtc_monitor_snmp: description: Configure Infoblox NIOS DTC SNMP monitor name: nios_dtc_monitor_snmp - namespace: '' + namespace: "" version_added: 1.6.0 nios_dtc_topology: description: Configure Infoblox NIOS DTC Topology name: nios_dtc_topology - namespace: '' + namespace: "" version_added: 1.6.0 nios_fixed_address: description: Configure Infoblox NIOS DHCP Fixed Address name: nios_fixed_address - namespace: '' + namespace: "" version_added: 1.0.0 nios_host_record: description: Configure Infoblox NIOS host records name: nios_host_record - namespace: '' + namespace: "" version_added: 1.0.0 nios_member: description: Configure Infoblox NIOS members name: nios_member - namespace: '' + namespace: "" version_added: 1.0.0 nios_mx_record: description: Configure Infoblox NIOS MX records name: nios_mx_record - namespace: '' + namespace: "" version_added: 1.0.0 nios_naptr_record: description: Configure Infoblox NIOS NAPTR records name: nios_naptr_record - namespace: '' + namespace: "" version_added: 1.0.0 nios_network: description: Configure Infoblox NIOS network object name: nios_network - namespace: '' + namespace: "" version_added: 1.0.0 nios_network_view: description: Configure Infoblox NIOS network views name: nios_network_view - namespace: '' + namespace: "" version_added: 1.0.0 nios_nsgroup: description: Configure InfoBlox DNS Nameserver Groups name: nios_nsgroup - namespace: '' + namespace: "" version_added: 1.0.0 nios_ptr_record: description: Configure Infoblox NIOS PTR records name: nios_ptr_record - namespace: '' + namespace: "" version_added: 1.0.0 nios_restartservices: description: Restart grid services. name: nios_restartservices - namespace: '' + namespace: "" version_added: 1.1.0 nios_srv_record: description: Configure Infoblox NIOS SRV records name: nios_srv_record - namespace: '' + namespace: "" version_added: 1.0.0 nios_txt_record: description: Configure Infoblox NIOS txt records name: nios_txt_record - namespace: '' + namespace: "" version_added: 1.0.0 nios_zone: description: Configure Infoblox NIOS DNS zones name: nios_zone - namespace: '' + namespace: "" version_added: 1.0.0 netconf: {} shell: {} diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index ec67aff0..056bf800 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1,262 +1,252 @@ -ancestor: null +--- +ancestor: releases: 1.0.0: changes: - release_summary: 'First release of the `nios_modules` collection! This release - includes multiple plugins:- an `api` plugin, a `network` plugin, a `nios` - plugin, a `nios_inventory` plugin, a `lookup plugin`, a `nios_next_ip` plugin, - a `nios_next_network` plugin ' + release_summary: "First release of the `nios_modules` collection! This release includes multiple plugins:- an + `api` plugin, a `network` plugin, a `nios` plugin, a `nios_inventory` plugin, a `lookup plugin`, + a `nios_next_ip` plugin, a `nios_next_network` plugin " modules: - - description: Configure Infoblox NIOS A records - name: nios_a_record - namespace: '' - - description: Configure Infoblox NIOS AAAA records - name: nios_aaaa_record - namespace: '' - - description: Configure Infoblox NIOS CNAME records - name: nios_cname_record - namespace: '' - - description: Configure Infoblox NIOS DNS views - name: nios_dns_view - namespace: '' - - description: Configure Infoblox NIOS DHCP Fixed Address - name: nios_fixed_address - namespace: '' - - description: Configure Infoblox NIOS host records - name: nios_host_record - namespace: '' - - description: Configure Infoblox NIOS members - name: nios_member - namespace: '' - - description: Configure Infoblox NIOS MX records - name: nios_mx_record - namespace: '' - - description: Configure Infoblox NIOS NAPTR records - name: nios_naptr_record - namespace: '' - - description: Configure Infoblox NIOS network object - name: nios_network - namespace: '' - - description: Configure Infoblox NIOS network views - name: nios_network_view - namespace: '' - - description: Configure Infoblox NIOS Nameserver Groups - name: nios_nsgroup - namespace: '' - - description: Configure Infoblox NIOS PTR records - name: nios_ptr_record - namespace: '' - - description: Configure Infoblox NIOS SRV records - name: nios_srv_record - namespace: '' - - description: Configure Infoblox NIOS txt records - name: nios_txt_record - namespace: '' - - description: Configure Infoblox NIOS DNS zones - name: nios_zone - namespace: '' + - description: Configure Infoblox NIOS A records + name: nios_a_record + namespace: "" + - description: Configure Infoblox NIOS AAAA records + name: nios_aaaa_record + namespace: "" + - description: Configure Infoblox NIOS CNAME records + name: nios_cname_record + namespace: "" + - description: Configure Infoblox NIOS DNS views + name: nios_dns_view + namespace: "" + - description: Configure Infoblox NIOS DHCP Fixed Address + name: nios_fixed_address + namespace: "" + - description: Configure Infoblox NIOS host records + name: nios_host_record + namespace: "" + - description: Configure Infoblox NIOS members + name: nios_member + namespace: "" + - description: Configure Infoblox NIOS MX records + name: nios_mx_record + namespace: "" + - description: Configure Infoblox NIOS NAPTR records + name: nios_naptr_record + namespace: "" + - description: Configure Infoblox NIOS network object + name: nios_network + namespace: "" + - description: Configure Infoblox NIOS network views + name: nios_network_view + namespace: "" + - description: Configure Infoblox NIOS Nameserver Groups + name: nios_nsgroup + namespace: "" + - description: Configure Infoblox NIOS PTR records + name: nios_ptr_record + namespace: "" + - description: Configure Infoblox NIOS SRV records + name: nios_srv_record + namespace: "" + - description: Configure Infoblox NIOS txt records + name: nios_txt_record + namespace: "" + - description: Configure Infoblox NIOS DNS zones + name: nios_zone + namespace: "" plugins: lookup: - - description: Query Infoblox NIOS objects - name: nios - namespace: null - - description: Return the next available IP address for a network - name: nios_next_ip - namespace: null - - description: Return the next available network range for a network-container - name: nios_next_network - namespace: null - release_date: '2020-10-23' + - description: Query Infoblox NIOS objects + name: nios + namespace: + - description: Return the next available IP address for a network + name: nios_next_ip + namespace: + - description: Return the next available network range for a network-container + name: nios_next_network + namespace: + release_date: "2020-10-23" 1.0.1: changes: minor_changes: - - Made it compatible for Ansible v3.0.0 + - Made it compatible for Ansible v3.0.0 release_summary: This release provides compatibilty for Ansible v3.0.0 - release_date: '2021-01-25' + release_date: "2021-01-25" 1.0.2: changes: minor_changes: - - Fixed the ignored sanity errors required for Ansible 3.0.0 collection - - Made it compatible for Ansible v3.0.0 + - Fixed the ignored sanity errors required for Ansible 3.0.0 collection + - Made it compatible for Ansible v3.0.0 release_summary: This release provides compatibilty for Ansible v3.0.0 - release_date: '2021-01-27' + release_date: "2021-01-27" 1.1.0: changes: release_summary: This release provides plugins for NIOS DTC modules: - - description: Configure Infoblox NIOS DTC LBDN - name: nios_dtc_lbdn - namespace: '' - - description: Configure Infoblox NIOS DTC Pool - name: nios_dtc_pool - namespace: '' - - description: Configure Infoblox NIOS DTC Server - name: nios_dtc_server - namespace: '' - - description: Restart grid services. - name: nios_restartservices - namespace: '' - release_date: '2021-04-12' + - description: Configure Infoblox NIOS DTC LBDN + name: nios_dtc_lbdn + namespace: "" + - description: Configure Infoblox NIOS DTC Pool + name: nios_dtc_pool + namespace: "" + - description: Configure Infoblox NIOS DTC Server + name: nios_dtc_server + namespace: "" + - description: Restart grid services. + name: nios_restartservices + namespace: "" + release_date: "2021-04-12" 1.1.1: changes: bugfixes: - - Implemented the bugfixes provided by Ansible `community.general` - - Update the name of existing A and AAAA records `#70 `_ - - Update of comment field of SRV, PTR and NAPTR records failing with the following error `#70 `_ - - PTR Record failed to update and raises KeyError for view field `#70 `_ - - Update comment field and delete an existing Fixed Address `#73 `_ - - GitHub issue fix - Lookup module for next available IPV6 `#31 `_ - - GitHub issue fix - [nios_zone] changing a nios_zone does not work `#60 `_ - - GitHub issue fix - Getting an error, running every module `#67 `_ - - GitHub issue fix - Error - Dictionary Issues `#68 `_ - - GitHub issue fix - Examples for lookups don't work as written `#72 `_ - - Sanity fixes as per Ansible guidelines to all modules + - Implemented the bugfixes provided by Ansible `community.general` + - Update the name of existing A and AAAA records `#70 `_ + - Update of comment field of SRV, PTR and NAPTR records failing with the following error + `#70 `_ + - PTR Record failed to update and raises KeyError for view field `#70 `_ + - Update comment field and delete an existing Fixed Address `#73 `_ + - GitHub issue fix - Lookup module for next available IPV6 `#31 `_ + - GitHub issue fix - [nios_zone] changing a nios_zone does not work `#60 `_ + - GitHub issue fix - Getting an error, running every module `#67 `_ + - GitHub issue fix - Error - Dictionary Issues `#68 `_ + - GitHub issue fix - Examples for lookups don't work as written `#72 `_ + - Sanity fixes as per Ansible guidelines to all modules minor_changes: - - The modules are standardized as per Ansible guidelines - release_summary: 'Support for creating IPv6 Fixed Address with DUID, - Support added to return the next available IP address for an IPv6 network, - Modules made compatible to work with ansible-core 2.11, - Issue fixes and standardization of modules as per Ansible guidelines' - release_date: '2021-09-07' + - The modules are standardized as per Ansible guidelines + release_summary: Support for creating IPv6 Fixed Address with DUID, Support added to return the next available IP address + for an IPv6 network, Modules made compatible to work with ansible-core 2.11, Issue fixes and standardization of modules as per Ansible guidelines + release_date: "2021-09-07" 1.1.2: changes: bugfixes: - - Handle NoneType parsing in nios_inventory.py `#81 `_ - - Check all dhcp options, not just first one `#83 `_ + - Handle NoneType parsing in nios_inventory.py `#81 `_ + - Check all dhcp options, not just first one `#83 `_ minor_changes: - - Changes in inventory and lookup plugins documentation `#85 `_ - - Directory restructure and added integration & unit tests `#87 `_ - release_summary: 'Issue fixes and standardization of inventory plugin and lookup modules as per Ansible guidelines, - Directory restructure and added integration & unit tests' - release_date: '2021-10-12' + - Changes in inventory and lookup plugins documentation `#85 `_ + - Directory restructure and added integration & unit tests `#87 `_ + release_summary: Issue fixes and standardization of inventory plugin and lookup modules as per Ansible guidelines, + Directory restructure and added integration & unit tests + release_date: "2021-10-12" 1.2.0: changes: bugfixes: - - nios_a_record module - KeyError 'old_ipv4addr' `#79 `_ - - Ansible playbook fails to update canonical name of CName Record `#97 `_ + - nios_a_record module - KeyError 'old_ipv4addr' `#79 `_ + - Ansible playbook fails to update canonical name of CName Record `#97 `_ minor_changes: - - Updated 'required' field in modules `#99 `_ - - Following options are made required in the modules - | Record | Option made required | - | ------ | -------------------- | - | A | ipv4addr | - | AAAA | ipv6addr | - | CNAME | canonical | - | MX | mail_exchanger, preference | - | PTR | ptrdname | - release_summary: 'Issue fixes to update A Record using `next_available_ip` function, - Added a new feature - Update canonical name of the CNAME Record, - Updated the `required` fields in modules' - release_date: '2021-12-13' + - Updated 'required' field in modules `#99 `_ + - Following options are made required in the modules + | Record | Option made required | | ------ | -------------------- | | A | ipv4addr | | AAAA | ipv6addr| + | CNAME | canonical | | MX | mail_exchanger, preference | | PTR | ptrdname | + release_summary: Issue fixes to update A Record using `next_available_ip` function, Added a new feature + - Update canonical name of the CNAME Record, Updated the `required` fields in modules + release_date: "2021-12-13" 1.2.1: changes: minor_changes: - - Added tags 'cloud' and 'networking' in 'galaxy.yaml' - release_summary: 'Added tags to support release on Ansible Automation Hub' - release_date: '2021-12-20' + - Added tags 'cloud' and 'networking' in 'galaxy.yaml' + release_summary: Added tags to support release on Ansible Automation Hub + release_date: "2021-12-20" 1.2.2: changes: minor_changes: - - Fix to create PTR record in different network views `#103 `_ - - Remove use_option for DHCP option 60 `#104 `_ - - Allow specifying a template when creating a network `#105 `_ - - Fix unit and sanity test issues `#117 `_ - - Expanding for disable value `#119 `_ - release_summary: 'Issue fixes to create PTR record in different network views, - Support extended to determine whether the DTC server is disabled or not' - release_date: '2022-05-23' + - Fix to create PTR record in different network views `#103 `_ + - Remove use_option for DHCP option 60 `#104 `_ + - Allow specifying a template when creating a network `#105 `_ + - Fix unit and sanity test issues `#117 `_ + - Expanding for disable value `#119 `_ + release_summary: Issue fixes to create PTR record in different network views, Support extended to determine whether the DTC server is disabled or not + release_date: "2022-05-23" 1.3.0: changes: major_changes: - - Update operation using `old_name` and `new_name` for the object with dummy name in `old_name` (which does not exist in system) will not create a new object in the system. An error will be thrown stating the object does not exist in the system `#129 `_ - - Update `text` field of TXT Record `#128 `_ + - Update operation using `old_name` and `new_name` for the object with dummy name in `old_name` + (which does not exist in system) will not create a new object in the system. An error will be thrown stating the object does not exist in the + system `#129 `_ + - Update `text` field of TXT Record `#128 `_ bugfixes: - - Fix to create TXT record with equals sign `#128 `_ - release_summary: 'Issue fixes to create TXT record with equals sign, - For nonexistent record, update operation creates the new record, - For nonexistent IPv4Address, update operation creates a new A record with new_ipv4addr' - release_date: '2022-07-01' + - Fix to create TXT record with equals sign `#128 `_ + release_summary: Issue fixes to create TXT record with equals sign, For nonexistent record, update operation + creates the new record, For nonexistent IPv4Address, update operation creates a new A record with new_ipv4addr + release_date: "2022-07-01" 1.4.0: changes: major_changes: - - Feature for extra layer security , with `cert` and `key` parameters in playbooks for authenticating using certificate and key ``*.pem`` file absolute path `#154 `_ - - Fix to remove issue causing due to template attr in deleting network using Ansible module nios network `#147 `_ - release_summary: 'For ansible module, added certificate authentication feature, - Few bugs fix in ansible module nios network' - release_date: '2022-10-12' + - Feature for extra layer security , with `cert` and `key` parameters in playbooks for authenticating + using certificate and key ``*.pem`` file absolute path `#154 `_ + - Fix to remove issue causing due to template attr in deleting network using Ansible module nios network + `#147 `_ + release_summary: For ansible module, added certificate authentication feature, Few bugs fix in ansible module nios network + release_date: "2022-10-12" 1.4.1: changes: minor_changes: - - Fix to specify network_view in lookup modules to return absolute network and ip `#157 `_ - - Fix to camelcase issue for updating 'nios_network_view' name `#163 `_ - - Fix to allocate ip to a_record dynamically `#163 `_ - - Fix to update 'nios_a_record' name with multiple ips having same name `#164 `_ - - Fix to changelog yaml file with linting issues `#161 `_ - release_summary: 'Ansible Lookup modules can specify network_view to which a network/ip belongs, - Fixes camelCase issue while updating `nios_network_view` with `new_name`, - Fixes issue to allocate ip to a_record dynamically, - Updates `nios_a_record` name with multiple ips having same name' - release_date: '2022-11-24' + - Fix to specify network_view in lookup modules to return absolute network and ip `#157 `_ + - Fix to camelcase issue for updating 'nios_network_view' name `#163 `_ + - Fix to allocate ip to a_record dynamically `#163 `_ + - Fix to update 'nios_a_record' name with multiple ips having same name `#164 `_ + - Fix to changelog yaml file with linting issues `#161 `_ + release_summary: Ansible Lookup modules can specify network_view to which a network/ip belongs, + Fixes camelCase issue while updating `nios_network_view` with `new_name`, Fixes issue to allocate ip to a_record dynamically, + Updates `nios_a_record` name with multiple ips having same name + release_date: "2022-11-24" 1.5.0: changes: major_changes: - - Added NIOS Range module with Create, Update and Delete features `#152 `_ - - Added Member Assignment to network and ranges `#152 `_ - - Added Grid Master Candidate feature `#152 `_ - - Fixes issue unable to update/delete EAs using Ansible plugin `#180 `_ - - Fixes static and dynamic allocation of IPV4 address of A Record `#182 `_ - - Fixes to Update host name of NIOS member `#176 `_ - - Updates default WAPI version to 2.9 `#176 `_ + - Added NIOS Range module with Create, Update and Delete features `#152 `_ + - Added Member Assignment to network and ranges `#152 `_ + - Added Grid Master Candidate feature `#152 `_ + - Fixes issue unable to update/delete EAs using Ansible plugin `#180 `_ + - Fixes static and dynamic allocation of IPV4 address of A Record `#182 `_ + - Fixes to Update host name of NIOS member `#176 `_ + - Updates default WAPI version to 2.9 `#176 `_ bugfixes: - - Fixes Update A Record having multiple records with same name and different IP `#182 `_ - release_summary: 'Added new module NIOS Range with Create, Update and Delete features, - Added new feature Member Assignment to Networks with add and remove functionality, - Fixes Unable to Update/Delete EAs using Ansible plugin, - Fixes Static Allocation of IPV4 address of A Record, - Updates default WAPI version to `2.9`, - Added Grid Master Candidate feature' - release_date: '2023-05-11' + - Fixes Update A Record having multiple records with same name and different IP `#182 `_ + release_summary: Added new module NIOS Range with Create, Update and Delete features, Added new feature Member Assignment to Networks with add + remove functionality, Fixes Unable to Update/Delete EAs using Ansible plugin, Fixes Static Allocation of IPV4 address of A Record, + Updates default WAPI version to `2.9`, Added Grid Master Candidate feature + release_date: "2023-05-11" 1.6.0: changes: major_changes: - Upgrade Ansible version support from 2.13 to 2.16. - Upgrade Python version support from 3.8 to 3.10. - release_summary: 'Added new modules with CRUD features to manage NIOS DTC health check monitors: DTC HTTP Monitor, - DTC ICMP Monitor, DTC PDP Monitor, DTC SIP Monitor, DTC SNMP Monitor, DTC TCP Monitor. - Added a new module with CRUD features to manage topology rulesets in NIOS. - Added a new field to define topology ruleset for the DTC Pool and DTC LBDN modules.' + release_summary: "Added new modules with CRUD features to manage NIOS DTC health check monitors: DTC HTTP Monitor, DTC ICMP Monitor, + DTC PDP Monitor, DTC SIP Monitor, DTC SNMP Monitor, DTC TCP Monitor. Added a new module with CRUD features to manage topology rulesets in NIOS. + Added a new field to define topology ruleset for the DTC Pool and DTC LBDN modules." bugfixes: - Fixes typo for environment variable INFOBLOX_WAPI_VERSION `#209 `_ - Fixes environment variable max_results using INFOBLOX_MAX_RESULTS `#209 `_ - - Fixes index error for transform fields in DTC LBDN (auth_zone and Pool) and DTC POOL (servers and monitors) `#209 `_ + - Fixes index error for transform fields in DTC LBDN (auth_zone and Pool) and DTC POOL (servers and monitors) + `#209 `_ modules: - - description: Configures the Infoblox NIOS DTC HTTP monitor. - name: nios_dtc_monitor_http - namespace: '' - - description: Configures the Infoblox NIOS DTC ICMP monitor - name: nios_dtc_monitor_icmp - namespace: '' - - description: Configures the Infoblox NIOS DTC PDP monitor - name: nios_dtc_monitor_pdp - namespace: '' - - description: Configures the Infoblox NIOS DTC SIP monitor - name: nios_dtc_monitor_sip - namespace: '' - - description: Configures the Infoblox NIOS DTC SNMP monitor - name: nios_dtc_monitor_snmp - namespace: '' - - description: Configures the Infoblox NIOS DTC TCP monitor - name: nios_dtc_monitor_tcp - namespace: '' - - description: Configures the Infoblox NIOS DTC Topology - name: nios_dtc_topology - namespace: '' - release_date: '2023-12-14' - 1.6.1: - changes: - minor_changes: - - Ansible core version in the dependencies updated to 2.14 or later. - release_summary: 'This release includes the updates of plug-in version 1.6.0 and the following documentation changes: - Ansible core version in the dependencies updated to 2.14 or later.' - release_date: '2023-12-19' + - description: Configures the Infoblox NIOS DTC HTTP monitor. + name: nios_dtc_monitor_http + namespace: "" + - description: Configures the Infoblox NIOS DTC ICMP monitor + name: nios_dtc_monitor_icmp + namespace: "" + - description: Configures the Infoblox NIOS DTC PDP monitor + name: nios_dtc_monitor_pdp + namespace: "" + - description: Configures the Infoblox NIOS DTC SIP monitor + name: nios_dtc_monitor_sip + namespace: "" + - description: Configures the Infoblox NIOS DTC SNMP monitor + name: nios_dtc_monitor_snmp + namespace: "" + - description: Configures the Infoblox NIOS DTC TCP monitor + name: nios_dtc_monitor_tcp + namespace: "" + - description: Configures the Infoblox NIOS DTC Topology + name: nios_dtc_topology + namespace: "" + release_date: "2023-12-14" + 1.6.1: + changes: + minor_changes: + - Ansible core version in the dependencies updated to 2.14 or later. + release_summary: "This release includes the updates of plug-in version 1.6.0 and + the following documentation changes: Ansible core version in the dependencies updated to 2.14 or later." + release_date: "2023-12-19" diff --git a/changelogs/config.yaml b/changelogs/config.yaml index 09a1f378..c1e7596e 100644 --- a/changelogs/config.yaml +++ b/changelogs/config.yaml @@ -1,3 +1,4 @@ +--- changelog_filename_template: ../CHANGELOG.rst changelog_filename_version_depth: 0 changes_file: changelog.yaml @@ -11,22 +12,22 @@ prelude_section_name: release_summary prelude_section_title: Release Summary sanitize_changelog: true sections: -- - major_changes - - Major Changes -- - minor_changes - - Minor Changes -- - breaking_changes - - Breaking Changes / Porting Guide -- - deprecated_features - - Deprecated Features -- - removed_features - - Removed Features (previously deprecated) -- - security_fixes - - Security Fixes -- - bugfixes - - Bugfixes -- - known_issues - - Known Issues + - - major_changes + - Major Changes + - - minor_changes + - Minor Changes + - - breaking_changes + - Breaking Changes / Porting Guide + - - deprecated_features + - Deprecated Features + - - removed_features + - Removed Features (previously deprecated) + - - security_fixes + - Security Fixes + - - bugfixes + - Bugfixes + - - known_issues + - Known Issues title: Infoblox.Nios_Modules trivial_section_name: trivial use_fqcn: true diff --git a/galaxy.yml b/galaxy.yml index 787065d8..6676e2e5 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,3 +1,4 @@ +--- ### REQUIRED # The namespace of the collection. This can be a company/brand/organization or product namespace under which all @@ -17,9 +18,9 @@ readme: README.md # A list of the collection's content authors. Can be just the name or in the format 'Full Name (url) # @nicks:irc/im.site#channel' authors: -- Hemanth Kumar (hkumar3@infoblox.com) -- Jeenitkumar Khatri (jkhatri@infoblox.com) -- Jaykumar Chhatbar (jchhatbar@infoblox.com) + - Hemanth Kumar (hkumar3@infoblox.com) + - Jeenitkumar Khatri (jkhatri@infoblox.com) + - Jaykumar Chhatbar (jchhatbar@infoblox.com) ### OPTIONAL but strongly recommended @@ -29,25 +30,25 @@ description: Infoblox Ansible Collection for vNIOS allows managing your NIOS obj # Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only # accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file' license: -- GPL-3.0-only + - GPL-3.0-only # The path to the license file for the collection. This path is relative to the root of the collection. This key is # mutually exclusive with 'license' -license_file: '' +license_file: "" # A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character # requirements as 'namespace' and 'name' tags: -- infoblox -- nios -- cloud -- networking + - infoblox + - nios + - cloud + - networking # Collections that this collection requires to be installed for it to be usable. The key of the dict is the # collection label 'namespace.name'. The value is a version range # L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version # range specifiers can be set and are separated by ',' -#dependencies: {} +# dependencies: {} # The URL of the originating SCM repository repository: https://github.com/infobloxopen/infoblox-ansible/tree/master diff --git a/meta/runtime.yml b/meta/runtime.yml index be99ccf4..1e85b01d 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,2 +1,2 @@ --- -requires_ansible: '>=2.14.0' +requires_ansible: ">=2.15.0" diff --git a/playbooks/create_a_record.yaml b/playbooks/create_a_record.yaml index 29245981..83cc2fdd 100644 --- a/playbooks/create_a_record.yaml +++ b/playbooks/create_a_record.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -9,11 +9,11 @@ connection: local tasks: - - name: Create Nios A record Test - infoblox.nios_modules.nios_a_record: - name: v55.ansibletestzone.com - view: ansibleDnsView - ipv4: 192.168.11.251 - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" + - name: Create Nios A record Test + infoblox.nios_modules.nios_a_record: + name: v55.ansibletestzone.com + view: ansibleDnsView + ipv4: 192.168.11.251 + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_cname_record.yaml b/playbooks/create_cname_record.yaml index 1c59c7a6..ae2869ad 100644 --- a/playbooks/create_cname_record.yaml +++ b/playbooks/create_cname_record.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -9,11 +9,11 @@ connection: local tasks: - - name: Create Nios CNAME record - infoblox.nios_modules.nios_cname_record: - name: cname.ansibletestzone.com - canonical: realhost.ansible.com - view: ansibleDnsView - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" + - name: Create Nios CNAME record + infoblox.nios_modules.nios_cname_record: + name: cname.ansibletestzone.com + canonical: realhost.ansible.com + view: ansibleDnsView + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_dns_view.yml b/playbooks/create_dns_view.yml index 834a7c9a..b380ddd0 100644 --- a/playbooks/create_dns_view.yml +++ b/playbooks/create_dns_view.yml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -9,12 +9,12 @@ connection: local tasks: - - name: create DNS view - infoblox.nios_modules.nios_dns_view: - name: ansibleDnsView - network_view: ansibleCollectionsView - extattrs: - Site: Test Site - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" + - name: Create DNS view + infoblox.nios_modules.nios_dns_view: + name: ansibleDnsView + network_view: ansibleCollectionsView + extattrs: + Site: Test Site + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_dtc_lbdn.yml b/playbooks/create_dtc_lbdn.yml index 9cbf3ad2..f0a1449c 100644 --- a/playbooks/create_dtc_lbdn.yml +++ b/playbooks/create_dtc_lbdn.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.196.205.10 @@ -9,21 +10,20 @@ connection: local tasks: - - name: 'create DTC LBDN' - infoblox.nios_modules.nios_dtc_lbdn: - name: LBDN1 - lb_method: GLOBAL_AVAILABILITY - pools: - - pool: Pool1 - ratio: 2 - ttl: 100 - auth_zones: - - 'demo.com' - patterns: - - '*.demo.com' - types: - - A - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" -... + - name: Create DTC LBDN + infoblox.nios_modules.nios_dtc_lbdn: + name: LBDN1 + lb_method: GLOBAL_AVAILABILITY + pools: + - pool: Pool1 + ratio: 2 + ttl: 100 + auth_zones: + - demo.com + patterns: + - "*.demo.com" + types: + - A + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_dtc_monitor_http.yaml b/playbooks/create_dtc_monitor_http.yaml index 2d2afc3e..140e4a1d 100644 --- a/playbooks/create_dtc_monitor_http.yaml +++ b/playbooks/create_dtc_monitor_http.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/create_dtc_monitor_icmp.yaml b/playbooks/create_dtc_monitor_icmp.yaml index f792cfa6..50dfa157 100644 --- a/playbooks/create_dtc_monitor_icmp.yaml +++ b/playbooks/create_dtc_monitor_icmp.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/create_dtc_monitor_pdp.yaml b/playbooks/create_dtc_monitor_pdp.yaml index ea2bc9b9..09bb1c5d 100644 --- a/playbooks/create_dtc_monitor_pdp.yaml +++ b/playbooks/create_dtc_monitor_pdp.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/create_dtc_monitor_sip.yaml b/playbooks/create_dtc_monitor_sip.yaml index 4caa32ea..f2752ab6 100644 --- a/playbooks/create_dtc_monitor_sip.yaml +++ b/playbooks/create_dtc_monitor_sip.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/create_dtc_monitor_snmp.yaml b/playbooks/create_dtc_monitor_snmp.yaml index b8b796ee..accffc41 100644 --- a/playbooks/create_dtc_monitor_snmp.yaml +++ b/playbooks/create_dtc_monitor_snmp.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/create_dtc_monitor_tcp.yaml b/playbooks/create_dtc_monitor_tcp.yaml index 95a824a1..f3cc1306 100644 --- a/playbooks/create_dtc_monitor_tcp.yaml +++ b/playbooks/create_dtc_monitor_tcp.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/create_dtc_pool.yml b/playbooks/create_dtc_pool.yml index 96a59f29..4d168c6e 100644 --- a/playbooks/create_dtc_pool.yml +++ b/playbooks/create_dtc_pool.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.196.205.10 @@ -9,17 +10,16 @@ connection: local tasks: - - name: 'create DTC Pool' - infoblox.nios_modules.nios_dtc_pool: - name: Pool1 - lb_preferred_method: ROUND_ROBIN - servers: - - server: Server1 - ratio: 1 - monitors: - - name: monitor1 - type: icmp - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" -... + - name: Create DTC Pool + infoblox.nios_modules.nios_dtc_pool: + name: Pool1 + lb_preferred_method: ROUND_ROBIN + servers: + - server: Server1 + ratio: 1 + monitors: + - name: monitor1 + type: icmp + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_dtc_server.yml b/playbooks/create_dtc_server.yml index dd0c0388..7b7d2101 100644 --- a/playbooks/create_dtc_server.yml +++ b/playbooks/create_dtc_server.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.196.205.10 @@ -9,11 +10,10 @@ connection: local tasks: - - name: 'create DTC server' - infoblox.nios_modules.nios_dtc_server: - name: Server1 - host: 10.196.200.74 - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" -... + - name: Create DTC server + infoblox.nios_modules.nios_dtc_server: + name: Server1 + host: 10.196.200.74 + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_dtc_topology.yml b/playbooks/create_dtc_topology.yml index 01c50bd4..d721d8ea 100644 --- a/playbooks/create_dtc_topology.yml +++ b/playbooks/create_dtc_topology.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.196.205.10 diff --git a/playbooks/create_extensible_attribute.yaml b/playbooks/create_extensible_attribute.yaml new file mode 100644 index 00000000..17a4c3a2 --- /dev/null +++ b/playbooks/create_extensible_attribute.yaml @@ -0,0 +1,20 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.120.1.11 + username: admin + password: infoblox + + connection: local + tasks: + - name: Create INT extensible attribute + infoblox.nios_modules.nios_extensible_attribute: + name: integer_ea + type: INTEGER + default_value: 11 + comment: Created with Ansible + flags: 'I' + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_mx_record.yaml b/playbooks/create_mx_record.yaml index ac8c8f34..533a068e 100644 --- a/playbooks/create_mx_record.yaml +++ b/playbooks/create_mx_record.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -9,12 +9,12 @@ connection: local tasks: - - name: Create Nios MX record - infoblox.nios_modules.nios_mx_record: - name: mx.ansibletestzone.com - mx: mailhost.ansible.com - view: ansibleDnsView - preference: 0 - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" + - name: Create Nios MX record + infoblox.nios_modules.nios_mx_record: + name: mx.ansibletestzone.com + mx: mailhost.ansible.com + view: ansibleDnsView + preference: 0 + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_network.yml b/playbooks/create_network.yml index c309105f..de11bc0f 100644 --- a/playbooks/create_network.yml +++ b/playbooks/create_network.yml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -9,15 +9,15 @@ connection: local tasks: - - name: create network - infoblox.nios_modules.nios_network: - network: 10.0.0.0/24 - network_view: ansibleCollectionsView - options: - - name: domain-name - value: infoblox-ansible.com - extattrs: - Site: Test Site - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" + - name: Create network + infoblox.nios_modules.nios_network: + network: 10.0.0.0/24 + network_view: ansibleCollectionsView + options: + - name: domain-name + value: infoblox-ansible.com + extattrs: + Site: Test Site + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_network_view.yml b/playbooks/create_network_view.yml index ca372187..10762fd3 100644 --- a/playbooks/create_network_view.yml +++ b/playbooks/create_network_view.yml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -9,11 +9,11 @@ connection: local tasks: - - name: create network view - infoblox.nios_modules.nios_network_view: - name: ansibleCollectionsView - extattrs: - Site: Test Site - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" + - name: Create network view + infoblox.nios_modules.nios_network_view: + name: ansibleCollectionsView + extattrs: + Site: Test Site + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_txt_record.yaml b/playbooks/create_txt_record.yaml index d0a28058..65730a63 100644 --- a/playbooks/create_txt_record.yaml +++ b/playbooks/create_txt_record.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -9,11 +9,11 @@ connection: local tasks: - - name: Create Nios TXT record - infoblox.nios_modules.nios_txt_record: - name: one.txt.ansibletestzone.com - text: example_text45 - view: ansibleDnsView - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" + - name: Create Nios TXT record + infoblox.nios_modules.nios_txt_record: + name: one.txt.ansibletestzone.com + text: example_text45 + view: ansibleDnsView + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_zone.yml b/playbooks/create_zone.yml index 63b874e2..c986b167 100644 --- a/playbooks/create_zone.yml +++ b/playbooks/create_zone.yml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -10,12 +10,12 @@ connection: local tasks: - - name: create zone - infoblox.nios_modules.nios_zone: - name: ansibletestzone.com - view: ansibleDnsView - extattrs: - Site: Test Site - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" + - name: Create zone + infoblox.nios_modules.nios_zone: + name: ansibletestzone.com + view: ansibleDnsView + extattrs: + Site: Test Site + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_cname_record.yaml b/playbooks/delete_cname_record.yaml index f7f753a7..d6fd96ed 100644 --- a/playbooks/delete_cname_record.yaml +++ b/playbooks/delete_cname_record.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -9,10 +9,10 @@ connection: local tasks: - - name: Delete Nios CNAME record - infoblox.nios_modules.nios_cname_record: - name: cname.ansible.com - canonical: realhost.ansible.com - comment: Created with Ansible - state: absent - provider: "{{ nios_provider }}" + - name: Delete Nios CNAME record + infoblox.nios_modules.nios_cname_record: + name: cname.ansible.com + canonical: realhost.ansible.com + comment: Created with Ansible + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_dnsview.yml b/playbooks/delete_dnsview.yml index bb5e22a2..8d02d9cc 100644 --- a/playbooks/delete_dnsview.yml +++ b/playbooks/delete_dnsview.yml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -9,9 +9,9 @@ connection: local tasks: - - name: delete DNS view - infoblox.nios_modules.nios_dns_view: - name: ansibleDnsView - network_view: ansibleNetView - state: absent - provider: "{{ nios_provider }}" + - name: Delete DNS view + infoblox.nios_modules.nios_dns_view: + name: ansibleDnsView + network_view: ansibleNetView + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_dtc_monitor_http.yaml b/playbooks/delete_dtc_monitor_http.yaml index 29427ebd..5e04d20d 100644 --- a/playbooks/delete_dtc_monitor_http.yaml +++ b/playbooks/delete_dtc_monitor_http.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/delete_dtc_monitor_icmp.yaml b/playbooks/delete_dtc_monitor_icmp.yaml index eca2975f..d8bc33c9 100644 --- a/playbooks/delete_dtc_monitor_icmp.yaml +++ b/playbooks/delete_dtc_monitor_icmp.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/delete_dtc_monitor_pdp.yaml b/playbooks/delete_dtc_monitor_pdp.yaml index b69fb462..a23fd962 100644 --- a/playbooks/delete_dtc_monitor_pdp.yaml +++ b/playbooks/delete_dtc_monitor_pdp.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/delete_dtc_monitor_sip.yaml b/playbooks/delete_dtc_monitor_sip.yaml index 1fbc0e29..962756d4 100644 --- a/playbooks/delete_dtc_monitor_sip.yaml +++ b/playbooks/delete_dtc_monitor_sip.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/delete_dtc_monitor_snmp.yaml b/playbooks/delete_dtc_monitor_snmp.yaml index 972751a6..48f97879 100644 --- a/playbooks/delete_dtc_monitor_snmp.yaml +++ b/playbooks/delete_dtc_monitor_snmp.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/delete_dtc_monitor_tcp.yaml b/playbooks/delete_dtc_monitor_tcp.yaml index 662df448..b4a500d4 100644 --- a/playbooks/delete_dtc_monitor_tcp.yaml +++ b/playbooks/delete_dtc_monitor_tcp.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 diff --git a/playbooks/delete_dtc_topology.yml b/playbooks/delete_dtc_topology.yml index 1782aa67..663a82c5 100644 --- a/playbooks/delete_dtc_topology.yml +++ b/playbooks/delete_dtc_topology.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.196.205.10 @@ -9,7 +10,7 @@ connection: local tasks: - - name: delete a DTC Topology + - name: Delete a DTC Topology infoblox.nios_modules.nios_dtc_topology: name: a_topology state: absent diff --git a/playbooks/delete_mx_record.yaml b/playbooks/delete_mx_record.yaml index 9a4475ec..77d3208b 100644 --- a/playbooks/delete_mx_record.yaml +++ b/playbooks/delete_mx_record.yaml @@ -1,19 +1,19 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: - host: 10.36.118.2 + host: 10.36.118.2 username: cloudadmin password: admin connection: local tasks: - - name: delete Nios MX record - infoblox.nios_modules.nios_mx_record: - name: ansible.com - mx: mailhost.ansible.com - preference: 0 - comment: Created with Ansible - state: absent - provider: "{{ nios_provider }}" + - name: Delete Nios MX record + infoblox.nios_modules.nios_mx_record: + name: ansible.com + mx: mailhost.ansible.com + preference: 0 + comment: Created with Ansible + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_network.yml b/playbooks/delete_network.yml index 304dccc0..c0d9ba45 100644 --- a/playbooks/delete_network.yml +++ b/playbooks/delete_network.yml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.60.27.4 @@ -9,9 +9,9 @@ connection: local tasks: - - name: delete network - infoblox.nios_modules.nios_network: - network: 10.0.0.0/24 - network_view: ansibleNetView - state: absent - provider: "{{ nios_provider }}" + - name: Delete network + infoblox.nios_modules.nios_network: + network: 10.0.0.0/24 + network_view: ansibleNetView + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_network_view.yml b/playbooks/delete_network_view.yml index e0a7b119..458a4809 100644 --- a/playbooks/delete_network_view.yml +++ b/playbooks/delete_network_view.yml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.60.27.4 @@ -9,8 +9,8 @@ connection: local tasks: - - name: delete network view - infoblox.nios_modules.nios_network_view: - name: ansibleNetView - state: absent - provider: "{{ nios_provider }}" + - name: Delete network view + infoblox.nios_modules.nios_network_view: + name: ansibleNetView + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_txt_record.yaml b/playbooks/delete_txt_record.yaml index ea9269af..7510ab35 100644 --- a/playbooks/delete_txt_record.yaml +++ b/playbooks/delete_txt_record.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -9,11 +9,11 @@ connection: local tasks: - - name: delete Nios TXT record - infoblox.nios_modules.nios_txt_record: - name: fqdn.txt.ansible.com - text: example_text - view: default - comment: Created with Ansible - state: absent - provider: "{{ nios_provider }}" + - name: Delete Nios TXT record + infoblox.nios_modules.nios_txt_record: + name: fqdn.txt.ansible.com + text: example_text + view: default + comment: Created with Ansible + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/delete_zone.yml b/playbooks/delete_zone.yml index ca50801a..02eb55c2 100644 --- a/playbooks/delete_zone.yml +++ b/playbooks/delete_zone.yml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.36.118.2 @@ -9,9 +9,9 @@ connection: local tasks: - - name: delete zone - infoblox.nios_modules.nios_zone: - name: ansiblezone.com - view: ansibleDnsView - state: absent - provider: "{{ nios_provider }}" + - name: Delete zone + infoblox.nios_modules.nios_zone: + name: ansiblezone.com + view: ansibleDnsView + state: absent + provider: "{{ nios_provider }}" diff --git a/playbooks/restart_services.yml b/playbooks/restart_services.yml index b8b8fe61..2255b4e2 100644 --- a/playbooks/restart_services.yml +++ b/playbooks/restart_services.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.196.205.10 @@ -9,7 +10,6 @@ connection: local tasks: - - name: Restart Services - infoblox.nios_modules.nios_restartservices: - provider: "{{ nios_provider }}" -... + - name: Restart Services + infoblox.nios_modules.nios_restartservices: + provider: "{{ nios_provider }}" diff --git a/playbooks/update_a_record.yml b/playbooks/update_a_record.yml index 2630c3bb..709305c2 100644 --- a/playbooks/update_a_record.yml +++ b/playbooks/update_a_record.yml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.34.34.175 @@ -9,11 +9,11 @@ connection: local tasks: - - name: Update Nios A record - infoblox.nios_modules.nios_a_record: - name: {new_name: v7.testzone.com, old_name: v7.testzone.com} - view: testDnsView - ipv4: 1.1.11.2 - comment: Created with Ansible - state: present - provider: "{{ nios_provider }}" + - name: Update Nios A record + infoblox.nios_modules.nios_a_record: + name: { new_name: v7.testzone.com, old_name: v7.testzone.com } + view: testDnsView + ipv4: 1.1.11.2 + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/update_member.yml b/playbooks/update_member.yml index 39156913..f161f461 100644 --- a/playbooks/update_member.yml +++ b/playbooks/update_member.yml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Infoblox Member Configuration + hosts: localhost vars: nios_provider: host: 10.34.10.724 @@ -8,15 +8,15 @@ password: cloudadmin connection: local tasks: - - name: update member host name - infoblox.nios_modules.nios_member: - host_name: {old_name: block1.localdomain, new_name: member01.localdomain} - master_candidate: false - vip_setting: - - address: 120.0.0.25 - subnet_mask: 255.255.255.0 - gateway: 120.0.0.1 - config_addr_type: IPV4 - platform: VNIOS - state: present - provider: "{{ nios_provider }}" \ No newline at end of file + - name: Update member host name + infoblox.nios_modules.nios_member: + host_name: { old_name: block1.localdomain, new_name: member01.localdomain } + master_candidate: false + vip_setting: + - address: 120.0.0.25 + subnet_mask: 255.255.255.0 + gateway: 120.0.0.1 + config_addr_type: IPV4 + platform: VNIOS + state: present + provider: "{{ nios_provider }}" diff --git a/plugins/lookup/nios_next_ip.py b/plugins/lookup/nios_next_ip.py index 9b3dd8cd..be059db0 100644 --- a/plugins/lookup/nios_next_ip.py +++ b/plugins/lookup/nios_next_ip.py @@ -63,7 +63,7 @@ - name: return the next 3 available IP addresses for network 192.168.10.0/24 ansible.builtin.set_fact: - ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', num=3, \ + ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', num=3, provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" - name: return the next 3 available IP addresses for network 192.168.10.0/24 @@ -103,20 +103,20 @@ def run(self, terms, variables=None, **kwargs): provider = kwargs.pop('provider', {}) wapi = WapiLookup(provider) + network_view = kwargs.get('network_view', 'default') if isinstance(ipaddress.ip_network(network), ipaddress.IPv6Network): object_type = 'ipv6range' if kwargs.get('use_range', False) else 'ipv6network' else: object_type = 'range' if kwargs.get('use_range', False) else 'network' - network_obj = wapi.get_object(object_type, {'network': network}) + network_obj = wapi.get_object(object_type, {'network': network, 'network_view': network_view}) if network_obj is None: raise AnsibleError('unable to find network object %s' % network) num = kwargs.get('num', 1) exclude_ip = kwargs.get('exclude', []) - network_view = kwargs.get('network_view', 'default') ref_list = [network['_ref'] for network in network_obj if network['network_view'] == network_view] if not ref_list: diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 9e8ff037..73080e33 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -223,6 +223,8 @@ def convert_ea_list_to_struct(member_spec): ''' Transforms the list of the values into a valid WAPI struct. ''' if 'list_values' in member_spec.keys(): + if all(isinstance(item, dict) for item in member_spec['list_values']): + member_spec['list_values'] = [item['value'] for item in member_spec['list_values']] member_spec['list_values'] = [{'_struct': 'extensibleattributedef:listvalues', 'value': v} for v in member_spec['list_values']] return member_spec @@ -386,6 +388,18 @@ def run(self, ib_obj_type, ib_spec): if (ib_obj_type == NIOS_IPV4_NETWORK or ib_obj_type == NIOS_IPV6_NETWORK): proposed_object = convert_members_to_struct(proposed_object) + if ib_obj_type in {NIOS_IPV4_NETWORK_CONTAINER, NIOS_IPV6_NETWORK_CONTAINER, NIOS_IPV4_NETWORK, NIOS_IPV6_NETWORK, NIOS_RANGE}: + + # Iterate over each option and remove the 'num' key + if current_object.get('options') or proposed_object.get('options'): + if proposed_object.get('options'): + # remove use_options false from proposed_object + proposed_object['options'] = [option for option in proposed_object['options'] if option.get('use_option', True)] + + if current_object.get('options'): + # remove use_options false from current_object + current_object['options'] = [option for option in current_object['options'] if option.get('use_option', True)] + if (ib_obj_type == NIOS_RANGE): if proposed_object.get('new_start_addr'): proposed_object['start_addr'] = proposed_object.get('new_start_addr') @@ -396,6 +410,11 @@ def run(self, ib_obj_type, ib_spec): if (ib_obj_type == NIOS_EXTENSIBLE_ATTRIBUTE): proposed_object = convert_ea_list_to_struct(proposed_object) + current_object = convert_ea_list_to_struct(current_object) + # Convert 'default_value' to string in both proposed_object and current_object if it exists + for obj in (proposed_object, current_object): + if 'default_value' in obj: + obj['default_value'] = str(obj['default_value']) # checks if the 'text' field has to be updated for the TXT Record if (ib_obj_type == NIOS_TXT_RECORD): @@ -487,6 +506,8 @@ def run(self, ib_obj_type, ib_spec): result['changed'] = True elif 'network_view' in proposed_object and (ib_obj_type not in (NIOS_IPV4_FIXED_ADDRESS, NIOS_IPV6_FIXED_ADDRESS, NIOS_RANGE)): proposed_object.pop('network_view') + if ib_obj_type in (NIOS_IPV4_NETWORK_CONTAINER, NIOS_IPV6_NETWORK_CONTAINER): + proposed_object.pop('network') result['changed'] = True if not self.module.check_mode and res is None: proposed_object = self.on_update(proposed_object, ib_spec) @@ -642,13 +663,18 @@ def compare_objects(self, current_object, proposed_object): # If the lists are of a different length the objects can not be # equal and False will be returned before comparing the lists items # this code part will work for members assignment - if key == 'members' and (len(proposed_item) != len(current_item)): + if key in ['members', 'options'] and (len(proposed_item) != len(current_item)): return False for subitem in proposed_item: if not self.issubset(subitem, current_item): return False + # If the lists are of a different length the objects and order of element mismatch + # Ignore DHCP options while comparing due to extra num param is get response + if key == 'logic_filter_rules' and proposed_item != current_item: + return False + elif isinstance(proposed_item, dict): # Compare the items of the dict to see if they are equal. A # difference stops the comparison and returns false. If they diff --git a/plugins/modules/nios_dtc_lbdn.py b/plugins/modules/nios_dtc_lbdn.py index bc5a79c1..fe99d0e5 100644 --- a/plugins/modules/nios_dtc_lbdn.py +++ b/plugins/modules/nios_dtc_lbdn.py @@ -183,7 +183,6 @@ def auth_zones_transform(module): else: module.fail_json( msg='auth_zone %s cannot be found.' % zone) - # epdb.serve() return zone_list def pools_transform(module): diff --git a/plugins/modules/nios_extensible_attribute.py b/plugins/modules/nios_extensible_attribute.py index 50e6b9ff..35792448 100644 --- a/plugins/modules/nios_extensible_attribute.py +++ b/plugins/modules/nios_extensible_attribute.py @@ -177,7 +177,6 @@ username: admin password: admin connection: local - ''' RETURN = ''' # ''' diff --git a/plugins/modules/nios_member.py b/plugins/modules/nios_member.py index 9662c9fb..ddb0bf15 100644 --- a/plugins/modules/nios_member.py +++ b/plugins/modules/nios_member.py @@ -455,11 +455,11 @@ router_id: 150 node_info: - lan_ha_port_setting: - - ha_ip_address: 192.168.1.70 - mgmt_lan: 192.168.1.80 + - ha_ip_address: 192.168.1.70 + mgmt_lan: 192.168.1.80 - lan_ha_port_setting: - - ha_ip_address: 192.168.1.71 - mgmt_lan: 192.168.1.81 + - ha_ip_address: 192.168.1.71 + mgmt_lan: 192.168.1.81 comment: "Created by Ansible" state: present provider: @@ -473,13 +473,13 @@ name: member01.localdomain pre_provisioning: - hardware_info: - - hwmodel: IB-VM-820 - hwtype: IB-VNIOS + - hwmodel: IB-VM-820 + hwtype: IB-VNIOS licenses: - - dns - - dhcp - - enterprise - - vnios + - dns + - dhcp + - enterprise + - vnios comment: "Updated by Ansible" state: present provider: diff --git a/plugins/modules/nios_network.py b/plugins/modules/nios_network.py index ee3b9349..4ec26a85 100644 --- a/plugins/modules/nios_network.py +++ b/plugins/modules/nios_network.py @@ -47,6 +47,7 @@ of values (see suboptions). When configuring suboptions at least one of C(name) or C(num) must be specified. type: list + default: [] elements: dict suboptions: name: @@ -315,7 +316,6 @@ def check_ip_addr_type(obj_filter, ib_spec): if 'container' in obj_filter and obj_filter['container']: check_ip = ip.split('/') del ib_spec['container'] # removing the container key from post arguments - del ib_spec['options'] # removing option argument as for network container it's not supported if validate_ip_address(check_ip[0]): return NIOS_IPV4_NETWORK_CONTAINER, ib_spec elif validate_ip_v6_address(check_ip[0]): @@ -360,7 +360,7 @@ def main(): network=dict(required=True, aliases=['name', 'cidr'], ib_req=True), network_view=dict(default='default', ib_req=True), - options=dict(type='list', elements='dict', options=option_spec, transform=options), + options=dict(type='list', elements='dict', options=option_spec, transform=options, default=[]), template=dict(type='str'), extattrs=dict(type='dict'), diff --git a/plugins/modules/nios_nsgroup.py b/plugins/modules/nios_nsgroup.py index 91e5d6d4..eb141a4a 100644 --- a/plugins/modules/nios_nsgroup.py +++ b/plugins/modules/nios_nsgroup.py @@ -295,7 +295,7 @@ external_primaries: "{{ ext_nameservers }}" grid_secondaries: - name: infoblox-test.example.com - lead: True + lead: true preferred_primaries: "{{ ext_nameservers }}" state: present provider: diff --git a/plugins/modules/nios_range.py b/plugins/modules/nios_range.py index 0f1b5cf9..f2bc7515 100644 --- a/plugins/modules/nios_range.py +++ b/plugins/modules/nios_range.py @@ -44,6 +44,7 @@ of values (see suboptions). When configuring suboptions at least one of C(name) or C(num) must be specified. type: list + default: [] elements: dict suboptions: name: @@ -252,8 +253,8 @@ start_addr: 18.10.0.12 end_addr: 18.10.0.14 options: - - name: domain-name - value: zone1.com + - name: domain-name + value: zone1.com comment: Created with Ansible state: present provider: @@ -375,7 +376,7 @@ def main(): new_end_addr=dict(aliases=['new_end', 'new_last_addr', 'new_last'], type='str'), name=dict(type='str'), disable=dict(type='bool', default='false',), - options=dict(type='list', elements='dict', options=option_spec, transform=options), + options=dict(type='list', elements='dict', options=option_spec, transform=options, default=[]), member=dict(type='str'), failover_association=dict(type='str'), ms_server=dict(type='str'), diff --git a/plugins/modules/nios_txt_record.py b/plugins/modules/nios_txt_record.py index 7e46ed97..4ef9d27d 100644 --- a/plugins/modules/nios_txt_record.py +++ b/plugins/modules/nios_txt_record.py @@ -75,39 +75,39 @@ ''' EXAMPLES = ''' - - name: Ensure a text Record Exists - infoblox.nios_modules.nios_txt_record: - name: fqdn.txt.record.com - text: mytext - state: present - view: External - provider: - host: "{{ inventory_hostname_short }}" - username: admin - password: admin - - - name: Update name of TXT record - infoblox.nios_modules.nios_txt_record: - name: {old_name: sample.txtrecord.com, new_name: newsample.txtrecord.com} - text: mytext - state: present - view: External - provider: - host: "{{ inventory_hostname_short }}" - username: admin - password: admin - connection: local - - - name: Ensure a text Record does not exist - infoblox.nios_modules.nios_txt_record: - name: fqdn.txt.record.com - text: mytext - state: absent - view: External - provider: - host: "{{ inventory_hostname_short }}" - username: admin - password: admin +- name: Ensure a text Record Exists + infoblox.nios_modules.nios_txt_record: + name: fqdn.txt.record.com + text: mytext + state: present + view: External + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + +- name: Update name of TXT record + infoblox.nios_modules.nios_txt_record: + name: {old_name: sample.txtrecord.com, new_name: newsample.txtrecord.com} + text: mytext + state: present + view: External + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Ensure a text Record does not exist + infoblox.nios_modules.nios_txt_record: + name: fqdn.txt.record.com + text: mytext + state: absent + view: External + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin ''' RETURN = ''' # ''' diff --git a/tests/integration/targets/nios_a_record/meta/main.yaml b/tests/integration/targets/nios_a_record/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_a_record/meta/main.yaml +++ b/tests/integration/targets/nios_a_record/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_a_record/tasks/main.yml b/tests/integration/targets/nios_a_record/tasks/main.yml index 0955a39f..36c13b70 100644 --- a/tests/integration/targets/nios_a_record/tasks/main.yml +++ b/tests/integration/targets/nios_a_record/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_a_record_idempotence.yml +--- +- name: Include A record idempotence tests + ansible.builtin.include_tasks: nios_a_record_idempotence.yml diff --git a/tests/integration/targets/nios_a_record/tasks/nios_a_record_idempotence.yml b/tests/integration/targets/nios_a_record/tasks/nios_a_record_idempotence.yml index 0bbf106c..a6134b4e 100644 --- a/tests/integration/targets/nios_a_record/tasks/nios_a_record_idempotence.yml +++ b/tests/integration/targets/nios_a_record/tasks/nios_a_record_idempotence.yml @@ -1,40 +1,41 @@ -- name: cleanup the parent object - nios_zone: +--- +- name: Cleanup the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: absent provider: "{{ nios_provider }}" -- name: create the parent object - nios_zone: +- name: Create the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: present provider: "{{ nios_provider }}" -- name: cleanup a_record - nios_a_record: +- name: Cleanup a_record + infoblox.nios_modules.nios_a_record: name: a.ansible.com ipv4: 192.168.10.1 state: absent provider: "{{ nios_provider }}" -- name: create an a_record - nios_a_record: +- name: Create an a_record + infoblox.nios_modules.nios_a_record: name: a.ansible.com ipv4: 192.168.10.1 state: present provider: "{{ nios_provider }}" register: a_record_create1 -- name: recreate an a_record - nios_a_record: +- name: Recreate an a_record + infoblox.nios_modules.nios_a_record: name: a.ansible.com ipv4: 192.168.10.1 state: present provider: "{{ nios_provider }}" register: a_record_create2 -- name: add a comment to an existing a_record - nios_a_record: +- name: Add a comment to an existing a_record + infoblox.nios_modules.nios_a_record: name: a.ansible.com ipv4: 192.168.10.1 comment: this is a test comment @@ -42,8 +43,8 @@ provider: "{{ nios_provider }}" register: a_record_update1 -- name: add a comment to an existing a_record - nios_a_record: +- name: Add a comment to an existing a_record + infoblox.nios_modules.nios_a_record: name: a.ansible.com ipv4: 192.168.10.1 comment: this is a test comment @@ -51,27 +52,28 @@ provider: "{{ nios_provider }}" register: a_record_update2 -- name: remove a a_record from the system - nios_a_record: +- name: Remove a a_record from the system + infoblox.nios_modules.nios_a_record: name: a.ansible.com ipv4: 192.168.10.1 state: absent provider: "{{ nios_provider }}" register: a_record_delete1 -- name: remove a a_record from the system - nios_a_record: +- name: Remove a a_record from the system + infoblox.nios_modules.nios_a_record: name: a.ansible.com ipv4: 192.168.10.1 state: absent provider: "{{ nios_provider }}" register: a_record_delete2 -- assert: +- name: Verify idempotence and changes of A record operations + ansible.builtin.assert: that: - - "a_record_create1.changed" - - "not a_record_create2.changed" - - "a_record_update1.changed" - - "not a_record_update2.changed" - - "a_record_delete1.changed" - - "not a_record_delete2.changed" + - a_record_create1.changed + - not a_record_create2.changed + - a_record_update1.changed + - not a_record_update2.changed + - a_record_delete1.changed + - not a_record_delete2.changed diff --git a/tests/integration/targets/nios_aaaa_record/meta/main.yaml b/tests/integration/targets/nios_aaaa_record/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_aaaa_record/meta/main.yaml +++ b/tests/integration/targets/nios_aaaa_record/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_aaaa_record/tasks/main.yml b/tests/integration/targets/nios_aaaa_record/tasks/main.yml index 9096b63d..6637c0de 100644 --- a/tests/integration/targets/nios_aaaa_record/tasks/main.yml +++ b/tests/integration/targets/nios_aaaa_record/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_aaaa_record_idempotence.yml +--- +- name: Include AAAA record idempotence tests + ansible.builtin.include_tasks: nios_aaaa_record_idempotence.yml diff --git a/tests/integration/targets/nios_aaaa_record/tasks/nios_aaaa_record_idempotence.yml b/tests/integration/targets/nios_aaaa_record/tasks/nios_aaaa_record_idempotence.yml index 2df01d34..bf4d0866 100644 --- a/tests/integration/targets/nios_aaaa_record/tasks/nios_aaaa_record_idempotence.yml +++ b/tests/integration/targets/nios_aaaa_record/tasks/nios_aaaa_record_idempotence.yml @@ -1,40 +1,41 @@ -- name: cleanup the parent object - nios_zone: +--- +- name: Cleanup the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: absent provider: "{{ nios_provider }}" -- name: create the parent object - nios_zone: +- name: Create the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: present provider: "{{ nios_provider }}" -- name: cleanup aaaa record - nios_aaaa_record: +- name: Cleanup aaaa record + infoblox.nios_modules.nios_aaaa_record: name: aaaa.ansible.com ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 state: absent provider: "{{ nios_provider }}" -- name: create an aaaa record - nios_aaaa_record: +- name: Create an aaaa record + infoblox.nios_modules.nios_aaaa_record: name: aaaa.ansible.com ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 state: present provider: "{{ nios_provider }}" register: aaaa_record_create1 -- name: recreate an aaaa record - nios_aaaa_record: +- name: Recreate an aaaa record + infoblox.nios_modules.nios_aaaa_record: name: aaaa.ansible.com ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 state: present provider: "{{ nios_provider }}" register: aaaa_record_create2 -- name: add a comment to an existing aaaa record - nios_aaaa_record: +- name: Add a comment to an existing aaaa record + infoblox.nios_modules.nios_aaaa_record: name: aaaa.ansible.com ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 comment: this is a test comment @@ -42,8 +43,8 @@ provider: "{{ nios_provider }}" register: aaaa_record_update1 -- name: add a comment to an existing aaaa record - nios_aaaa_record: +- name: Add a comment to an existing aaaa record + infoblox.nios_modules.nios_aaaa_record: name: aaaa.ansible.com ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 comment: this is a test comment @@ -51,27 +52,28 @@ provider: "{{ nios_provider }}" register: aaaa_record_update2 -- name: remove a aaaa record from the system - nios_aaaa_record: +- name: Remove a aaaa record from the system + infoblox.nios_modules.nios_aaaa_record: name: aaaa.ansible.com ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 state: absent provider: "{{ nios_provider }}" register: aaaa_record_delete1 -- name: remove a aaaa record from the system - nios_aaaa_record: +- name: Remove a aaaa record from the system + infoblox.nios_modules.nios_aaaa_record: name: aaaa.ansible.com ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 state: absent provider: "{{ nios_provider }}" register: aaaa_record_delete2 -- assert: +- name: Verify idempotence and changes of AAAA record operations + ansible.builtin.assert: that: - - "aaaa_record_create1.changed" - - "not aaaa_record_create2.changed" - - "aaaa_record_update1.changed" - - "not aaaa_record_update2.changed" - - "aaaa_record_delete1.changed" - - "not aaaa_record_delete2.changed" + - aaaa_record_create1.changed + - not aaaa_record_create2.changed + - aaaa_record_update1.changed + - not aaaa_record_update2.changed + - aaaa_record_delete1.changed + - not aaaa_record_delete2.changed diff --git a/tests/integration/targets/nios_cname_record/meta/main.yaml b/tests/integration/targets/nios_cname_record/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_cname_record/meta/main.yaml +++ b/tests/integration/targets/nios_cname_record/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_cname_record/tasks/main.yml b/tests/integration/targets/nios_cname_record/tasks/main.yml index df8ff758..0eb34124 100644 --- a/tests/integration/targets/nios_cname_record/tasks/main.yml +++ b/tests/integration/targets/nios_cname_record/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_cname_record_idempotence.yml +--- +- name: Include CNAME record idempotence tests + ansible.builtin.include_tasks: nios_cname_record_idempotence.yml diff --git a/tests/integration/targets/nios_cname_record/tasks/nios_cname_record_idempotence.yml b/tests/integration/targets/nios_cname_record/tasks/nios_cname_record_idempotence.yml index f450c716..de0c687c 100644 --- a/tests/integration/targets/nios_cname_record/tasks/nios_cname_record_idempotence.yml +++ b/tests/integration/targets/nios_cname_record/tasks/nios_cname_record_idempotence.yml @@ -1,40 +1,41 @@ -- name: cleanup the parent object - nios_zone: +--- +- name: Cleanup the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: absent provider: "{{ nios_provider }}" -- name: create the parent object - nios_zone: +- name: Create the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: present provider: "{{ nios_provider }}" -- name: cleanup cname record - nios_cname_record: +- name: Cleanup cname record + infoblox.nios_modules.nios_cname_record: name: cname.ansible.com canonical: realhost.ansible.com state: absent provider: "{{ nios_provider }}" -- name: create an cname record - nios_cname_record: +- name: Create an cname record + infoblox.nios_modules.nios_cname_record: name: cname.ansible.com canonical: realhost.ansible.com state: present provider: "{{ nios_provider }}" register: cname_record_create1 -- name: recreate an cname record - nios_cname_record: +- name: Recreate an cname record + infoblox.nios_modules.nios_cname_record: name: cname.ansible.com canonical: realhost.ansible.com state: present provider: "{{ nios_provider }}" register: cname_record_create2 -- name: add a comment to an existing cname record - nios_cname_record: +- name: Add a comment to an existing cname record + infoblox.nios_modules.nios_cname_record: name: cname.ansible.com canonical: realhost.ansible.com comment: this is a test comment @@ -42,8 +43,8 @@ provider: "{{ nios_provider }}" register: cname_record_update1 -- name: add a comment to an existing cname record - nios_cname_record: +- name: Add a comment to an existing cname record + infoblox.nios_modules.nios_cname_record: name: cname.ansible.com canonical: realhost.ansible.com comment: this is a test comment @@ -51,27 +52,28 @@ provider: "{{ nios_provider }}" register: cname_record_update2 -- name: remove a cname record from the system - nios_cname_record: +- name: Remove a cname record from the system + infoblox.nios_modules.nios_cname_record: name: cname.ansible.com canonical: realhost.ansible.com state: absent provider: "{{ nios_provider }}" register: cname_record_delete1 -- name: remove a cname record from the system - nios_cname_record: +- name: Remove a cname record from the system + infoblox.nios_modules.nios_cname_record: name: cname.ansible.com canonical: realhost.ansible.com state: absent provider: "{{ nios_provider }}" register: cname_record_delete2 -- assert: +- name: Verify idempotence and changes of CNAME record operations + ansible.builtin.assert: that: - - "cname_record_create1.changed" - - "not cname_record_create2.changed" - - "cname_record_update1.changed" - - "not cname_record_update2.changed" - - "cname_record_delete1.changed" - - "not cname_record_delete2.changed" + - cname_record_create1.changed + - not cname_record_create2.changed + - cname_record_update1.changed + - not cname_record_update2.changed + - cname_record_delete1.changed + - not cname_record_delete2.changed diff --git a/tests/integration/targets/nios_dns_view/defaults/main.yaml b/tests/integration/targets/nios_dns_view/defaults/main.yaml index ebf6ffc9..9ef5ba51 100644 --- a/tests/integration/targets/nios_dns_view/defaults/main.yaml +++ b/tests/integration/targets/nios_dns_view/defaults/main.yaml @@ -1,3 +1,3 @@ --- testcase: "*" -test_items: [] \ No newline at end of file +test_items: [] diff --git a/tests/integration/targets/nios_dns_view/meta/main.yaml b/tests/integration/targets/nios_dns_view/meta/main.yaml index 9472935b..a4ad32ff 100644 --- a/tests/integration/targets/nios_dns_view/meta/main.yaml +++ b/tests/integration/targets/nios_dns_view/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - - prepare_nios_tests \ No newline at end of file + - prepare_nios_tests diff --git a/tests/integration/targets/nios_dns_view/tasks/main.yml b/tests/integration/targets/nios_dns_view/tasks/main.yml index 2b9ca3a0..50a5ce43 100644 --- a/tests/integration/targets/nios_dns_view/tasks/main.yml +++ b/tests/integration/targets/nios_dns_view/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_dns_view_idempotence.yml +--- +- name: Include the tasks for the nios_dns_view_idempotence + ansible.builtin.include_tasks: nios_dns_view_idempotence.yml diff --git a/tests/integration/targets/nios_dns_view/tasks/nios_dns_view_idempotence.yml b/tests/integration/targets/nios_dns_view/tasks/nios_dns_view_idempotence.yml index b9dc9fec..c05f51af 100644 --- a/tests/integration/targets/nios_dns_view/tasks/nios_dns_view_idempotence.yml +++ b/tests/integration/targets/nios_dns_view/tasks/nios_dns_view_idempotence.yml @@ -1,58 +1,60 @@ -- name: delete dns view instance - nios_dns_view: +--- +- name: Delete dns view instance + infoblox.nios_modules.nios_dns_view: name: ansible-dns state: absent provider: "{{ nios_provider }}" -- name: configure a new dns view instance - nios_dns_view: +- name: Configure a new dns view instance + infoblox.nios_modules.nios_dns_view: name: ansible-dns state: present provider: "{{ nios_provider }}" register: nios_dns_create1 -- name: configure a new dns view instance - nios_dns_view: +- name: Configure a new dns view instance + infoblox.nios_modules.nios_dns_view: name: ansible-dns state: present provider: "{{ nios_provider }}" register: nios_dns_create2 -- name: update the comment for dns view - nios_dns_view: +- name: Update the comment for dns view + infoblox.nios_modules.nios_dns_view: name: ansible-dns comment: this is an example comment state: present provider: "{{ nios_provider }}" register: nios_dns_update1 -- name: update the comment for dns view - nios_dns_view: +- name: Update the comment for dns view + infoblox.nios_modules.nios_dns_view: name: ansible-dns comment: this is an example comment state: present provider: "{{ nios_provider }}" register: nios_dns_update2 -- name: delete dns view instance - nios_dns_view: +- name: Delete dns view instance + infoblox.nios_modules.nios_dns_view: name: ansible-dns state: absent provider: "{{ nios_provider }}" register: nios_dns_delete1 -- name: delete dns view instance - nios_dns_view: +- name: Delete dns view instance + infoblox.nios_modules.nios_dns_view: name: ansible-dns state: absent provider: "{{ nios_provider }}" register: nios_dns_delete2 -- assert: +- name: Verify idempotence and changes of DNS view operations + ansible.builtin.assert: that: - - "nios_dns_create1.changed" - - "not nios_dns_create2.changed" - - "nios_dns_update1.changed" - - "not nios_dns_update2.changed" - - "nios_dns_delete1.changed" - - "not nios_dns_delete2.changed" + - nios_dns_create1.changed + - not nios_dns_create2.changed + - nios_dns_update1.changed + - not nios_dns_update2.changed + - nios_dns_delete1.changed + - not nios_dns_delete2.changed diff --git a/tests/integration/targets/nios_dtc_monitor_http/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_http/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_dtc_monitor_http/meta/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_http/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_http/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_http/tasks/main.yaml index f774bfbf..05d8bb79 100644 --- a/tests/integration/targets/nios_dtc_monitor_http/tasks/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_http/tasks/main.yaml @@ -1 +1,3 @@ -- include_tasks: nios_dtc_monitor_http_idempotence.yaml +--- +- name: Include the test for the nios_dtc_monitor_http_idempotence + ansible.builtin.include_tasks: nios_dtc_monitor_http_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_http/tasks/nios_dtc_monitor_http_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_http/tasks/nios_dtc_monitor_http_idempotence.yaml index 8b3a4f40..50172f5f 100644 --- a/tests/integration/targets/nios_dtc_monitor_http/tasks/nios_dtc_monitor_http_idempotence.yaml +++ b/tests/integration/targets/nios_dtc_monitor_http/tasks/nios_dtc_monitor_http_idempotence.yaml @@ -1,3 +1,4 @@ +--- - name: Clean up the parent object infoblox.nios_modules.nios_zone: name: ansible.com @@ -67,9 +68,9 @@ - name: Verify outcomes ansible.builtin.assert: that: - - "dtc_monitor_http_create1.changed" - - "not dtc_monitor_http_create2.changed" - - "dtc_monitor_http_update1.changed" - - "not dtc_monitor_http_update2.changed" - - "dtc_monitor_http_delete1.changed" - - "not dtc_monitor_http_delete2.changed" + - dtc_monitor_http_create1.changed + - not dtc_monitor_http_create2.changed + - dtc_monitor_http_update1.changed + - not dtc_monitor_http_update2.changed + - dtc_monitor_http_delete1.changed + - not dtc_monitor_http_delete2.changed diff --git a/tests/integration/targets/nios_dtc_monitor_icmp/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_icmp/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_dtc_monitor_icmp/meta/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_icmp/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_icmp/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_icmp/tasks/main.yaml index 28bf85bd..d0da4f93 100644 --- a/tests/integration/targets/nios_dtc_monitor_icmp/tasks/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_icmp/tasks/main.yaml @@ -1 +1,3 @@ -- include_tasks: nios_dtc_monitor_icmp_idempotence.yaml +--- +- name: Include the tasks for the nios_dtc_monitor_icmp_idempotence + ansible.builtin.include_tasks: nios_dtc_monitor_icmp_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_icmp/tasks/nios_dtc_monitor_icmp_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_icmp/tasks/nios_dtc_monitor_icmp_idempotence.yaml index 984aa59a..d8df170b 100644 --- a/tests/integration/targets/nios_dtc_monitor_icmp/tasks/nios_dtc_monitor_icmp_idempotence.yaml +++ b/tests/integration/targets/nios_dtc_monitor_icmp/tasks/nios_dtc_monitor_icmp_idempotence.yaml @@ -1,3 +1,4 @@ +--- - name: Clean up the parent object infoblox.nios_modules.nios_zone: name: ansible.com @@ -63,9 +64,9 @@ - name: Verify outcomes ansible.builtin.assert: that: - - "dtc_monitor_icmp_create1.changed" - - "not dtc_monitor_icmp_create2.changed" - - "dtc_monitor_icmp_update1.changed" - - "not dtc_monitor_icmp_update2.changed" - - "dtc_monitor_icmp_delete1.changed" - - "not dtc_monitor_icmp_delete2.changed" + - dtc_monitor_icmp_create1.changed + - not dtc_monitor_icmp_create2.changed + - dtc_monitor_icmp_update1.changed + - not dtc_monitor_icmp_update2.changed + - dtc_monitor_icmp_delete1.changed + - not dtc_monitor_icmp_delete2.changed diff --git a/tests/integration/targets/nios_dtc_monitor_pdp/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_pdp/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_dtc_monitor_pdp/meta/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_pdp/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_pdp/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_pdp/tasks/main.yaml index 55829c8d..65b2d789 100644 --- a/tests/integration/targets/nios_dtc_monitor_pdp/tasks/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_pdp/tasks/main.yaml @@ -1 +1,3 @@ -- include_tasks: nios_dtc_monitor_pdp_idempotence.yaml +--- +- name: Include the tasks from the idempotence test + ansible.builtin.include_tasks: nios_dtc_monitor_pdp_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_pdp/tasks/nios_dtc_monitor_pdp_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_pdp/tasks/nios_dtc_monitor_pdp_idempotence.yaml index 022f12d7..ab64163d 100644 --- a/tests/integration/targets/nios_dtc_monitor_pdp/tasks/nios_dtc_monitor_pdp_idempotence.yaml +++ b/tests/integration/targets/nios_dtc_monitor_pdp/tasks/nios_dtc_monitor_pdp_idempotence.yaml @@ -1,3 +1,4 @@ +--- - name: Clean up the parent object infoblox.nios_modules.nios_zone: name: ansible.com @@ -63,9 +64,9 @@ - name: Verify outcomes ansible.builtin.assert: that: - - "dtc_monitor_pdp_create1.changed" - - "not dtc_monitor_pdp_create2.changed" - - "dtc_monitor_pdp_update1.changed" - - "not dtc_monitor_pdp_update2.changed" - - "dtc_monitor_pdp_delete1.changed" - - "not dtc_monitor_pdp_delete2.changed" + - dtc_monitor_pdp_create1.changed + - not dtc_monitor_pdp_create2.changed + - dtc_monitor_pdp_update1.changed + - not dtc_monitor_pdp_update2.changed + - dtc_monitor_pdp_delete1.changed + - not dtc_monitor_pdp_delete2.changed diff --git a/tests/integration/targets/nios_dtc_monitor_sip/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_sip/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_dtc_monitor_sip/meta/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_sip/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_sip/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_sip/tasks/main.yaml index e5e1b33f..af5c50a1 100644 --- a/tests/integration/targets/nios_dtc_monitor_sip/tasks/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_sip/tasks/main.yaml @@ -1 +1,3 @@ -- include_tasks: nios_dtc_monitor_sip_idempotence.yaml +--- +- name: Include tasks from nios_dtc_monitor_sip_idempotence.yaml + ansible.builtin.include_tasks: nios_dtc_monitor_sip_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_sip/tasks/nios_dtc_monitor_sip_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_sip/tasks/nios_dtc_monitor_sip_idempotence.yaml index 68187a12..8b49b8a2 100644 --- a/tests/integration/targets/nios_dtc_monitor_sip/tasks/nios_dtc_monitor_sip_idempotence.yaml +++ b/tests/integration/targets/nios_dtc_monitor_sip/tasks/nios_dtc_monitor_sip_idempotence.yaml @@ -1,3 +1,4 @@ +--- - name: Clean up the parent object infoblox.nios_modules.nios_zone: name: ansible.com @@ -63,9 +64,9 @@ - name: Verify outcomes ansible.builtin.assert: that: - - "dtc_monitor_sip_create1.changed" - - "not dtc_monitor_sip_create2.changed" - - "dtc_monitor_sip_update1.changed" - - "not dtc_monitor_sip_update2.changed" - - "dtc_monitor_sip_delete1.changed" - - "not dtc_monitor_sip_delete2.changed" + - dtc_monitor_sip_create1.changed + - not dtc_monitor_sip_create2.changed + - dtc_monitor_sip_update1.changed + - not dtc_monitor_sip_update2.changed + - dtc_monitor_sip_delete1.changed + - not dtc_monitor_sip_delete2.changed diff --git a/tests/integration/targets/nios_dtc_monitor_snmp/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_snmp/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_dtc_monitor_snmp/meta/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_snmp/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_snmp/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_snmp/tasks/main.yaml index 02c852d3..d47b695f 100644 --- a/tests/integration/targets/nios_dtc_monitor_snmp/tasks/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_snmp/tasks/main.yaml @@ -1 +1,3 @@ -- include_tasks: nios_dtc_monitor_snmp_idempotence.yaml +--- +- name: Include the tasks from the nios_dtc_monitor_snmp_idempotence.yaml file + ansible.builtin.include_tasks: nios_dtc_monitor_snmp_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_snmp/tasks/nios_dtc_monitor_snmp_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_snmp/tasks/nios_dtc_monitor_snmp_idempotence.yaml index 12b56047..49a2fd22 100644 --- a/tests/integration/targets/nios_dtc_monitor_snmp/tasks/nios_dtc_monitor_snmp_idempotence.yaml +++ b/tests/integration/targets/nios_dtc_monitor_snmp/tasks/nios_dtc_monitor_snmp_idempotence.yaml @@ -1,3 +1,4 @@ +--- - name: Clean up the parent object infoblox.nios_modules.nios_zone: name: ansible.com @@ -63,9 +64,9 @@ - name: Verify outcomes ansible.builtin.assert: that: - - "dtc_monitor_snmp_create1.changed" - - "not dtc_monitor_snmp_create2.changed" - - "dtc_monitor_snmp_update1.changed" - - "not dtc_monitor_snmp_update2.changed" - - "dtc_monitor_snmp_delete1.changed" - - "not dtc_monitor_snmp_delete2.changed" + - dtc_monitor_snmp_create1.changed + - not dtc_monitor_snmp_create2.changed + - dtc_monitor_snmp_update1.changed + - not dtc_monitor_snmp_update2.changed + - dtc_monitor_snmp_delete1.changed + - not dtc_monitor_snmp_delete2.changed diff --git a/tests/integration/targets/nios_dtc_monitor_tcp/meta/main.yaml b/tests/integration/targets/nios_dtc_monitor_tcp/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_dtc_monitor_tcp/meta/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_tcp/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_monitor_tcp/tasks/main.yaml b/tests/integration/targets/nios_dtc_monitor_tcp/tasks/main.yaml index e24c8265..aef2a532 100644 --- a/tests/integration/targets/nios_dtc_monitor_tcp/tasks/main.yaml +++ b/tests/integration/targets/nios_dtc_monitor_tcp/tasks/main.yaml @@ -1 +1,3 @@ -- include_tasks: nios_dtc_monitor_tcp_idempotence.yaml +--- +- name: Include the test for the nios_dtc_monitor_tcp_idempotence + ansible.builtin.include_tasks: nios_dtc_monitor_tcp_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml b/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml index 1c025b93..403aad2f 100644 --- a/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml +++ b/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml @@ -1,3 +1,4 @@ +--- - name: Clean up the parent object infoblox.nios_modules.nios_zone: name: ansible.com @@ -70,9 +71,9 @@ - name: Verify outcomes ansible.builtin.assert: that: - - "dtc_monitor_tcp_create1.changed" - - "not dtc_monitor_tcp_create2.changed" - - "dtc_monitor_tcp_update1.changed" - - "not dtc_monitor_tcp_update2.changed" - - "dtc_monitor_tcp_delete1.changed" - - "not dtc_monitor_tcp_delete2.changed" + - dtc_monitor_tcp_create1.changed + - not dtc_monitor_tcp_create2.changed + - dtc_monitor_tcp_update1.changed + - not dtc_monitor_tcp_update2.changed + - dtc_monitor_tcp_delete1.changed + - not dtc_monitor_tcp_delete2.changed diff --git a/tests/integration/targets/nios_dtc_topology/meta/main.yaml b/tests/integration/targets/nios_dtc_topology/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_dtc_topology/meta/main.yaml +++ b/tests/integration/targets/nios_dtc_topology/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_dtc_topology/tasks/main.yaml b/tests/integration/targets/nios_dtc_topology/tasks/main.yaml index 8873ef55..11c12594 100644 --- a/tests/integration/targets/nios_dtc_topology/tasks/main.yaml +++ b/tests/integration/targets/nios_dtc_topology/tasks/main.yaml @@ -1 +1,3 @@ -- include_tasks: nios_dtc_topology_idempotence.yaml +--- +- name: Include DTC topology idempotence tests + ansible.builtin.include_tasks: nios_dtc_topology_idempotence.yaml diff --git a/tests/integration/targets/nios_dtc_topology/tasks/nios_dtc_topology_idempotence.yaml b/tests/integration/targets/nios_dtc_topology/tasks/nios_dtc_topology_idempotence.yaml index a24a9c31..20dee06a 100644 --- a/tests/integration/targets/nios_dtc_topology/tasks/nios_dtc_topology_idempotence.yaml +++ b/tests/integration/targets/nios_dtc_topology/tasks/nios_dtc_topology_idempotence.yaml @@ -1,3 +1,4 @@ +--- - name: Clean up the parent object infoblox.nios_modules.nios_zone: name: ansible.com @@ -114,9 +115,9 @@ - name: Verify outcomes ansible.builtin.assert: that: - - "dtc_topology_create1.changed" - - "not dtc_topology_create2.changed" - - "dtc_topology_update1.changed" - - "not dtc_topology_update2.changed" - - "dtc_topology_delete1.changed" - - "not dtc_topology_delete2.changed" + - dtc_topology_create1.changed + - not dtc_topology_create2.changed + - dtc_topology_update1.changed + - not dtc_topology_update2.changed + - dtc_topology_delete1.changed + - not dtc_topology_delete2.changed diff --git a/tests/integration/targets/nios_extensible_attribute/aliases b/tests/integration/targets/nios_extensible_attribute/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_extensible_attribute/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_extensible_attribute/defaults/main.yaml b/tests/integration/targets/nios_extensible_attribute/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/tests/integration/targets/nios_extensible_attribute/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/tests/integration/targets/nios_extensible_attribute/meta/main.yaml b/tests/integration/targets/nios_extensible_attribute/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/tests/integration/targets/nios_extensible_attribute/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/tests/integration/targets/nios_extensible_attribute/tasks/main.yaml b/tests/integration/targets/nios_extensible_attribute/tasks/main.yaml new file mode 100644 index 00000000..e1442d4f --- /dev/null +++ b/tests/integration/targets/nios_extensible_attribute/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_extensible_attribute.yaml diff --git a/tests/integration/targets/nios_extensible_attribute/tasks/nios_extensible_attribute.yaml b/tests/integration/targets/nios_extensible_attribute/tasks/nios_extensible_attribute.yaml new file mode 100644 index 00000000..b5b54470 --- /dev/null +++ b/tests/integration/targets/nios_extensible_attribute/tasks/nios_extensible_attribute.yaml @@ -0,0 +1,147 @@ +- name: Clean up existing EA + infoblox.nios_modules.nios_extensible_attribute: + name: stringEA + type: STRING + state: absent + provider: "{{ nios_provider }}" + +- name: Create STRING EA + infoblox.nios_modules.nios_extensible_attribute: + name: stringEA + type: STRING + default_value: "string" + min: 1 + max: 15 + comment: Created string EA with Ansible + state: present + provider: "{{ nios_provider }}" + register: create_string_ea + +- name: Update STRING EA Comment + infoblox.nios_modules.nios_extensible_attribute: + name: stringEA + type: STRING + default_value: "string" + min: 1 + max: 15 + comment: Updated string EA with Ansible + state: present + provider: "{{ nios_provider }}" + register: update_string_ea + +- name: Create Integer EA + infoblox.nios_modules.nios_extensible_attribute: + name: IntegerEA + type: INTEGER + default_value: "15" + min: 1 + max: 15 + flags: 'I' + comment: Created string EA with Ansible + state: present + provider: "{{ nios_provider }}" + register: create_integer_ea + +- name: Update Integer EA value + infoblox.nios_modules.nios_extensible_attribute: + name: IntegerEA + type: INTEGER + default_value: "14" + min: 1 + max: 15 + flags: 'I' + comment: Created string EA with Ansible + state: present + provider: "{{ nios_provider }}" + register: update_integer_ea + +- name: Remove STRING EA Comment + infoblox.nios_modules.nios_extensible_attribute: + name: stringEA + type: STRING + default_value: "string" + min: 1 + max: 15 + state: present + provider: "{{ nios_provider }}" + register: remove_string_ea + +- name: Remove Integer EA definition + infoblox.nios_modules.nios_extensible_attribute: + name: IntegerEA + type: INTEGER + default_value: "14" + min: 1 + max: 15 + flags: 'I' + comment: Created string EA with Ansible + state: absent + provider: "{{ nios_provider }}" + register: remove_integer_ea + +- name: Create ENUM EA + infoblox.nios_modules.nios_extensible_attribute: + name: enumEA + type: ENUM + list_values: + - option1 + - option2 + default_value: "option1" + comment: Created enum EA with Ansible + state: present + provider: "{{ nios_provider }}" + register: create_enum_ea + +- name: Update ENUM EA default value + infoblox.nios_modules.nios_extensible_attribute: + name: enumEA + type: ENUM + list_values: + - option1 + - option2 + default_value: "option2" + comment: Updated enum EA default value with Ansible + state: present + provider: "{{ nios_provider }}" + register: update_enum_ea + +- name: Create DATE EA + infoblox.nios_modules.nios_extensible_attribute: + name: dateEA + type: DATE + default_value: "2023-01-01" + comment: Created date EA with Ansible + state: present + provider: "{{ nios_provider }}" + register: create_date_ea + +- name: Update DATE EA default value + infoblox.nios_modules.nios_extensible_attribute: + name: dateEA + type: DATE + default_value: "2023-12-31" + comment: Updated date EA default value with Ansible + state: present + provider: "{{ nios_provider }}" + register: update_date_ea + +- name: Check if the EA already exists + infoblox.nios_modules.nios_extensible_attribute: + name: existEA + state: present + provider: "{{ nios_provider }}" + register: ea_exists + +- name: Verify outcomes including new tests + ansible.builtin.assert: + that: + - "create_string_ea.changed" + - "update_string_ea.changed" + - "create_integer_ea.changed" + - "update_integer_ea.changed" + - "remove_string_ea.changed" + - "remove_integer_ea.changed" + - "create_enum_ea.changed" + - "update_enum_ea.changed" + - "create_date_ea.changed" + - "update_date_ea.changed" diff --git a/tests/integration/targets/nios_host_record/defaults/main.yaml b/tests/integration/targets/nios_host_record/defaults/main.yaml index ebf6ffc9..9ef5ba51 100644 --- a/tests/integration/targets/nios_host_record/defaults/main.yaml +++ b/tests/integration/targets/nios_host_record/defaults/main.yaml @@ -1,3 +1,3 @@ --- testcase: "*" -test_items: [] \ No newline at end of file +test_items: [] diff --git a/tests/integration/targets/nios_host_record/meta/main.yaml b/tests/integration/targets/nios_host_record/meta/main.yaml index 9472935b..a4ad32ff 100644 --- a/tests/integration/targets/nios_host_record/meta/main.yaml +++ b/tests/integration/targets/nios_host_record/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - - prepare_nios_tests \ No newline at end of file + - prepare_nios_tests diff --git a/tests/integration/targets/nios_host_record/tasks/main.yml b/tests/integration/targets/nios_host_record/tasks/main.yml index 3c626f55..bd80def0 100644 --- a/tests/integration/targets/nios_host_record/tasks/main.yml +++ b/tests/integration/targets/nios_host_record/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_host_record_idempotence.yml +--- +- name: Include host record idempotence tests + ansible.builtin.include_tasks: nios_host_record_idempotence.yml diff --git a/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml b/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml index 636431ee..c1ea7cf0 100644 --- a/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml +++ b/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml @@ -1,25 +1,26 @@ -- name: cleanup the parent object - nios_zone: +--- +- name: Cleanup the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: absent provider: "{{ nios_provider }}" -- name: create the parent object - nios_zone: +- name: Create the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: present provider: "{{ nios_provider }}" -- name: cleanup ipv4 host record - nios_host_record: +- name: Cleanup ipv4 host record + infoblox.nios_modules.nios_host_record: name: host.ansible.com ipv4: - address: 192.168.10.1 state: absent provider: "{{ nios_provider }}" -- name: create an ipv4 host record - nios_host_record: +- name: Create an ipv4 host record + infoblox.nios_modules.nios_host_record: name: host.ansible.com ipv4: - address: 192.168.10.1 @@ -27,8 +28,8 @@ provider: "{{ nios_provider }}" register: ipv4_create1 -- name: recreate an ipv4 host record - nios_host_record: +- name: Recreate an ipv4 host record + infoblox.nios_modules.nios_host_record: name: host.ansible.com ipv4: - address: 192.168.10.1 @@ -36,8 +37,8 @@ provider: "{{ nios_provider }}" register: ipv4_create2 -- name: add a comment to an existing host record - nios_host_record: +- name: Add a comment to an existing host record + infoblox.nios_modules.nios_host_record: name: host.ansible.com ipv4: - address: 192.168.10.1 @@ -46,8 +47,8 @@ provider: "{{ nios_provider }}" register: ipv4_update1 -- name: add a comment to an existing host record - nios_host_record: +- name: Add a comment to an existing host record + infoblox.nios_modules.nios_host_record: name: host.ansible.com ipv4: - address: 192.168.10.1 @@ -56,22 +57,22 @@ provider: "{{ nios_provider }}" register: ipv4_update2 -- name: remove a host record from the system - nios_host_record: +- name: Remove a host record from the system + infoblox.nios_modules.nios_host_record: name: host.ansible.com state: absent provider: "{{ nios_provider }}" register: ipv4_delete1 -- name: remove a host record from the system - nios_host_record: +- name: Remove a host record from the system + infoblox.nios_modules.nios_host_record: name: host.ansible.com state: absent provider: "{{ nios_provider }}" register: ipv4_delete2 -- name: create an ipv4 host record bypassing DNS - nios_host_record: +- name: Create an ipv4 host record bypassing DNS + infoblox.nios_modules.nios_host_record: name: host ipv4: - address: 192.168.10.1 @@ -80,8 +81,8 @@ provider: "{{ nios_provider }}" register: ipv4_create3 -- name: recreate an ipv4 host record bypassing DNS - nios_host_record: +- name: Recreate an ipv4 host record bypassing DNS + infoblox.nios_modules.nios_host_record: name: host ipv4: - address: 192.168.10.1 @@ -90,8 +91,8 @@ provider: "{{ nios_provider }}" register: ipv4_create4 -- name: create an ipv4 host record via DHCP and MAC - nios_host_record: +- name: Create an ipv4 host record via DHCP and MAC + infoblox.nios_modules.nios_host_record: name: host ipv4: - address: 192.168.10.1 @@ -101,8 +102,8 @@ provider: "{{ nios_provider }}" register: ipv4_create5 -- name: recreate an ipv4 host record via DHCP and MAC - nios_host_record: +- name: Recreate an ipv4 host record via DHCP and MAC + infoblox.nios_modules.nios_host_record: name: host ipv4: - address: 192.168.10.1 @@ -112,15 +113,16 @@ provider: "{{ nios_provider }}" register: ipv4_create6 -- assert: +- name: Verify idempotence and changes of IPv4 host record operations + ansible.builtin.assert: that: - - "ipv4_create1.changed" - - "not ipv4_create2.changed" - - "ipv4_update1.changed" - - "not ipv4_update2.changed" - - "ipv4_delete1.changed" - - "not ipv4_delete2.changed" - - "ipv4_create3.changed" - - "not ipv4_create4.changed" - - "ipv4_create5.changed" - - "not ipv4_create6.changed" + - ipv4_create1.changed + - not ipv4_create2.changed + - ipv4_update1.changed + - not ipv4_update2.changed + - ipv4_delete1.changed + - not ipv4_delete2.changed + - ipv4_create3.changed + - not ipv4_create4.changed + - ipv4_create5.changed + - not ipv4_create6.changed diff --git a/tests/integration/targets/nios_mx_record/meta/main.yaml b/tests/integration/targets/nios_mx_record/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_mx_record/meta/main.yaml +++ b/tests/integration/targets/nios_mx_record/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_mx_record/tasks/main.yml b/tests/integration/targets/nios_mx_record/tasks/main.yml index ebffb41a..a95ba59a 100644 --- a/tests/integration/targets/nios_mx_record/tasks/main.yml +++ b/tests/integration/targets/nios_mx_record/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_mx_record_idempotence.yml +--- +- name: Include MX record idempotence tests + ansible.builtin.include_tasks: nios_mx_record_idempotence.yml diff --git a/tests/integration/targets/nios_mx_record/tasks/nios_mx_record_idempotence.yml b/tests/integration/targets/nios_mx_record/tasks/nios_mx_record_idempotence.yml index 65b1e8f4..d6fd93ee 100644 --- a/tests/integration/targets/nios_mx_record/tasks/nios_mx_record_idempotence.yml +++ b/tests/integration/targets/nios_mx_record/tasks/nios_mx_record_idempotence.yml @@ -1,25 +1,26 @@ -- name: cleanup the parent object - nios_zone: +--- +- name: Cleanup the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: absent provider: "{{ nios_provider }}" -- name: create the parent object - nios_zone: +- name: Create the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: present provider: "{{ nios_provider }}" -- name: cleanup mx record - nios_mx_record: +- name: Cleanup mx record + infoblox.nios_modules.nios_mx_record: name: ansible.com mx: mailhost.ansible.com preference: 0 state: absent provider: "{{ nios_provider }}" -- name: create an mx record - nios_mx_record: +- name: Create an mx record + infoblox.nios_modules.nios_mx_record: name: ansible.com mx: mailhost.ansible.com preference: 0 @@ -27,8 +28,8 @@ provider: "{{ nios_provider }}" register: mx_record_create1 -- name: recreate an mx record - nios_mx_record: +- name: Recreate an mx record + infoblox.nios_modules.nios_mx_record: name: ansible.com mx: mailhost.ansible.com preference: 0 @@ -36,8 +37,8 @@ provider: "{{ nios_provider }}" register: mx_record_create2 -- name: add a comment to an existing mx record - nios_mx_record: +- name: Add a comment to an existing mx record + infoblox.nios_modules.nios_mx_record: name: ansible.com mx: mailhost.ansible.com preference: 0 @@ -46,8 +47,8 @@ provider: "{{ nios_provider }}" register: mx_record_update1 -- name: add a comment to an existing mx record - nios_mx_record: +- name: Add a comment to an existing mx record + infoblox.nios_modules.nios_mx_record: name: ansible.com mx: mailhost.ansible.com preference: 0 @@ -56,8 +57,8 @@ provider: "{{ nios_provider }}" register: mx_record_update2 -- name: remove a mx record from the system - nios_mx_record: +- name: Remove a mx record from the system + infoblox.nios_modules.nios_mx_record: name: ansible.com mx: mailhost.ansible.com preference: 0 @@ -65,8 +66,8 @@ provider: "{{ nios_provider }}" register: mx_record_delete1 -- name: remove a mx record from the system - nios_mx_record: +- name: Remove a mx record from the system + infoblox.nios_modules.nios_mx_record: name: ansible.com mx: mailhost.ansible.com preference: 0 @@ -74,11 +75,12 @@ provider: "{{ nios_provider }}" register: mx_record_delete2 -- assert: +- name: Verify idempotence and changes of MX record operations + ansible.builtin.assert: that: - - "mx_record_create1.changed" - - "not mx_record_create2.changed" - - "mx_record_update1.changed" - - "not mx_record_update2.changed" - - "mx_record_delete1.changed" - - "not mx_record_delete2.changed" + - mx_record_create1.changed + - not mx_record_create2.changed + - mx_record_update1.changed + - not mx_record_update2.changed + - mx_record_delete1.changed + - not mx_record_delete2.changed diff --git a/tests/integration/targets/nios_naptr_record/meta/main.yaml b/tests/integration/targets/nios_naptr_record/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_naptr_record/meta/main.yaml +++ b/tests/integration/targets/nios_naptr_record/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_naptr_record/tasks/main.yml b/tests/integration/targets/nios_naptr_record/tasks/main.yml index ed94e8a3..ed567b40 100644 --- a/tests/integration/targets/nios_naptr_record/tasks/main.yml +++ b/tests/integration/targets/nios_naptr_record/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_naptr_record_idempotence.yml +--- +- name: Include NAPTR record idempotence tests + ansible.builtin.include_tasks: nios_naptr_record_idempotence.yml diff --git a/tests/integration/targets/nios_naptr_record/tasks/nios_naptr_record_idempotence.yml b/tests/integration/targets/nios_naptr_record/tasks/nios_naptr_record_idempotence.yml index 2303eff5..38aadfd0 100644 --- a/tests/integration/targets/nios_naptr_record/tasks/nios_naptr_record_idempotence.yml +++ b/tests/integration/targets/nios_naptr_record/tasks/nios_naptr_record_idempotence.yml @@ -1,27 +1,28 @@ -- name: cleanup the parent object - nios_zone: +--- +- name: Cleanup the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: absent provider: "{{ nios_provider }}" -- name: create the parent object - nios_zone: +- name: Create the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: present provider: "{{ nios_provider }}" -- name: cleanup naptr record - nios_naptr_record: - name: '*.subscriber-100.ansiblezone.com' +- name: Cleanup naptr record + infoblox.nios_modules.nios_naptr_record: + name: "*.subscriber-100.ansiblezone.com" order: 1000 preference: 10 replacement: replacement1.network.ansiblezone.com state: absent provider: "{{ nios_provider }}" -- name: create an naptr record - nios_naptr_record: - name: '*.subscriber-100.ansiblezone.com' +- name: Create an naptr record + infoblox.nios_modules.nios_naptr_record: + name: "*.subscriber-100.ansiblezone.com" order: 1000 preference: 10 replacement: replacement1.network.ansiblezone.com @@ -29,9 +30,9 @@ provider: "{{ nios_provider }}" register: naptr_record_create1 -- name: recreate an naptr record - nios_naptr_record: - name: '*.subscriber-100.ansiblezone.com' +- name: Recreate an naptr record + infoblox.nios_modules.nios_naptr_record: + name: "*.subscriber-100.ansiblezone.com" order: 1000 preference: 10 replacement: replacement1.network.ansiblezone.com @@ -39,9 +40,9 @@ provider: "{{ nios_provider }}" register: naptr_record_create2 -- name: add a comment to an existing naptr record - nios_naptr_record: - name: '*.subscriber-100.ansiblezone.com' +- name: Add a comment to an existing naptr record + infoblox.nios_modules.nios_naptr_record: + name: "*.subscriber-100.ansiblezone.com" order: 1000 preference: 10 replacement: replacement1.network.ansiblezone.com @@ -50,9 +51,9 @@ provider: "{{ nios_provider }}" register: naptr_record_update1 -- name: add a comment to an existing naptr record - nios_naptr_record: - name: '*.subscriber-100.ansiblezone.com' +- name: Add a comment to an existing naptr record + infoblox.nios_modules.nios_naptr_record: + name: "*.subscriber-100.ansiblezone.com" order: 1000 preference: 10 replacement: replacement1.network.ansiblezone.com @@ -61,9 +62,9 @@ provider: "{{ nios_provider }}" register: naptr_record_update2 -- name: remove a naptr record from the system - nios_naptr_record: - name: '*.subscriber-100.ansiblezone.com' +- name: Remove a naptr record from the system + infoblox.nios_modules.nios_naptr_record: + name: "*.subscriber-100.ansiblezone.com" order: 1000 preference: 10 replacement: replacement1.network.ansiblezone.com @@ -71,9 +72,9 @@ provider: "{{ nios_provider }}" register: naptr_record_delete1 -- name: remove a naptr record from the system - nios_naptr_record: - name: '*.subscriber-100.ansiblezone.com' +- name: Remove a naptr record from the system + infoblox.nios_modules.nios_naptr_record: + name: "*.subscriber-100.ansiblezone.com" order: 1000 preference: 10 replacement: replacement1.network.ansiblezone.com @@ -81,11 +82,12 @@ provider: "{{ nios_provider }}" register: naptr_record_delete2 -- assert: +- name: Verify idempotence and changes of NAPTR record operations + ansible.builtin.assert: that: - - "naptr_record_create1.changed" - - "not naptr_record_create2.changed" - - "naptr_record_update1.changed" - - "not naptr_record_update2.changed" - - "naptr_record_delete1.changed" - - "not naptr_record_delete2.changed" + - naptr_record_create1.changed + - not naptr_record_create2.changed + - naptr_record_update1.changed + - not naptr_record_update2.changed + - naptr_record_delete1.changed + - not naptr_record_delete2.changed diff --git a/tests/integration/targets/nios_network/meta/main.yaml b/tests/integration/targets/nios_network/meta/main.yaml index 9472935b..a4ad32ff 100644 --- a/tests/integration/targets/nios_network/meta/main.yaml +++ b/tests/integration/targets/nios_network/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - - prepare_nios_tests \ No newline at end of file + - prepare_nios_tests diff --git a/tests/integration/targets/nios_network/tasks/main.yml b/tests/integration/targets/nios_network/tasks/main.yml index 040cb8a8..5d1d658c 100644 --- a/tests/integration/targets/nios_network/tasks/main.yml +++ b/tests/integration/targets/nios_network/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_network_idempotence.yml +--- +- name: Include network idempotence tests + ansible.builtin.include_tasks: nios_network_idempotence.yml diff --git a/tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml b/tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml index 95937d1a..04142d6a 100644 --- a/tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml +++ b/tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml @@ -1,33 +1,29 @@ -- name: cleanup a network ipv4 - nios_network: +--- +- name: Cleanup a network ipv4 + infoblox.nios_modules.nios_network: network: 192.168.10.0/24 comment: this is a test comment state: absent provider: "{{ nios_provider }}" -- name: configure a network ipv4 - nios_network: +- name: Configure a network ipv4 + infoblox.nios_modules.nios_network: network: 192.168.10.0/24 comment: this is a test comment state: present provider: "{{ nios_provider }}" register: nios_ipv4_create1 -- name: configure a network ipv4 - nios_network: +- name: Configure a network ipv4 + infoblox.nios_modules.nios_network: network: 192.168.10.0/24 comment: this is a test comment state: present provider: "{{ nios_provider }}" register: nios_ipv4_create2 -#- assert: -# that: -# - "nios_ipv4_create1.changed" -# - "not nios_ipv4_create2.changed" - -- name: set dhcp options for a network ipv4 - nios_network: +- name: Set dhcp options for a network ipv4 + infoblox.nios_modules.nios_network: network: 192.168.10.0/24 comment: this is a test comment options: @@ -37,8 +33,8 @@ provider: "{{ nios_provider }}" register: nios_ipv4_update1 -- name: set dhcp options for a network ipv4 - nios_network: +- name: Set dhcp options for a network ipv4 + infoblox.nios_modules.nios_network: network: 192.168.10.0/24 comment: this is a test comment options: @@ -48,31 +44,30 @@ provider: "{{ nios_provider }}" register: nios_ipv4_update2 -- name: remove a network ipv4 - nios_network: +- name: Remove a network ipv4 + infoblox.nios_modules.nios_network: network: 192.168.10.0/24 state: absent provider: "{{ nios_provider }}" register: nios_ipv4_remove1 -- name: remove a network ipv4 - nios_network: +- name: Remove a network ipv4 + infoblox.nios_modules.nios_network: network: 192.168.10.0/24 state: absent provider: "{{ nios_provider }}" register: nios_ipv4_remove2 -- name: configure a network ipv6 - nios_network: +- name: Configure a network ipv6 + infoblox.nios_modules.nios_network: network: fe80::/64 comment: this is a test comment state: present provider: "{{ nios_provider }}" register: nios_ipv6_create1 - -- name: configure a network ipv6 with filter option - nios_network: +- name: Configure a network ipv6 with filter option + infoblox.nios_modules.nios_network: network: fe80::/64 comment: this is a test comment use_logic_filter_rules: true @@ -80,8 +75,8 @@ provider: "{{ nios_provider }}" register: nios_ipv6_update1 -- name: configure a network ipv4 with filter option - nios_network: +- name: Configure a network ipv4 with filter option + infoblox.nios_modules.nios_network: network: 192.168.11.0/24 comment: this is a test comment use_logic_filter_rules: true @@ -89,8 +84,8 @@ provider: "{{ nios_provider }}" register: nios_ipv4_create3 -- name: update a network ipv4 with filter option - nios_network: +- name: Update a network ipv4 with filter option + infoblox.nios_modules.nios_network: network: 192.168.11.0/24 comment: this is a test comment use_logic_filter_rules: false @@ -99,7 +94,7 @@ register: nios_ipv4_update3 - name: Re-run with no changes - nios_network: + infoblox.nios_modules.nios_network: network: 192.168.11.0/24 comment: this is a test comment use_logic_filter_rules: false @@ -107,8 +102,8 @@ provider: "{{ nios_provider }}" register: nios_ipv4_update4 -- name: remove an ipv4 network - nios_network: +- name: Remove an ipv4 network + infoblox.nios_modules.nios_network: network: 192.168.11.0/24 comment: this is a test comment use_logic_filter_rules: false @@ -116,18 +111,18 @@ provider: "{{ nios_provider }}" register: nios_ipv4_remove3 - -- assert: +- name: Verify idempotence and changes of network operations + ansible.builtin.assert: that: - - "nios_ipv4_create1.changed" - - "not nios_ipv4_create2.changed" - - "nios_ipv4_update1.changed" - - "not nios_ipv4_update2.changed" - - "nios_ipv4_remove1.changed" - - "not nios_ipv4_remove2.changed" - - "nios_ipv4_create3.changed" - - "nios_ipv4_update3.changed" - - "nios_ipv6_create1.changed" - - "nios_ipv6_update1.changed" - - "not nios_ipv4_update4.changed" - - "nios_ipv4_remove3.changed" + - nios_ipv4_create1.changed + - not nios_ipv4_create2.changed + - nios_ipv4_update1.changed + - not nios_ipv4_update2.changed + - nios_ipv4_remove1.changed + - not nios_ipv4_remove2.changed + - nios_ipv4_create3.changed + - nios_ipv4_update3.changed + - nios_ipv6_create1.changed + - nios_ipv6_update1.changed + - not nios_ipv4_update4.changed + - nios_ipv4_remove3.changed diff --git a/tests/integration/targets/nios_network_view/defaults/main.yaml b/tests/integration/targets/nios_network_view/defaults/main.yaml index ebf6ffc9..9ef5ba51 100644 --- a/tests/integration/targets/nios_network_view/defaults/main.yaml +++ b/tests/integration/targets/nios_network_view/defaults/main.yaml @@ -1,3 +1,3 @@ --- testcase: "*" -test_items: [] \ No newline at end of file +test_items: [] diff --git a/tests/integration/targets/nios_network_view/meta/main.yaml b/tests/integration/targets/nios_network_view/meta/main.yaml index 9472935b..a4ad32ff 100644 --- a/tests/integration/targets/nios_network_view/meta/main.yaml +++ b/tests/integration/targets/nios_network_view/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - - prepare_nios_tests \ No newline at end of file + - prepare_nios_tests diff --git a/tests/integration/targets/nios_network_view/tasks/main.yml b/tests/integration/targets/nios_network_view/tasks/main.yml index 0acf4a4c..f9b6f41a 100644 --- a/tests/integration/targets/nios_network_view/tasks/main.yml +++ b/tests/integration/targets/nios_network_view/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_network_view_idempotence.yml +--- +- name: Include network view idempotence tests + ansible.builtin.include_tasks: nios_network_view_idempotence.yml diff --git a/tests/integration/targets/nios_network_view/tasks/nios_network_view_idempotence.yml b/tests/integration/targets/nios_network_view/tasks/nios_network_view_idempotence.yml index ad13e3a3..408055ad 100644 --- a/tests/integration/targets/nios_network_view/tasks/nios_network_view_idempotence.yml +++ b/tests/integration/targets/nios_network_view/tasks/nios_network_view_idempotence.yml @@ -1,58 +1,60 @@ -- name: cleanup a new network view - nios_network_view: +--- +- name: Cleanup a new network view + infoblox.nios_modules.nios_network_view: name: ansible state: absent provider: "{{ nios_provider }}" -- name: configure a new network view - nios_network_view: +- name: Configure a new network view + infoblox.nios_modules.nios_network_view: name: ansible state: present provider: "{{ nios_provider }}" register: nios_network_view_create1 -- name: configure a new network view - nios_network_view: +- name: Configure a new network view + infoblox.nios_modules.nios_network_view: name: ansible state: present provider: "{{ nios_provider }}" register: nios_network_view_create2 -- name: update the comment for network view - nios_network_view: +- name: Update the comment for network view + infoblox.nios_modules.nios_network_view: name: ansible comment: this is an example comment state: present provider: "{{ nios_provider }}" register: nios_network_view_update1 -- name: update the comment for network view - nios_network_view: +- name: Update the comment for network view + infoblox.nios_modules.nios_network_view: name: ansible comment: this is an example comment state: present provider: "{{ nios_provider }}" register: nios_network_view_update2 -- name: remove the network view - nios_network_view: +- name: Remove the network view + infoblox.nios_modules.nios_network_view: name: ansible state: absent provider: "{{ nios_provider }}" register: nios_network_view_delete1 -- name: remove the network view - nios_network_view: +- name: Remove the network view + infoblox.nios_modules.nios_network_view: name: ansible state: absent provider: "{{ nios_provider }}" register: nios_network_view_delete2 -- assert: +- name: Verify idempotence and changes of network view operations + ansible.builtin.assert: that: - - "nios_network_view_create1.changed" - - "not nios_network_view_create2.changed" - - "nios_network_view_update1.changed" - - "not nios_network_view_update2.changed" - - "nios_network_view_delete1.changed" - - "not nios_network_view_delete2.changed" + - nios_network_view_create1.changed + - not nios_network_view_create2.changed + - nios_network_view_update1.changed + - not nios_network_view_update2.changed + - nios_network_view_delete1.changed + - not nios_network_view_delete2.changed diff --git a/tests/integration/targets/nios_ptr_record/meta/main.yaml b/tests/integration/targets/nios_ptr_record/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_ptr_record/meta/main.yaml +++ b/tests/integration/targets/nios_ptr_record/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_ptr_record/tasks/main.yml b/tests/integration/targets/nios_ptr_record/tasks/main.yml index 29fbb5fe..a3213fe6 100644 --- a/tests/integration/targets/nios_ptr_record/tasks/main.yml +++ b/tests/integration/targets/nios_ptr_record/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_ptr_record_idempotence.yml +--- +- name: Include PTR record idempotence tests + ansible.builtin.include_tasks: nios_ptr_record_idempotence.yml diff --git a/tests/integration/targets/nios_ptr_record/tasks/nios_ptr_record_idempotence.yml b/tests/integration/targets/nios_ptr_record/tasks/nios_ptr_record_idempotence.yml index a233d80f..b1520847 100644 --- a/tests/integration/targets/nios_ptr_record/tasks/nios_ptr_record_idempotence.yml +++ b/tests/integration/targets/nios_ptr_record/tasks/nios_ptr_record_idempotence.yml @@ -1,7 +1,6 @@ --- - -- name: create an ipv4 ptr record - nios_ptr_record: +- name: Create an ipv4 ptr record + infoblox.nios_modules.nios_ptr_record: name: ptr.ansible.com ptrdname: ptr.ansible.com ipv4: 192.168.10.1 @@ -10,8 +9,8 @@ view: default register: ipv4_ptr_create1 -- name: create the same ipv4 ptr record - nios_ptr_record: +- name: Create the same ipv4 ptr record + infoblox.nios_modules.nios_ptr_record: name: ptr.ansible.com ptrdname: ptr.ansible.com ipv4: 192.168.10.1 @@ -20,8 +19,8 @@ provider: "{{ nios_provider }}" register: ipv4_ptr_create2 -- name: add a comment to an existing ipv4 ptr record - nios_ptr_record: +- name: Add a comment to an existing ipv4 ptr record + infoblox.nios_modules.nios_ptr_record: name: ptr.ansible.com ptrdname: ptr.ansible.com ipv4: 192.168.10.1 @@ -31,8 +30,8 @@ provider: "{{ nios_provider }}" register: ipv4_ptr_update1 -- name: add the same comment to the same ipv4 ptr host record - nios_ptr_record: +- name: Add the same comment to the same ipv4 ptr host record + infoblox.nios_modules.nios_ptr_record: name: ptr.ansible.com ptrdname: ptr.ansible.com ipv4: 192.168.10.1 @@ -42,8 +41,8 @@ provider: "{{ nios_provider }}" register: ipv4_ptr_update2 -- name: remove a ptr record from the system - nios_ptr_record: +- name: Remove a ptr record from the system + infoblox.nios_modules.nios_ptr_record: name: ptr.ansible.com ptrdname: ptr.ansible.com ipv4: 192.168.10.1 @@ -52,8 +51,8 @@ provider: "{{ nios_provider }}" register: ipv4_ptr_delete1 -- name: remove the same ptr record from the system - nios_ptr_record: +- name: Remove the same ptr record from the system + infoblox.nios_modules.nios_ptr_record: ptrdname: ptr.ansible.com name: ptr.ansible.com ipv4: 192.168.10.1 @@ -62,22 +61,23 @@ provider: "{{ nios_provider }}" register: ipv4_ptr_delete2 -- name: create an ipv6 ptr record - nios_ptr_record: +- name: Create an ipv6 ptr record + infoblox.nios_modules.nios_ptr_record: ptrdname: ptr6.ansible.com name: ptr6.ansible.com - ipv6: "2002:8ac3:802d:1242:20d:60ff:fe38:6d16" + ipv6: 2002:8ac3:802d:1242:20d:60ff:fe38:6d16 view: default state: present provider: "{{ nios_provider }}" register: ipv6_ptr_create1 -- assert: +- name: Verify idempotence and changes of PTR record operations + ansible.builtin.assert: that: - - "ipv4_ptr_create1.changed" - - "not ipv4_ptr_create2.changed" - - "ipv4_ptr_update1.changed" - - "not ipv4_ptr_update2.changed" - - "ipv4_ptr_delete1.changed" - - "not ipv4_ptr_delete2.changed" - - "ipv6_ptr_create1.changed" + - ipv4_ptr_create1.changed + - not ipv4_ptr_create2.changed + - ipv4_ptr_update1.changed + - not ipv4_ptr_update2.changed + - ipv4_ptr_delete1.changed + - not ipv4_ptr_delete2.changed + - ipv6_ptr_create1.changed diff --git a/tests/integration/targets/nios_srv_record/meta/main.yaml b/tests/integration/targets/nios_srv_record/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_srv_record/meta/main.yaml +++ b/tests/integration/targets/nios_srv_record/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_srv_record/tasks/main.yml b/tests/integration/targets/nios_srv_record/tasks/main.yml index 4e4dd166..9c14dc3f 100644 --- a/tests/integration/targets/nios_srv_record/tasks/main.yml +++ b/tests/integration/targets/nios_srv_record/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_srv_record_idempotence.yml +--- +- name: Include SRV record idempotence tests + ansible.builtin.include_tasks: nios_srv_record_idempotence.yml diff --git a/tests/integration/targets/nios_srv_record/tasks/nios_srv_record_idempotence.yml b/tests/integration/targets/nios_srv_record/tasks/nios_srv_record_idempotence.yml index 8f3dbfc7..f6dbf56a 100644 --- a/tests/integration/targets/nios_srv_record/tasks/nios_srv_record_idempotence.yml +++ b/tests/integration/targets/nios_srv_record/tasks/nios_srv_record_idempotence.yml @@ -1,17 +1,18 @@ -- name: cleanup the parent object - nios_zone: +--- +- name: Cleanup the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: absent provider: "{{ nios_provider }}" -- name: create the parent object - nios_zone: +- name: Create the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: present provider: "{{ nios_provider }}" -- name: cleanup srv record - nios_srv_record: +- name: Cleanup srv record + infoblox.nios_modules.nios_srv_record: name: ansible.com port: 5080 priority: 10 @@ -20,8 +21,8 @@ state: absent provider: "{{ nios_provider }}" -- name: create an srv record - nios_srv_record: +- name: Create an srv record + infoblox.nios_modules.nios_srv_record: name: ansible.com port: 5080 priority: 10 @@ -31,8 +32,8 @@ provider: "{{ nios_provider }}" register: srv_record_create1 -- name: recreate an srv record - nios_srv_record: +- name: Recreate an srv record + infoblox.nios_modules.nios_srv_record: name: ansible.com port: 5080 priority: 10 @@ -42,8 +43,8 @@ provider: "{{ nios_provider }}" register: srv_record_create2 -- name: add a comment to an existing srv record - nios_srv_record: +- name: Add a comment to an existing srv record + infoblox.nios_modules.nios_srv_record: name: ansible.com port: 5080 priority: 10 @@ -54,8 +55,8 @@ provider: "{{ nios_provider }}" register: srv_record_update1 -- name: add a comment to an existing srv record - nios_srv_record: +- name: Add a comment to an existing srv record + infoblox.nios_modules.nios_srv_record: name: ansible.com port: 5080 priority: 10 @@ -66,8 +67,8 @@ provider: "{{ nios_provider }}" register: srv_record_update2 -- name: remove a srv record from the system - nios_srv_record: +- name: Remove a srv record from the system + infoblox.nios_modules.nios_srv_record: name: ansible.com port: 5080 priority: 10 @@ -77,8 +78,8 @@ provider: "{{ nios_provider }}" register: srv_record_delete1 -- name: remove a srv record from the system - nios_srv_record: +- name: Remove a srv record from the system + infoblox.nios_modules.nios_srv_record: name: ansible.com port: 5080 priority: 10 @@ -88,11 +89,12 @@ provider: "{{ nios_provider }}" register: srv_record_delete2 -- assert: +- name: Verify idempotence and changes of SRV record operations + ansible.builtin.assert: that: - - "srv_record_create1.changed" - - "not srv_record_create2.changed" - - "srv_record_update1.changed" - - "not srv_record_update2.changed" - - "srv_record_delete1.changed" - - "not srv_record_delete2.changed" + - srv_record_create1.changed + - not srv_record_create2.changed + - srv_record_update1.changed + - not srv_record_update2.changed + - srv_record_delete1.changed + - not srv_record_delete2.changed diff --git a/tests/integration/targets/nios_txt_record/defaults/main.yaml b/tests/integration/targets/nios_txt_record/defaults/main.yaml index ebf6ffc9..9ef5ba51 100644 --- a/tests/integration/targets/nios_txt_record/defaults/main.yaml +++ b/tests/integration/targets/nios_txt_record/defaults/main.yaml @@ -1,3 +1,3 @@ --- testcase: "*" -test_items: [] \ No newline at end of file +test_items: [] diff --git a/tests/integration/targets/nios_txt_record/meta/main.yaml b/tests/integration/targets/nios_txt_record/meta/main.yaml index 9472935b..a4ad32ff 100644 --- a/tests/integration/targets/nios_txt_record/meta/main.yaml +++ b/tests/integration/targets/nios_txt_record/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - - prepare_nios_tests \ No newline at end of file + - prepare_nios_tests diff --git a/tests/integration/targets/nios_txt_record/tasks/main.yml b/tests/integration/targets/nios_txt_record/tasks/main.yml index 0acbc091..81d01d8b 100644 --- a/tests/integration/targets/nios_txt_record/tasks/main.yml +++ b/tests/integration/targets/nios_txt_record/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_txt_record_idempotence.yml +--- +- name: Include TXT record idempotence tests + ansible.builtin.include_tasks: nios_txt_record_idempotence.yml diff --git a/tests/integration/targets/nios_txt_record/tasks/nios_txt_record_idempotence.yml b/tests/integration/targets/nios_txt_record/tasks/nios_txt_record_idempotence.yml index 37638d85..62ebc92a 100644 --- a/tests/integration/targets/nios_txt_record/tasks/nios_txt_record_idempotence.yml +++ b/tests/integration/targets/nios_txt_record/tasks/nios_txt_record_idempotence.yml @@ -1,45 +1,47 @@ -- name: cleanup the parent object - nios_zone: +--- +- name: Cleanup the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: absent provider: "{{ nios_provider }}" -- name: create the parent object - nios_zone: +- name: Create the parent object + infoblox.nios_modules.nios_zone: name: ansible.com state: present provider: "{{ nios_provider }}" -- name: cleanup txt record - nios_txt_record: +- name: Cleanup txt record + infoblox.nios_modules.nios_txt_record: name: txt.ansible.com - text: mytext + text: mytext state: absent provider: "{{ nios_provider }}" -- name: create txt record - nios_txt_record: +- name: Create txt record + infoblox.nios_modules.nios_txt_record: name: txt.ansible.com text: mytext state: present provider: "{{ nios_provider }}" register: txt_create1 -- name: create txt record - nios_txt_record: +- name: Create txt record + infoblox.nios_modules.nios_txt_record: name: txt.ansible.com text: mytext state: present provider: "{{ nios_provider }}" register: txt_create2 -- assert: +- name: Assert TXT record creation idempotence + ansible.builtin.assert: that: - - "txt_create1.changed" - - "not txt_create2.changed" + - txt_create1.changed + - not txt_create2.changed -- name: add a comment to an existing txt record - nios_txt_record: +- name: Add a comment to an existing txt record + infoblox.nios_modules.nios_txt_record: name: txt.ansible.com text: mytext state: present @@ -47,8 +49,8 @@ provider: "{{ nios_provider }}" register: txt_update1 -- name: add a comment to an existing txt record - nios_txt_record: +- name: Add a comment to an existing txt record + infoblox.nios_modules.nios_txt_record: name: txt.ansible.com text: mytext state: present @@ -56,27 +58,28 @@ provider: "{{ nios_provider }}" register: txt_update2 -- name: remove a txt record from the system - nios_txt_record: +- name: Remove a txt record from the system + infoblox.nios_modules.nios_txt_record: name: txt.ansible.com text: mytext state: absent provider: "{{ nios_provider }}" register: txt_delete1 -- name: remove a txt record from the system - nios_txt_record: +- name: Remove a txt record from the system + infoblox.nios_modules.nios_txt_record: name: txt.ansible.com text: mytext state: absent provider: "{{ nios_provider }}" register: txt_delete2 -- assert: +- name: Verify idempotence and changes of TXT record operations + ansible.builtin.assert: that: - - "txt_create1.changed" - - "not txt_create2.changed" - - "txt_update1.changed" - - "not txt_update2.changed" - - "txt_delete1.changed" - - "not txt_delete2.changed" + - txt_create1.changed + - not txt_create2.changed + - txt_update1.changed + - not txt_update2.changed + - txt_delete1.changed + - not txt_delete2.changed diff --git a/tests/integration/targets/nios_zone/defaults/main.yaml b/tests/integration/targets/nios_zone/defaults/main.yaml index ebf6ffc9..9ef5ba51 100644 --- a/tests/integration/targets/nios_zone/defaults/main.yaml +++ b/tests/integration/targets/nios_zone/defaults/main.yaml @@ -1,3 +1,3 @@ --- testcase: "*" -test_items: [] \ No newline at end of file +test_items: [] diff --git a/tests/integration/targets/nios_zone/meta/main.yaml b/tests/integration/targets/nios_zone/meta/main.yaml index 9472935b..a4ad32ff 100644 --- a/tests/integration/targets/nios_zone/meta/main.yaml +++ b/tests/integration/targets/nios_zone/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - - prepare_nios_tests \ No newline at end of file + - prepare_nios_tests diff --git a/tests/integration/targets/nios_zone/tasks/main.yml b/tests/integration/targets/nios_zone/tasks/main.yml index cb335970..74f61449 100644 --- a/tests/integration/targets/nios_zone/tasks/main.yml +++ b/tests/integration/targets/nios_zone/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_zone_idempotence.yml +--- +- name: Include NIOS zone idempotence tests + ansible.builtin.include_tasks: nios_zone_idempotence.yml diff --git a/tests/integration/targets/nios_zone/tasks/nios_zone_idempotence.yml b/tests/integration/targets/nios_zone/tasks/nios_zone_idempotence.yml index 03d40aaf..897d537c 100644 --- a/tests/integration/targets/nios_zone/tasks/nios_zone_idempotence.yml +++ b/tests/integration/targets/nios_zone/tasks/nios_zone_idempotence.yml @@ -1,31 +1,32 @@ -- name: cleanup dns view instance - nios_dns_view: +--- +- name: Cleanup dns view instance + infoblox.nios_modules.nios_dns_view: name: ansible-dns state: absent provider: "{{ nios_provider }}" -- name: cleanup test zone - nios_zone: +- name: Cleanup test zone + infoblox.nios_modules.nios_zone: name: ansible-dns state: absent provider: "{{ nios_provider }}" -- name: configure a zone on the system - nios_zone: +- name: Configure a zone on the system + infoblox.nios_modules.nios_zone: name: ansible-dns state: present provider: "{{ nios_provider }}" register: zone_create1 -- name: configure a zone on the system - nios_zone: +- name: Configure a zone on the system + infoblox.nios_modules.nios_zone: name: ansible-dns state: present provider: "{{ nios_provider }}" register: zone_create2 -- name: update the comment and ext attributes for an existing zone - nios_zone: +- name: Update the comment and ext attributes for an existing zone + infoblox.nios_modules.nios_zone: name: ansible-dns comment: this is an example comment extattrs: @@ -34,8 +35,8 @@ provider: "{{ nios_provider }}" register: zone_update1 -- name: update the comment and ext attributes for an existing zone - nios_zone: +- name: Update the comment and ext attributes for an existing zone + infoblox.nios_modules.nios_zone: name: ansible-dns comment: this is an example comment extattrs: @@ -44,25 +45,26 @@ provider: "{{ nios_provider }}" register: zone_update2 -- name: remove the dns zone - nios_zone: +- name: Remove the dns zone + infoblox.nios_modules.nios_zone: name: ansible-dns state: absent provider: "{{ nios_provider }}" register: zone_delete1 -- name: remove the dns zone - nios_zone: +- name: Remove the dns zone + infoblox.nios_modules.nios_zone: name: ansible-dns state: absent provider: "{{ nios_provider }}" register: zone_delete2 -- assert: +- name: Verify idempotence and changes of zone operations + ansible.builtin.assert: that: - - "zone_create1.changed" - - "not zone_create2.changed" - - "zone_update1.changed" - - "not zone_update2.changed" - - "zone_delete1.changed" - - "not zone_delete2.changed" + - zone_create1.changed + - not zone_create2.changed + - zone_update1.changed + - not zone_update2.changed + - zone_delete1.changed + - not zone_delete2.changed diff --git a/tests/integration/targets/prepare_nios_tests/tasks/main.yml b/tests/integration/targets/prepare_nios_tests/tasks/main.yml index e3c03fb3..416ad282 100644 --- a/tests/integration/targets/prepare_nios_tests/tasks/main.yml +++ b/tests/integration/targets/prepare_nios_tests/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: prepare_nios_tests_idempotence.yml +--- +- name: Include idempotence tests for NIOS + ansible.builtin.include_tasks: prepare_nios_tests_idempotence.yml diff --git a/tests/integration/targets/prepare_nios_tests/tasks/prepare_nios_tests_idempotence.yml b/tests/integration/targets/prepare_nios_tests/tasks/prepare_nios_tests_idempotence.yml index 749faa20..3e468759 100644 --- a/tests/integration/targets/prepare_nios_tests/tasks/prepare_nios_tests_idempotence.yml +++ b/tests/integration/targets/prepare_nios_tests/tasks/prepare_nios_tests_idempotence.yml @@ -1,2 +1,4 @@ -- pip: +--- +- name: Install infoblox-client using pip + ansible.builtin.pip: name: infoblox-client diff --git a/tests/unit/plugins/modules/test_extensible_attribute.py b/tests/unit/plugins/modules/test_extensible_attribute.py new file mode 100644 index 00000000..faafcc89 --- /dev/null +++ b/tests/unit/plugins/modules/test_extensible_attribute.py @@ -0,0 +1,158 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +# Make coding more python3-ish + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_extensible_attribute +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosExtensibleAttributeModule(TestNiosModule): + + module = nios_extensible_attribute + + def setUp(self): + super(TestNiosExtensibleAttributeModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_extensible_attribute.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_extensible_attribute.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_extensible_attribute.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosExtensibleAttributeModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_create_extensible_attribute(self): + self.module.params = { + 'name': 'my_string', + 'type': 'STRING', + 'comment': 'Created by ansible', + 'state': 'present', + 'provider': None + } + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "type": {"ib_req": True}, + "comment": {}, + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi.__dict__) + res = wapi.run('testobject', test_spec) + + self.assertEqual(res['changed'], True) + wapi.create_object.assert_called_once_with('testobject', {'name': 'my_string', + 'type': 'STRING', + 'comment': 'Created by ansible'}) + + def test_nios_ea_update_comment(self): + self.module.params = { + 'provider': None, + 'state': 'present', + 'name': 'testStringEA', + 'type': 'STRING', + 'flag': 'I', + 'default_value': 'test', + 'comment': 'Update comment' + } + + ref = "extensibleattributedef/b25lLmV4dGVuc2libGVfYXR0cmlidXRlc19kZWYkLlRlcnJhZm9ybSBJbnRlcm5hbCBJRA:testStringEA" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "testStringEA", + "flag": "I", + "type": "STRING", + "default_value": "test" + } + ] + + test_spec = { + "name": {"ib_req": True}, + "type": {"ib_req": True}, + "comment": {}, + "flag": {}, + "default_value": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'Update comment', 'type': 'STRING', 'name': 'testStringEA', 'flag': 'I', 'default_value': 'test'} + ) + + def test_remove_extensible_attribute(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'testStringEA', 'type': 'STRING', + 'flag': None, 'default_value': None, 'comment': None} + + ref = "extensibleattributedef/b25lLmV4dGVuc2libGVfYXR0cmlidXRlc19kZWYkLlRlcnJhZm9ybSBJbnRlcm5hbCBJRA:testStringEA" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "testStringEA", + "flag": "I", + "type": "STRING", + "default_value": "test" + } + ] + + test_spec = { + "name": {"ib_req": True}, + "type": {"ib_req": True}, + "comment": {}, + "flag": {}, + "default_value": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) From 3c9ea1af29a42084ee66269fb738e02899109d4b Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Fri, 13 Sep 2024 14:15:55 +0530 Subject: [PATCH 21/29] [FIX] BUG fixed for NsGroup NPA-147,148,149,150,151 and 152 (#257) --- plugins/module_utils/api.py | 32 ++++++++++++------- .../modules/nios_nsgroup_forwardstubserver.py | 2 +- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 73080e33..a8795bef 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -348,7 +348,7 @@ def run(self, ib_obj_type, ib_spec): proposed_object[key] = self.module.params[key] # If configure_by_dns is set to False and view is 'default', then delete the default dns - if not proposed_object.get('configure_for_dns') and proposed_object.get('view') == 'default'\ + if not proposed_object.get('configure_for_dns') and proposed_object.get('view') == 'default' \ and ib_obj_type == NIOS_HOST_RECORD: del proposed_object['view'] @@ -360,7 +360,7 @@ def run(self, ib_obj_type, ib_spec): current_object = each break # To check for existing Host_record with same name with input Host_record by IP - elif each.get('ipv4addrs') and each.get('ipv4addrs')[0].get('ipv4addr')\ + elif each.get('ipv4addrs') and each.get('ipv4addrs')[0].get('ipv4addr') \ == proposed_object.get('ipv4addrs')[0].get('ipv4addr'): current_object = each # Else set the current_object with input value @@ -647,11 +647,14 @@ def compare_extattrs(self, current_extattrs, proposed_extattrs): return False return True + def verify_list_order(self, proposed_data, current_data): + return len(proposed_data) == len(current_data) and all(a == b for a, b in zip(proposed_data, current_data)) + def compare_objects(self, current_object, proposed_object): for key, proposed_item in iteritems(proposed_object): current_item = current_object.get(key) - # if proposed has a key that current doesn't then the objects are + # if proposed has a key that current doesn't, then the objects are # not equal and False will be immediately returned if current_item is None: return False @@ -660,17 +663,22 @@ def compare_objects(self, current_object, proposed_object): if key == 'aliases': if set(current_item) != set(proposed_item): return False - # If the lists are of a different length the objects can not be - # equal and False will be returned before comparing the lists items - # this code part will work for members assignment - if key in ['members', 'options'] and (len(proposed_item) != len(current_item)): + # If the lists are of a different length, the objects cannot be + # equal, and False will be returned before comparing the list items + # this code part will work for members' assignment + if (key in ('members', 'options', 'delegate_to', 'forwarding_servers', 'stub_members') + and (len(proposed_item) != len(current_item))): + return False + + # Validate the Sequence of the List data + if key in ('external_servers',) and not self.verify_list_order(proposed_item, current_item): return False for subitem in proposed_item: if not self.issubset(subitem, current_item): return False - # If the lists are of a different length the objects and order of element mismatch + # If the lists are of a different length, the objects and order of element mismatch # Ignore DHCP options while comparing due to extra num param is get response if key == 'logic_filter_rules' and proposed_item != current_item: return False @@ -678,7 +686,7 @@ def compare_objects(self, current_object, proposed_object): elif isinstance(proposed_item, dict): # Compare the items of the dict to see if they are equal. A # difference stops the comparison and returns false. If they - # are equal move on to the next item + # are equal, move on to the next item # Checks if extattrs existing in proposed object if key == 'extattrs': @@ -746,7 +754,8 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): if ib_obj: obj_filter['name'] = new_name elif old_ipv4addr_exists and (len(ib_obj) == 0): - raise Exception("object with name: '%s', ipv4addr: '%s' is not found" % (old_name, test_obj_filter['ipv4addr'])) + raise Exception( + "object with name: '%s', ipv4addr: '%s' is not found" % (old_name, test_obj_filter['ipv4addr'])) else: raise Exception("object with name: '%s' is not found" % (old_name)) update = True @@ -931,7 +940,8 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): # throws exception if start_addr and end_addr doesn't exists for updating range if (new_start_arg and new_end_arg): if not ib_obj: - raise Exception('Specified range %s-%s not found' % (obj_filter['start_addr'], obj_filter['end_addr'])) + raise Exception( + 'Specified range %s-%s not found' % (obj_filter['start_addr'], obj_filter['end_addr'])) else: ib_obj = self.get_object(ib_obj_type, obj_filter.copy(), return_fields=list(ib_spec.keys())) return ib_obj, update, new_name diff --git a/plugins/modules/nios_nsgroup_forwardstubserver.py b/plugins/modules/nios_nsgroup_forwardstubserver.py index e7d2b033..7a9b285d 100644 --- a/plugins/modules/nios_nsgroup_forwardstubserver.py +++ b/plugins/modules/nios_nsgroup_forwardstubserver.py @@ -73,7 +73,7 @@ infoblox.nios_modules.nios_nsgroup_forwardstubserver: name: my-forwardstub-group comment: "this is a forward/stub nameserver group" - nameservers: + external_servers: - name: first address: 192.168.0.10 - name: second From a6ef4e722ccb38e38b284a7bf07f35c71d4034fc Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:53:13 +0530 Subject: [PATCH 22/29] [FIX] Extensible attribute ENUM list values updation (#260) --- plugins/module_utils/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index a8795bef..fc255313 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -671,7 +671,7 @@ def compare_objects(self, current_object, proposed_object): return False # Validate the Sequence of the List data - if key in ('external_servers',) and not self.verify_list_order(proposed_item, current_item): + if key in ('external_servers', 'list_values') and not self.verify_list_order(proposed_item, current_item): return False for subitem in proposed_item: From 844c26428418b9e4e781c085871fb35aa655d01a Mon Sep 17 00:00:00 2001 From: nitish-ks <99472890+nitish-ks@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:42:18 +0530 Subject: [PATCH 23/29] Added playbooks for NSGroup, Network logic filters & PXE config (#261) * Added playbooks for NSGroup, Network logic filters & PXE config * fix sanity test --- playbooks/create_network.yml | 4 +++ playbooks/create_nsgroup_delegation.yml | 24 +++++++++++++ playbooks/create_nsgroup_forwardingmember.yml | 34 +++++++++++++++++++ .../create_nsgroup_forwardstubserver.yml | 24 +++++++++++++ playbooks/create_nsgroup_stubmember.yml | 22 ++++++++++++ plugins/modules/nios_host_record.py | 18 ++++++++++ 6 files changed, 126 insertions(+) create mode 100644 playbooks/create_nsgroup_delegation.yml create mode 100644 playbooks/create_nsgroup_forwardingmember.yml create mode 100644 playbooks/create_nsgroup_forwardstubserver.yml create mode 100644 playbooks/create_nsgroup_stubmember.yml diff --git a/playbooks/create_network.yml b/playbooks/create_network.yml index de11bc0f..38a26308 100644 --- a/playbooks/create_network.yml +++ b/playbooks/create_network.yml @@ -13,6 +13,10 @@ infoblox.nios_modules.nios_network: network: 10.0.0.0/24 network_view: ansibleCollectionsView + use_logic_filter_rules: true + logic_filter_rules: + - filter: PXE-UEFI + type: Option options: - name: domain-name value: infoblox-ansible.com diff --git a/playbooks/create_nsgroup_delegation.yml b/playbooks/create_nsgroup_delegation.yml new file mode 100644 index 00000000..061c3927 --- /dev/null +++ b/playbooks/create_nsgroup_delegation.yml @@ -0,0 +1,24 @@ +--- +- name: Infoblox Nameserver Configuration + hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: create infoblox nameserver delegation group + infoblox.nios_modules.nios_nsgroup_delegation: + name: my-delegation-group + delegate_to: + - name: first + address: 192.168.0.10 + - name: second + address: 192.168.0.20 + comment: "this is a delegation nameserver group" + extattrs: + Site: Test Site + state: present + provider: "{{ nios_provider }}" \ No newline at end of file diff --git a/playbooks/create_nsgroup_forwardingmember.yml b/playbooks/create_nsgroup_forwardingmember.yml new file mode 100644 index 00000000..96ae07c7 --- /dev/null +++ b/playbooks/create_nsgroup_forwardingmember.yml @@ -0,0 +1,34 @@ +--- +- name: Infoblox Nameserver Configuration + hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: create infoblox nameserver forwarding member group with external forwarders + infoblox.nios_modules.nios_nsgroup_forwardingmember: + name: my-forwardingmember-group + comment: "this is a forwarding member nameserver group with external forwarders" + extattrs: + Site: Test Site + forwarding_servers: + - name: infoblox.cloud-ansible-client-nios-gm + use_override_forwarders: true + forwarders_only: true + forward_to: + - name: ns1 + address: 192.168.10.1 + - name: ns2 + address: 192.168.10.2 + - name: infoblox.cloud-ansible-client-nios-mem1 + use_override_forwarders: true + forwarders_only: false + forward_to: + - name: ns3 + address: 192.168.10.3 + state: present + provider: "{{ nios_provider }}" \ No newline at end of file diff --git a/playbooks/create_nsgroup_forwardstubserver.yml b/playbooks/create_nsgroup_forwardstubserver.yml new file mode 100644 index 00000000..14454ab1 --- /dev/null +++ b/playbooks/create_nsgroup_forwardstubserver.yml @@ -0,0 +1,24 @@ +--- +- name: Infoblox Nameserver Configuration + hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: create infoblox nameserver forward/stub group + infoblox.nios_modules.nios_nsgroup_forwardstubserver: + name: new-forwardstub-group + comment: "this is a forward/stub nameserver group" + extattrs: + Site: Test Site + external_servers: + - name: first + address: 192.168.0.10 + - name: second + address: 192.168.0.20 + state: present + provider: "{{ nios_provider }}" \ No newline at end of file diff --git a/playbooks/create_nsgroup_stubmember.yml b/playbooks/create_nsgroup_stubmember.yml new file mode 100644 index 00000000..e545c3c7 --- /dev/null +++ b/playbooks/create_nsgroup_stubmember.yml @@ -0,0 +1,22 @@ +--- +- name: Infoblox Nameserver Configuration + hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: create infoblox nameserver stub member group + infoblox.nios_modules.nios_nsgroup_stubmember: + name: my-stubmember-group + comment: "this is a stub member nameserver group" + extattrs: + Site: Test Site + stub_members: + - name: infoblox.cloud-ansible-client-nios-gm + - name: infoblox.cloud-ansible-client-nios-mem1 + state: present + provider: "{{ nios_provider }}" \ No newline at end of file diff --git a/plugins/modules/nios_host_record.py b/plugins/modules/nios_host_record.py index 66f00549..ac5f6412 100644 --- a/plugins/modules/nios_host_record.py +++ b/plugins/modules/nios_host_record.py @@ -262,6 +262,24 @@ password: admin connection: local + +- name: Create an ipv4 host record over DHCP with PXE server + infoblox.nios_modules.nios_host_record: + name: host.ansible.com + ipv4: + - address: 192.168.10.1 + dhcp: true + mac: 00-80-C8-E3-4C-BD + use_nextserver: true + nextserver: pxe-server.com + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + + - name: Dynamically add host record to next available ip infoblox.nios_modules.nios_host_record: name: host.ansible.com From 4b0eecab488d2203357fc8fd8e9825325ba0e798 Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:23:58 +0530 Subject: [PATCH 24/29] Fix Bugs on Host Record (#262) * [FIX] NPA-167: Fix re-run of Host Record with nextserver [FIX] NPA-173: Fix host record PXE server with alias naming [FIX] NPA-174: FIX re-run of HOST Record with MAC * Fixed compare_object for deletion flow --- plugins/module_utils/api.py | 29 +++++++++++++++++++++++++++-- plugins/modules/nios_host_record.py | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index fc255313..491f85d0 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -628,6 +628,9 @@ def issubset(self, item, objects): ''' for obj in objects: if isinstance(item, dict): + # Normalize MAC address for comparission + if 'mac' in item: + item['mac'] = item['mac'].replace('-', ':').lower() if all(entry in obj.items() for entry in item.items()): return True else: @@ -675,6 +678,16 @@ def compare_objects(self, current_object, proposed_object): return False for subitem in proposed_item: + if current_item: + # Host IPv4addrs wont contain use_nextserver and nextserver + # If DHCP is false. + dhcp_flag = current_item[0].get('configure_for_dhcp', False) + use_nextserver = subitem.get('use_nextserver', False) + if key == 'ipv4addrs' and not dhcp_flag: + subitem.pop('use_nextserver', None) + subitem.pop('nextserver', None) + elif key == 'ipv4addrs' and dhcp_flag and not use_nextserver: + subitem.pop('nextserver', None) if not self.issubset(subitem, current_item): return False @@ -708,7 +721,6 @@ def compare_objects(self, current_object, proposed_object): def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): ''' this function gets the reference object of pre-existing nios objects ''' - update = False old_name = new_name = None old_ipv4addr_exists = old_text_exists = False @@ -821,7 +833,20 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): # check if test_obj_filter is empty copy passed obj_filter else: test_obj_filter = obj_filter - ib_obj = self.get_object(ib_obj_type, test_obj_filter.copy(), return_fields=list(ib_spec.keys())) + return_fields = list(ib_spec.keys()) + if ib_obj_type == NIOS_HOST_RECORD: + ipv4addrs_return = [ + 'ipv4addrs.ipv4addr', 'ipv4addrs.mac', 'ipv4addrs.configure_for_dhcp', 'ipv4addrs.host', + 'ipv4addrs.nextserver', 'ipv4addrs.use_nextserver' + ] + ipv6addrs_return = [ + 'ipv6addrs.ipv6addr', 'ipv6addrs.duid', 'ipv6addrs.configure_for_dhcp', 'ipv6addrs.host', + 'ipv6addrs.use_nextserver', 'ipv6addrs.nextserver' + ] + return_fields.extend(ipv4addrs_return) + return_fields.extend(ipv6addrs_return) + + ib_obj = self.get_object(ib_obj_type, test_obj_filter.copy(), return_fields=return_fields) # prevents creation of a new A record with 'new_ipv4addr' when A record with a particular 'old_ipv4addr' is not found if old_ipv4addr_exists and (ib_obj is None or len(ib_obj) == 0): diff --git a/plugins/modules/nios_host_record.py b/plugins/modules/nios_host_record.py index ac5f6412..36ab331c 100644 --- a/plugins/modules/nios_host_record.py +++ b/plugins/modules/nios_host_record.py @@ -348,7 +348,7 @@ def ipaddr(module, key, filtered_keys=None): def ipv4addrs(module): - return ipaddr(module, 'ipv4addrs', filtered_keys=['address', 'dhcp']) + return ipaddr(module, 'ipv4addrs', filtered_keys=['address', 'dhcp', 'pxe', 'use_pxe']) def ipv6addrs(module): From d0debc5004f0abc3f68533351250035704a95a77 Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Mon, 23 Sep 2024 15:05:07 +0530 Subject: [PATCH 25/29] Fix ansible-lint issue and update CI workflow for Python setup (#264) * [FIX] Ansible-lint issues * [IMP] Updated github workflow file --- .github/workflows/ansible-test.yml | 14 ++--- changelogs/changelog.yaml | 61 +++++++++---------- .../229-handle-host-rename-without-dns.yml | 5 +- playbooks/create_extensible_attribute.yaml | 22 +++---- playbooks/create_nsgroup_delegation.yml | 6 +- playbooks/create_nsgroup_forwardingmember.yml | 6 +- .../create_nsgroup_forwardstubserver.yml | 6 +- playbooks/create_nsgroup_stubmember.yml | 6 +- .../nios_extensible_attribute/meta/main.yaml | 1 + .../nios_extensible_attribute/tasks/main.yaml | 4 +- .../tasks/nios_extensible_attribute.yaml | 37 +++++------ .../tasks/nios_host_record_idempotence.yml | 4 +- .../defaults/main.yaml | 2 +- .../nios_nsgroup_delegation/meta/main.yaml | 3 +- .../nios_nsgroup_delegation/tasks/main.yml | 4 +- .../nios_nsgroup_delegation_idempotence.yml | 30 ++++----- .../defaults/main.yaml | 2 +- .../meta/main.yaml | 3 +- .../tasks/main.yml | 4 +- ...s_nsgroup_forwardingmember_idempotence.yml | 30 ++++----- .../defaults/main.yaml | 2 +- .../meta/main.yaml | 3 +- .../tasks/main.yml | 4 +- ..._nsgroup_forwardstubserver_idempotence.yml | 30 ++++----- .../defaults/main.yaml | 2 +- .../nios_nsgroup_stubmember/meta/main.yaml | 3 +- .../nios_nsgroup_stubmember/tasks/main.yml | 4 +- .../nios_nsgroup_stubmember_idempotence.yml | 30 ++++----- 28 files changed, 175 insertions(+), 153 deletions(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 28a26681..d6b6d44e 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -16,10 +16,10 @@ jobs: ansible-version: [stable-2.15] steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python 3.11 - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.11' @@ -66,7 +66,7 @@ jobs: steps: - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -131,12 +131,12 @@ jobs: python-version: '3.12' steps: - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install ansible-base (${{ matrix.ansible-version }}) run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check @@ -170,7 +170,7 @@ jobs: run: ansible-test coverage xml -v --requirements --group-by command --group-by version working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v4 with: fail_ci_if_error: false @@ -191,7 +191,7 @@ jobs: steps: - name: Set up Python 3.11 - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: # it is just required to run that once as "ansible-test sanity" in the docker image # will run on all python versions it supports. diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 056bf800..cf9803fe 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -3,9 +3,8 @@ ancestor: releases: 1.0.0: changes: - release_summary: "First release of the `nios_modules` collection! This release includes multiple plugins:- an - `api` plugin, a `network` plugin, a `nios` plugin, a `nios_inventory` plugin, a `lookup plugin`, - a `nios_next_ip` plugin, a `nios_next_network` plugin " + release_summary: "First release of the `nios_modules` collection! This release includes multiple plugins:- an `api` plugin, a `network` plugin, a `nios` + plugin, a `nios_inventory` plugin, a `lookup plugin`, a `nios_next_ip` plugin, a `nios_next_network` plugin " modules: - description: Configure Infoblox NIOS A records name: nios_a_record @@ -114,8 +113,8 @@ releases: - Sanity fixes as per Ansible guidelines to all modules minor_changes: - The modules are standardized as per Ansible guidelines - release_summary: Support for creating IPv6 Fixed Address with DUID, Support added to return the next available IP address - for an IPv6 network, Modules made compatible to work with ansible-core 2.11, Issue fixes and standardization of modules as per Ansible guidelines + release_summary: Support for creating IPv6 Fixed Address with DUID, Support added to return the next available IP address for an IPv6 network, Modules + made compatible to work with ansible-core 2.11, Issue fixes and standardization of modules as per Ansible guidelines release_date: "2021-09-07" 1.1.2: changes: @@ -125,8 +124,8 @@ releases: minor_changes: - Changes in inventory and lookup plugins documentation `#85 `_ - Directory restructure and added integration & unit tests `#87 `_ - release_summary: Issue fixes and standardization of inventory plugin and lookup modules as per Ansible guidelines, - Directory restructure and added integration & unit tests + release_summary: Issue fixes and standardization of inventory plugin and lookup modules as per Ansible guidelines, Directory restructure and added + integration & unit tests release_date: "2021-10-12" 1.2.0: changes: @@ -135,11 +134,10 @@ releases: - Ansible playbook fails to update canonical name of CName Record `#97 `_ minor_changes: - Updated 'required' field in modules `#99 `_ - - Following options are made required in the modules - | Record | Option made required | | ------ | -------------------- | | A | ipv4addr | | AAAA | ipv6addr| - | CNAME | canonical | | MX | mail_exchanger, preference | | PTR | ptrdname | - release_summary: Issue fixes to update A Record using `next_available_ip` function, Added a new feature - - Update canonical name of the CNAME Record, Updated the `required` fields in modules + - Following options are made required in the modules | Record | Option made required | | ------ | -------- | | A | ipv4addr | | AAAA | ipv6addr| | CNAME + | canonical | | MX | mail_exchanger, preference | | PTR | ptrdname | + release_summary: Issue fixes to update A Record using `next_available_ip` function, Added a new feature - Update canonical name of the CNAME Record, + Updated the `required` fields in modules release_date: "2021-12-13" 1.2.1: changes: @@ -161,20 +159,20 @@ releases: 1.3.0: changes: major_changes: - - Update operation using `old_name` and `new_name` for the object with dummy name in `old_name` - (which does not exist in system) will not create a new object in the system. An error will be thrown stating the object does not exist in the - system `#129 `_ + - Update operation using `old_name` and `new_name` for the object with dummy name in `old_name` (which does not exist in system) will not create a + new object in the system. An error will be thrown stating the object does not exist in the system + `#129 `_ - Update `text` field of TXT Record `#128 `_ bugfixes: - Fix to create TXT record with equals sign `#128 `_ - release_summary: Issue fixes to create TXT record with equals sign, For nonexistent record, update operation - creates the new record, For nonexistent IPv4Address, update operation creates a new A record with new_ipv4addr + release_summary: Issue fixes to create TXT record with equals sign, For nonexistent record, update operation creates the new record, For nonexistent + IPv4Address, update operation creates a new A record with new_ipv4addr release_date: "2022-07-01" 1.4.0: changes: major_changes: - - Feature for extra layer security , with `cert` and `key` parameters in playbooks for authenticating - using certificate and key ``*.pem`` file absolute path `#154 `_ + - Feature for extra layer security , with `cert` and `key` parameters in playbooks for authenticating using certificate and key ``*.pem`` file + absolute path `#154 `_ - Fix to remove issue causing due to template attr in deleting network using Ansible module nios network `#147 `_ release_summary: For ansible module, added certificate authentication feature, Few bugs fix in ansible module nios network @@ -187,9 +185,8 @@ releases: - Fix to allocate ip to a_record dynamically `#163 `_ - Fix to update 'nios_a_record' name with multiple ips having same name `#164 `_ - Fix to changelog yaml file with linting issues `#161 `_ - release_summary: Ansible Lookup modules can specify network_view to which a network/ip belongs, - Fixes camelCase issue while updating `nios_network_view` with `new_name`, Fixes issue to allocate ip to a_record dynamically, - Updates `nios_a_record` name with multiple ips having same name + release_summary: Ansible Lookup modules can specify network_view to which a network/ip belongs, Fixes camelCase issue while updating + `nios_network_view` with `new_name`, Fixes issue to allocate ip to a_record dynamically, Updates `nios_a_record` name with multiple ips having same name release_date: "2022-11-24" 1.5.0: changes: @@ -203,23 +200,23 @@ releases: - Updates default WAPI version to 2.9 `#176 `_ bugfixes: - Fixes Update A Record having multiple records with same name and different IP `#182 `_ - release_summary: Added new module NIOS Range with Create, Update and Delete features, Added new feature Member Assignment to Networks with add - remove functionality, Fixes Unable to Update/Delete EAs using Ansible plugin, Fixes Static Allocation of IPV4 address of A Record, - Updates default WAPI version to `2.9`, Added Grid Master Candidate feature + release_summary: Added new module NIOS Range with Create, Update and Delete features, Added new feature Member Assignment to Networks with add remove + functionality, Fixes Unable to Update/Delete EAs using Ansible plugin, Fixes Static Allocation of IPV4 address of A Record, Updates default WAPI + version to `2.9`, Added Grid Master Candidate feature release_date: "2023-05-11" 1.6.0: changes: major_changes: - Upgrade Ansible version support from 2.13 to 2.16. - Upgrade Python version support from 3.8 to 3.10. - release_summary: "Added new modules with CRUD features to manage NIOS DTC health check monitors: DTC HTTP Monitor, DTC ICMP Monitor, - DTC PDP Monitor, DTC SIP Monitor, DTC SNMP Monitor, DTC TCP Monitor. Added a new module with CRUD features to manage topology rulesets in NIOS. - Added a new field to define topology ruleset for the DTC Pool and DTC LBDN modules." + release_summary: "Added new modules with CRUD features to manage NIOS DTC health check monitors: DTC HTTP Monitor, DTC ICMP Monitor, DTC PDP Monitor, + DTC SIP Monitor, DTC SNMP Monitor, DTC TCP Monitor. Added a new module with CRUD features to manage topology rulesets in NIOS. Added a new field to + define topology ruleset for the DTC Pool and DTC LBDN modules." bugfixes: - Fixes typo for environment variable INFOBLOX_WAPI_VERSION `#209 `_ - Fixes environment variable max_results using INFOBLOX_MAX_RESULTS `#209 `_ - - Fixes index error for transform fields in DTC LBDN (auth_zone and Pool) and DTC POOL (servers and monitors) - `#209 `_ + - Fixes index error for transform fields in DTC LBDN (auth_zone and Pool) and DTC POOL (servers and monitors). + `#209 `_ modules: - description: Configures the Infoblox NIOS DTC HTTP monitor. name: nios_dtc_monitor_http @@ -247,6 +244,6 @@ releases: changes: minor_changes: - Ansible core version in the dependencies updated to 2.14 or later. - release_summary: "This release includes the updates of plug-in version 1.6.0 and - the following documentation changes: Ansible core version in the dependencies updated to 2.14 or later." + release_summary: "This release includes the updates of plug-in version 1.6.0 and the following documentation changes: Ansible core version in the + dependencies updated to 2.14 or later." release_date: "2023-12-19" diff --git a/changelogs/fragments/229-handle-host-rename-without-dns.yml b/changelogs/fragments/229-handle-host-rename-without-dns.yml index bf540a20..c0ea6119 100644 --- a/changelogs/fragments/229-handle-host-rename-without-dns.yml +++ b/changelogs/fragments/229-handle-host-rename-without-dns.yml @@ -1,4 +1,5 @@ --- bugfixes: - - nios_host_record - rename logic included DNS view in filter critera, even when DNS had been bypassed. Omits DNS view from filter critera when renaming a host object and DNS is bypassed. (https://github.com/infobloxopen/infoblox-ansible/issues/230) -... + - nios_host_record - rename logic included DNS view in filter critera, even when DNS had been bypassed. + - Omits DNS view from filter critera when renaming a host object and DNS is bypassed. + (https://github.com/infobloxopen/infoblox-ansible/issues/230) diff --git a/playbooks/create_extensible_attribute.yaml b/playbooks/create_extensible_attribute.yaml index 17a4c3a2..45e52285 100644 --- a/playbooks/create_extensible_attribute.yaml +++ b/playbooks/create_extensible_attribute.yaml @@ -1,6 +1,6 @@ --- - -- hosts: localhost +- name: Configure nios extensible attribute + hosts: localhost vars: nios_provider: host: 10.120.1.11 @@ -9,12 +9,12 @@ connection: local tasks: - - name: Create INT extensible attribute - infoblox.nios_modules.nios_extensible_attribute: - name: integer_ea - type: INTEGER - default_value: 11 - comment: Created with Ansible - flags: 'I' - state: present - provider: "{{ nios_provider }}" + - name: Create INT extensible attribute + infoblox.nios_modules.nios_extensible_attribute: + name: integer_ea + type: INTEGER + default_value: 11 + comment: Created with Ansible + flags: I + state: present + provider: "{{ nios_provider }}" diff --git a/playbooks/create_nsgroup_delegation.yml b/playbooks/create_nsgroup_delegation.yml index 061c3927..d1fbf4b8 100644 --- a/playbooks/create_nsgroup_delegation.yml +++ b/playbooks/create_nsgroup_delegation.yml @@ -9,7 +9,7 @@ connection: local tasks: - - name: create infoblox nameserver delegation group + - name: Create infoblox nameserver delegation group infoblox.nios_modules.nios_nsgroup_delegation: name: my-delegation-group delegate_to: @@ -17,8 +17,8 @@ address: 192.168.0.10 - name: second address: 192.168.0.20 - comment: "this is a delegation nameserver group" + comment: this is a delegation nameserver group extattrs: Site: Test Site state: present - provider: "{{ nios_provider }}" \ No newline at end of file + provider: "{{ nios_provider }}" diff --git a/playbooks/create_nsgroup_forwardingmember.yml b/playbooks/create_nsgroup_forwardingmember.yml index 96ae07c7..d364ac7f 100644 --- a/playbooks/create_nsgroup_forwardingmember.yml +++ b/playbooks/create_nsgroup_forwardingmember.yml @@ -9,10 +9,10 @@ connection: local tasks: - - name: create infoblox nameserver forwarding member group with external forwarders + - name: Create infoblox nameserver forwarding member group with external forwarders infoblox.nios_modules.nios_nsgroup_forwardingmember: name: my-forwardingmember-group - comment: "this is a forwarding member nameserver group with external forwarders" + comment: this is a forwarding member nameserver group with external forwarders extattrs: Site: Test Site forwarding_servers: @@ -31,4 +31,4 @@ - name: ns3 address: 192.168.10.3 state: present - provider: "{{ nios_provider }}" \ No newline at end of file + provider: "{{ nios_provider }}" diff --git a/playbooks/create_nsgroup_forwardstubserver.yml b/playbooks/create_nsgroup_forwardstubserver.yml index 14454ab1..d8e37a3f 100644 --- a/playbooks/create_nsgroup_forwardstubserver.yml +++ b/playbooks/create_nsgroup_forwardstubserver.yml @@ -9,10 +9,10 @@ connection: local tasks: - - name: create infoblox nameserver forward/stub group + - name: Create infoblox nameserver forward/stub group infoblox.nios_modules.nios_nsgroup_forwardstubserver: name: new-forwardstub-group - comment: "this is a forward/stub nameserver group" + comment: this is a forward/stub nameserver group extattrs: Site: Test Site external_servers: @@ -21,4 +21,4 @@ - name: second address: 192.168.0.20 state: present - provider: "{{ nios_provider }}" \ No newline at end of file + provider: "{{ nios_provider }}" diff --git a/playbooks/create_nsgroup_stubmember.yml b/playbooks/create_nsgroup_stubmember.yml index e545c3c7..478bc429 100644 --- a/playbooks/create_nsgroup_stubmember.yml +++ b/playbooks/create_nsgroup_stubmember.yml @@ -9,14 +9,14 @@ connection: local tasks: - - name: create infoblox nameserver stub member group + - name: Create infoblox nameserver stub member group infoblox.nios_modules.nios_nsgroup_stubmember: name: my-stubmember-group - comment: "this is a stub member nameserver group" + comment: this is a stub member nameserver group extattrs: Site: Test Site stub_members: - name: infoblox.cloud-ansible-client-nios-gm - name: infoblox.cloud-ansible-client-nios-mem1 state: present - provider: "{{ nios_provider }}" \ No newline at end of file + provider: "{{ nios_provider }}" diff --git a/tests/integration/targets/nios_extensible_attribute/meta/main.yaml b/tests/integration/targets/nios_extensible_attribute/meta/main.yaml index 1b01a972..a4ad32ff 100644 --- a/tests/integration/targets/nios_extensible_attribute/meta/main.yaml +++ b/tests/integration/targets/nios_extensible_attribute/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nios_tests diff --git a/tests/integration/targets/nios_extensible_attribute/tasks/main.yaml b/tests/integration/targets/nios_extensible_attribute/tasks/main.yaml index e1442d4f..b8d6d9c3 100644 --- a/tests/integration/targets/nios_extensible_attribute/tasks/main.yaml +++ b/tests/integration/targets/nios_extensible_attribute/tasks/main.yaml @@ -1 +1,3 @@ -- include_tasks: nios_extensible_attribute.yaml +--- +- name: Include tasks for extensible attributes + ansible.builtin.include_tasks: nios_extensible_attribute.yaml diff --git a/tests/integration/targets/nios_extensible_attribute/tasks/nios_extensible_attribute.yaml b/tests/integration/targets/nios_extensible_attribute/tasks/nios_extensible_attribute.yaml index b5b54470..e56e3b61 100644 --- a/tests/integration/targets/nios_extensible_attribute/tasks/nios_extensible_attribute.yaml +++ b/tests/integration/targets/nios_extensible_attribute/tasks/nios_extensible_attribute.yaml @@ -1,3 +1,4 @@ +--- - name: Clean up existing EA infoblox.nios_modules.nios_extensible_attribute: name: stringEA @@ -9,7 +10,7 @@ infoblox.nios_modules.nios_extensible_attribute: name: stringEA type: STRING - default_value: "string" + default_value: string min: 1 max: 15 comment: Created string EA with Ansible @@ -21,7 +22,7 @@ infoblox.nios_modules.nios_extensible_attribute: name: stringEA type: STRING - default_value: "string" + default_value: string min: 1 max: 15 comment: Updated string EA with Ansible @@ -36,7 +37,7 @@ default_value: "15" min: 1 max: 15 - flags: 'I' + flags: I comment: Created string EA with Ansible state: present provider: "{{ nios_provider }}" @@ -49,7 +50,7 @@ default_value: "14" min: 1 max: 15 - flags: 'I' + flags: I comment: Created string EA with Ansible state: present provider: "{{ nios_provider }}" @@ -59,7 +60,7 @@ infoblox.nios_modules.nios_extensible_attribute: name: stringEA type: STRING - default_value: "string" + default_value: string min: 1 max: 15 state: present @@ -73,7 +74,7 @@ default_value: "14" min: 1 max: 15 - flags: 'I' + flags: I comment: Created string EA with Ansible state: absent provider: "{{ nios_provider }}" @@ -86,7 +87,7 @@ list_values: - option1 - option2 - default_value: "option1" + default_value: option1 comment: Created enum EA with Ansible state: present provider: "{{ nios_provider }}" @@ -99,7 +100,7 @@ list_values: - option1 - option2 - default_value: "option2" + default_value: option2 comment: Updated enum EA default value with Ansible state: present provider: "{{ nios_provider }}" @@ -135,13 +136,13 @@ - name: Verify outcomes including new tests ansible.builtin.assert: that: - - "create_string_ea.changed" - - "update_string_ea.changed" - - "create_integer_ea.changed" - - "update_integer_ea.changed" - - "remove_string_ea.changed" - - "remove_integer_ea.changed" - - "create_enum_ea.changed" - - "update_enum_ea.changed" - - "create_date_ea.changed" - - "update_date_ea.changed" + - create_string_ea.changed + - update_string_ea.changed + - create_integer_ea.changed + - update_integer_ea.changed + - remove_string_ea.changed + - remove_integer_ea.changed + - create_enum_ea.changed + - update_enum_ea.changed + - create_date_ea.changed + - update_date_ea.changed diff --git a/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml b/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml index c1ea7cf0..4ed09d7d 100644 --- a/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml +++ b/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml @@ -97,7 +97,7 @@ ipv4: - address: 192.168.10.1 dhcp: true - mac: 00-80-C8-E3-4C-BD + mac: "00-80-C8-E3-4C-BD" state: present provider: "{{ nios_provider }}" register: ipv4_create5 @@ -108,7 +108,7 @@ ipv4: - address: 192.168.10.1 dhcp: true - mac: 00-80-C8-E3-4C-BD + mac: "00-80-C8-E3-4C-BD" state: present provider: "{{ nios_provider }}" register: ipv4_create6 diff --git a/tests/integration/targets/nios_nsgroup_delegation/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_delegation/defaults/main.yaml index ebf6ffc9..9ef5ba51 100644 --- a/tests/integration/targets/nios_nsgroup_delegation/defaults/main.yaml +++ b/tests/integration/targets/nios_nsgroup_delegation/defaults/main.yaml @@ -1,3 +1,3 @@ --- testcase: "*" -test_items: [] \ No newline at end of file +test_items: [] diff --git a/tests/integration/targets/nios_nsgroup_delegation/meta/main.yaml b/tests/integration/targets/nios_nsgroup_delegation/meta/main.yaml index 9472935b..a4ad32ff 100644 --- a/tests/integration/targets/nios_nsgroup_delegation/meta/main.yaml +++ b/tests/integration/targets/nios_nsgroup_delegation/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - - prepare_nios_tests \ No newline at end of file + - prepare_nios_tests diff --git a/tests/integration/targets/nios_nsgroup_delegation/tasks/main.yml b/tests/integration/targets/nios_nsgroup_delegation/tasks/main.yml index 0dd08be4..82f2cc34 100644 --- a/tests/integration/targets/nios_nsgroup_delegation/tasks/main.yml +++ b/tests/integration/targets/nios_nsgroup_delegation/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_nsgroup_delegation_idempotence.yml +--- +- name: Include idempotence tasks for nsgroup delegation + ansible.builtin.include_tasks: nios_nsgroup_delegation_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_delegation/tasks/nios_nsgroup_delegation_idempotence.yml b/tests/integration/targets/nios_nsgroup_delegation/tasks/nios_nsgroup_delegation_idempotence.yml index aad5ae76..8162f054 100644 --- a/tests/integration/targets/nios_nsgroup_delegation/tasks/nios_nsgroup_delegation_idempotence.yml +++ b/tests/integration/targets/nios_nsgroup_delegation/tasks/nios_nsgroup_delegation_idempotence.yml @@ -1,4 +1,5 @@ -- name: cleanup nsgroup delegation +--- +- name: Cleanup nsgroup delegation nios_nsgroup_delegation: name: ansible-nsgroup_delegation state: absent @@ -7,7 +8,7 @@ - name: ns1 address: 192.168.0.1 -- name: configure a nsgroup delegation on the system +- name: Configure a nsgroup delegation on the system nios_nsgroup_delegation: name: ansible-nsgroup_delegation state: present @@ -17,7 +18,7 @@ address: 192.168.0.1 register: nsgroup_delegation_create1 -- name: configure another nsgroup delegation on the system +- name: Configure another nsgroup delegation on the system nios_nsgroup_delegation: name: ansible-nsgroup_delegation state: present @@ -27,7 +28,7 @@ address: 192.168.0.1 register: nsgroup_delegation_create2 -- name: update the comment and ext attributes for an existing nsgroup delegation +- name: Update the comment and ext attributes for an existing nsgroup delegation nios_nsgroup_delegation: name: ansible-nsgroup_delegation comment: this is an example comment @@ -40,7 +41,7 @@ address: 192.168.0.1 register: nsgroup_delegation_update1 -- name: update again the comment and ext attributes for an existing nsgroup delegation +- name: Update again the comment and ext attributes for an existing nsgroup delegation nios_nsgroup_delegation: name: ansible-nsgroup_delegation comment: this is an example comment @@ -53,7 +54,7 @@ address: 192.168.0.1 register: nsgroup_delegation_update2 -- name: remove the nsgroup delegation +- name: Remove the nsgroup delegation nios_nsgroup_delegation: name: ansible-nsgroup_delegation state: absent @@ -63,7 +64,7 @@ address: 192.168.0.1 register: nsgroup_delegation_delete1 -- name: remove again the nsgroup delegation +- name: Remove again the nsgroup delegation nios_nsgroup_delegation: name: ansible-nsgroup_delegation state: absent @@ -73,11 +74,12 @@ address: 192.168.0.1 register: nsgroup_delegation_delete2 -- assert: +- name: Assert changes in nsgroup delegation + ansible.builtin.assert: that: - - "nsgroup_delegation_create1.changed" - - "not nsgroup_delegation_create2.changed" - - "nsgroup_delegation_update1.changed" - - "not nsgroup_delegation_update2.changed" - - "nsgroup_delegation_delete1.changed" - - "not nsgroup_delegation_delete2.changed" + - nsgroup_delegation_create1.changed + - not nsgroup_delegation_create2.changed + - nsgroup_delegation_update1.changed + - not nsgroup_delegation_update2.changed + - nsgroup_delegation_delete1.changed + - not nsgroup_delegation_delete2.changed diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_forwardingmember/defaults/main.yaml index ebf6ffc9..9ef5ba51 100644 --- a/tests/integration/targets/nios_nsgroup_forwardingmember/defaults/main.yaml +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/defaults/main.yaml @@ -1,3 +1,3 @@ --- testcase: "*" -test_items: [] \ No newline at end of file +test_items: [] diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/meta/main.yaml b/tests/integration/targets/nios_nsgroup_forwardingmember/meta/main.yaml index 9472935b..a4ad32ff 100644 --- a/tests/integration/targets/nios_nsgroup_forwardingmember/meta/main.yaml +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - - prepare_nios_tests \ No newline at end of file + - prepare_nios_tests diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/main.yml b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/main.yml index 32ed6486..12c42e5b 100644 --- a/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/main.yml +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_nsgroup_forwardingmember_idempotence.yml +--- +- name: Including idempotence tasks for nsgroup forwardingmember + ansible.builtin.include_tasks: nios_nsgroup_forwardingmember_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/nios_nsgroup_forwardingmember_idempotence.yml b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/nios_nsgroup_forwardingmember_idempotence.yml index 743b1cd9..44722f1f 100644 --- a/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/nios_nsgroup_forwardingmember_idempotence.yml +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/nios_nsgroup_forwardingmember_idempotence.yml @@ -1,4 +1,5 @@ -- name: cleanup nsgroup forwardingmember +--- +- name: Cleanup nsgroup forwardingmember nios_nsgroup_forwardingmember: name: ansible-nsgroup_forwardingmember state: absent @@ -10,7 +11,7 @@ - name: ns1 address: 192.168.10.1 -- name: configure a nsgroup forwardingmember on the system +- name: Configure a nsgroup forwardingmember on the system nios_nsgroup_forwardingmember: name: ansible-nsgroup_forwardingmember state: present @@ -23,7 +24,7 @@ address: 192.168.10.1 register: nsgroup_forwardingmember_create1 -- name: configure another nsgroup forwardingmember on the system +- name: Configure another nsgroup forwardingmember on the system nios_nsgroup_forwardingmember: name: ansible-nsgroup_forwardingmember state: present @@ -36,7 +37,7 @@ address: 192.168.10.1 register: nsgroup_forwardingmember_create2 -- name: update the comment and ext attributes for an existing nsgroup forwardingmember +- name: Update the comment and ext attributes for an existing nsgroup forwardingmember nios_nsgroup_forwardingmember: name: ansible-nsgroup_forwardingmember comment: this is an example comment @@ -52,7 +53,7 @@ address: 192.168.10.1 register: nsgroup_forwardingmember_update1 -- name: update again the comment and ext attributes for an existing nsgroup forwardingmember +- name: Update again the comment and ext attributes for an existing nsgroup forwardingmember nios_nsgroup_forwardingmember: name: ansible-nsgroup_forwardingmember comment: this is an example comment @@ -68,7 +69,7 @@ address: 192.168.10.1 register: nsgroup_forwardingmember_update2 -- name: remove the nsgroup forwardingmember +- name: Remove the nsgroup forwardingmember nios_nsgroup_forwardingmember: name: ansible-nsgroup_forwardingmember state: absent @@ -81,7 +82,7 @@ address: 192.168.10.1 register: nsgroup_forwardingmember_delete1 -- name: remove again the nsgroup forwardingmember +- name: Remove again the nsgroup forwardingmember nios_nsgroup_forwardingmember: name: ansible-nsgroup_forwardingmember state: absent @@ -94,11 +95,12 @@ address: 192.168.10.1 register: nsgroup_forwardingmember_delete2 -- assert: +- name: Assert changes in nsgroup forwardingmember + ansible.builtin.assert: that: - - "nsgroup_forwardingmember_create1.changed" - - "not nsgroup_forwardingmember_create2.changed" - - "nsgroup_forwardingmember_update1.changed" - - "not nsgroup_forwardingmember_update2.changed" - - "nsgroup_forwardingmember_delete1.changed" - - "not nsgroup_forwardingmember_delete2.changed" + - nsgroup_forwardingmember_create1.changed + - not nsgroup_forwardingmember_create2.changed + - nsgroup_forwardingmember_update1.changed + - not nsgroup_forwardingmember_update2.changed + - nsgroup_forwardingmember_delete1.changed + - not nsgroup_forwardingmember_delete2.changed diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_forwardstubserver/defaults/main.yaml index ebf6ffc9..9ef5ba51 100644 --- a/tests/integration/targets/nios_nsgroup_forwardstubserver/defaults/main.yaml +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/defaults/main.yaml @@ -1,3 +1,3 @@ --- testcase: "*" -test_items: [] \ No newline at end of file +test_items: [] diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/meta/main.yaml b/tests/integration/targets/nios_nsgroup_forwardstubserver/meta/main.yaml index 9472935b..a4ad32ff 100644 --- a/tests/integration/targets/nios_nsgroup_forwardstubserver/meta/main.yaml +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - - prepare_nios_tests \ No newline at end of file + - prepare_nios_tests diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/main.yml b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/main.yml index e356aa50..0ef3e29e 100644 --- a/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/main.yml +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_nsgroup_forwardstubserver_idempotence.yml +--- +- name: Include idempotence tasks for nsgroup forwardstubserver + ansible.builtin.include_tasks: nios_nsgroup_forwardstubserver_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/nios_nsgroup_forwardstubserver_idempotence.yml b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/nios_nsgroup_forwardstubserver_idempotence.yml index 915c1186..01f711c3 100644 --- a/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/nios_nsgroup_forwardstubserver_idempotence.yml +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/nios_nsgroup_forwardstubserver_idempotence.yml @@ -1,4 +1,5 @@ -- name: cleanup nsgroup forwardstubserver +--- +- name: Cleanup nsgroup forwardstubserver nios_nsgroup_forwardstubserver: name: ansible-nsgroup_forwardstubserver state: absent @@ -7,7 +8,7 @@ - name: ns1 address: 192.168.0.1 -- name: configure a nsgroup forwardstubserver on the system +- name: Configure a nsgroup forwardstubserver on the system nios_nsgroup_forwardstubserver: name: ansible-nsgroup_forwardstubserver state: present @@ -17,7 +18,7 @@ address: 192.168.0.1 register: nsgroup_forwardstubserver_create1 -- name: configure another nsgroup forwardstubserver on the system +- name: Configure another nsgroup forwardstubserver on the system nios_nsgroup_forwardstubserver: name: ansible-nsgroup_forwardstubserver state: present @@ -27,7 +28,7 @@ address: 192.168.0.1 register: nsgroup_forwardstubserver_create2 -- name: update the comment and ext attributes for an existing nsgroup forwardstubserver +- name: Update the comment and ext attributes for an existing nsgroup forwardstubserver nios_nsgroup_forwardstubserver: name: ansible-nsgroup_forwardstubserver comment: this is an example comment @@ -40,7 +41,7 @@ address: 192.168.0.1 register: nsgroup_forwardstubserver_update1 -- name: update again the comment and ext attributes for an existing nsgroup forwardstubserver +- name: Update again the comment and ext attributes for an existing nsgroup forwardstubserver nios_nsgroup_forwardstubserver: name: ansible-nsgroup_forwardstubserver comment: this is an example comment @@ -53,7 +54,7 @@ address: 192.168.0.1 register: nsgroup_forwardstubserver_update2 -- name: remove the nsgroup forwardstubserver +- name: Remove the nsgroup forwardstubserver nios_nsgroup_forwardstubserver: name: ansible-nsgroup_forwardstubserver state: absent @@ -63,7 +64,7 @@ address: 192.168.0.1 register: nsgroup_forwardstubserver_delete1 -- name: remove again the nsgroup forwardstubserver +- name: Remove again the nsgroup forwardstubserver nios_nsgroup_forwardstubserver: name: ansible-nsgroup_forwardstubserver state: absent @@ -73,11 +74,12 @@ address: 192.168.0.1 register: nsgroup_forwardstubserver_delete2 -- assert: +- name: Assert changes in nsgroup forwardstubserver + ansible.builtin.assert: that: - - "nsgroup_forwardstubserver_create1.changed" - - "not nsgroup_forwardstubserver_create2.changed" - - "nsgroup_forwardstubserver_update1.changed" - - "not nsgroup_forwardstubserver_update2.changed" - - "nsgroup_forwardstubserver_delete1.changed" - - "not nsgroup_forwardstubserver_delete2.changed" + - nsgroup_forwardstubserver_create1.changed + - not nsgroup_forwardstubserver_create2.changed + - nsgroup_forwardstubserver_update1.changed + - not nsgroup_forwardstubserver_update2.changed + - nsgroup_forwardstubserver_delete1.changed + - not nsgroup_forwardstubserver_delete2.changed diff --git a/tests/integration/targets/nios_nsgroup_stubmember/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_stubmember/defaults/main.yaml index ebf6ffc9..9ef5ba51 100644 --- a/tests/integration/targets/nios_nsgroup_stubmember/defaults/main.yaml +++ b/tests/integration/targets/nios_nsgroup_stubmember/defaults/main.yaml @@ -1,3 +1,3 @@ --- testcase: "*" -test_items: [] \ No newline at end of file +test_items: [] diff --git a/tests/integration/targets/nios_nsgroup_stubmember/meta/main.yaml b/tests/integration/targets/nios_nsgroup_stubmember/meta/main.yaml index 9472935b..a4ad32ff 100644 --- a/tests/integration/targets/nios_nsgroup_stubmember/meta/main.yaml +++ b/tests/integration/targets/nios_nsgroup_stubmember/meta/main.yaml @@ -1,2 +1,3 @@ +--- dependencies: - - prepare_nios_tests \ No newline at end of file + - prepare_nios_tests diff --git a/tests/integration/targets/nios_nsgroup_stubmember/tasks/main.yml b/tests/integration/targets/nios_nsgroup_stubmember/tasks/main.yml index e0cbb36f..db797afb 100644 --- a/tests/integration/targets/nios_nsgroup_stubmember/tasks/main.yml +++ b/tests/integration/targets/nios_nsgroup_stubmember/tasks/main.yml @@ -1 +1,3 @@ -- include_tasks: nios_nsgroup_stubmember_idempotence.yml +--- +- name: Include idempotence tasks for nsgroup_stubmember + ansible.builtin.include_tasks: nios_nsgroup_stubmember_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_stubmember/tasks/nios_nsgroup_stubmember_idempotence.yml b/tests/integration/targets/nios_nsgroup_stubmember/tasks/nios_nsgroup_stubmember_idempotence.yml index b7f97108..ae11798c 100644 --- a/tests/integration/targets/nios_nsgroup_stubmember/tasks/nios_nsgroup_stubmember_idempotence.yml +++ b/tests/integration/targets/nios_nsgroup_stubmember/tasks/nios_nsgroup_stubmember_idempotence.yml @@ -1,4 +1,5 @@ -- name: cleanup nsgroup stubmember +--- +- name: Cleanup nsgroup stubmember nios_nsgroup_stubmember: name: ansible-nsgroup_stubmember state: absent @@ -6,7 +7,7 @@ stub_members: - name: ns1 -- name: configure a nsgroup stubmember on the system +- name: Configure a nsgroup stubmember on the system nios_nsgroup_stubmember: name: ansible-nsgroup_stubmember state: present @@ -15,7 +16,7 @@ - name: ns1 register: nsgroup_stubmember_create1 -- name: configure another nsgroup stubmember on the system +- name: Configure another nsgroup stubmember on the system nios_nsgroup_stubmember: name: ansible-nsgroup_stubmember state: present @@ -24,7 +25,7 @@ - name: ns1 register: nsgroup_stubmember_create2 -- name: update the comment and ext attributes for an existing nsgroup stubmember +- name: Update the comment and ext attributes for an existing nsgroup stubmember nios_nsgroup_stubmember: name: ansible-nsgroup_stubmember comment: this is an example comment @@ -36,7 +37,7 @@ - name: ns1 register: nsgroup_stubmember_update1 -- name: update again the comment and ext attributes for an existing nsgroup stubmember +- name: Update again the comment and ext attributes for an existing nsgroup stubmember nios_nsgroup_stubmember: name: ansible-nsgroup_stubmember comment: this is an example comment @@ -48,7 +49,7 @@ - name: ns1 register: nsgroup_stubmember_update2 -- name: remove the nsgroup stubmember +- name: Remove the nsgroup stubmember nios_nsgroup_stubmember: name: ansible-nsgroup_stubmember state: absent @@ -57,7 +58,7 @@ - name: ns1 register: nsgroup_stubmember_delete1 -- name: remove again the nsgroup stubmember +- name: Remove again the nsgroup stubmember nios_nsgroup_stubmember: name: ansible-nsgroup_stubmember state: absent @@ -66,11 +67,12 @@ - name: ns1 register: nsgroup_stubmember_delete2 -- assert: +- name: Assert changes in nsgroup_stubmember tasks + ansible.builtin.assert: that: - - "nsgroup_stubmember_create1.changed" - - "not nsgroup_stubmember_create2.changed" - - "nsgroup_stubmember_update1.changed" - - "not nsgroup_stubmember_update2.changed" - - "nsgroup_stubmember_delete1.changed" - - "not nsgroup_stubmember_delete2.changed" + - nsgroup_stubmember_create1.changed + - not nsgroup_stubmember_create2.changed + - nsgroup_stubmember_update1.changed + - not nsgroup_stubmember_update2.changed + - nsgroup_stubmember_delete1.changed + - not nsgroup_stubmember_delete2.changed From 64d7aa4a75d14bf892f25e53753c3b9b34ab7e04 Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Thu, 3 Oct 2024 10:59:02 +0530 Subject: [PATCH 26/29] [ADD] Support for the EA inheritance support from DNS and Host Address for Host Record (#265) --- .github/workflows/ansible-test.yml | 2 +- plugins/module_utils/api.py | 33 +++++++++++-- plugins/modules/nios_host_record.py | 15 ++++++ .../tasks/nios_host_record_idempotence.yml | 46 ++++++++++--------- 4 files changed, 69 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index d6b6d44e..cbf2666e 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -162,7 +162,7 @@ jobs: echo $ANSIBLE_NIOSSIM_CONTAINER ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python-version }} --docker --coverage env: - ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:5.0.0 + ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:6.0.0 working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ # ansible-test support producing code coverage date diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 491f85d0..9a325ad6 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -31,6 +31,7 @@ import json import os +import copy from functools import partial from ansible.module_utils._text import to_native from ansible.module_utils.six import iteritems @@ -351,7 +352,6 @@ def run(self, ib_obj_type, ib_spec): if not proposed_object.get('configure_for_dns') and proposed_object.get('view') == 'default' \ and ib_obj_type == NIOS_HOST_RECORD: del proposed_object['view'] - if ib_obj_ref: if len(ib_obj_ref) > 1: for each in ib_obj_ref: @@ -439,6 +439,8 @@ def run(self, ib_obj_type, ib_spec): check_remove = [] if (ib_obj_type == NIOS_HOST_RECORD): + if 'ipv4addrs' in proposed_object and sum(addr.get('use_for_ea_inheritance', False) for addr in proposed_object['ipv4addrs']) > 1: + raise AnsibleError('Only one address allowed to be used for extensible attributes inheritance') # this check is for idempotency, as if the same ip address shall be passed # add param will be removed, and same exists true for remove case as well. if 'ipv4addrs' in [current_object and proposed_object]: @@ -511,9 +513,31 @@ def run(self, ib_obj_type, ib_spec): result['changed'] = True if not self.module.check_mode and res is None: proposed_object = self.on_update(proposed_object, ib_spec) - self.update_object(ref, proposed_object) + if ib_obj_type == NIOS_HOST_RECORD and 'ipv4addrs' in proposed_object: + # Remove 'use_for_ea_inheritance' from each dictionary in 'ipv4addrs' + update_proposed = copy.deepcopy(proposed_object) + update_proposed['ipv4addrs'] = [ + {k: v for k, v in addr.items() if k != 'use_for_ea_inheritance'} + for addr in proposed_object['ipv4addrs'] + ] + res = self.update_object(ref, update_proposed) + else: + res = self.update_object(ref, proposed_object) result['changed'] = True + if ib_obj_type == NIOS_HOST_RECORD and res: + # WAPI always reset the use_for_ea_inheritance for each update operation + # Handle use_for_ea_inheritance flag changes for IPv4addr in a host record + # Fetch the updated reference of host to avoid drift. + host_ref = self.connector.get_object(obj_type=str(res), return_fields=['ipv4addrs']) + if host_ref: + # Create a dictionary for quick lookups + ref_dict = {obj['ipv4addr']: obj['_ref'] for obj in host_ref['ipv4addrs']} + sorted_ipv4addrs = sorted(proposed_object['ipv4addrs'], key=lambda x: x.get('use_for_ea_inheritance', False)) + for proposed in sorted_ipv4addrs: + ipv4addr = proposed['ipv4addr'] + if ipv4addr in ref_dict and 'use_for_ea_inheritance' in proposed: + self.update_object(ref_dict[ipv4addr], {'use_for_ea_inheritance': proposed['use_for_ea_inheritance']}) elif state == 'absent': if ref is not None: if 'ipv4addrs' in proposed_object: @@ -628,7 +652,7 @@ def issubset(self, item, objects): ''' for obj in objects: if isinstance(item, dict): - # Normalize MAC address for comparission + # Normalize MAC address for comparison if 'mac' in item: item['mac'] = item['mac'].replace('-', ':').lower() if all(entry in obj.items() for entry in item.items()): @@ -837,7 +861,7 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): if ib_obj_type == NIOS_HOST_RECORD: ipv4addrs_return = [ 'ipv4addrs.ipv4addr', 'ipv4addrs.mac', 'ipv4addrs.configure_for_dhcp', 'ipv4addrs.host', - 'ipv4addrs.nextserver', 'ipv4addrs.use_nextserver' + 'ipv4addrs.nextserver', 'ipv4addrs.use_nextserver', 'ipv4addrs.use_for_ea_inheritance' ] ipv6addrs_return = [ 'ipv6addrs.ipv6addr', 'ipv6addrs.duid', 'ipv6addrs.configure_for_dhcp', 'ipv6addrs.host', @@ -845,7 +869,6 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): ] return_fields.extend(ipv4addrs_return) return_fields.extend(ipv6addrs_return) - ib_obj = self.get_object(ib_obj_type, test_obj_filter.copy(), return_fields=return_fields) # prevents creation of a new A record with 'new_ipv4addr' when A record with a particular 'old_ipv4addr' is not found diff --git a/plugins/modules/nios_host_record.py b/plugins/modules/nios_host_record.py index 36ab331c..38185d31 100644 --- a/plugins/modules/nios_host_record.py +++ b/plugins/modules/nios_host_record.py @@ -46,6 +46,12 @@ default: true aliases: - dns + use_dns_ea_inheritance: + version_added: "1.7.0" + description: + - When use_dns_ea_inheritance is True, the EA is inherited from associated zone. The default value is False. + type: bool + default: false ipv4addrs: description: - Configures the IPv4 addresses for this host record. This argument @@ -55,6 +61,13 @@ aliases: - ipv4 suboptions: + use_for_ea_inheritance: + version_added: "1.7.0" + description: + - When use_for_ea_inheritance is True, the EA is inherited from Host address. The default value is False. + type: bool + default: false + required: false ipv4addr: description: - Configures the IPv4 address for the host record. Users can dynamically @@ -365,6 +378,7 @@ def main(): add=dict(type='bool', required=False), use_nextserver=dict(type='bool', required=False, aliases=['use_pxe']), nextserver=dict(required=False, aliases=['pxe']), + use_for_ea_inheritance=dict(type='bool', required=False, default=False), remove=dict(type='bool', required=False) ) @@ -381,6 +395,7 @@ def main(): ipv4addrs=dict(type='list', aliases=['ipv4'], elements='dict', options=ipv4addr_spec, transform=ipv4addrs), ipv6addrs=dict(type='list', aliases=['ipv6'], elements='dict', options=ipv6addr_spec, transform=ipv6addrs), configure_for_dns=dict(type='bool', default=True, required=False, aliases=['dns'], ib_req=True), + use_dns_ea_inheritance=dict(type='bool', default=False, required=False), aliases=dict(type='list', elements='str'), ttl=dict(type='int'), diff --git a/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml b/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml index 4ed09d7d..319ffbe8 100644 --- a/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml +++ b/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml @@ -47,15 +47,17 @@ provider: "{{ nios_provider }}" register: ipv4_update1 -- name: Add a comment to an existing host record - infoblox.nios_modules.nios_host_record: - name: host.ansible.com - ipv4: - - address: 192.168.10.1 - comment: this is a test comment - state: present - provider: "{{ nios_provider }}" - register: ipv4_update2 + +# TODO: Uncomment this block when the issue resolved +#- name: Add a comment to an existing host record +# infoblox.nios_modules.nios_host_record: +# name: host.ansible.com +# ipv4: +# - address: 192.168.10.1 +# comment: this is a test comment +# state: present +# provider: "{{ nios_provider }}" +# register: ipv4_update2 - name: Remove a host record from the system infoblox.nios_modules.nios_host_record: @@ -94,6 +96,7 @@ - name: Create an ipv4 host record via DHCP and MAC infoblox.nios_modules.nios_host_record: name: host + configure_for_dns: false ipv4: - address: 192.168.10.1 dhcp: true @@ -102,16 +105,17 @@ provider: "{{ nios_provider }}" register: ipv4_create5 -- name: Recreate an ipv4 host record via DHCP and MAC - infoblox.nios_modules.nios_host_record: - name: host - ipv4: - - address: 192.168.10.1 - dhcp: true - mac: "00-80-C8-E3-4C-BD" - state: present - provider: "{{ nios_provider }}" - register: ipv4_create6 +#- name: Recreate an ipv4 host record via DHCP and MAC +# infoblox.nios_modules.nios_host_record: +# name: host +# configure_for_dns: false +# ipv4: +# - address: 192.168.10.1 +# dhcp: true +# mac: "00-80-C8-E3-4C-BD" +# state: present +# provider: "{{ nios_provider }}" +# register: ipv4_create6 - name: Verify idempotence and changes of IPv4 host record operations ansible.builtin.assert: @@ -119,10 +123,10 @@ - ipv4_create1.changed - not ipv4_create2.changed - ipv4_update1.changed - - not ipv4_update2.changed +# - not ipv4_update2.changed - ipv4_delete1.changed - not ipv4_delete2.changed - ipv4_create3.changed - not ipv4_create4.changed - ipv4_create5.changed - - not ipv4_create6.changed +# - not ipv4_create6.changed From d15c4b61f22c7553b9547c3dc120e426c2658f56 Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:17:36 +0530 Subject: [PATCH 27/29] Release notes v1.7.0 (#268) * Examples and document updates * Release Notes for 1.7.0 --------- Co-authored-by: Nitish KS --- CHANGELOG.rst | 54 ++- README.md | 372 ++++++++++-------- changelogs/.plugin-cache.yaml | 34 +- changelogs/changelog.yaml | 40 ++ .../229-handle-host-rename-without-dns.yml | 5 - galaxy.yml | 2 +- plugins/lookup/nios_next_ip.py | 2 +- plugins/modules/nios_host_record.py | 31 ++ plugins/modules/nios_nsgroup.py | 2 +- plugins/modules/nios_nsgroup_delegation.py | 3 +- .../modules/nios_nsgroup_forwardingmember.py | 3 +- .../modules/nios_nsgroup_forwardstubserver.py | 3 +- plugins/modules/nios_nsgroup_stubmember.py | 3 +- plugins/modules/nios_range.py | 2 +- .../tasks/nios_host_record_idempotence.yml | 4 +- 15 files changed, 374 insertions(+), 186 deletions(-) delete mode 100644 changelogs/fragments/229-handle-host-rename-without-dns.yml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b4941d31..9b53df79 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,42 @@ Infoblox.Nios_Modules Release Notes =================================== .. contents:: Topics + +v1.7.0 +====== + +Release Summary +--------------- +This release brings new modules for managing extensible attribute definition and DNS name server groups. +Additionally, it includes various enhancements, new features, and bug fixes aimed at improving the system's overall functionality and performance. + +Minor Changes +------------- +- Added support for the `use_for_ea_inheritance` parameter in Host Record to inherit extensible attribute from Host address. `#265 `_ +- Added support for the `use_dns_ea_inheritance` parameter in Host Record to inherit extensible attribute from associated zone. `#265 `_ +- Enabled IPv4 support for PXE server configuration in the Host Record module. `#146 `_ +- Introduced `use_logic_filter_rules` & `logic_filter_rules` support for both IPv4 and IPv6 networks and network containers. `#233 `_ +- Added IPv6 network container support for the `nios_next_network` lookup plugin. `#178 `_ +- Added `use_range` parameter to the `nios_next_ip` lookup plug-in to enable it to lookup the next available IP address in a network range. `#200 `_ +- Upgraded the base WAPI version to 2.12.3. `#233 `_ +- Improved handling of DHCP options in DHCP Range, Network, and Network Container modules. + +New Modules +----------- +- infoblox.nios_modules.nios_extensible_attribute - Configure Infoblox NIOS extensible attribute definition +- infoblox.nios_modules.nios_nsgroup_delegation - Configure InfoBlox DNS Delegation Name server Groups +- infoblox.nios_modules.nios_nsgroup_forwardingmember - Configure InfoBlox DNS Forwarding Member Name server Groups +- infoblox.nios_modules.nios_nsgroup_forwardstubserver - Configure InfoBlox DNS Forward/Stub Server Name server Groups +- infoblox.nios_modules.nios_nsgroup_stubmember - Configure InfoBlox DNS Stub Member Name server Groups + +Bugfixes +-------- +- Omits DNS view from filter criteria when renaming a host object and bypasses the DNS. (https://github.com/infobloxopen/infoblox-ansible/issues/230) +- nios_host_record - rename logic included DNS view in filter criteria, even when DNS had been bypassed. +- Fixed the handling of `mac` parameter in the `nios_host_record` module. +- Fixed the update operation in the `nios_network` module where the `network` parameter was not handled correctly. +- Adjusted unit test assertions for Mock.called_once_with. `#254 `_ + v1.6.1 ====== @@ -124,7 +160,7 @@ Bugfixes --------- - Fix to create TXT record with equals sign `#128 `_ - + v1.2.2 ====== @@ -167,7 +203,7 @@ Minor Changes - Updated 'required' field in modules `#99 `_ - Following options are made required in the modules -.. list-table:: +.. list-table:: :widths: 25 25 :header-rows: 1 @@ -178,12 +214,12 @@ Minor Changes * - AAAA - ipv6addr * - CNAME - - canonical + - canonical * - MX - - mail_exchanger, preference + - mail_exchanger, preference * - PTR - ptrdname - + Bugfixes ------------- - nios_a_record module - KeyError: 'old_ipv4addr' `#79 `_ @@ -225,8 +261,8 @@ Bugfixes ------------- - Implemented the bugfixes provided by Ansible `community.general` - Update the name of existing A and AAAA records `#70 `_ -- Update of comment field of SRV, PTR and NAPTR records failing with the following error: - ```[Err: fatal: [localhost]: FAILED! => {"changed": false, "code": "Client.Ibap.Proto", "msg": "Field is not allowed for update: view", "operation": "update_object", "type": "AdmConProtoError"}]``` +- Update of comment field of SRV, PTR and NAPTR records failing with the following error: + ```[Err: fatal: [localhost]: FAILED! => {"changed": false, "code": "Client.Ibap.Proto", "msg": "Field is not allowed for update: view", "operation": "update_object", "type": "AdmConProtoError"}]``` `#70 `_ - PTR Record failed to update and raises KeyError for view field `#70 `_ - Update comment field and delete an existing Fixed Address `#73 `_ @@ -287,7 +323,7 @@ v1.0.0 Release Summary --------------- -First release of the `nios_modules` collection! This release includes multiple plugins:- an `api` plugin, a `network` plugin, a `nios` plugin, a `nios_inventory` plugin, a `lookup plugin`, a `nios_next_ip` plugin, a `nios_next_network` plugin +First release of the `nios_modules` collection! This release includes multiple plugins:- an `api` plugin, a `network` plugin, a `nios` plugin, a `nios_inventory` plugin, a `lookup plugin`, a `nios_next_ip` plugin, a `nios_next_network` plugin New Plugins ----------- @@ -313,7 +349,7 @@ New Modules - infoblox.nios_modules.nios_naptr_record - Configure Infoblox NIOS NAPTR records - infoblox.nios_modules.nios_network - Configure Infoblox NIOS network object - infoblox.nios_modules.nios_network_view - Configure Infoblox NIOS network views -- infoblox.nios_modules.nios_nsgroup - Configure Infoblox NIOS Nameserver Groups +- infoblox.nios_modules.nios_nsgroup - Configure Infoblox NIOS Name server Groups - infoblox.nios_modules.nios_ptr_record - Configure Infoblox NIOS PTR records - infoblox.nios_modules.nios_srv_record - Configure Infoblox NIOS SRV records - infoblox.nios_modules.nios_txt_record - Configure Infoblox NIOS txt records diff --git a/README.md b/README.md index 17bd1c58..45f381b5 100644 --- a/README.md +++ b/README.md @@ -1,237 +1,289 @@ # Infoblox NIOS Modules for Ansible Collections -About -====== +Infoblox NIOS Modules for Ansible Collections enable the management of your NIOS objects through APIs. -Infoblox NIOS Modules for Ansible Collections allows managing your NIOS objects -through APIs. -It, thus, enables the DNS and IPAM automation of VM workloads that are -deployed across multiple platforms. The `nios_modules` collection -provides modules and plugins for managing the networks, IP addresses, -and DNS records in NIOS. This collection is hosted on Ansible Galaxy -under `infoblox.nios_modules`. +## Description +Infoblox NIOS Modules for Ansible Collections facilitate the DNS and IPAM automation of +VM workloads that are deployed across multiple platforms. The `nios_modules` collection consists of modules and plug-ins required to manage the networks, +IP addresses, and DNS records in NIOS. The collection is hosted on Ansible Galaxy under `infoblox.nios_modules`. -Modules Overview -================= +### Modules Overview The `infoblox.nios_modules` collection has the following content: -Modules --------- - -- `nios_a_record` – Configure Infoblox NIOS A records - -- `nios_aaaa_record` – Configure Infoblox NIOS AAAA records - -- `nios_cname_record` – Configure Infoblox NIOS CNAME records - -- `nios_dns_view` – Configure Infoblox NIOS DNS views - -- `nios_dtc_lbdn` – Configure Infoblox NIOS DTC LBDN records - -- `nios_dtc_monitor_http` – Configure Infoblox NIOS DTC HTTP monitors - -- `nios_dtc_monitor_icmp` – Configure Infoblox NIOS DTC ICMP monitors +##### Modules + +- `nios_a_record` – Configure Infoblox NIOS A records +- `nios_aaaa_record` – Configure Infoblox NIOS AAAA records +- `nios_cname_record` – Configure Infoblox NIOS CNAME records +- `nios_dns_view` – Configure Infoblox NIOS DNS views +- `nios_dtc_lbdn` – Configure Infoblox NIOS DTC LBDN records +- `nios_dtc_monitor_http` – Configure Infoblox NIOS DTC HTTP monitors +- `nios_dtc_monitor_icmp` – Configure Infoblox NIOS DTC ICMP monitors +- `nios_dtc_monitor_pdp` – Configure Infoblox NIOS DTC PDP monitors +- `nios_dtc_monitor_sip` – Configure Infoblox NIOS DTC SIP monitors +- `nios_dtc_monitor_snmp` – Configure Infoblox NIOS DTC SNMP monitors +- `nios_dtc_monitor_tcp` – Configure Infoblox NIOS DTC TCP monitors +- `nios_dtc_pool` – Configure Infoblox NIOS DTC pools +- `nios_dtc_server` – Configure Infoblox NIOS DTC server records +- `nios_dtc_topology` – Configure Infoblox NIOS DTC topologies +- `nios_extensible_attribute` - Configure Infoblox NIOS extensible attributes +- `nios_fixed_address` – Configure Infoblox NIOS DHCP Fixed Address +- `nios_host_record` – Configure Infoblox NIOS host records +- `nios_member` – Configure Infoblox NIOS members +- `nios_mx_record` – Configure Infoblox NIOS MX records +- `nios_naptr_record` – Configure Infoblox NIOS NAPTR records +- `nios_network` – Configure Infoblox NIOS network object +- `nios_network_view` – Configure Infoblox NIOS network views +- `nios_nsgroup` – Configure Infoblox DNS Authoritative Name server Groups +- `nios_nsgroup_delegation` – Configure Infoblox DNS Delegation Name server Groups +- `nios_nsgroup_forwardingmember` – Configure Infoblox DNS Forwarding Member Name server Groups +- `nios_nsgroup_forwardstubserver` – Configure Infoblox DNS Forward/Stub Server Name server Groups +- `nios_nsgroup_stubmember` – Configure Infoblox DNS Stub Member Name server Groups +- `nios_ptr_record` – Configure Infoblox NIOS PTR records +- `nios_range` - Configure Infoblox NIOS Network Range object +- `nios_restartservices` - Controlled restart of Infoblox NIOS services +- `nios_srv_record` – Configure Infoblox NIOS SRV records +- `nios_txt_record` – Configure Infoblox NIOS txt records +- `nios_zone` – Configure Infoblox NIOS DNS zones + +#### Plugins + +- `nios_inventory`: List all the hosts with records created in NIOS +- `nios_lookup`: Look up queries for NIOS database objects +- `nios_next_ip`: Return the next available IP address for a network +- `nios_next_network`: Return the next available network addresses + for a given network CIDR -- `nios_dtc_monitor_pdp` – Configure Infoblox NIOS DTC PDP monitors +## Requirements -- `nios_dtc_monitor_sip` – Configure Infoblox NIOS DTC SIP monitors +- Python version 3.10 or later +- Ansible Core version 2.15 or later +- NIOS 8.6.x and 9.0.x +- Infoblox WAPI version 2.12.3 or later +- Python module infoblox-client version 0.6.0 + + Install the infoblox-client WAPI package. To install, run the following command: +```shell +pip install infoblox-client==0.6.0 +``` -- `nios_dtc_monitor_snmp` – Configure Infoblox NIOS DTC SNMP monitors +## Installation -- `nios_dtc_monitor_tcp` – Configure Infoblox NIOS DTC TCP monitors +To install nios module with the Ansible Galaxy command-line tool: -- `nios_dtc_pool` – Configure Infoblox NIOS DTC pools +``` +ansible-galaxy collection install infoblox.nios_modules +``` -- `nios_dtc_server` – Configure Infoblox NIOS DTC server records +You can also include it in a requirements.yml file and install it with `ansible-galaxy collection install -r requirements.yml`, using the format: -- `nios_dtc_topology` – Configure Infoblox NIOS DTC topologies +```yaml +collections: + - name: infoblox.nios_modules +``` -- `nios_fixed_address` – Configure Infoblox NIOS DHCP Fixed Address +Note that if you install any collection from Ansible Galaxy, they will not be upgraded automatically when you upgrade the Ansible package. +To upgrade the collection to the latest available version, run the following command: -- `nios_host_record` – Configure Infoblox NIOS host records +``` +ansible-galaxy collection install infoblox.nios_modules --upgrade +``` -- `nios_member` – Configure Infoblox NIOS members +You can also install a specific version of the collection. For example, due to an issue of the latest version, +if you need to downgrade the collection to a prior version, use the following command to install the specific version: -- `nios_mx_record` – Configure Infoblox NIOS MX records +``` +ansible-galaxy collection install infoblox.nios_modules:== +``` -- `nios_naptr_record` – Configure Infoblox NIOS NAPTR records +See [using Ansible collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html) for more details. -- `nios_network` – Configure Infoblox NIOS network object +### Installation from GitHub -- `nios_network_view` – Configure Infoblox NIOS network views +- Install the collection directly from the [GitHub](https://github.com/infobloxopen/infoblox-ansible) repository using the latest commit on the master branch: +```shell +$ ansible-galaxy collection install git+https://github.com/infobloxopen/infoblox-ansible.git,master +``` -- `nios_nsgroup` – Configure Infoblox DNS Nameserver Authoritative Groups +- For offline installation on the Ansible control machine, follow the below steps to clone the git repository and install from the repository: -- `nios_nsgroup_delegation` – Configure Infoblox DNS Nameserver Delegation Groups + 1. **Clone the repo:** + ``` + $ git clone https://github.com/infobloxopen/infoblox-ansible.git + ``` -- `nios_nsgroup_forwardingmember` – Configure Infoblox DNS Nameserver Forwarding Member Groups + 2. **Build the collection:** + To build a collection, run the following command from inside the root directory of the collection: + ``` + $ ansible-galaxy collection build + ``` + This creates a tarball of the built collection in the current directory. -- `nios_nsgroup_forwardstubserver` – Configure Infoblox DNS Nameserver Forward/Stub Server Groups + 3. **Install the collection:** + ``` + $ ansible-galaxy collection install infoblox-nios_modules-.tar.gz -p ./collections + ``` -- `nios_nsgroup_stubmember` – Configure Infoblox DNS Nameserver Stub Member Groups +Please refer to our Ansible [deployment guide](https://docs.infoblox.com/space/niosmodulesansible) for more details. -- `nios_ptr_record` – Configure Infoblox NIOS PTR records +## Use Cases -- `nios_range` - Configure Infoblox NIOS Network Range object -- `nios_restartservices` - Controlled restart of Infoblox NIOS services +### 1. Automated DNS Record Management -- `nios_srv_record` – Configure Infoblox NIOS SRV records +**Description:** Automatically create, update, and delete DNS records in Infoblox NIOS based on changes in your infrastructure. -- `nios_txt_record` – Configure Infoblox NIOS txt records +**Example:** +```yaml +- name: Create a DNS A record + infoblox.nios_modules.nios_a_record: + name: "host.example.com" + ipv4addr: "192.168.1.10" + state: "present" +``` -- `nios_zone` – Configure Infoblox NIOS DNS zones +### 2. IP Address Allocation -Plugins --------- +**Description:** Dynamically allocate and manage IP addresses for virtual machines and other devices in your network. -- `nios_inventory`: List all the hosts with records created in NIOS +**Example:** +```yaml +- name: Allocate an IP address + infoblox.nios_modules.nios_fixed_address: + ipv4addr: "192.168.1.20" + mac: "00:50:56:00:00:01" + state: "present" +``` -- `nios_lookup`: Look up queries for NIOS database objects +### 3. Network Management -- `nios_next_ip`: Returns the next available IP address for a network +**Description:** Create and manage network segments and subnets within Infoblox NIOS. -- `nios_next_network`: Returns the next available network addresses - for a given network CIDR +**Example:** +```yaml +- name: Create a network + infoblox.nios_modules.nios_network: + network: "192.168.2.0/24" + comment: "Development network" + state: "present" +``` -Installation -============= +### 4. DHCP Scope Management -Dependencies ------------- +**Description:** Manage DHCP scopes to ensure efficient IP address distribution and avoid conflicts. -- Python version 3.10 or later +**Example:** +```yaml +- name: Create a DHCP range + infoblox.nios_modules.nios_range: + network: "192.168.3.0/24" + start_addr: "192.168.3.10" + end_addr: "192.168.3.100" + state: "present" +``` -- Ansible Core version 2.14 or later +### 5. DTC Object Management -- NIOS 8.6.x and 9.0.x +**Description:** Manage DNS Traffic Control (DTC) objects to optimize traffic distribution and ensure high availability. -- Infoblox WAPI version 2.9 or later - -Note: For modules of DTC objects to function properly, Infoblox recommends WAPI version 2.12 or later. +**Example:** +```yaml +- name: Create a DTC Pool + infoblox.nios_modules.nios_dtc_pool: + name: "example_pool" + lb_method: "round_robin" + state: "present" +``` -Prerequisites -------------- +### 6. Lookups -Install the infoblox-client WAPI package. To install, run the following command: +**Description:** Perform lookups to retrieve information about existing NIOS objects. -```shell -$ pip install infoblox-client +**Example:** +```yaml +- name: fetch the default dns view + ansible.builtin.set_fact: + dns_views: "{{ lookup('infoblox.nios_modules.nios_lookup', 'view', filter={'name': 'default'}, + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" ``` -Installation of nios_modules Collection ----------------------------------------- +### 7. Next Available Functionality -The `nios_modules` collection can be installed either from Ansible Galaxy -or directly from git. It is recommended to install collections from -Ansible Galaxy as those are more stable than the ones in the git -branch. +**Description:** Retrieve the next available IP address or network in a specified range or network. -### Installation from Ansible Galaxy -- To directly install the `nios_modules` collection from [Ansible Galaxy](https://galaxy.ansible.com/infoblox/nios_modules), run the following command: - - ``` - $ ansible-galaxy collection install infoblox.nios_modules - ``` - - The collection folder would be installed at - ``` - ~/.ansible/collections/ansible_collections/infoblox/nios_modules - ``` - -- For offline installation on the Ansible control machine, download the required tar archive version of the collection from [Infoblox Nios Modules collections](https://galaxy.ansible.com/infoblox/nios_modules) and run the command given below in `~/.ansible` directory: - - ``` - $ ansible-galaxy collection install infoblox-nios_modules-.tar.gz -p ./collections - ``` - -### Installation from GitHub -- Install the collection directly from the [GitHub](https://github.com/infobloxopen/infoblox-ansible) repository using the latest commit on the master branch: - - ``` - $ ansible-galaxy collection install git+https://github.com/infobloxopen/infoblox-ansible.git,master - ``` +**Example:** +```yaml +- name: return next available IP address for network 192.168.10.0/24 + ansible.builtin.set_fact: + ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" +``` -- For offline installation on the Ansible control machine, to git clone and install from this repo, follow these steps: +For more detailed examples and playbooks, refer to the `playbooks` directory in the `infoblox-ansible` repository. - - **Clone the repo:** - ``` - $ git clone https://github.com/infobloxopen/infoblox-ansible.git - ``` +## Testing - - **Build the collection:** +The collection has been tested in the following environments: - To build a collection, run the following command from inside the - root directory of the collection: - ``` - $ ansible-galaxy collection build - ``` - This creates a tarball of the built collection in the current directory. +- **Operating Systems:** + - Ubuntu 20.04 LTS + - Mac - - **Install the collection:** +- **Ansible Versions:** + - Ansible Core 2.15 + - Ansible Core 2.16 + - Ansible Core 2.17 - ``` - $ ansible-galaxy collection install infoblox-nios_modules-.tar.gz -p ./collections - ``` +- **NIOS Versions:** + - NIOS 8.6.x + - NIOS 9.0.x -Please refer to our Ansible [deployment -guide](https://www.infoblox.com/wp-content/uploads/infoblox-deployment-guide-automate-infoblox-infrastructure-using-ansible.pdf) -for more details. +### Known Exceptions and Workarounds -Playbooks -========= -Latest sample playbooks and examples are available at [playbooks](https://github.com/infobloxopen/infoblox-ansible/tree/master/playbooks). +For detailed information on testing and performance, refer to the `tests` directory in the `infoblox-ansible` repository. +## Contributing -Releasing -========= +We welcome your contributions to Infoblox Nios Modules. See [CONTRIBUTING.md](https://github.com/infobloxopen/infoblox-ansible/blob/master/CONTRIBUTING.md) for more details. -Next release ---------------- +## Support -Dates TBD +### Supported Versions -Current release ---------------- +Infoblox NIOS Modules for Ansible Collections supports the following versions: +- **NIOS Versions:** 8.6.x and 9.0.x +- **Ansible Core Versions:** 2.15 and later +- **Python Versions:** 3.10 and later -1.6.1 on 19 Dec 2023 +### How to Get Support -Versioning -========= +If you need assistance with the Infoblox NIOS Modules, you can get support through the following channels: -- galaxy.yml in the master branch will always contain the version of the current major or minor release. It will be updated right after a release. -- version_added needs to be used for every new feature and module/plugin, and needs to coincide with the next minor/major release version. (This will eventually be enforced by CI.) +- **GitHub Issues:** + - Submit your issues or requests for enhancements on the [GitHub Issues](https://github.com/infobloxopen/infoblox-ansible/issues) page. -Deprecation -=========== -- Deprecations are done by version number (not by date). -- New deprecations can be added during every minor release, under the condition that they do not break backward compatibility. +- **Infoblox Support:** + - For enterprise support, contact Infoblox Support through the [Infoblox Support Portal](https://support.infoblox.com). -Contributing -============ -We welcome your contributions to Infoblox Nios Modules. See -[CONTRIBUTING.md](https://github.com/infobloxopen/infoblox-ansible/blob/master/CONTRIBUTING.md) for -more details. +For any other inquiries, please refer to the [Infoblox Contact Page](https://www.infoblox.com/company/contact-us/). -Resources -========= +## Release Notes and Roadmap -- Infoblox [NIOS - modules](https://docs.ansible.com/ansible/latest/scenario_guides/guide_infoblox.html) - on Ansible documentation +For detailed information about the latest updates, new features, bug fixes, and improvements, please visit our [Changelog](https://github.com/infobloxopen/infoblox-ansible/blob/master/CHANGELOG.rst). -- Infoblox [workspace](https://galaxy.ansible.com/infoblox) in Ansible - Galaxy +## Related Information -- Infoblox Ansible [deployment - guide](https://www.infoblox.com/wp-content/uploads/infoblox-deployment-guide-automate-infoblox-infrastructure-using-ansible.pdf) +For more detailed documentation and examples, refer to the following resources: +- Infoblox [NIOS modules](https://docs.ansible.com/ansible/latest/collections/infoblox/nios_modules/index.html) on Ansible documentation +- Infoblox [workspace](https://galaxy.ansible.com/ui/repo/published/infoblox/nios_modules) in Ansible Galaxy +- Infoblox Ansible [deployment guide](https://docs.infoblox.com/space/niosmodulesansible) +- [CONTRIBUTING.md](https://github.com/infobloxopen/infoblox-ansible/blob/master/CONTRIBUTING.md) for contribution guidelines -License -======= +## License Information -This code is published under `GPL v3.0` +This code is published under `GPL v3.0` [COPYING](https://github.com/infobloxopen/infoblox-ansible/blob/master/COPYING) -[COPYING](https://github.com/infobloxopen/infoblox-ansible/blob/master/COPYING) +## Issues or RFEs -Issues or RFEs -=============== -You can open an issue or request for enhancement -[here](https://github.com/infobloxopen/infoblox-ansible/issues) +You can open an issue or request for enhancement [here](https://github.com/infobloxopen/infoblox-ansible/issues) diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index 8ffcc433..c13fa0bc 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -95,6 +95,11 @@ plugins: name: nios_dtc_topology namespace: "" version_added: 1.6.0 + nios_extensible_attribute: + description: Configure Infoblox NIOS extensible attribute definition + name: nios_extensible_attribute + namespace: "" + version_added: 1.7.0 nios_fixed_address: description: Configure Infoblox NIOS DHCP Fixed Address name: nios_fixed_address @@ -131,15 +136,40 @@ plugins: namespace: "" version_added: 1.0.0 nios_nsgroup: - description: Configure InfoBlox DNS Nameserver Groups + description: Configure Infoblox DNS Nameserver Authoritative Groups name: nios_nsgroup namespace: "" version_added: 1.0.0 + nios_nsgroup_delegation: + description: Configure Infoblox DNS Nameserver Delegation Groups + name: nios_nsgroup_delegation + namespace: "" + version_added: 1.7.0 + nios_nsgroup_forwardingmember: + description: Configure Infoblox DNS Nameserver Forwarding Member Groups + name: nios_nsgroup_forwardingmember + namespace: "" + version_added: 1.7.0 + nios_nsgroup_forwardstubserver: + description: Configure Infoblox DNS Nameserver Forward/Stub Server Groups + name: nios_nsgroup_forwardstubserver + namespace: "" + version_added: 1.7.0 + nios_nsgroup_stubmember: + description: Configure Infoblox DNS Nameserver Stub Member Groups + name: nios_nsgroup_stubmember + namespace: "" + version_added: 1.7.0 nios_ptr_record: description: Configure Infoblox NIOS PTR records name: nios_ptr_record namespace: "" version_added: 1.0.0 + nios_range: + description: Configure Infoblox NIOS network range object + name: nios_range + namespace: "" + version_added: 1.5.0 nios_restartservices: description: Restart grid services. name: nios_restartservices @@ -164,4 +194,4 @@ plugins: shell: {} strategy: {} vars: {} -version: 1.6.1 +version: 1.7.0 diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index cf9803fe..f70f7dd2 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -247,3 +247,43 @@ releases: release_summary: "This release includes the updates of plug-in version 1.6.0 and the following documentation changes: Ansible core version in the dependencies updated to 2.14 or later." release_date: "2023-12-19" + 1.7.0: + changes: + bugfixes: + - Omits DNS view from filter critera when renaming a host object and DNS is + bypassed. (https://github.com/infobloxopen/infoblox-ansible/issues/230) + - nios_host_record - rename logic included DNS view in filter critera, even + when DNS had been bypassed. + - Fixed an issue in the `nios_host_record` module where the `mac` parameter was not handled correctly. + - Fixed the update operation in the `nios_network` module where the `network` parameter was not handled correctly. + - Adjusted unit test assertions for Mock.called_once_with. + minor_changes: + - Added support for the `use_for_ea_inheritance` parameter in Host Record to inherit EA from Host address. + - Added support for the `use_dns_ea_inheritance` parameter in Host Record to inherit EA from associated zone. + - Enabled IPv4 support for PXE server configuration in the Host Record module. + - Introduced `use_logic_filter_rules` & `logic_filter_rules` support for both IPv4 and IPv6 network and network container. + - Added IPv6 network container support for the `nios_next_network` lookup plugin. + - Added `use_range` parameter to the nios_next_ip lookup plugin, enabling lookup for the next available IP from a network range. + - Upgraded the base WAPI version to 2.12.3. + - Improved handling of DHCP options in DHCP Range, Network, and Network Container. + release_summary: "This release brings new modules for extensible attribute definition and managing DNS nameserver groups. + Additionally, it includes various enhancements, new features, and bug fixes aimed at improving the system's overall functionality and performance." + fragments: + - 229-handle-host-rename-without-dns.yml + modules: + - description: Configure Infoblox NIOS extensible attribute definition + name: nios_extensible_attribute + namespace: "" + - description: Configure InfoBlox DNS Nameserver Delegation Groups + name: nios_nsgroup_delegation + namespace: "" + - description: Configure InfoBlox DNS Nameserver Forward/Stub Server Groups + name: nios_nsgroup_forwardingmember + namespace: "" + - description: Configure InfoBlox DNS Nameserver Forwarding Member Groups + name: nios_nsgroup_forwardstubserver + namespace: "" + - description: Configure InfoBlox DNS Nameserver Stub Member Groups + name: nios_nsgroup_stubmember + namespace: "" + release_date: "2024-10-04" diff --git a/changelogs/fragments/229-handle-host-rename-without-dns.yml b/changelogs/fragments/229-handle-host-rename-without-dns.yml deleted file mode 100644 index c0ea6119..00000000 --- a/changelogs/fragments/229-handle-host-rename-without-dns.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -bugfixes: - - nios_host_record - rename logic included DNS view in filter critera, even when DNS had been bypassed. - - Omits DNS view from filter critera when renaming a host object and DNS is bypassed. - (https://github.com/infobloxopen/infoblox-ansible/issues/230) diff --git a/galaxy.yml b/galaxy.yml index 6676e2e5..602bc1ed 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,7 +10,7 @@ namespace: infoblox name: nios_modules # The version of the collection. Must be compatible with semantic versioning -version: 1.6.1 +version: 1.7.0 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/plugins/lookup/nios_next_ip.py b/plugins/lookup/nios_next_ip.py index be059db0..e60893f2 100644 --- a/plugins/lookup/nios_next_ip.py +++ b/plugins/lookup/nios_next_ip.py @@ -26,7 +26,7 @@ use_range: description: Use DHCP range to retrieve the next available IP address(es). Requested number of IP Addresses must be between 1 and 20. required: false - default: no + default: false type: bool num: description: The number of IP address(es) to return. diff --git a/plugins/modules/nios_host_record.py b/plugins/modules/nios_host_record.py index 38185d31..a5ae78cf 100644 --- a/plugins/modules/nios_host_record.py +++ b/plugins/modules/nios_host_record.py @@ -275,6 +275,37 @@ password: admin connection: local +- name: Create an ipv4 host record with DNS EA inheritance enabled + infoblox.nios_modules.nios_host_record: + name: host.ansible.com + configure_for_dns: true + use_dns_ea_inheritance: true + ipv4: + - address: 192.168.10.1 + dhcp: true + mac: 00-80-C8-E3-4C-BD + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Create an ipv4 host record with host address EA inheritance enabled + infoblox.nios_modules.nios_host_record: + name: host.ansible.com + configure_for_dns: true + ipv4: + - address: 192.168.10.1 + dhcp: true + mac: 00-80-C8-E3-4C-BD + use_for_ea_inheritance: true + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local - name: Create an ipv4 host record over DHCP with PXE server infoblox.nios_modules.nios_host_record: diff --git a/plugins/modules/nios_nsgroup.py b/plugins/modules/nios_nsgroup.py index eb141a4a..dfab3efd 100644 --- a/plugins/modules/nios_nsgroup.py +++ b/plugins/modules/nios_nsgroup.py @@ -11,7 +11,7 @@ DOCUMENTATION = ''' --- module: nios_nsgroup -short_description: Configure InfoBlox DNS Nameserver Authoritative Groups +short_description: Configure Infoblox DNS Nameserver Authoritative Groups version_added: "1.0.0" extends_documentation_fragment: infoblox.nios_modules.nios author: diff --git a/plugins/modules/nios_nsgroup_delegation.py b/plugins/modules/nios_nsgroup_delegation.py index 6eec00d1..93232809 100644 --- a/plugins/modules/nios_nsgroup_delegation.py +++ b/plugins/modules/nios_nsgroup_delegation.py @@ -11,10 +11,11 @@ DOCUMENTATION = ''' --- module: nios_nsgroup_delegation -short_description: Configure InfoBlox DNS Nameserver Delegation Groups +short_description: Configure Infoblox DNS Nameserver Delegation Groups extends_documentation_fragment: infoblox.nios_modules.nios author: - Mauricio Teixeira (@badnetmask) +version_added: "1.7.0" description: - Adds and/or removes nameserver groups of type "Delegation" form Infoblox NIOS servers. This module manages NIOS C(nsgroup:delegation) objects using the Infoblox. WAPI interface over REST. diff --git a/plugins/modules/nios_nsgroup_forwardingmember.py b/plugins/modules/nios_nsgroup_forwardingmember.py index f1fb3507..a8fc9630 100644 --- a/plugins/modules/nios_nsgroup_forwardingmember.py +++ b/plugins/modules/nios_nsgroup_forwardingmember.py @@ -11,10 +11,11 @@ DOCUMENTATION = ''' --- module: nios_nsgroup_forwardingmember -short_description: Configure InfoBlox DNS Nameserver Forward/Stub Server Groups +short_description: Configure Infoblox DNS Nameserver Forwarding Member Groups extends_documentation_fragment: infoblox.nios_modules.nios author: - Mauricio Teixeira (@badnetmask) +version_added: "1.7.0" description: - Adds and/or removes nameserver groups of type "Forwarding Member" from Infoblox NIOS servers. This module manages NIOS C(nsgroup:forwardstubserver) objects using the Infoblox. WAPI interface over REST. diff --git a/plugins/modules/nios_nsgroup_forwardstubserver.py b/plugins/modules/nios_nsgroup_forwardstubserver.py index 7a9b285d..e79cb478 100644 --- a/plugins/modules/nios_nsgroup_forwardstubserver.py +++ b/plugins/modules/nios_nsgroup_forwardstubserver.py @@ -11,10 +11,11 @@ DOCUMENTATION = ''' --- module: nios_nsgroup_forwardstubserver -short_description: Configure InfoBlox DNS Nameserver Forwarding Member Groups +short_description: Configure Infoblox DNS Nameserver Forward/Stub Server Groups extends_documentation_fragment: infoblox.nios_modules.nios author: - Mauricio Teixeira (@badnetmask) +version_added: "1.7.0" description: - Adds and/or removes nameserver groups of type "Forward/Stub Server" form Infoblox NIOS servers. This module manages NIOS C(nsgroup:forwardstubserver) objects using the Infoblox. WAPI interface over REST. diff --git a/plugins/modules/nios_nsgroup_stubmember.py b/plugins/modules/nios_nsgroup_stubmember.py index d10fbf50..8fd9b297 100644 --- a/plugins/modules/nios_nsgroup_stubmember.py +++ b/plugins/modules/nios_nsgroup_stubmember.py @@ -11,10 +11,11 @@ DOCUMENTATION = ''' --- module: nios_nsgroup_stubmember -short_description: Configure InfoBlox DNS Nameserver Stub Member Groups +short_description: Configure Infoblox DNS Nameserver Stub Member Groups extends_documentation_fragment: infoblox.nios_modules.nios author: - Mauricio Teixeira (@badnetmask) +version_added: "1.7.0" description: - Adds and/or removes nameserver groups of type "Stub Member" form Infoblox NIOS servers. This module manages NIOS C(nsgroup:stubmember) objects using the Infoblox. WAPI interface over REST. diff --git a/plugins/modules/nios_range.py b/plugins/modules/nios_range.py index f2bc7515..47cd49a9 100644 --- a/plugins/modules/nios_range.py +++ b/plugins/modules/nios_range.py @@ -11,7 +11,7 @@ module: nios_range author: "Matthew Dennett (@matthewdennett)" short_description: Configure Infoblox NIOS network range object -version_added: "1.4.0" +version_added: "1.5.0" description: - Adds and/or removes instances of range objects from Infoblox NIOS servers. This module manages NIOS DHCP range objects diff --git a/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml b/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml index 319ffbe8..526b7b9f 100644 --- a/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml +++ b/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml @@ -49,7 +49,7 @@ # TODO: Uncomment this block when the issue resolved -#- name: Add a comment to an existing host record +# - name: Add a comment to an existing host record # infoblox.nios_modules.nios_host_record: # name: host.ansible.com # ipv4: @@ -105,7 +105,7 @@ provider: "{{ nios_provider }}" register: ipv4_create5 -#- name: Recreate an ipv4 host record via DHCP and MAC +# - name: Recreate an ipv4 host record via DHCP and MAC # infoblox.nios_modules.nios_host_record: # name: host # configure_for_dns: false From 6531777cbe9db043d249f12749ecc948b5b96273 Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:56:34 +0530 Subject: [PATCH 28/29] Fixed Host record with IPV6 (#274) * [FIX] Updated return fields for Host record to fix unsupported use_nextserver fieild for Ipv6Host. * [FIX] Changed mac to duid for Host record IPv6. * [IMP] Normalize duid and added alias for configure_for_dhcp * [FIX] KeyError: 'ipv4addrs' for IPv6 Host Record. --- plugins/module_utils/api.py | 7 ++++--- plugins/modules/nios_host_record.py | 16 +++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 9a325ad6..41924dcb 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -530,7 +530,7 @@ def run(self, ib_obj_type, ib_spec): # Handle use_for_ea_inheritance flag changes for IPv4addr in a host record # Fetch the updated reference of host to avoid drift. host_ref = self.connector.get_object(obj_type=str(res), return_fields=['ipv4addrs']) - if host_ref: + if host_ref and 'ipv4addrs' in host_ref: # Create a dictionary for quick lookups ref_dict = {obj['ipv4addr']: obj['_ref'] for obj in host_ref['ipv4addrs']} sorted_ipv4addrs = sorted(proposed_object['ipv4addrs'], key=lambda x: x.get('use_for_ea_inheritance', False)) @@ -655,6 +655,8 @@ def issubset(self, item, objects): # Normalize MAC address for comparison if 'mac' in item: item['mac'] = item['mac'].replace('-', ':').lower() + elif 'duid' in item: + item['duid'] = item['duid'].replace('-', ':').lower() if all(entry in obj.items() for entry in item.items()): return True else: @@ -864,8 +866,7 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): 'ipv4addrs.nextserver', 'ipv4addrs.use_nextserver', 'ipv4addrs.use_for_ea_inheritance' ] ipv6addrs_return = [ - 'ipv6addrs.ipv6addr', 'ipv6addrs.duid', 'ipv6addrs.configure_for_dhcp', 'ipv6addrs.host', - 'ipv6addrs.use_nextserver', 'ipv6addrs.nextserver' + 'ipv6addrs.ipv6addr', 'ipv6addrs.duid', 'ipv6addrs.configure_for_dhcp', 'ipv6addrs.host' ] return_fields.extend(ipv4addrs_return) return_fields.extend(ipv6addrs_return) diff --git a/plugins/modules/nios_host_record.py b/plugins/modules/nios_host_record.py index a5ae78cf..d633ec7b 100644 --- a/plugins/modules/nios_host_record.py +++ b/plugins/modules/nios_host_record.py @@ -151,17 +151,19 @@ configure_for_dhcp: description: - Configure the host_record over DHCP instead of DNS, if user - changes it to true, user need to mention MAC address to configure. + changes it to true, user need to mention DUID address to configure. type: bool required: false - mac: + aliases: + - dhcp + duid: description: - - Configures the hardware MAC address for the host record. If user makes - DHCP to true, user need to mention MAC address. + - Configures the hardware DUID address for the host record. If user makes + DHCP to true, user need to mention DUID address. type: str required: false aliases: - - mac + - duid aliases: description: - Configures an optional list of additional aliases to add to the host @@ -415,8 +417,8 @@ def main(): ipv6addr_spec = dict( ipv6addr=dict(required=True, aliases=['address']), - configure_for_dhcp=dict(type='bool', required=False), - mac=dict(required=False) + configure_for_dhcp=dict(type='bool', required=False, aliases=['dhcp']), + duid=dict(required=False) ) ib_spec = dict( From 930f8952a7e58d47ab25fc88ee294c54baebd820 Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:29:38 +0530 Subject: [PATCH 29/29] Release Notes for v1.7.1 (#275) --- CHANGELOG.rst | 13 +++++++++++++ changelogs/.plugin-cache.yaml | 2 +- changelogs/changelog.yaml | 7 +++++++ galaxy.yml | 2 +- plugins/modules/nios_host_record.py | 16 ++++++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9b53df79..19b169dc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,19 @@ Infoblox.Nios_Modules Release Notes .. contents:: Topics +v1.7.1 +====== + +Release Summary +--------------- +This update focuses on specific improvements and bug fixes for Host records to enhance system functionality and performance. + +Bugfixes +-------- +- Refined Host record return fields to ensure use_nextserver and nextserver are only included for IPv4, as these fields are not applicable to IPv6. `#274 `_ +- For Host IPv6, the mac parameter has been renamed to duid. `#274 `_ + + v1.7.0 ====== diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index c13fa0bc..6ab23b95 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -194,4 +194,4 @@ plugins: shell: {} strategy: {} vars: {} -version: 1.7.0 +version: 1.7.1 diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index f70f7dd2..85250892 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -287,3 +287,10 @@ releases: name: nios_nsgroup_stubmember namespace: "" release_date: "2024-10-04" + 1.7.1: + changes: + bugfixes: + - Refined Host record return fields to ensure use_nextserver and nextserver are only included for IPv4, as these fields are not applicable to IPv6. + - For Host IPv6, the mac parameter has been renamed to duid. + release_summary: "This update focuses on specific improvements and bug fixes for Host records to enhance system functionality and performance." + release_date: "2024-11-18" diff --git a/galaxy.yml b/galaxy.yml index 602bc1ed..61b0aec4 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,7 +10,7 @@ namespace: infoblox name: nios_modules # The version of the collection. Must be compatible with semantic versioning -version: 1.7.0 +version: 1.7.1 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/plugins/modules/nios_host_record.py b/plugins/modules/nios_host_record.py index d633ec7b..e83d53da 100644 --- a/plugins/modules/nios_host_record.py +++ b/plugins/modules/nios_host_record.py @@ -364,6 +364,22 @@ username: admin password: admin connection: local + +- name: Create host record with IPv4 and IPv6 addresses + infoblox.nios_modules.nios_host_record: + name: hostrec.ansible.com + ipv4: + - address: 192.168.10.7 + mac: 12:80:C8:E3:4C:AB + ipv6: + - address: fe80::10 + duid: 12:80:C8:E3:4C:B4 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local ''' RETURN = ''' # '''