diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:03:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:03:42 +0000 |
commit | 66cec45960ce1d9c794e9399de15c138acb18aed (patch) | |
tree | 59cd19d69e9d56b7989b080da7c20ef1a3fe2a5a /ansible_collections/infoblox | |
parent | Initial commit. (diff) | |
download | ansible-66cec45960ce1d9c794e9399de15c138acb18aed.tar.xz ansible-66cec45960ce1d9c794e9399de15c138acb18aed.zip |
Adding upstream version 7.3.0+dfsg.upstream/7.3.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/infoblox')
155 files changed, 14114 insertions, 0 deletions
diff --git a/ansible_collections/infoblox/nios_modules/.github/workflows/ansible-test.yml b/ansible_collections/infoblox/nios_modules/.github/workflows/ansible-test.yml new file mode 100644 index 00000000..e6235107 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/.github/workflows/ansible-test.yml @@ -0,0 +1,200 @@ +name: CI +on: +# Run CI against all pushes (direct commits) and Pull Requests + push: + pull_request: + schedule: + - cron: '0 2 * * 1' + +jobs: + build: + name: Build collection + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ansible-version: [stable-2.10] + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - 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 + + - name: Build a collection tarball + run: ansible-galaxy collection build --output-path "${GITHUB_WORKSPACE}/.cache/collection-tarballs" + + - name: Store migrated collection artifacts + uses: actions/upload-artifact@v1 + with: + name: collection + path: .cache/collection-tarballs + + +### +# Unit tests +# +# https://docs.ansible.com/ansible/latest/dev_guide/testing_units.html + + unit: + name: Unit Tests + needs: [build] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [2.7, 3.8, 3.9] + ansible-version: [stable-2.9, stable-2.10, stable-2.11, stable-2.12, stable-2.13, devel] + exclude: + - ansible-version: devel + python-version: 2.7 + - ansible-version: devel + python-version: 3.8 + - ansible-version: stable-2.12 + python-version: 2.7 + - ansible-version: stable-2.13 + python-version: 2.7 + - ansible-version: stable-2.9 + python-version: 3.9 + + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - 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 + + - name: Download migrated collection artifacts + uses: actions/download-artifact@v1 + with: + name: collection + path: .cache/collection-tarballs + + - 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/ + 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 + - name: Run Unit tests using ansible-test + run: ansible-test units -v --color --python ${{ matrix.python-version }} --coverage + working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ + + - name: Generate coverage report + run: | + if [ "${{ matrix.ansible-version }}" == "devel" ]; 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/ + + +### +# Integration tests +# +# https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html + + integration: + name: Integration tests + needs: [build] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [2.7, 3.8, 3.9] + ansible-version: [stable-2.9, stable-2.10, stable-2.11, stable-2.12, stable-2.13, devel] + exclude: + - ansible-version: stable-2.9 + python-version: 3.9 + steps: + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - name: Check out code + uses: actions/checkout@v2 + + - name: Install ansible-base (${{ matrix.ansible }}) + 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 + with: + name: collection + path: .cache/collection-tarball + + - name: Install the collection tarball + run: ansible-galaxy collection install .cache/collection-tarball/*.tar.gz + + - name: Setup Integration test Pre-requisites + run: | + 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 + + # Run the integration tests + - name: Run integration test + run: | + 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:1.4.0 + working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ + + # ansible-test support producing code coverage date + - name: Generate coverage report + 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 + with: + fail_ci_if_error: false + + +### +# Sanity tests (REQUIRED) +# +# https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html + + sanity: + name: Sanity Tests + runs-on: ubuntu-latest + needs: [build] + strategy: + fail-fast: false + matrix: + ansible-version: [stable-2.9, stable-2.10, stable-2.11, stable-2.12, stable-2.13, devel] + + steps: + - name: Set up Python 3.9 + 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 + + - 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 + + - name: Download migrated collection artifacts + uses: actions/download-artifact@v1 + with: + name: collection + path: .cache/collection-tarballs + + - name: Setup Sanity test Pre-requisites + run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz + + # run ansible-test sanity inside of Docker. + # The docker container has all the pinned dependencies that are required + # and all python versions ansible supports. + - name: Run sanity tests + run: ansible-test sanity --docker -v --color + working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules diff --git a/ansible_collections/infoblox/nios_modules/.gitignore b/ansible_collections/infoblox/nios_modules/.gitignore new file mode 100644 index 00000000..7bbc71c0 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/.gitignore @@ -0,0 +1,101 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/ansible_collections/infoblox/nios_modules/CHANGELOG.rst b/ansible_collections/infoblox/nios_modules/CHANGELOG.rst new file mode 100644 index 00000000..1ad355cb --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/CHANGELOG.rst @@ -0,0 +1,251 @@ +=================================== +Infoblox.Nios_Modules Release Notes +=================================== + +.. contents:: Topics + +v1.4.1 +====== + +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 + +Minor Changes +------------- +- Fix to specify network_view in lookup modules to return absolute network/ip `#157 <https://github.com/infobloxopen/infoblox-ansible/pull/157>`_ +- Fix to camelcase issue for updating 'nios_network_view' name `#163 <https://github.com/infobloxopen/infoblox-ansible/pull/163>`_ +- Fix to allocate ip to a_record dynamically `#163 <https://github.com/infobloxopen/infoblox-ansible/pull/163>`_ +- Fix to update 'nios_a_record' name with multiple ips having same name `#164 <https://github.com/infobloxopen/infoblox-ansible/pull/164>`_ +- Fix to changelog yaml file with linting issues `#161 <https://github.com/infobloxopen/infoblox-ansible/pull/161>`_ + + +v1.4.0 +====== + +Release Summary +--------------- +- For ansible module, added certificate authentication feature +- Few bug fixes in ansible module nios network + +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 <https://github.com/infobloxopen/infoblox-ansible/pull/154>` +- Fix to remove issue causing due to template attr in deleting network using Ansible module nios network `#147 <https://github.com/infobloxopen/infoblox-ansible/pull/147>`_ + + +v1.3.0 +====== + +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 + +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 <https://github.com/infobloxopen/infoblox-ansible/pull/129>`_ +- Update `text` field of TXT Record `#128 <https://github.com/infobloxopen/infoblox-ansible/pull/128>`_ + +Bugfixes +--------- +- Fix to create TXT record with equals sign `#128 <https://github.com/infobloxopen/infoblox-ansible/pull/128>`_ + + +v1.2.2 +====== + +Release Summary +--------------- +- Issue fixes to create PTR record in different network views +- Support extended to determine whether the DTC server is disabled or not + +Minor Changes +------------- +- Fix to create PTR record in different network views `#103 <https://github.com/infobloxopen/infoblox-ansible/pull/103>`_ +- Remove use_option for DHCP option 60 `#104 <https://github.com/infobloxopen/infoblox-ansible/pull/104>`_ +- Allow specifying a template when creating a network `#105 <https://github.com/infobloxopen/infoblox-ansible/pull/105>`_ +- Fix unit and sanity test issues `#117 <https://github.com/infobloxopen/infoblox-ansible/pull/117>`_ +- Expanding for disable value `#119 <https://github.com/infobloxopen/infoblox-ansible/pull/119>`_ + + +v1.2.1 +====== + +Release Summary +--------------- +Added tags to support release on Ansible Automation Hub + +Minor Changes +------------- +Added tags 'cloud' and 'networking' in 'galaxy.yaml' + + +v1.2.0 +====== +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 + +Minor Changes +------------- +- Updated 'required' field in modules `#99 <https://github.com/infobloxopen/infoblox-ansible/pull/99>`_ +- Following options are made required in the modules + +.. list-table:: + :widths: 25 25 + :header-rows: 1 + + * - Record + - Option made required + * - A + - ipv4addr + * - AAAA + - ipv6addr + * - CNAME + - canonical + * - MX + - mail_exchanger, preference + * - PTR + - ptrdname + +Bugfixes +------------- +- nios_a_record module - KeyError: 'old_ipv4addr' `#79 <https://github.com/infobloxopen/infoblox-ansible/issues/79>`_ +- Ansible playbook fails to update canonical name of CName Record `#97 <https://github.com/infobloxopen/infoblox-ansible/pull/97>`_ + + +v1.1.2 +====== +Release Summary +--------------- +- Issue fixes and standardization of inventory plugin and lookup modules as per Ansible guidelines +- Directory restructure and added integration & unit tests + +Minor Changes +------------- +- Changes in inventory and lookup plugins documentation `#85 <https://github.com/infobloxopen/infoblox-ansible/pull/85>`_ +- Directory restructure and added integration & unit tests `#87 <https://github.com/infobloxopen/infoblox-ansible/pull/87>`_ + +Bugfixes +------------- +- Handle NoneType parsing in nios_inventory.py `#81 <https://github.com/infobloxopen/infoblox-ansible/pull/81>`_ +- Check all dhcp options, not just first one `#83 <https://github.com/infobloxopen/infoblox-ansible/pull/83>`_ + + +v1.1.1 +====== +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 + +Minor Changes +------------- +- The modules are standardized as per Ansible guidelines + +Bugfixes +------------- +- Implemented the bugfixes provided by Ansible `community.general` +- Update the name of existing A and AAAA records `#70 <https://github.com/infobloxopen/infoblox-ansible/pull/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"}]``` + `#70 <https://github.com/infobloxopen/infoblox-ansible/pull/70>`_ +- PTR Record failed to update and raises KeyError for view field `#70 <https://github.com/infobloxopen/infoblox-ansible/pull/70>`_ +- Update comment field and delete an existing Fixed Address `#73 <https://github.com/infobloxopen/infoblox-ansible/pull/73>`_ +- GitHub issue fix - Lookup module for next available IPV6 `#31 <https://github.com/infobloxopen/infoblox-ansible/issues/31>`_ +- GitHub issue fix - [nios_zone] changing a nios_zone does not work `#60 <https://github.com/infobloxopen/infoblox-ansible/issues/60>`_ +- GitHub issue fix - Getting an error, running every module `#67 <https://github.com/infobloxopen/infoblox-ansible/issues/67>`_ +- GitHub issue fix - Error - Dictionary Issues `#68 <https://github.com/infobloxopen/infoblox-ansible/issues/68>`_ +- GitHub issue fix - Examples for lookups don't work as written `#72 <https://github.com/infobloxopen/infoblox-ansible/issues/72>`_ +- Sanity fixes as per Ansible guidelines to all modules + + +v1.1.0 +====== + +Release Summary +--------------- + +This release provides plugins for NIOS DTC + +New Modules +----------- + +- infoblox.nios_modules.nios_dtc_lbdn - Configure Infoblox NIOS DTC LBDN +- infoblox.nios_modules.nios_dtc_pool - Configure Infoblox NIOS DTC Pool +- infoblox.nios_modules.nios_dtc_server - Configure Infoblox NIOS DTC Server +- infoblox.nios_modules.nios_restartservices - Restart grid services. + +v1.0.2 +====== + +Release Summary +--------------- + +This release provides compatibilty for Ansible v3.0.0 + +Minor Changes +------------- + +- Fixed the ignored sanity errors required for Ansible 3.0.0 collection +- Made it compatible for Ansible v3.0.0 + +v1.0.1 +====== + +Release Summary +--------------- + +This release provides compatibilty for Ansible v3.0.0 + +Minor Changes +------------- + +- Made it compatible for Ansible v3.0.0 + +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 + +New Plugins +----------- + +Lookup +~~~~~~ + +- infoblox.nios_modules.nios - Query Infoblox NIOS objects +- infoblox.nios_modules.nios_next_ip - Return the next available IP address for a network +- infoblox.nios_modules.nios_next_network - Return the next available network range for a network-container + +New Modules +----------- + +- infoblox.nios_modules.nios_a_record - Configure Infoblox NIOS A records +- infoblox.nios_modules.nios_aaaa_record - Configure Infoblox NIOS AAAA records +- infoblox.nios_modules.nios_cname_record - Configure Infoblox NIOS CNAME records +- infoblox.nios_modules.nios_dns_view - Configure Infoblox NIOS DNS views +- infoblox.nios_modules.nios_fixed_address - Configure Infoblox NIOS DHCP Fixed Address +- infoblox.nios_modules.nios_host_record - Configure Infoblox NIOS host records +- infoblox.nios_modules.nios_member - Configure Infoblox NIOS members +- infoblox.nios_modules.nios_mx_record - Configure Infoblox NIOS MX records +- 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_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 +- infoblox.nios_modules.nios_zone - Configure Infoblox NIOS DNS zones diff --git a/ansible_collections/infoblox/nios_modules/CONTRIBUTING.md b/ansible_collections/infoblox/nios_modules/CONTRIBUTING.md new file mode 100644 index 00000000..436410b8 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# Contributing + +Hello and welcome! Thank you for being interested in contributing to this project. + +First of all get confident with the [Ansible Collections Overview](https://github.com/ansible-collections/overview). + +We accept pull requests for bugfixes, new features, and other improvements, assuming they pass our review. If you are planning a larger feature or refactoring, please create an issue first to discuss it with us. + +## :bug: Reporting an issue + +Please [search in the issue list](https://github.com/infobloxopen/infoblox-ansible/issues) and if has not been already reported, [open a new issue](https://github.com/infobloxopen/infoblox-ansible/issues/new) + +## 🏗 To contribute + +A more extensive walk-through can be found in [Ansible's Contributing to collections](https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html#hacking-collections). + +1. Fork this repo (when checking it out, see [here](https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html#contributing-to-collections) for how to place the checkout correctly) +1. Create a feature branch +1. Commit and push your code. To make the process faster, please ensure: + + - the tests are green. Tests runs using [GitHub Actions](https://help.github.com/en/actions) + - you added a [changelog fragment](https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to) + +Please note that all PRs that are not strictly documentation, testing, or add a new plugin or module, require a changelog fragment. See [Creating a changelog fragment](https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to) for information on that. + +Further resources: + +- [Ansible Developer guide: developing collections](https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html) +- [Ansible Developer guide](https://docs.ansible.com/ansible/latest/dev_guide/index.html) + +This repository adheres to the [Ansible Community code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html) diff --git a/ansible_collections/infoblox/nios_modules/COPYING b/ansible_collections/infoblox/nios_modules/COPYING new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program 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. + + This program 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 this program. If not, see <https://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<https://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<https://www.gnu.org/licenses/why-not-lgpl.html>. diff --git a/ansible_collections/infoblox/nios_modules/FILES.json b/ansible_collections/infoblox/nios_modules/FILES.json new file mode 100644 index 00000000..5446f5dd --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/FILES.json @@ -0,0 +1,1601 @@ +{ + "files": [ + { + "name": ".", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".gitignore", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9cde0277827d89b86382822f9ac4b8519f3db2cf535aab10e5fc931b3a4879f9", + "format": 1 + }, + { + "name": "plugins", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/doc_fragments", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/doc_fragments/nios.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "94f28d629cd27662f493fb392d2ebb05c83e3f308a5e0069ae26a4e452da5c02", + "format": 1 + }, + { + "name": "plugins/lookup", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/lookup/nios_lookup.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b8982cb06294b51bbfc8aa6754077c3f12e1613a8986f0519eb75d895645174b", + "format": 1 + }, + { + "name": "plugins/lookup/nios_next_ip.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a0a81954f6f2d819f76de82c6a5ba98c544f901153b20c804078dc4b97bb2481", + "format": 1 + }, + { + "name": "plugins/lookup/nios_next_network.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e9a8c057f7e902a411772d411ad98436d265c86f73073af61443b6e2c1b7e7e9", + "format": 1 + }, + { + "name": "plugins/module_utils", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/api.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5caef2eadefdce453068614852108a4177cd74be0da6fce0758889ccdc9c8c2c", + "format": 1 + }, + { + "name": "plugins/module_utils/network.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "dced8c65f333a3a101224574c358fa55aa40f2e0e21cfc5f49b64f4bd1ab12d8", + "format": 1 + }, + { + "name": "plugins/inventory", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/inventory/nios_inventory.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8c05e0161380bd212badf22d3004260424d538b7f7674f9eb52d0b2b0d80bcae", + "format": 1 + }, + { + "name": "plugins/README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c82ee692702ec1dd604cdbc38ff252114e5204e1b0627045a66c9451e7a918ac", + "format": 1 + }, + { + "name": "plugins/modules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/modules/nios_network_view.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "60249f22776ba43cbc456c7a305fea55f5c5825a80aa384472d71cd8b58b4924", + "format": 1 + }, + { + "name": "plugins/modules/nios_srv_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8d220967209c16b4edc94f9ab8d1e2e7c9f1984a9239df3f8b3c7734edccdd17", + "format": 1 + }, + { + "name": "plugins/modules/nios_naptr_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "05fcfda337dd1408c3bd622c0032efb2b4fe3c0c8b4f9e0da79b2a17e7718250", + "format": 1 + }, + { + "name": "plugins/modules/nios_dns_view.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e762c774e13ddcd2e12d7df728bcf8c6c572eaff7cf4819f2aa822b078db7b7d", + "format": 1 + }, + { + "name": "plugins/modules/nios_network.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f30befbfba62d0ea58a59121bf5d856c08576c1f7dc1771d25cec81a4c1b9258", + "format": 1 + }, + { + "name": "plugins/modules/nios_a_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "098d4de36c1ca5b71af73d57a198ef707498017c5607941cd938ca48921cb269", + "format": 1 + }, + { + "name": "plugins/modules/nios_zone.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4f3a1763e347e5fdaf55d7ae7ed1c1d2bf937b645b25023f5317869fac56107c", + "format": 1 + }, + { + "name": "plugins/modules/nios_cname_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "85c3a554eddd72cd08cee90b783ec56ffd70466c68c9cc60e0c2591f6722d6f1", + "format": 1 + }, + { + "name": "plugins/modules/nios_restartservices.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c5f2b010272ca85393050f85cc6c36b2c8b973965e70fa114388838164ae92a4", + "format": 1 + }, + { + "name": "plugins/modules/nios_fixed_address.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6d16da939f573934520c585c6fcf38c7bb8de40b5f43ffca6dd0563c2fa75935", + "format": 1 + }, + { + "name": "plugins/modules/nios_dtc_server.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4977aa719a713e9b6d68732a28ad84cc54aa5fd9d3d53a45f07d74ac1cf92a86", + "format": 1 + }, + { + "name": "plugins/modules/nios_member.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3643fdf1c188ef8d5584f787e4ce7cf8bea277a0a93d9a715cb3e3b6aad65da", + "format": 1 + }, + { + "name": "plugins/modules/nios_ptr_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a5cdd84504c3183b7b83c592e662cb0950fae8b0efa29836366dcd1445f9caf6", + "format": 1 + }, + { + "name": "plugins/modules/nios_dtc_lbdn.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "de73793e44a144dd9cfedae4e4de9e64931e55e5e8bc05784c1ffb341c239293", + "format": 1 + }, + { + "name": "plugins/modules/nios_nsgroup.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f75be0f86aa6fe535cbcee064ba4f77db1a74c912fae0cb79d3c9238e14d7014", + "format": 1 + }, + { + "name": "plugins/modules/nios_aaaa_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1cba14889411e1ad1c634ea391c99b8a3fd0c40219e9d440bb63cc7cdc42f496", + "format": 1 + }, + { + "name": "plugins/modules/nios_mx_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4b0573f4f57a5ed22ebef5c4f5e0dd22eb228d833fbd1351ef4a48e9c7326284", + "format": 1 + }, + { + "name": "plugins/modules/nios_dtc_pool.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "284caec37488fde49bad0451d9bf0b5c3a5c1bef3ab0652e96c1dcb981e59887", + "format": 1 + }, + { + "name": "plugins/modules/nios_host_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e6784e231f0b78340516b8ec5d45f6e100cc82e80b5ead94cdae6c36bfda063c", + "format": 1 + }, + { + "name": "plugins/modules/nios_txt_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "044cef98685547f09d8c3aad87784c5b47e743507243e1e03160d85f7dedd833", + "format": 1 + }, + { + "name": "requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "55fb25c4faa774de799493c0f9ca57dae363e19d91e1358131ec9a0cc326f1e9", + "format": 1 + }, + { + "name": ".github", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/workflows", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/workflows/ansible-test.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7cb4cc28ab268c0318231914511e5b976b2998466358fcc66887b0b8fc13168a", + "format": 1 + }, + { + "name": "playbooks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "playbooks/create_txt_record.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "111d1ce384d339af78c3e8daae32e7deda1b9cb62f08023733ea8e693586dc0d", + "format": 1 + }, + { + "name": "playbooks/delete_zone.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "61e5e563e04d918cc76bac07f0ce374bf3796ecb63ea75257d976376c4157c20", + "format": 1 + }, + { + "name": "playbooks/delete_txt_record.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f72cdc6c618cd7e75a1a1063d5cba782af5fcb07c226e91c2535ac8ff113150f", + "format": 1 + }, + { + "name": "playbooks/create_cname_record.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10e363c89e5d82b68d4f63ed529282de833b7951b12b9a97f5469d580b24b576", + "format": 1 + }, + { + "name": "playbooks/create_network_view.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7fc8ebffa421f96e493531d3436d6fa73fe741a55746e669e8c89a1ff9ff030d", + "format": 1 + }, + { + "name": "playbooks/delete_dnsview.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "37deda100ff17068ff552ba5e1e74b9fad1394ebe2db62e7f2adad294c1affc6", + "format": 1 + }, + { + "name": "playbooks/restart_services.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5dcc9476be118206220829486758c5465cd784a95b66550a414f9004907bc3c1", + "format": 1 + }, + { + "name": "playbooks/delete_mx_record.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "da47165c799c1e87329ccf9461c4681b4245f097b55d3d62dba411edd3e25da5", + "format": 1 + }, + { + "name": "playbooks/create_mx_record.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b9ae5787aaf298aeaa8b5d7f768402f0f50065699938a3eb5eaacbd7bce1ce8d", + "format": 1 + }, + { + "name": "playbooks/create_dtc_server.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e4a00c5e95b6476e354b5564c874eff4e38b9fd92d71dc921677b689213b9199", + "format": 1 + }, + { + "name": "playbooks/create_dns_view.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cd1b9dc35122024065dacfff26cc6a690c677d44f4a047d2a661618d71b409a6", + "format": 1 + }, + { + "name": "playbooks/create_network.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4786f86ec3ed73faf52441b153f81eaf5020907be7cce195cec049e6abbef51e", + "format": 1 + }, + { + "name": "playbooks/update_a_record.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2d74da9f596d41369eb8859bb6a628662b573f695d3326a587c5683d4a2e90b3", + "format": 1 + }, + { + "name": "playbooks/create_a_record.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ace1f52c338c1f9032444ed75f51ef2e8ded43e30fd6af74461b27266900e6bf", + "format": 1 + }, + { + "name": "playbooks/delete_network_view.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c9fbcaff43e867ffc8a9d8cb8e6a3dc92d1af8c92fb96cbd887655e8cadb0971", + "format": 1 + }, + { + "name": "playbooks/create_dtc_lbdn.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "17840632d509d7e87e5af56b654c7df3cc6ebd92f25d4f86a4c46cbce6ff7edd", + "format": 1 + }, + { + "name": "playbooks/create_zone.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1d94121423e1184461a55897c7427e7cfd1a242fbfd4709e99c61d16025556d7", + "format": 1 + }, + { + "name": "playbooks/delete_cname_record.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c04b11f344bfd49f03995665d553e5a008975067010554fd9f1f1a161b7796ae", + "format": 1 + }, + { + "name": "playbooks/create_dtc_pool.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5d39c51ed9d38d8a1fa9f6c9968203ef1633dce612ff0fcd46706fa6c3969796", + "format": 1 + }, + { + "name": "playbooks/delete_network.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4577274aa1bba6a8450e1c534ee8c97cbab9b47b2339f6f2f7cce4f79124ad36", + "format": 1 + }, + { + "name": "changelogs", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "changelogs/config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "44e348d60d00b2812b8cb8aba66308db03d0c83b228611759a2630240b29dfdf", + "format": 1 + }, + { + "name": "changelogs/changelog.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0ec8d5b4ad41682e233ca578bbaafa5556a049c3900e1c18fb76612048e55e43", + "format": 1 + }, + { + "name": "changelogs/.plugin-cache.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fb49b92734edb8224cc865269784f571d5edf629123137471917df284ee32b53", + "format": 1 + }, + { + "name": "tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f1d4cbfb694f6fe029ac69b53766a557c3c91f82efe8cc4540c483bda5d4d329", + "format": 1 + }, + { + "name": "tests/integration", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_cname_record", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_cname_record/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_cname_record/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_cname_record/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "665288590cd4226da42511817f09ccdfc92df36c9621583cd2c82919af295c5a", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_cname_record/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_cname_record/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f6641fa60f8ba09c7ce762c2ef3514012995ac5302b4864a10e6aa0f1c83d512", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_cname_record/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_cname_record/tasks/nios_cname_record_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6e5e3f2f0b5ed874e855b9122802b8706faa49150d1d8d4fe2e9d46a535f754e", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_cname_record/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "787a53293d68001b9cccea1154d4c6b4c6277aa52df187ef6b7ecb4e519e5a65", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_aaaa_record", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_aaaa_record/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_aaaa_record/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_aaaa_record/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "665288590cd4226da42511817f09ccdfc92df36c9621583cd2c82919af295c5a", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_aaaa_record/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_aaaa_record/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f6641fa60f8ba09c7ce762c2ef3514012995ac5302b4864a10e6aa0f1c83d512", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_aaaa_record/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_aaaa_record/tasks/nios_aaaa_record_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9b7293e35f42a9951679d1eb30c0a73c5b20e8563373e81e77ef4ef149145abe", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_aaaa_record/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "51f2c8c8d2bf554c82d3ef5a8158377adadd87b71b6de8bc09a360e9ff1f5524", + "format": 1 + }, + { + "name": "tests/integration/targets/prepare_nios_tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/prepare_nios_tests/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/prepare_nios_tests/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7f6b41fc52044ee283bfaa36506ad6e8e63e40abb080d4d955b57682c0c5a895", + "format": 1 + }, + { + "name": "tests/integration/targets/prepare_nios_tests/tasks/prepare_nios_tests_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9f7ef612d02c82d058380d8a5db2a7f593236034fc83da2b78165186ebb7a095", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9b2c007ef16bd19c23982f22d955c1cebe881731f8e06615c9a8fb2985604cc4", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0e8b1f0c838de0cea2151ce497b6d631b0aefda15731e2eb6bc0daefdab3774f", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "11b1faac4c49c5acbace378328c5fea92014f667d732dbe2ef2a2583f826dc82", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_a_record", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_a_record/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_a_record/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_a_record/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "665288590cd4226da42511817f09ccdfc92df36c9621583cd2c82919af295c5a", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_a_record/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_a_record/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f6641fa60f8ba09c7ce762c2ef3514012995ac5302b4864a10e6aa0f1c83d512", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_a_record/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_a_record/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5d15dab6a8d8e6b40ac5147025cb8a316ebff5b5822d2305a7fa768ba209f894", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_a_record/tasks/nios_a_record_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ce6edea9daaa81eaeabe5c9565437f59744da7eefe0834b66a35fdba9408a3c5", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_dns_view", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_dns_view/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_dns_view/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_dns_view/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3cb79c3d80cffc120afea8cc796848a327b790dbe8b6702bd51c1e2a5d82d906", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_dns_view/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_dns_view/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9b2c007ef16bd19c23982f22d955c1cebe881731f8e06615c9a8fb2985604cc4", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_dns_view/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_dns_view/tasks/nios_dns_view_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "35a60985b368995a2347da83a8cbb30217cf2d5a3b71204e40f626ef13d228bb", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_dns_view/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ba5bfe201c74edd65e1df617cad400bd2634d1bf5c9b6b66a22108e73566ebd2", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_ptr_record", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_ptr_record/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_ptr_record/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_ptr_record/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "665288590cd4226da42511817f09ccdfc92df36c9621583cd2c82919af295c5a", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_ptr_record/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_ptr_record/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f6641fa60f8ba09c7ce762c2ef3514012995ac5302b4864a10e6aa0f1c83d512", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_ptr_record/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_ptr_record/tasks/nios_ptr_record_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d963d7efe7113cc92ab45fc5bca5faafd1aa713346558b43004aedd684725019", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_ptr_record/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "964ab01e8de80401c3d083286c2fa5e85c13d8a80a9209433c44c6b8adb5f05e", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_srv_record", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_srv_record/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_srv_record/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_srv_record/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "665288590cd4226da42511817f09ccdfc92df36c9621583cd2c82919af295c5a", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_srv_record/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_srv_record/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f6641fa60f8ba09c7ce762c2ef3514012995ac5302b4864a10e6aa0f1c83d512", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_srv_record/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_srv_record/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d9588a0ae488ec618c82e823db100269d87978fc7336ed1d41ac282f40603483", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_srv_record/tasks/nios_srv_record_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "983b84f88a05dc722a0ef22e4a2deea656cf9425f86a40d10abe1c3d91cfe51d", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_txt_record", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_txt_record/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_txt_record/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_txt_record/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3cb79c3d80cffc120afea8cc796848a327b790dbe8b6702bd51c1e2a5d82d906", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_txt_record/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_txt_record/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9b2c007ef16bd19c23982f22d955c1cebe881731f8e06615c9a8fb2985604cc4", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_txt_record/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_txt_record/tasks/nios_txt_record_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c357b3236a490bbb05bf10f0bd9965882d4ffff7d48f0d8df059335c4c55227c", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_txt_record/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6143fed0b778a7af1a4f8f7d7c6da63e07dcb162dd794b861b2582c1c48a8854", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network_view", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network_view/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network_view/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network_view/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3cb79c3d80cffc120afea8cc796848a327b790dbe8b6702bd51c1e2a5d82d906", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network_view/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network_view/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9b2c007ef16bd19c23982f22d955c1cebe881731f8e06615c9a8fb2985604cc4", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network_view/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network_view/tasks/nios_network_view_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0988d75d8debe3ad04f656d77c22cff648214fff669323be2ae1d1707dfd06f1", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_network_view/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2e3e46fde3dbeb3ae613631df0384134902707bd5511c6dbb4f04ceca4abc714", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_zone", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_zone/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_zone/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_zone/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3cb79c3d80cffc120afea8cc796848a327b790dbe8b6702bd51c1e2a5d82d906", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_zone/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_zone/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9b2c007ef16bd19c23982f22d955c1cebe881731f8e06615c9a8fb2985604cc4", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_zone/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_zone/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "321785ddd2789cc1265b9502c5463bd9c4979267ae0be21558ea5eec4eceed72", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_zone/tasks/nios_zone_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "22e69c13af0623593d880c24015f6b8990c8d3d8f03bc887d10dca8972b76d0c", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_naptr_record", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_naptr_record/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_naptr_record/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_naptr_record/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "665288590cd4226da42511817f09ccdfc92df36c9621583cd2c82919af295c5a", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_naptr_record/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_naptr_record/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f6641fa60f8ba09c7ce762c2ef3514012995ac5302b4864a10e6aa0f1c83d512", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_naptr_record/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_naptr_record/tasks/nios_naptr_record_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "943fccfaaab7641fff4e8d2f809830fd3d266504e5a093ba19423fb79c3ac363", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_naptr_record/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f8c01642191a24501d81753c5cb8af0ab2b6962482903560d2547119686232a1", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_mx_record", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_mx_record/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_mx_record/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_mx_record/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "665288590cd4226da42511817f09ccdfc92df36c9621583cd2c82919af295c5a", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_mx_record/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_mx_record/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f6641fa60f8ba09c7ce762c2ef3514012995ac5302b4864a10e6aa0f1c83d512", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_mx_record/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_mx_record/tasks/nios_mx_record_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8082362994c85378fd9c5b26cad32f583dc83d84d5f83527fb905c401946e65a", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_mx_record/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3a2d3fb34b2974e819a3401ab9bc26576b2be2f1b2e3f3c428cb78039bc21f98", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_host_record", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_host_record/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2aba930fc2918934f7b9bdff17f9f99ab65167a6e9e41a0c9f45fffb31eaef0", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_host_record/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_host_record/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3cb79c3d80cffc120afea8cc796848a327b790dbe8b6702bd51c1e2a5d82d906", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_host_record/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_host_record/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9b2c007ef16bd19c23982f22d955c1cebe881731f8e06615c9a8fb2985604cc4", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_host_record/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2c6efd391e887105cc040b3dfc42ed5e8ce4ce3bafaba8ccd2377292a27de8c5", + "format": 1 + }, + { + "name": "tests/integration/targets/nios_host_record/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d6fddc4c90cd988fc0533529f29845b018b09d228e0079c37d7a938399d10480", + "format": 1 + }, + { + "name": "tests/unit", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/plugins", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/plugins/module_utils", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/plugins/module_utils/test_api.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "78cfcf64d2ba488d15e770dae5ea42f30643a77ed0780d14df66eefd3c8a2af0", + "format": 1 + }, + { + "name": "tests/unit/plugins/module_utils/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/plugins/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_naptr_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "95b80c1e4a02a4035952c7fd0f1ef5de4cd4665773cd1b56d88595eafcc5f2c0", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_srv_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bb147e9fcf3f5918b1c068af3a40d21dfeacdffc190c25d0951a190d3961bb93", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_aaaa_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "add3503be1f73a5eaf32e3e62fb70265e98bfee63cd6fefa0a8eec8dee4b3e3b", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_cname_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7c5e930a07686e4b0aee8f1469eec587dc2e06466f5724e626156b396e150708", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_zone.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbb7b98c199a0f7bb1c50e2e21e2a3353aa37c7ff9a676cf9194e4e659510710", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_nsgroup.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b8aeca79a11e3be969f82e845a712f1eb86ea8e562f91a10a008952226271186", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_host_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "07e4fc0b0abfb0bb6fa8c3a68eafe79635ea0e687b96fbaa1f2a776ceee84588", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_network.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "94bdde6ba5224d532a22d37b26f1b2398c42d4fd315a040a32fc61f9b91ff1ec", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_member.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bd0b8081e628d0112da7ba69398de00d7cdd9afa6ba1bd34ccbd9ae513b11285", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_a_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7da0ed2bbfdc92f9db397be48e201fb4d8bd67ac7069d5e457d0ad1e46bdcc97", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_fixed_address.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e6dc2a63173e9af0fa27a50f1ac4b524718eef99d0ae062fb7b8de1fe0a970da", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_mx_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a6a64554903eff210c9392ff0f66b3ca41a7accc9cc5d427f5723e899b283ef4", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_dns_view.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "832fd1e4f3bce40833e99466c2dab63930a321dd32250bd326c33d0d8cd919fc", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_network_view.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f9a94a50ee09d4f42755f1ce5d6ed87158825eec35b958e390ace6fcaa830378", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/fixtures", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/fixtures/nios_result.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_ptr_record.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e5388b813fc6c70b53545d05ec18792ed258e966f3e712ee78de0fd29f90dde1", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/utils.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3ebeccd641cf5de2b25ae1bf4e153492bb499c641c5b5465ca25168f08b1a1ac", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_nios_module.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c733e6ebea7febb7eab14e589c489aed9f5e6d6e188d85556d6d4d1b754f5b67", + "format": 1 + }, + { + "name": "tests/unit/requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c1b6aded0bacf264f0dcee417363adcb09fac038946bf434ae1c8a5f56a964a8", + "format": 1 + }, + { + "name": "tests/unit/compat", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/compat/mock.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e18448d2582e03b3c782d3f5039907f364b852021f8033951f5abbdcd5e07d7a", + "format": 1 + }, + { + "name": "tests/unit/compat/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "meta/runtime.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "df18179bb2f5447a56ac92261a911649b96821c0b2c08eea62d5cc6b0195203f", + "format": 1 + }, + { + "name": "CONTRIBUTING.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fd88c8b2920fd2d659c1ee76d5709c61a3d68e4af1c21a156670a5f543dc26ef", + "format": 1 + }, + { + "name": "README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "02b63d779ec8985281e1e2858d00bbdb919e5517aad637e8634d1971f8530cfd", + "format": 1 + }, + { + "name": "COPYING", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986", + "format": 1 + }, + { + "name": "CHANGELOG.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "479e7ae0fd077a8adcb801df27be0773976b4058c658fb3a1a79b1a9e4d06221", + "format": 1 + } + ], + "format": 1 +}
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/MANIFEST.json b/ansible_collections/infoblox/nios_modules/MANIFEST.json new file mode 100644 index 00000000..166a335c --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/MANIFEST.json @@ -0,0 +1,38 @@ +{ + "collection_info": { + "namespace": "infoblox", + "name": "nios_modules", + "version": "1.4.1", + "authors": [ + "Sailesh Giri (sgiri@infoblox.com)", + "Vaishnavi TR (vtr@infoblox.com)", + "Anagha KH (akh@infoblox.com)", + "Shankar Ganesh (sganesh@infoblox.com)" + ], + "readme": "README.md", + "tags": [ + "infoblox", + "nios", + "cloud", + "networking" + ], + "description": "Infoblox Ansible Collection for vNIOS allows managing your NIOS objects through APIs.", + "license": [ + "GPL-3.0-only" + ], + "license_file": null, + "dependencies": {}, + "repository": "https://github.com/infobloxopen/infoblox-ansible/tree/master", + "documentation": "https://github.com/infobloxopen/infoblox-ansible/blob/master/README.md", + "homepage": "https://github.com/infobloxopen/infoblox-ansible", + "issues": "https://github.com/infobloxopen/infoblox-ansible/issues" + }, + "file_manifest_file": { + "name": "FILES.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "322c0c8f3d92585641eade44b5d87df7c96cc3ee1b0a913a54732b73f325ba6f", + "format": 1 + }, + "format": 1 +}
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/README.md b/ansible_collections/infoblox/nios_modules/README.md new file mode 100644 index 00000000..131aaa2b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/README.md @@ -0,0 +1,209 @@ +# Infoblox NIOS Modules for Ansible Collections + +About +====== + +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`. + +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_pool` – Configure Infoblox NIOS DTC pools + +- `nios_dtc_server` – Configure Infoblox NIOS DTC server records + +- `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 Nameserver Groups + +- `nios_ptr_record` – Configure Infoblox NIOS PTR records + +- `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`: Returns the next available IP address for a network + +- `nios_next_network`: Returns the next available network addresses + for a given network CIDR + +Installation +============= + +Dependencies +------------ + +- Python version 2.7 or later + +- Ansible version 2.9.0 or later + +- NIOS 8.2.4 or later + +Prerequisites +------------- + +Install the infoblox-client WAPI package. To install, run the following command: + +```shell +$ pip install infoblox-client +``` + +Installation of nios_modules Collection +---------------------------------------- + +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. + +### 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-<version>.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 + ``` + +- For offline installation on the Ansible control machine, to git clone and install from this repo, follow these steps: + + - **Clone the repo:** + + ``` + $ git clone https://github.com/infobloxopen/infoblox-ansible.git + ``` + + - **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. + + - **Install the collection:** + + ``` + $ ansible-galaxy collection install infoblox-nios_modules-<version>.tar.gz -p ./collections + ``` + +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. + +Playbooks +========= +Latest sample playbooks and examples are available at [playbooks](https://github.com/infobloxopen/infoblox-ansible/tree/master/playbooks). + + +Releasing +========= + +Next release +--------------- + +Dates TBD + +Current release +--------------- + +1.4.1 on 24 November 2022 + +Versioning +========= + +- 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.) + +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. + +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. + +Resources +========= + +- Infoblox [NIOS + modules](https://docs.ansible.com/ansible/latest/scenario_guides/guide_infoblox.html) + on Ansible documentation + +- Infoblox [workspace](https://galaxy.ansible.com/infoblox) in Ansible + Galaxy + +- Infoblox Ansible [deployment + guide](https://www.infoblox.com/wp-content/uploads/infoblox-deployment-guide-automate-infoblox-infrastructure-using-ansible.pdf) + +License +======= + +This code is published under `GPL v3.0` + +[COPYING](https://github.com/infobloxopen/infoblox-ansible/blob/master/COPYING) + +Issues or RFEs +=============== +You can open an issue or request for enhancement +[here](https://github.com/infobloxopen/infoblox-ansible/issues) diff --git a/ansible_collections/infoblox/nios_modules/changelogs/.plugin-cache.yaml b/ansible_collections/infoblox/nios_modules/changelogs/.plugin-cache.yaml new file mode 100644 index 00000000..4eba71a2 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/changelogs/.plugin-cache.yaml @@ -0,0 +1,131 @@ +plugins: + become: {} + cache: {} + callback: {} + cliconf: {} + connection: {} + httpapi: {} + inventory: + nios_inventory: + description: Infoblox inventory plugin + name: nios_inventory + version_added: 1.0.0 + lookup: + nios_lookup: + description: Query Infoblox NIOS objects + name: nios_lookup + version_added: 1.0.0 + nios_next_ip: + description: Return the next available IP address for a network + name: nios_next_ip + version_added: 1.0.0 + nios_next_network: + description: Return the next available network range for a network-container + name: nios_next_network + version_added: 1.0.0 + module: + nios_a_record: + description: Configure Infoblox NIOS A records + name: nios_a_record + namespace: '' + version_added: 1.0.0 + nios_aaaa_record: + description: Configure Infoblox NIOS AAAA records + name: nios_aaaa_record + namespace: '' + version_added: 1.0.0 + nios_cname_record: + description: Configure Infoblox NIOS CNAME records + name: nios_cname_record + namespace: '' + version_added: 1.0.0 + nios_dns_view: + description: Configure Infoblox NIOS DNS views + name: nios_dns_view + namespace: '' + version_added: 1.0.0 + nios_dtc_lbdn: + description: Configure Infoblox NIOS DTC LBDN + name: nios_dtc_lbdn + namespace: '' + version_added: 1.1.0 + nios_dtc_pool: + description: Configure Infoblox NIOS DTC Pool + name: nios_dtc_pool + namespace: '' + version_added: 1.1.0 + nios_dtc_server: + description: Configure Infoblox NIOS DTC Server + name: nios_dtc_server + namespace: '' + version_added: 1.1.0 + nios_fixed_address: + description: Configure Infoblox NIOS DHCP Fixed Address + name: nios_fixed_address + namespace: '' + version_added: 1.0.0 + nios_host_record: + description: Configure Infoblox NIOS host records + name: nios_host_record + namespace: '' + version_added: 1.0.0 + nios_member: + description: Configure Infoblox NIOS members + name: nios_member + namespace: '' + version_added: 1.0.0 + nios_mx_record: + description: Configure Infoblox NIOS MX records + name: nios_mx_record + namespace: '' + version_added: 1.0.0 + nios_naptr_record: + description: Configure Infoblox NIOS NAPTR records + name: nios_naptr_record + namespace: '' + version_added: 1.0.0 + nios_network: + description: Configure Infoblox NIOS network object + name: nios_network + namespace: '' + version_added: 1.0.0 + nios_network_view: + description: Configure Infoblox NIOS network views + name: nios_network_view + namespace: '' + version_added: 1.0.0 + nios_nsgroup: + description: Configure InfoBlox DNS Nameserver Groups + name: nios_nsgroup + namespace: '' + version_added: 1.0.0 + nios_ptr_record: + description: Configure Infoblox NIOS PTR records + name: nios_ptr_record + namespace: '' + version_added: 1.0.0 + nios_restartservices: + description: Restart grid services. + name: nios_restartservices + namespace: '' + version_added: 1.1.0 + nios_srv_record: + description: Configure Infoblox NIOS SRV records + name: nios_srv_record + namespace: '' + version_added: 1.0.0 + nios_txt_record: + description: Configure Infoblox NIOS txt records + name: nios_txt_record + namespace: '' + version_added: 1.0.0 + nios_zone: + description: Configure Infoblox NIOS DNS zones + name: nios_zone + namespace: '' + version_added: 1.0.0 + netconf: {} + shell: {} + strategy: {} + vars: {} +version: 1.4.1 diff --git a/ansible_collections/infoblox/nios_modules/changelogs/changelog.yaml b/ansible_collections/infoblox/nios_modules/changelogs/changelog.yaml new file mode 100644 index 00000000..7c752c2c --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/changelogs/changelog.yaml @@ -0,0 +1,200 @@ +ancestor: null +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 ' + 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: '' + 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' + 1.0.1: + changes: + minor_changes: + - Made it compatible for Ansible v3.0.0 + release_summary: This release provides compatibilty for Ansible v3.0.0 + 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 + release_summary: This release provides compatibilty for Ansible v3.0.0 + 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' + 1.1.1: + changes: + bugfixes: + - Implemented the bugfixes provided by Ansible `community.general` + - Update the name of existing A and AAAA records `#70 <https://github.com/infobloxopen/infoblox-ansible/pull/70>`_ + - Update of comment field of SRV, PTR and NAPTR records failing with the following error `#70 <https://github.com/infobloxopen/infoblox-ansible/pull/70>`_ + - PTR Record failed to update and raises KeyError for view field `#70 <https://github.com/infobloxopen/infoblox-ansible/pull/70>`_ + - Update comment field and delete an existing Fixed Address `#73 <https://github.com/infobloxopen/infoblox-ansible/pull/73>`_ + - GitHub issue fix - Lookup module for next available IPV6 `#31 <https://github.com/infobloxopen/infoblox-ansible/issues/31>`_ + - GitHub issue fix - [nios_zone] changing a nios_zone does not work `#60 <https://github.com/infobloxopen/infoblox-ansible/issues/60>`_ + - GitHub issue fix - Getting an error, running every module `#67 <https://github.com/infobloxopen/infoblox-ansible/issues/67>`_ + - GitHub issue fix - Error - Dictionary Issues `#68 <https://github.com/infobloxopen/infoblox-ansible/issues/68>`_ + - GitHub issue fix - Examples for lookups don't work as written `#72 <https://github.com/infobloxopen/infoblox-ansible/issues/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' + 1.1.2: + changes: + bugfixes: + - Handle NoneType parsing in nios_inventory.py `#81 <https://github.com/infobloxopen/infoblox-ansible/pull/81>`_ + - Check all dhcp options, not just first one `#83 <https://github.com/infobloxopen/infoblox-ansible/pull/83>`_ + minor_changes: + - Changes in inventory and lookup plugins documentation `#85 <https://github.com/infobloxopen/infoblox-ansible/pull/85>`_ + - Directory restructure and added integration & unit tests `#87 <https://github.com/infobloxopen/infoblox-ansible/pull/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 <https://github.com/infobloxopen/infoblox-ansible/issues/79>`_ + - Ansible playbook fails to update canonical name of CName Record `#97 <https://github.com/infobloxopen/infoblox-ansible/pull/97>`_ + minor_changes: + - Updated 'required' field in modules `#99 <https://github.com/infobloxopen/infoblox-ansible/pull/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' + + 1.2.2: + changes: + minor_changes: + - Fix to create PTR record in different network views `#103 <https://github.com/infobloxopen/infoblox-ansible/pull/103>`_ + - Remove use_option for DHCP option 60 `#104 <https://github.com/infobloxopen/infoblox-ansible/pull/104>`_ + - Allow specifying a template when creating a network `#105 <https://github.com/infobloxopen/infoblox-ansible/pull/105>`_ + - Fix unit and sanity test issues `#117 <https://github.com/infobloxopen/infoblox-ansible/pull/117>`_ + - Expanding for disable value `#119 <https://github.com/infobloxopen/infoblox-ansible/pull/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 <https://github.com/infobloxopen/infoblox-ansible/pull/129>`_ + - Update `text` field of TXT Record `#128 <https://github.com/infobloxopen/infoblox-ansible/pull/128>`_ + bugfixes: + - Fix to create TXT record with equals sign `#128 <https://github.com/infobloxopen/infoblox-ansible/pull/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 <https://github.com/infobloxopen/infoblox-ansible/pull/154>`_ + - Fix to remove issue causing due to template attr in deleting network using Ansible module nios network `#147 <https://github.com/infobloxopen/infoblox-ansible/pull/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 <https://github.com/infobloxopen/infoblox-ansible/pull/157>`_ + - Fix to camelcase issue for updating 'nios_network_view' name `#163 <https://github.com/infobloxopen/infoblox-ansible/pull/163>`_ + - Fix to allocate ip to a_record dynamically `#163 <https://github.com/infobloxopen/infoblox-ansible/pull/163>`_ + - Fix to update 'nios_a_record' name with multiple ips having same name `#164 <https://github.com/infobloxopen/infoblox-ansible/pull/164>`_ + - Fix to changelog yaml file with linting issues `#161 <https://github.com/infobloxopen/infoblox-ansible/pull/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' diff --git a/ansible_collections/infoblox/nios_modules/changelogs/config.yaml b/ansible_collections/infoblox/nios_modules/changelogs/config.yaml new file mode 100644 index 00000000..09a1f378 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/changelogs/config.yaml @@ -0,0 +1,32 @@ +changelog_filename_template: ../CHANGELOG.rst +changelog_filename_version_depth: 0 +changes_file: changelog.yaml +changes_format: combined +ignore_other_fragment_extensions: true +keep_fragments: false +mention_ancestor: true +new_plugins_after_name: removed_features +notesdir: fragments +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 +title: Infoblox.Nios_Modules +trivial_section_name: trivial +use_fqcn: true diff --git a/ansible_collections/infoblox/nios_modules/meta/runtime.yml b/ansible_collections/infoblox/nios_modules/meta/runtime.yml new file mode 100644 index 00000000..2ee3c9fa --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/meta/runtime.yml @@ -0,0 +1,2 @@ +--- +requires_ansible: '>=2.9.10' diff --git a/ansible_collections/infoblox/nios_modules/playbooks/create_a_record.yaml b/ansible_collections/infoblox/nios_modules/playbooks/create_a_record.yaml new file mode 100644 index 00000000..29245981 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/create_a_record.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 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/ansible_collections/infoblox/nios_modules/playbooks/create_cname_record.yaml b/ansible_collections/infoblox/nios_modules/playbooks/create_cname_record.yaml new file mode 100644 index 00000000..1c59c7a6 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/create_cname_record.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 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/ansible_collections/infoblox/nios_modules/playbooks/create_dns_view.yml b/ansible_collections/infoblox/nios_modules/playbooks/create_dns_view.yml new file mode 100644 index 00000000..834a7c9a --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/create_dns_view.yml @@ -0,0 +1,20 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + 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 }}" diff --git a/ansible_collections/infoblox/nios_modules/playbooks/create_dtc_lbdn.yml b/ansible_collections/infoblox/nios_modules/playbooks/create_dtc_lbdn.yml new file mode 100644 index 00000000..9cbf3ad2 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/create_dtc_lbdn.yml @@ -0,0 +1,29 @@ +--- +- hosts: localhost + vars: + nios_provider: + host: 10.196.205.10 + username: cloudadmin + password: infoblox + wapi_version: "2.12" + + 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 }}" +... diff --git a/ansible_collections/infoblox/nios_modules/playbooks/create_dtc_pool.yml b/ansible_collections/infoblox/nios_modules/playbooks/create_dtc_pool.yml new file mode 100644 index 00000000..96a59f29 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/create_dtc_pool.yml @@ -0,0 +1,25 @@ +--- +- hosts: localhost + vars: + nios_provider: + host: 10.196.205.10 + username: cloudadmin + password: infoblox + wapi_version: "2.12" + + 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 }}" +... diff --git a/ansible_collections/infoblox/nios_modules/playbooks/create_dtc_server.yml b/ansible_collections/infoblox/nios_modules/playbooks/create_dtc_server.yml new file mode 100644 index 00000000..dd0c0388 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/create_dtc_server.yml @@ -0,0 +1,19 @@ +--- +- hosts: localhost + vars: + nios_provider: + host: 10.196.205.10 + username: cloudadmin + password: infoblox + wapi_version: "2.12" + + 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 }}" +... diff --git a/ansible_collections/infoblox/nios_modules/playbooks/create_mx_record.yaml b/ansible_collections/infoblox/nios_modules/playbooks/create_mx_record.yaml new file mode 100644 index 00000000..ac8c8f34 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/create_mx_record.yaml @@ -0,0 +1,20 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + 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 }}" diff --git a/ansible_collections/infoblox/nios_modules/playbooks/create_network.yml b/ansible_collections/infoblox/nios_modules/playbooks/create_network.yml new file mode 100644 index 00000000..c309105f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/create_network.yml @@ -0,0 +1,23 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + 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 }}" diff --git a/ansible_collections/infoblox/nios_modules/playbooks/create_network_view.yml b/ansible_collections/infoblox/nios_modules/playbooks/create_network_view.yml new file mode 100644 index 00000000..ca372187 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/create_network_view.yml @@ -0,0 +1,19 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + 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 }}" diff --git a/ansible_collections/infoblox/nios_modules/playbooks/create_txt_record.yaml b/ansible_collections/infoblox/nios_modules/playbooks/create_txt_record.yaml new file mode 100644 index 00000000..d0a28058 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/create_txt_record.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 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/ansible_collections/infoblox/nios_modules/playbooks/create_zone.yml b/ansible_collections/infoblox/nios_modules/playbooks/create_zone.yml new file mode 100644 index 00000000..63b874e2 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/create_zone.yml @@ -0,0 +1,21 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + wapi_version: 2.1 + + 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 }}" diff --git a/ansible_collections/infoblox/nios_modules/playbooks/delete_cname_record.yaml b/ansible_collections/infoblox/nios_modules/playbooks/delete_cname_record.yaml new file mode 100644 index 00000000..50c55105 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/delete_cname_record.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 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/ansible_collections/infoblox/nios_modules/playbooks/delete_dnsview.yml b/ansible_collections/infoblox/nios_modules/playbooks/delete_dnsview.yml new file mode 100644 index 00000000..bb5e22a2 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/delete_dnsview.yml @@ -0,0 +1,17 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: delete DNS view + infoblox.nios_modules.nios_dns_view: + name: ansibleDnsView + network_view: ansibleNetView + state: absent + provider: "{{ nios_provider }}" diff --git a/ansible_collections/infoblox/nios_modules/playbooks/delete_mx_record.yaml b/ansible_collections/infoblox/nios_modules/playbooks/delete_mx_record.yaml new file mode 100644 index 00000000..3b269a25 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/delete_mx_record.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 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/ansible_collections/infoblox/nios_modules/playbooks/delete_network.yml b/ansible_collections/infoblox/nios_modules/playbooks/delete_network.yml new file mode 100644 index 00000000..304dccc0 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/delete_network.yml @@ -0,0 +1,17 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.60.27.4 + username: admin + password: admin + + 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 }}" diff --git a/ansible_collections/infoblox/nios_modules/playbooks/delete_network_view.yml b/ansible_collections/infoblox/nios_modules/playbooks/delete_network_view.yml new file mode 100644 index 00000000..e0a7b119 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/delete_network_view.yml @@ -0,0 +1,16 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.60.27.4 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: delete network view + infoblox.nios_modules.nios_network_view: + name: ansibleNetView + state: absent + provider: "{{ nios_provider }}" diff --git a/ansible_collections/infoblox/nios_modules/playbooks/delete_txt_record.yaml b/ansible_collections/infoblox/nios_modules/playbooks/delete_txt_record.yaml new file mode 100644 index 00000000..376e2973 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/delete_txt_record.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 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/ansible_collections/infoblox/nios_modules/playbooks/delete_zone.yml b/ansible_collections/infoblox/nios_modules/playbooks/delete_zone.yml new file mode 100644 index 00000000..ca50801a --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/delete_zone.yml @@ -0,0 +1,17 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.36.118.2 + username: cloudadmin + password: admin + + connection: local + tasks: + - name: delete zone + infoblox.nios_modules.nios_zone: + name: ansiblezone.com + view: ansibleDnsView + state: absent + provider: "{{ nios_provider }}" diff --git a/ansible_collections/infoblox/nios_modules/playbooks/restart_services.yml b/ansible_collections/infoblox/nios_modules/playbooks/restart_services.yml new file mode 100644 index 00000000..23bbe590 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/restart_services.yml @@ -0,0 +1,15 @@ +--- +- hosts: localhost + vars: + nios_provider: + host: 10.196.205.10 + username: cloudadmin + password: infoblox + wapi_version: "2.12" + + connection: local + tasks: + - name: Restart Services + nios_restartservices: + provider: "{{ nios_provider }}" +... diff --git a/ansible_collections/infoblox/nios_modules/playbooks/update_a_record.yml b/ansible_collections/infoblox/nios_modules/playbooks/update_a_record.yml new file mode 100644 index 00000000..2630c3bb --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/playbooks/update_a_record.yml @@ -0,0 +1,19 @@ +--- + +- hosts: localhost + vars: + nios_provider: + host: 10.34.34.175 + username: cloudadmin + password: admin + + 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 }}" diff --git a/ansible_collections/infoblox/nios_modules/plugins/README.md b/ansible_collections/infoblox/nios_modules/plugins/README.md new file mode 100644 index 00000000..6541cf7c --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/README.md @@ -0,0 +1,31 @@ +# Collections Plugins Directory + +This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that +is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that +would contain module utils and modules respectively. + +Here is an example directory of the majority of plugins currently supported by Ansible: + +``` +└── plugins + ├── action + ├── become + ├── cache + ├── callback + ├── cliconf + ├── connection + ├── filter + ├── httpapi + ├── inventory + ├── lookup + ├── module_utils + ├── modules + ├── netconf + ├── shell + ├── strategy + ├── terminal + ├── test + └── vars +``` + +A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible/2.9/plugins/plugins.html).
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/plugins/doc_fragments/nios.py b/ansible_collections/infoblox/nios_modules/plugins/doc_fragments/nios.py new file mode 100644 index 00000000..b0cf764a --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/doc_fragments/nios.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- + +# Copyright: (c) 2015, Peter Sprygada <psprygada@ansible.com> +# 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 + + +class ModuleDocFragment(object): + + # Standard files documentation fragment + DOCUMENTATION = r''' +options: + provider: + description: + - A dict object containing connection details. + type: dict + suboptions: + host: + description: + - Specifies the DNS host name or address for connecting to the remote + instance of NIOS WAPI over REST + - Value can also be specified using C(INFOBLOX_HOST) environment + variable. + type: str + username: + description: + - Configures the username to use to authenticate the connection to + the remote instance of NIOS. + - Value can also be specified using C(INFOBLOX_USERNAME) environment + variable. + type: str + password: + description: + - Specifies the password to use to authenticate the connection to + the remote instance of NIOS. + - Value can also be specified using C(INFOBLOX_PASSWORD) environment + variable. + type: str + cert: + description: + - Specifies the client certificate file with digest of x509 config + for extra layer secure connection the remote instance of NIOS. + - Value can also be specified using C(INFOBLOX_CERT) environment + variable. + type: str + key: + description: + - Specifies private key file for encryption with the certificate + in order to connect with remote instance of NIOS. + - Value can also be specified using C(INFOBLOX_KEY) environment + variable. + type: str + validate_certs: + description: + - Boolean value to enable or disable verifying SSL certificates + - Value can also be specified using C(INFOBLOX_SSL_VERIFY) environment + variable. + type: bool + default: no + aliases: [ ssl_verify ] + http_request_timeout: + description: + - The amount of time before to wait before receiving a response + - Value can also be specified using C(INFOBLOX_HTTP_REQUEST_TIMEOUT) environment + variable. + type: int + default: 10 + max_retries: + description: + - Configures the number of attempted retries before the connection + is declared usable + - Value can also be specified using C(INFOBLOX_MAX_RETRIES) environment + variable. + type: int + default: 3 + wapi_version: + description: + - Specifies the version of WAPI to use + - Value can also be specified using C(INFOBLOX_WAP_VERSION) environment + variable. + - Until ansible 2.8 the default WAPI was 1.4 + type: str + default: '2.1' + max_results: + description: + - Specifies the maximum number of objects to be returned, + if set to a negative number the appliance will return an error when the + number of returned objects would exceed the setting. + - Value can also be specified using C(INFOBLOX_MAX_RESULTS) environment + variable. + type: int + default: 1000 + http_pool_maxsize: + description: + - Insert description here + type: int + default: 10 + http_pool_connections: + description: + - Insert decription here + type: int + default: 10 + silent_ssl_warnings: + description: + - Insert description here + type: bool + default: True +notes: + - "This module must be run locally, which can be achieved by specifying C(connection: local)." + - Please read the :ref:`nios_guide` for more detailed information on how to use Infoblox with Ansible. + +''' diff --git a/ansible_collections/infoblox/nios_modules/plugins/inventory/nios_inventory.py b/ansible_collections/infoblox/nios_modules/plugins/inventory/nios_inventory.py new file mode 100644 index 00000000..f23c0273 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/inventory/nios_inventory.py @@ -0,0 +1,107 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type +# 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) + +DOCUMENTATION = r''' + name: nios_inventory + author: + - Will Tome (@willtome) + short_description: Infoblox inventory plugin + version_added: "1.0.0" + description: + - This plugin allows you to query the Infoblox Grid for host records and + use the response data to populate the inventory file. + options: + host: + description: + - Specifies the DNS host name or address for connecting to the remote + instance of NIOS WAPI over REST. + - Value can also be specified using C(INFOBLOX_HOST) environment + variable. + type: string + required: True + env: + - name: INFOBLOX_HOST + username: + description: + - Configures the username to use to authenticate the connection to + the remote instance of NIOS. + - Value can also be specified using C(INFOBLOX_USERNAME) environment + variable. + type: string + required: True + env: + - name: INFOBLOX_USERNAME + password: + description: + - Specifies the password to use to authenticate the connection to + the remote instance of NIOS. + - Value can also be specified using C(INFOBLOX_PASSWORD) environment + variable. + type: string + env: + - name: INFOBLOX_PASSWORD + extattrs: + description: + - Allows you to filter the returned host record based on the + extensible attributes assigned to them. + default: {} + type: dict + hostfilter: + description: + - Accepts a key/value pair and uses it to filter the + host records to be returned. + default: {} + type: dict + requirements: + - python >= 3.4 + - infoblox-client +''' + +EXAMPLES = r''' +plugin: infoblox.nios_modules.nios_inventory +host: blox.example.com +username: admin +''' + + +from ansible.plugins.inventory import BaseInventoryPlugin +from ..module_utils.api import WapiInventory +from ..module_utils.api import normalize_extattrs, flatten_extattrs +from ansible.module_utils.six import iteritems +from ansible.errors import AnsibleError + + +class InventoryModule(BaseInventoryPlugin): + NAME = 'nios_inventory' + + def parse(self, inventory, loader, path, cache=True): # Plugin interface (2) + super(InventoryModule, self).parse(inventory, loader, path) + self._read_config_data(path) + + provider = {'host': self.get_option('host'), + 'username': self.get_option('username'), + 'password': self.get_option('password')} + + wapi = WapiInventory(provider) + + host_filter = self.get_option('hostfilter') + extattrs = normalize_extattrs(self.get_option('extattrs')) + return_fields = ['name', 'view', 'extattrs', 'ipv4addrs'] + + hosts = wapi.get_object('record:host', host_filter, extattrs=extattrs, return_fields=return_fields) or [] + + if not hosts: + raise AnsibleError("host record is not present") + + for host in hosts: + group_name = self.inventory.add_group(host['view']) + host_name = self.inventory.add_host(host['name']) + self.inventory.add_child(group_name, host_name) + + self.inventory.set_variable(host_name, 'view', host['view']) + + for key, value in iteritems(flatten_extattrs(host['extattrs'])): + self.inventory.set_variable(host_name, key, value) diff --git a/ansible_collections/infoblox/nios_modules/plugins/lookup/nios_lookup.py b/ansible_collections/infoblox/nios_modules/plugins/lookup/nios_lookup.py new file mode 100644 index 00000000..c33b212f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/lookup/nios_lookup.py @@ -0,0 +1,112 @@ +# 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 = ''' +--- +name: nios_lookup +short_description: Query Infoblox NIOS objects +version_added: "1.0.0" +description: + - Uses the Infoblox WAPI API to fetch NIOS specified objects. This lookup + supports adding additional keywords to filter the return data and specify + the desired set of returned fields. +requirements: + - infoblox-client + +options: + _terms: + description: + - The name of the network object to be returned from the Infoblox appliance. + required: True + type: str + return_fields: + description: The list of field names to return for the specified object. + type: list + elements: str + filter: + description: A dict object that is used to filter the returned objects. + type: dict + extattrs: + description: A dict object that is used to filter based on extensible attributes. + type: dict +''' + +EXAMPLES = """ +- name: fetch all networkview objects + ansible.builtin.set_fact: + networkviews: "{{ lookup('infoblox.nios_modules.nios_lookup', 'networkview', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + +- 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'}) }}" + +# all of the examples below use credentials that are set using env variables +# export INFOBLOX_HOST=nios01 +# export INFOBLOX_USERNAME=admin +# export INFOBLOX_PASSWORD=admin + +- name: fetch all host records and include extended attributes + ansible.builtin.set_fact: + host_records: "{{ lookup('infoblox.nios_modules.nios_lookup', 'record:host', return_fields=['extattrs', 'name', 'view', 'comment']}) }}" + + +- name: use env variables to pass credentials + ansible.builtin.set_fact: + networkviews: "{{ lookup('infoblox.nios_modules.nios_lookup', 'networkview') }}" + +- name: get a host record + ansible.builtin.set_fact: + host: "{{ lookup('infoblox.nios_modules.nios_lookup', 'record:host', filter={'name': 'hostname.ansible.com'}) }}" + +- name: get the authoritative zone from a non default dns view + ansible.builtin.set_fact: + host: "{{ lookup('infoblox.nios_modules.nios_lookup', 'zone_auth', filter={'fqdn': 'ansible.com', 'view': 'ansible-dns'}) }}" +""" + +RETURN = """ +obj_type: + description: + - The object type specified in the terms argument + returned: always + type: list + contains: + obj_field: + description: + - One or more obj_type fields as specified by return_fields argument or + the default set of fields as per the object type +""" + +from ansible.plugins.lookup import LookupBase +from ansible.errors import AnsibleError +from ..module_utils.api import WapiLookup +from ..module_utils.api import normalize_extattrs, flatten_extattrs + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + try: + obj_type = terms[0] + except IndexError: + raise AnsibleError('the object_type must be specified') + + return_fields = kwargs.pop('return_fields', None) + filter_data = kwargs.pop('filter', {}) + extattrs = normalize_extattrs(kwargs.pop('extattrs', {})) + provider = kwargs.pop('provider', {}) + wapi = WapiLookup(provider) + res = wapi.get_object(obj_type, filter_data, return_fields=return_fields, extattrs=extattrs) + if res is not None: + for obj in res: + if 'extattrs' in obj: + obj['extattrs'] = flatten_extattrs(obj['extattrs']) + else: + res = [] + return res diff --git a/ansible_collections/infoblox/nios_modules/plugins/lookup/nios_next_ip.py b/ansible_collections/infoblox/nios_modules/plugins/lookup/nios_next_ip.py new file mode 100644 index 00000000..e2fa076d --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/lookup/nios_next_ip.py @@ -0,0 +1,115 @@ +# 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 = ''' +--- +name: nios_next_ip +short_description: Return the next available IP address for a network +version_added: "1.0.0" +description: + - Uses the Infoblox WAPI API to return the next available IP addresses + for a given network CIDR +requirements: + - infoblox-client + +options: + _terms: + description: The CIDR network to retrieve the next address(es) from. + required: True + type: str + num: + description: The number of IP address(es) to return. + required: false + default: 1 + type: int + exclude: + description: List of IP's that need to be excluded from returned IP addresses. + required: false + type: list + elements: str + network_view: + description: The network view to retrieve the CIDR network from. + required: false + default: default + type: str +''' + +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'}) }}" + +- 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', \ + 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'}) }}" + +- 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'], + 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'}) }}" +""" + +RETURN = """ +_list: + description: + - The list of next IP addresses available + returned: always + type: list +""" + +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 + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + try: + network = terms[0] + except IndexError: + raise AnsibleError('missing argument in the form of A.B.C.D/E') + + provider = kwargs.pop('provider', {}) + wapi = WapiLookup(provider) + + if isinstance(ipaddress.ip_network(network), ipaddress.IPv6Network): + network_obj = wapi.get_object('ipv6network', {'network': network}) + else: + network_obj = wapi.get_object('network', {'network': network}) + + 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') + + 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)) diff --git a/ansible_collections/infoblox/nios_modules/plugins/lookup/nios_next_network.py b/ansible_collections/infoblox/nios_modules/plugins/lookup/nios_next_network.py new file mode 100644 index 00000000..af3dbf65 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/lookup/nios_next_network.py @@ -0,0 +1,118 @@ +# 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 = ''' +--- +name: nios_next_network +short_description: Return the next available network range for a network-container +version_added: "1.0.0" +description: + - Uses the Infoblox WAPI API to return the next available network addresses for + a given network CIDR +requirements: + - infoblox_client + +options: + _terms: + description: The CIDR network to retrieve the next network from next available network within the specified + container. + required: True + type: str + cidr: + description: + - The CIDR of the network to retrieve the next network from next available network within the + specified container. Also, Requested CIDR must be specified and greater than the parent CIDR. + required: True + type: str + num: + description: The number of network addresses to return from network-container. + required: false + default: 1 + type: int + exclude: + description: Network addresses returned from network-container excluding list of user's input network range. + required: false + default: '' + type: list + elements: str + network_view: + description: The network view to retrieve the CIDR network from. + required: false + default: default + type: str +''' + +EXAMPLES = """ +- name: return next available network for network-container 192.168.10.0/24 + ansible.builtin.set_fact: + networkaddr: "{{ lookup('infoblox.nios_modules.nios_next_network', '192.168.10.0/24', cidr=25, + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + +- name: return next available network for network-container 192.168.10.0/24 in a non-default network view + ansible.builtin.set_fact: + networkaddr: "{{ lookup('infoblox.nios_modules.nios_next_network', '192.168.10.0/24', cidr=25, network_view='ansible' + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + +- name: return the next 2 available network addresses for network-container 192.168.10.0/24 + ansible.builtin.set_fact: + networkaddr: "{{ lookup('infoblox.nios_modules.nios_next_network', '192.168.10.0/24', cidr=25, num=2, + provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + +- name: return the available network addresses for network-container 192.168.10.0/24 excluding network range '192.168.10.0/25' + 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'}) }}" +""" + +RETURN = """ +_list: + description: + - The list of next network addresses available + returned: always + type: list +""" + +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 + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + try: + network = terms[0] + except IndexError: + raise AnsibleError('missing network argument in the form of A.B.C.D/E') + try: + cidr = kwargs.get('cidr', 24) + except IndexError: + raise AnsibleError('missing CIDR argument in the form of xx') + + 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) + 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] + if not ref_list: + raise AnsibleError('no records found') + else: + ref = ref_list[0] + avail_nets = wapi.call_func('next_available_network', ref, {'cidr': cidr, 'num': num, 'exclude': exclude_ip}) + return [avail_nets['networks']] + except Exception as exc: + raise AnsibleError(to_text(exc)) diff --git a/ansible_collections/infoblox/nios_modules/plugins/module_utils/api.py b/ansible_collections/infoblox/nios_modules/plugins/module_utils/api.py new file mode 100644 index 00000000..018e9f15 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/module_utils/api.py @@ -0,0 +1,701 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type +# This code is part of Ansible, but is an independent component. +# This particular file snippet, and this file snippet only, is BSD licensed. +# Modules you write using this snippet, which is embedded dynamically by Ansible +# still belong to the author of the module, and may assign their own license +# to the complete work. +# +# Copyright © 2020 Infoblox Inc +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + + +import json +import os +from functools import partial +from ansible.module_utils._text import to_native +from ansible.module_utils.six import iteritems +from ansible.module_utils._text import to_text +from ansible.module_utils.basic import env_fallback +from ansible.module_utils.common.validation import check_type_dict, safe_eval +from ansible.module_utils.six import string_types + +try: + from infoblox_client.connector import Connector + from infoblox_client.exceptions import InfobloxException + HAS_INFOBLOX_CLIENT = True +except ImportError: + HAS_INFOBLOX_CLIENT = False + +# defining nios constants +NIOS_DNS_VIEW = 'view' +NIOS_NETWORK_VIEW = 'networkview' +NIOS_HOST_RECORD = 'record:host' +NIOS_IPV4_NETWORK = 'network' +NIOS_IPV6_NETWORK = 'ipv6network' +NIOS_ZONE = 'zone_auth' +NIOS_PTR_RECORD = 'record:ptr' +NIOS_A_RECORD = 'record:a' +NIOS_AAAA_RECORD = 'record:aaaa' +NIOS_CNAME_RECORD = 'record:cname' +NIOS_MX_RECORD = 'record:mx' +NIOS_SRV_RECORD = 'record:srv' +NIOS_NAPTR_RECORD = 'record:naptr' +NIOS_TXT_RECORD = 'record:txt' +NIOS_NSGROUP = 'nsgroup' +NIOS_IPV4_FIXED_ADDRESS = 'fixedaddress' +NIOS_IPV6_FIXED_ADDRESS = 'ipv6fixedaddress' +NIOS_NEXT_AVAILABLE_IP = 'func:nextavailableip' +NIOS_IPV4_NETWORK_CONTAINER = 'networkcontainer' +NIOS_IPV6_NETWORK_CONTAINER = 'ipv6networkcontainer' +NIOS_MEMBER = 'member' +NIOS_DTC_SERVER = 'dtc:server' +NIOS_DTC_POOL = 'dtc:pool' +NIOS_DTC_LBDN = 'dtc:lbdn' + +NIOS_PROVIDER_SPEC = { + 'host': dict(fallback=(env_fallback, ['INFOBLOX_HOST'])), + 'username': dict(fallback=(env_fallback, ['INFOBLOX_USERNAME'])), + 'password': dict(fallback=(env_fallback, ['INFOBLOX_PASSWORD']), no_log=True), + 'cert': dict(fallback=(env_fallback, ['INFOBLOX_CERT'])), + 'key': dict(fallback=(env_fallback, ['INFOBLOX_KEY']), no_log=True), + 'validate_certs': dict(type='bool', default=False, fallback=(env_fallback, ['INFOBLOX_SSL_VERIFY']), aliases=['ssl_verify']), + 'silent_ssl_warnings': dict(type='bool', default=True), + 'http_request_timeout': dict(type='int', default=10, fallback=(env_fallback, ['INFOBLOX_HTTP_REQUEST_TIMEOUT'])), + '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.1', fallback=(env_fallback, ['INFOBLOX_WAP_VERSION'])), + 'max_results': dict(type='int', default=1000, fallback=(env_fallback, ['INFOBLOX_MAX_RETRIES'])) +} + + +def get_connector(*args, **kwargs): + ''' Returns an instance of infoblox_client.connector.Connector + :params args: positional arguments are silently ignored + :params kwargs: dict that is passed to Connector init + :returns: Connector + ''' + if not HAS_INFOBLOX_CLIENT: + raise Exception('infoblox-client is required but does not appear ' + 'to be installed. It can be installed using the ' + 'command `pip install infoblox-client`') + + if not set(kwargs.keys()).issubset(list(NIOS_PROVIDER_SPEC.keys()) + ['ssl_verify']): + raise Exception('invalid or unsupported keyword argument for connector') + for key, value in iteritems(NIOS_PROVIDER_SPEC): + if key not in kwargs: + # apply default values from NIOS_PROVIDER_SPEC since we cannot just + # assume the provider values are coming from AnsibleModule + if 'default' in value: + kwargs[key] = value['default'] + + # override any values with env variables unless they were + # explicitly set + env = ('INFOBLOX_%s' % key).upper() + if env in os.environ: + kwargs[key] = os.environ.get(env) + + if 'validate_certs' in kwargs.keys(): + kwargs['ssl_verify'] = kwargs['validate_certs'] + kwargs.pop('validate_certs', None) + + return Connector(kwargs) + + +def normalize_extattrs(value): + ''' Normalize extattrs field to expected format + The module accepts extattrs as key/value pairs. This method will + transform the key/value pairs into a structure suitable for + sending across WAPI in the format of: + extattrs: { + key: { + value: <value> + } + } + ''' + return dict([(k, {'value': v}) for k, v in iteritems(value)]) + + +def flatten_extattrs(value): + ''' Flatten the key/value struct for extattrs + WAPI returns extattrs field as a dict in form of: + extattrs: { + key: { + value: <value> + } + } + This method will flatten the structure to: + extattrs: { + key: value + } + ''' + return dict([(k, v['value']) for k, v in iteritems(value)]) + + +def member_normalize(member_spec): + ''' Transforms the member module arguments into a valid WAPI struct + This function will transform the arguments into a structure that + is a valid WAPI structure in the format of: + { + key: <value>, + } + It will remove any arguments that are set to None since WAPI will error on + that condition. + The remainder of the value validation is performed by WAPI + Some parameters in ib_spec are passed as a list in order to pass the validation for elements. + In this function, they are converted to dictionary. + ''' + member_elements = ['vip_setting', 'ipv6_setting', 'lan2_port_setting', 'mgmt_port_setting', + 'pre_provisioning', 'network_setting', 'v6_network_setting', + 'ha_port_setting', 'lan_port_setting', 'lan2_physical_setting', + 'lan_ha_port_setting', 'mgmt_network_setting', 'v6_mgmt_network_setting'] + for key in list(member_spec.keys()): + if key in member_elements and member_spec[key] is not None: + member_spec[key] = member_spec[key][0] + if isinstance(member_spec[key], dict): + member_spec[key] = member_normalize(member_spec[key]) + elif isinstance(member_spec[key], list): + for x in member_spec[key]: + if isinstance(x, dict): + x = member_normalize(x) + elif member_spec[key] is None: + del member_spec[key] + return member_spec + + +def normalize_ib_spec(ib_spec): + result = {} + for arg in ib_spec: + result[arg] = dict([(k, v) + for k, v in iteritems(ib_spec[arg]) + if k not in ('ib_req', 'transform', 'update')]) + return result + + +class WapiBase(object): + ''' Base class for implementing Infoblox WAPI API ''' + provider_spec = {'provider': dict(type='dict', options=NIOS_PROVIDER_SPEC)} + + def __init__(self, provider): + self.connector = get_connector(**provider) + + def __getattr__(self, name): + try: + return self.__dict__[name] + except KeyError: + if name.startswith('_'): + raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name)) + return partial(self._invoke_method, name) + + def _invoke_method(self, name, *args, **kwargs): + try: + method = getattr(self.connector, name) + return method(*args, **kwargs) + except InfobloxException as exc: + if hasattr(self, 'handle_exception'): + self.handle_exception(name, exc) + else: + raise + + +class WapiLookup(WapiBase): + ''' Implements WapiBase for lookup plugins ''' + def handle_exception(self, method_name, exc): + if ('text' in exc.response): + raise Exception(exc.response['text']) + else: + raise Exception(exc) + + +class WapiInventory(WapiBase): + ''' Implements WapiBase for dynamic inventory script ''' + pass + + +class WapiModule(WapiBase): + ''' Implements WapiBase for executing a NIOS module ''' + def __init__(self, module): + self.module = module + provider = module.params['provider'] + try: + super(WapiModule, self).__init__(provider) + except Exception as exc: + self.module.fail_json(msg=to_text(exc)) + + def handle_exception(self, method_name, exc): + ''' Handles any exceptions raised + This method will be called if an InfobloxException is raised for + any call to the instance of Connector and also, in case of generic + exception. This method will then gracefully fail the module. + :args exc: instance of InfobloxException + ''' + if ('text' in exc.response): + self.module.fail_json( + msg=exc.response['text'], + type=exc.response['Error'].split(':')[0], + code=exc.response.get('code'), + operation=method_name + ) + else: + self.module.fail_json(msg=to_native(exc)) + + def run(self, ib_obj_type, ib_spec): + ''' Runs the module and performans configuration tasks + :args ib_obj_type: the WAPI object type to operate against + :args ib_spec: the specification for the WAPI object as a dict + :returns: a results dict + ''' + + update = new_name = None + state = self.module.params['state'] + if state not in ('present', 'absent'): + self.module.fail_json(msg='state must be one of `present`, `absent`, got `%s`' % state) + + result = {'changed': False} + + obj_filter = dict([(k, self.module.params[k]) for k, v in iteritems(ib_spec) if v.get('ib_req')]) + + # get object reference + ib_obj_ref, update, new_name = self.get_object_ref(self.module, ib_obj_type, obj_filter, ib_spec) + proposed_object = {} + for key, value in iteritems(ib_spec): + if self.module.params[key] is not None: + if 'transform' in value: + proposed_object[key] = value['transform'](self.module) + else: + 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'\ + 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: + # To check for existing A_record with same name with input A_record by IP + if each.get('ipv4addr') and each.get('ipv4addr') == proposed_object.get('ipv4addr'): + current_object = each + # 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')\ + == proposed_object.get('ipv4addrs')[0].get('ipv4addr'): + current_object = each + # Else set the current_object with input value + else: + current_object = obj_filter + ref = None + else: + current_object = ib_obj_ref[0] + if 'extattrs' in current_object: + current_object['extattrs'] = flatten_extattrs(current_object['extattrs']) + if current_object.get('_ref'): + ref = current_object.pop('_ref') + else: + current_object = obj_filter + ref = None + # checks if the object type is member to normalize the attributes being passed + if (ib_obj_type == NIOS_MEMBER): + proposed_object = member_normalize(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"] + if text_obj.startswith("{"): + try: + text_obj = json.loads(text_obj) + txt = text_obj['new_text'] + except Exception: + (result, exc) = safe_eval(text_obj, dict(), include_exceptions=True) + if exc is not None: + raise TypeError('unable to evaluate string as dictionary') + txt = result['new_text'] + proposed_object['text'] = txt + + # checks if the name's field has been updated + if update and new_name: + proposed_object['name'] = new_name + + check_remove = [] + if (ib_obj_type == NIOS_HOST_RECORD): + # 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]: + for each in current_object['ipv4addrs']: + if each['ipv4addr'] == proposed_object['ipv4addrs'][0]['ipv4addr']: + if 'add' in proposed_object['ipv4addrs'][0]: + del proposed_object['ipv4addrs'][0]['add'] + break + check_remove += each.values() + if proposed_object['ipv4addrs'][0]['ipv4addr'] not in check_remove: + if 'remove' in proposed_object['ipv4addrs'][0]: + del proposed_object['ipv4addrs'][0]['remove'] + + res = None + modified = not self.compare_objects(current_object, proposed_object) + if 'extattrs' in proposed_object: + proposed_object['extattrs'] = normalize_extattrs(proposed_object['extattrs']) + + # Checks if nios_next_ip param is passed in ipv4addrs/ipv4addr args + proposed_object = self.check_if_nios_next_ip_exists(proposed_object) + + if state == 'present': + if ref is None: + if not self.module.check_mode: + self.create_object(ib_obj_type, proposed_object) + result['changed'] = True + # Check if NIOS_MEMBER and the flag to call function create_token is set + elif (ib_obj_type == NIOS_MEMBER) and (proposed_object['create_token']): + proposed_object = None + # the function creates a token that can be used by a pre-provisioned member to join the grid + result['api_results'] = self.call_func('create_token', ref, proposed_object) + result['changed'] = True + elif modified: + if 'ipv4addrs' in proposed_object: + if ('add' not in proposed_object['ipv4addrs'][0]) and ('remove' not in proposed_object['ipv4addrs'][0]): + self.check_if_recordname_exists(obj_filter, ib_obj_ref, ib_obj_type, current_object, proposed_object) + + if (ib_obj_type in (NIOS_HOST_RECORD, NIOS_NETWORK_VIEW, NIOS_DNS_VIEW)): + run_update = True + proposed_object = self.on_update(proposed_object, ib_spec) + if 'ipv4addrs' in proposed_object: + if ('add' or 'remove') in proposed_object['ipv4addrs'][0]: + run_update, proposed_object = self.check_if_add_remove_ip_arg_exists(proposed_object) + if run_update: + res = self.update_object(ref, proposed_object) + result['changed'] = True + else: + res = ref + + if (ib_obj_type in (NIOS_A_RECORD, NIOS_AAAA_RECORD, NIOS_PTR_RECORD, NIOS_SRV_RECORD, NIOS_NAPTR_RECORD)): + # popping 'view' key as update of 'view' is not supported with respect to a:record/aaaa:record/srv:record/ptr:record/naptr:record + proposed_object = self.on_update(proposed_object, ib_spec) + del proposed_object['view'] + if not self.module.check_mode: + res = self.update_object(ref, proposed_object) + result['changed'] = True + if (ib_obj_type in (NIOS_ZONE)): + # popping 'zone_format' key as update of 'zone_format' is not supported with respect to zone_auth + proposed_object = self.on_update(proposed_object, ib_spec) + del proposed_object['zone_format'] + self.update_object(ref, proposed_object) + result['changed'] = True + elif 'network_view' in proposed_object and (ib_obj_type not in (NIOS_IPV4_FIXED_ADDRESS, NIOS_IPV6_FIXED_ADDRESS)): + proposed_object.pop('network_view') + 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) + result['changed'] = True + + elif state == 'absent': + if ref is not None: + if 'ipv4addrs' in proposed_object: + if 'remove' in proposed_object['ipv4addrs'][0]: + self.check_if_add_remove_ip_arg_exists(proposed_object) + self.update_object(ref, proposed_object) + result['changed'] = True + elif not self.module.check_mode: + self.delete_object(ref) + result['changed'] = True + + return result + + def check_if_recordname_exists(self, obj_filter, ib_obj_ref, ib_obj_type, current_object, proposed_object): + ''' Send POST request if host record input name and retrieved ref name is same, + but input IP and retrieved IP is different''' + + if 'name' in (obj_filter and ib_obj_ref[0]) and ib_obj_type == NIOS_HOST_RECORD: + obj_host_name = obj_filter['name'] + ref_host_name = ib_obj_ref[0]['name'] + if 'ipv4addrs' in (current_object and proposed_object): + current_ip_addr = current_object['ipv4addrs'][0]['ipv4addr'] + proposed_ip_addr = proposed_object['ipv4addrs'][0]['ipv4addr'] + elif 'ipv6addrs' in (current_object and proposed_object): + current_ip_addr = current_object['ipv6addrs'][0]['ipv6addr'] + proposed_ip_addr = proposed_object['ipv6addrs'][0]['ipv6addr'] + + if obj_host_name == ref_host_name and current_ip_addr != proposed_ip_addr: + self.create_object(ib_obj_type, proposed_object) + + def check_if_nios_next_ip_exists(self, proposed_object): + ''' Check if nios_next_ip argument is passed in ipaddr while creating + host record, if yes then format proposed object ipv4addrs and pass + func:nextavailableip and ipaddr range to create hostrecord with next + available ip in one call to avoid any race condition ''' + + if 'ipv4addrs' in proposed_object: + if 'nios_next_ip' in proposed_object['ipv4addrs'][0]['ipv4addr']: + ip_range = check_type_dict(proposed_object['ipv4addrs'][0]['ipv4addr'])['nios_next_ip'] + proposed_object['ipv4addrs'][0]['ipv4addr'] = NIOS_NEXT_AVAILABLE_IP + ':' + ip_range + elif 'ipv4addr' in proposed_object: + if 'nios_next_ip' in proposed_object['ipv4addr']: + ip_range = check_type_dict(proposed_object['ipv4addr'])['nios_next_ip'] + proposed_object['ipv4addr'] = NIOS_NEXT_AVAILABLE_IP + ':' + ip_range + + return proposed_object + + def check_if_add_remove_ip_arg_exists(self, proposed_object): + ''' + This function shall check if add/remove param is set to true and + is passed in the args, then we will update the proposed dictionary + to add/remove IP to existing host_record, if the user passes false + param with the argument nothing shall be done. + :returns: True if param is changed based on add/remove, and also the + changed proposed_object. + ''' + update = False + if 'add' in proposed_object['ipv4addrs'][0]: + if proposed_object['ipv4addrs'][0]['add']: + proposed_object['ipv4addrs+'] = proposed_object['ipv4addrs'] + del proposed_object['ipv4addrs'] + del proposed_object['ipv4addrs+'][0]['add'] + update = True + else: + del proposed_object['ipv4addrs'][0]['add'] + elif 'remove' in proposed_object['ipv4addrs'][0]: + if proposed_object['ipv4addrs'][0]['remove']: + proposed_object['ipv4addrs-'] = proposed_object['ipv4addrs'] + del proposed_object['ipv4addrs'] + del proposed_object['ipv4addrs-'][0]['remove'] + update = True + else: + del proposed_object['ipv4addrs'][0]['remove'] + return update, proposed_object + + def issubset(self, item, objects): + ''' Checks if item is a subset of objects + :args item: the subset item to validate + :args objects: superset list of objects to validate against + :returns: True if item is a subset of one entry in objects otherwise + this method will return None + ''' + for obj in objects: + if isinstance(item, dict): + if all(entry in obj.items() for entry in item.items()): + return True + else: + if item in obj: + return True + + 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 + # not equal and False will be immediately returned + if current_item is None: + return False + + elif isinstance(proposed_item, list): + if key == 'aliases': + if set(current_item) != set(proposed_item): + return False + for subitem in proposed_item: + if not self.issubset(subitem, current_item): + return False + + elif isinstance(proposed_item, dict): + return self.compare_objects(current_item, proposed_item) + + else: + if current_item != proposed_item: + return False + + return True + + 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 + if ('name' in obj_filter): + # gets and returns the current object based on name/old_name passed + try: + name_obj = check_type_dict(obj_filter['name']) + # check if network_view allows searching and updating with camelCase + if (ib_obj_type == NIOS_NETWORK_VIEW): + old_name = name_obj['old_name'] + new_name = name_obj['new_name'] + else: + old_name = name_obj['old_name'].lower() + new_name = name_obj['new_name'].lower() + except TypeError: + name = obj_filter['name'] + + if old_name and new_name: + if (ib_obj_type == NIOS_HOST_RECORD): + test_obj_filter = dict([('name', old_name), ('view', obj_filter['view'])]) + else: + test_obj_filter = dict([('name', old_name)]) + # get the object reference + ib_obj = self.get_object(ib_obj_type, test_obj_filter, return_fields=list(ib_spec.keys())) + if ib_obj: + obj_filter['name'] = new_name + else: + raise Exception("object with name: '%s' is not found" % (old_name)) + update = True + return ib_obj, update, new_name + if (ib_obj_type == NIOS_HOST_RECORD): + # to fix the sanity issue + name = obj_filter['name'] + # to check only by name if dns bypassing is set + if not obj_filter['configure_for_dns']: + test_obj_filter = dict([('name', name)]) + else: + test_obj_filter = dict([('name', name), ('view', obj_filter['view'])]) + elif (ib_obj_type == NIOS_IPV4_FIXED_ADDRESS and 'mac' in obj_filter): + test_obj_filter = dict([['mac', obj_filter['mac']]]) + elif (ib_obj_type == NIOS_IPV6_FIXED_ADDRESS and 'duid' in obj_filter): + test_obj_filter = dict([['duid', obj_filter['duid']]]) + elif (ib_obj_type == NIOS_CNAME_RECORD): + test_obj_filter = dict([('name', obj_filter['name']), ('view', obj_filter['view'])]) + elif (ib_obj_type == NIOS_A_RECORD): + # resolves issue where a_record with uppercase name was returning null and was failing + test_obj_filter = obj_filter + test_obj_filter['name'] = test_obj_filter['name'].lower() + # resolves issue where multiple a_records with same name and different IP address + try: + ipaddr_obj = check_type_dict(obj_filter['ipv4addr']) + ipaddr = ipaddr_obj.get('old_ipv4addr') + old_ipv4addr_exists = True if ipaddr else False + except TypeError: + ipaddr = obj_filter['ipv4addr'] + test_obj_filter['ipv4addr'] = ipaddr + elif (ib_obj_type == NIOS_TXT_RECORD): + # resolves issue where multiple txt_records with same name and different text + test_obj_filter = obj_filter + try: + text_obj = obj_filter['text'] + if text_obj.startswith("{"): + try: + text_obj = json.loads(text_obj) + txt = text_obj['old_text'] + old_text_exists = True + except Exception: + (result, exc) = safe_eval(text_obj, dict(), include_exceptions=True) + if exc is not None: + raise TypeError('unable to evaluate string as dictionary') + txt = result['old_text'] + old_text_exists = True + else: + txt = text_obj + except TypeError: + txt = obj_filter['text'] + test_obj_filter['text'] = txt + # 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())) + + # 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)) + # prevents creation of a new TXT record with 'new_text' when TXT record with a particular 'old_text' is not found + if old_text_exists and ib_obj is None: + raise Exception("TXT Record with text: '%s' is not found" % (txt)) + elif (ib_obj_type == NIOS_A_RECORD): + # resolves issue where multiple a_records with same name and different IP address + test_obj_filter = obj_filter + try: + ipaddr_obj = check_type_dict(obj_filter['ipv4addr']) + ipaddr = ipaddr_obj.get('old_ipv4addr') + old_ipv4addr_exists = True if ipaddr else False + 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: + raise Exception("A Record with ipv4addr: '%s' is not found" % (ipaddr)) + elif (ib_obj_type == NIOS_TXT_RECORD): + # resolves issue where multiple txt_records with same name and different text + test_obj_filter = obj_filter + try: + text_obj = obj_filter(['text']) + if text_obj.startswith("{"): + try: + text_obj = json.loads(text_obj) + txt = text_obj['old_text'] + old_text_exists = True + except Exception: + (result, exc) = safe_eval(text_obj, dict(), include_exceptions=True) + if exc is not None: + raise TypeError('unable to evaluate string as dictionary') + txt = result['old_text'] + old_text_exists = True + else: + txt = text_obj + except TypeError: + txt = obj_filter['text'] + test_obj_filter['text'] = txt + ib_obj = self.get_object(ib_obj_type, test_obj_filter.copy(), return_fields=list(ib_spec.keys())) + # prevents creation of a new TXT record with 'new_text' when TXT record with a particular 'old_text' is not found + if old_text_exists and ib_obj is None: + raise Exception("TXT Record with text: '%s' is not found" % (txt)) + elif (ib_obj_type == NIOS_ZONE): + # del key 'restart_if_needed' as nios_zone get_object fails with the key present + temp = ib_spec['restart_if_needed'] + del ib_spec['restart_if_needed'] + ib_obj = self.get_object(ib_obj_type, obj_filter.copy(), return_fields=list(ib_spec.keys())) + # reinstate restart_if_needed if ib_obj is none, meaning there's no existing nios_zone ref + if not ib_obj: + ib_spec['restart_if_needed'] = temp + elif (ib_obj_type == NIOS_MEMBER): + # del key 'create_token' as nios_member get_object fails with the key present + temp = ib_spec['create_token'] + del ib_spec['create_token'] + ib_obj = self.get_object(ib_obj_type, obj_filter.copy(), return_fields=list(ib_spec.keys())) + if temp: + # reinstate 'create_token' key + ib_spec['create_token'] = temp + elif (ib_obj_type in (NIOS_IPV4_NETWORK, NIOS_IPV6_NETWORK, NIOS_IPV4_NETWORK_CONTAINER, NIOS_IPV6_NETWORK_CONTAINER)): + # del key 'template' as nios_network get_object fails with the key present + temp = ib_spec['template'] + del ib_spec['template'] + ib_obj = self.get_object(ib_obj_type, obj_filter.copy(), return_fields=list(ib_spec.keys())) + if temp: + # reinstate 'template' key + ib_spec['template'] = temp + else: + ib_obj = self.get_object(ib_obj_type, obj_filter.copy(), return_fields=list(ib_spec.keys())) + return ib_obj, update, new_name + + def on_update(self, proposed_object, ib_spec): + ''' Event called before the update is sent to the API endpoing + This method will allow the final proposed object to be changed + and/or keys filtered before it is sent to the API endpoint to + be processed. + :args proposed_object: A dict item that will be encoded and sent + the API endpoint with the updated data structure + :returns: updated object to be sent to API endpoint + ''' + keys = set() + for key, value in iteritems(proposed_object): + update = ib_spec[key].get('update', True) + if not update: + keys.add(key) + return dict([(k, v) for k, v in iteritems(proposed_object) if k not in keys]) diff --git a/ansible_collections/infoblox/nios_modules/plugins/module_utils/network.py b/ansible_collections/infoblox/nios_modules/plugins/module_utils/network.py new file mode 100644 index 00000000..4357a9b5 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/module_utils/network.py @@ -0,0 +1,19 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type +import socket + + +def validate_ip_address(address): + try: + socket.inet_aton(address) + except socket.error: + return False + return address.count('.') == 3 + + +def validate_ip_v6_address(address): + try: + socket.inet_pton(socket.AF_INET6, address) + except socket.error: + return False + return True diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_a_record.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_a_record.py new file mode 100644 index 00000000..0164e94e --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_a_record.py @@ -0,0 +1,178 @@ +#!/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_a_record +author: "Blair Rampling (@brampling)" +short_description: Configure Infoblox NIOS A records +version_added: "1.0.0" +description: + - Adds and/or removes instances of A record objects from + Infoblox NIOS servers. This module manages NIOS C(record:a) 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 fully qualified hostname to add or remove from + the system. + required: true + type: str + view: + description: + - Sets the DNS view to associate this A record with. The DNS + view must already be configured on the system. + default: default + aliases: + - dns_view + type: str + ipv4addr: + description: + - Configures the IPv4 address for this A record. Users can dynamically + allocate ipv4 address to A record by passing dictionary containing, + I(nios_next_ip) and I(CIDR network range). See example. + aliases: + - ipv4 + required: true + type: str + ttl: + description: + - Configures the TTL to be associated with this A record. + type: int + 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 an A record + infoblox.nios_modules.nios_a_record: + name: a.ansible.com + ipv4: 192.168.10.1 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- 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 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove an A record from the system + infoblox.nios_modules.nios_a_record: + name: a.ansible.com + ipv4: 192.168.10.1 + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Update an A record name + infoblox.nios_modules.nios_a_record: + name: {new_name: a_new.ansible.com, old_name: a.ansible.com} + ipv4: 192.168.10.1 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Dynamically add a record to next available ip + infoblox.nios_modules.nios_a_record: + name: a.ansible.com + ipv4: {nios_next_ip: 192.168.10.0/24} + state: present + 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_A_RECORD +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), + view=dict(default='default', aliases=['dns_view'], ib_req=True), + + ipv4addr=dict(required=True, aliases=['ipv4'], ib_req=True), + + ttl=dict(type='int'), + + 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_A_RECORD, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_aaaa_record.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_aaaa_record.py new file mode 100644 index 00000000..bbafe8db --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_aaaa_record.py @@ -0,0 +1,166 @@ +#!/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_aaaa_record +author: "Blair Rampling (@brampling)" +short_description: Configure Infoblox NIOS AAAA records +version_added: "1.0.0" +description: + - Adds and/or removes instances of AAAA record objects from + Infoblox NIOS servers. This module manages NIOS C(record:aaaa) objects + using the Infoblox WAPI interface over REST. +requirements: + - infoblox-client +options: + name: + description: + - Specifies the fully qualified hostname to add or remove from + the system. + required: true + type: str + view: + description: + - Sets the DNS view to associate this AAAA record with. The DNS + view must already be configured on the system. + default: default + aliases: + - dns_view + type: str + ipv6addr: + description: + - Configures the IPv6 address for this AAAA record. + aliases: + - ipv6 + required: true + type: str + ttl: + description: + - Configures the TTL to be associated with this AAAA record. + type: int + 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 +extends_documentation_fragment: + - infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +''' + +EXAMPLES = ''' +- name: Configure 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: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- 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 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove an 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: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Update an AAAA record name + infoblox.nios_modules.nios_aaaa_record: + name: {new_name: aaaa_new.ansible.com, old_name: aaaa.ansible.com} + ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 + state: present + 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_AAAA_RECORD +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), + view=dict(default='default', aliases=['dns_view'], ib_req=True), + + ipv6addr=dict(required=True, aliases=['ipv6'], ib_req=True), + + ttl=dict(type='int'), + + 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_AAAA_RECORD, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_cname_record.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_cname_record.py new file mode 100644 index 00000000..5bc117d1 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_cname_record.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_cname_record +author: "Blair Rampling (@brampling)" +short_description: Configure Infoblox NIOS CNAME records +version_added: "1.0.0" +description: + - Adds and/or removes instances of CNAME record objects from + Infoblox NIOS servers. This module manages NIOS C(record:cname) 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 fully qualified hostname to add or remove from + the system. + required: true + type: str + view: + description: + - Sets the DNS view to associate this CNAME record with. The DNS + view must already be configured on the system. + default: default + aliases: + - dns_view + type: str + canonical: + description: + - Configures the canonical name for this CNAME record. + aliases: + - cname + required: true + type: str + ttl: + description: + - Configures the TTL to be associated with this CNAME record. + type: int + 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 CNAME record + infoblox.nios_modules.nios_cname_record: + name: cname.ansible.com + canonical: realhost.ansible.com + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- 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 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- 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: + 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_CNAME_RECORD +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), + view=dict(default='default', aliases=['dns_view'], ib_req=True), + + canonical=dict(required=True, aliases=['cname'], ib_req=True), + + ttl=dict(type='int'), + + 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_CNAME_RECORD, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dns_view.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dns_view.py new file mode 100644 index 00000000..83790aca --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dns_view.py @@ -0,0 +1,148 @@ +#!/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_dns_view +author: "Peter Sprygada (@privateip)" +short_description: Configure Infoblox NIOS DNS views +version_added: "1.0.0" +description: + - Adds and/or removes instances of DNS view objects from + Infoblox NIOS servers. This module manages NIOS C(view) objects + using the Infoblox WAPI interface over REST. + - Updates instances of DNS view object from Infoblox NIOS servers. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + name: + description: + - Specifies the fully qualified hostname to add or remove from + the system. User can also update the hostname as it is possible + to pass a dict containing I(new_name), I(old_name). See examples. + required: true + aliases: + - view + type: str + network_view: + description: + - Specifies the name of the network view to assign the configured + DNS view to. The network view must already be configured on the + target system. + default: default + 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. + 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 new dns view instance + infoblox.nios_modules.nios_dns_view: + name: ansible-dns + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- 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: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove the dns view instance + infoblox.nios_modules.nios_dns_view: + name: ansible-dns + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Update the dns view instance + infoblox.nios_modules.nios_dns_view: + name: {new_name: ansible-dns-new, old_name: ansible-dns} + 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_DNS_VIEW +from ..module_utils.api import normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + ib_spec = dict( + name=dict(required=True, aliases=['view'], ib_req=True), + network_view=dict(default='default', ib_req=True), + + 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_DNS_VIEW, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_lbdn.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_lbdn.py new file mode 100644 index 00000000..392a7cb5 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_lbdn.py @@ -0,0 +1,242 @@ +#!/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_lbdn +author: "Mauricio Teixeira (@badnetmask)" +version_added: "1.1.0" +short_description: Configure Infoblox NIOS DTC LBDN +description: + - Adds and/or removes instances of DTC Load Balanced Domain Name (LBDN) + objects from Infoblox NIOS servers. This module manages NIOS + C(dtc:lbdn) 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 display name of the DTC LBDN, not DNS related. + required: true + type: str + lb_method: + description: + - Configures the load balancing method. Used to select pool. + required: true + type: str + choices: + - GLOBAL_AVAILABILITY + - RATIO + - ROUND_ROBIN + - TOPOLOGY + auth_zones: + description: + - List of linked authoritative zones. + - When using I(auth_zones), you must specify at least one + I(patterns) + required: false + type: list + elements: str + patterns: + description: + - Specify LBDN wildcards for pattern match. + required: false + type: list + elements: str + types: + description: + - Specifies the list of resource record types supported by LBDN. + - This option will work properly only if you set the C(wapi_version) + variable on your C(provider) variable to a + number higher than "2.6". + required: false + type: list + elements: str + choices: + - A + - AAAA + - CNAME + - NAPTR + - SRV + pools: + description: + - The pools used for load balancing. + required: false + type: list + elements: dict + suboptions: + pool: + description: + - Provide the name of the pool to link with + required: true + type: str + ratio: + description: + - Provide the weight of the pool + default: 1 + required: false + type: int + ttl: + description: + - The Time To Live (TTL) value for the DTC LBDN. A 32-bit unsigned + integer that represents the duration, in seconds, for which the + record is valid (cached). Zero indicates that the record should + not be cached. + type: int + 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 LBDN + infoblox.nios_modules.nios_dtc_lbdn: + name: web.ansible.com + lb_method: ROUND_ROBIN + pools: + - pool: web_pool + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to a DTC LBDN + infoblox.nios_modules.nios_dtc_lbdn: + name: web.ansible.com + lb_method: ROUND_ROBIN + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a DTC LBDN from the system + infoblox.nios_modules.nios_dtc_lbdn: + name: web.ansible.com + lb_method: ROUND_ROBIN + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ..module_utils.api import NIOS_DTC_LBDN +from ..module_utils.api import WapiModule +from ..module_utils.api import normalize_ib_spec +from ansible.module_utils.six import iteritems +from ansible.module_utils.basic import AnsibleModule + + +def main(): + ''' Main entry point for module execution + ''' + + def auth_zones_transform(module): + zone_list = list() + if module.params['auth_zones']: + for zone in module.params['auth_zones']: + zone_obj = wapi.get_object('zone_auth', + {'fqdn': zone}) + if zone_obj is not None: + zone_list.append(zone_obj[0]['_ref']) + else: + module.fail_json( + msg='auth_zone %s cannot be found.' % zone) + # epdb.serve() + return zone_list + + def pools_transform(module): + pool_list = list() + if module.params['pools']: + for pool in module.params['pools']: + pool_obj = wapi.get_object('dtc:pool', + {'name': pool['pool']}) + if 'ratio' not in pool: + pool['ratio'] = 1 + if pool_obj is not None: + pool_list.append({'pool': pool_obj[0]['_ref'], + 'ratio': pool['ratio']}) + else: + module.fail_json(msg='pool %s cannot be found.' % pool) + return pool_list + + auth_zones_spec = dict() + + pools_spec = dict( + pool=dict(required=True), + ratio=dict(type='int', default=1) + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + lb_method=dict(required=True, choices=['GLOBAL_AVAILABILITY', + 'RATIO', 'ROUND_ROBIN', 'TOPOLOGY']), + + auth_zones=dict(type='list', elements='str', options=auth_zones_spec, + transform=auth_zones_transform), + patterns=dict(type='list', elements='str'), + types=dict(type='list', elements='str', choices=['A', 'AAAA', 'CNAME', 'NAPTR', + 'SRV']), + pools=dict(type='list', elements='dict', options=pools_spec, + transform=pools_transform), + ttl=dict(type='int'), + + 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_LBDN, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_pool.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_pool.py new file mode 100644 index 00000000..2611fe1b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_pool.py @@ -0,0 +1,235 @@ +#!/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_pool +author: "Mauricio Teixeira (@badnetmask)" +version_added: "1.1.0" +short_description: Configure Infoblox NIOS DTC Pool +description: + - Adds and/or removes instances of DTC Pool objects from + Infoblox NIOS servers. This module manages NIOS C(dtc:pool) objects + using the Infoblox WAPI interface over REST. A DTC pool is a collection + of IDNS resources (virtual servers). +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + name: + description: + - Specifies the DTC Pool display name + required: true + type: str + lb_preferred_method: + description: + - Configures the preferred load balancing method. + - Use this to select a method type from the pool. + choices: + - ALL_AVAILABLE + - DYNAMIC_RATIO + - GLOBAL_AVAILABILITY + - RATIO + - ROUND_ROBIN + - TOPOLOGY + required: true + type: str + servers: + description: + - Configure the DTC Servers related to the pool + required: false + type: list + elements: dict + suboptions: + server: + description: + - Provide the name of the DTC Server + required: true + type: str + ratio: + description: + - Provide the weight of the server + default: 1 + required: false + type: int + monitors: + description: + - Specifies the health monitors related to pool. + - The format of this parameter is required due to an API + limitation. + - This option only works if you set the C(wapi_version) + variable on your C(provider) variable to a number higher + than "2.6". + required: false + type: list + elements: dict + suboptions: + name: + description: + - Provide the name of the health monitor. + required: true + type: str + type: + description: + - Provide the type of health monitor. + choices: + - http + - icmp + - tcp + - pdp + - sip + - snmp + 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. + 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 Pool + infoblox.nios_modules.nios_dtc_pool: + name: web_pool + lb_preferred_method: ROUND_ROBIN + servers: + - server: a.ansible.com + - server: b.ansible.com + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to a DTC Pool + infoblox.nios_modules.nios_dtc_pool: + name: web_pool + lb_preferred_method: ROUND_ROBIN + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a DTC Pool from the system + infoblox.nios_modules.nios_dtc_pool: + name: web_pool + lb_preferred_method: ROUND_ROBIN + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ..module_utils.api import NIOS_DTC_POOL +from ..module_utils.api import WapiModule +from ..module_utils.api import normalize_ib_spec +from ansible.module_utils.six import iteritems +from ansible.module_utils.basic import AnsibleModule + + +def main(): + ''' Main entry point for module execution + ''' + + def servers_transform(module): + server_list = list() + if module.params['servers']: + for server in module.params['servers']: + server_obj = wapi.get_object('dtc:server', + {'name': server['server']}) + if server_obj is not None: + server_list.append({'server': server_obj[0]['_ref'], + 'ratio': server['ratio']}) + return server_list + + def monitors_transform(module): + monitor_list = list() + if module.params['monitors']: + for monitor in module.params['monitors']: + monitor_obj = wapi.get_object('dtc:monitor:' + monitor['type'], + {'name': monitor['name']}) + if monitor_obj is not None: + monitor_list.append(monitor_obj[0]['_ref']) + return monitor_list + + servers_spec = dict( + server=dict(required=True), + ratio=dict(type='int', default=1) + ) + + monitors_spec = dict( + name=dict(required=True), + type=dict(required=True, choices=['http', 'icmp', 'tcp', 'pdp', 'sip', 'snmp']) + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + lb_preferred_method=dict(required=True, choices=['ALL_AVAILABLE', + 'DYNAMIC_RATIO', + 'GLOBAL_AVAILABILITY', + 'RATIO', + 'ROUND_ROBIN', + 'TOPOLOGY']), + + servers=dict(type='list', elements='dict', options=servers_spec, + transform=servers_transform), + monitors=dict(type='list', elements='dict', options=monitors_spec, + transform=monitors_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_POOL, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_server.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_server.py new file mode 100644 index 00000000..d2810a80 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_server.py @@ -0,0 +1,144 @@ +#!/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_server +author: "Mauricio Teixeira (@badnetmask)" +short_description: Configure Infoblox NIOS DTC Server +version_added: "1.1.0" +description: + - Adds and/or removes instances of DTC Server objects from + Infoblox NIOS servers. This module manages NIOS C(dtc:server) 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 Server display name + required: true + type: str + host: + description: + - Configures the IP address (A response) or FQDN (CNAME response) + of the server + required: true + type: str + disable: + description: + - Determines whether the DTC Server is disabled or not. + When this is set to False, the fixed address is enabled. + required: false + type: bool + default: False + 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 Server + infoblox.nios_modules.nios_dtc_server: + name: a.example.com + host: 192.168.10.1 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to a DTC server + infoblox.nios_modules.nios_dtc_server: + name: a.example.com + host: 192.168.10.1 + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a DTC Server from the system + infoblox.nios_modules.nios_dtc_server: + name: a.example.com + host: 192.168.10.1 + 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_SERVER +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), + host=dict(required=True, ib_req=True), + + disable=dict(type='bool', default=False), + 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_SERVER, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_fixed_address.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_fixed_address.py new file mode 100644 index 00000000..c01d762e --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_fixed_address.py @@ -0,0 +1,324 @@ +#!/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_fixed_address +author: "Sumit Jaiswal (@sjaiswal)" +short_description: Configure Infoblox NIOS DHCP Fixed Address +version_added: "1.0.0" +description: + - A fixed address is a specific IP address that a DHCP server + always assigns when a lease request comes from a particular + MAC address of the client. + - A fix address reservation is a specific IP address that a DHCP + server reserves and never assigns to a client. + - Supports both IPV4 and IPV6 internet protocols. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - The "mac" field is mandatory for all CRUD operations relating to + IPv4 Fixed address. + - The "duid" field is mandatory for all CRUD operations relating to + IPv6 Fixed address. + - This module supports C(check_mode). +options: + name: + description: + - Specifies the hostname with which fixed DHCP ip-address is stored + for respective mac. + type: str + required: true + ipaddr: + description: + - IPV4/V6 address of the fixed address. + type: str + required: true + mac: + description: + - The MAC address of the IPv4 interface. For a fix address reservation + specify mac address as 00:00:00:00:00:00 + type: str + duid: + description: + - The DUID address of the IPv6 interface. + type: str + network: + description: + - Specifies the network range in which ipaddr exists. + type: str + aliases: + - network + network_view: + description: + - Configures the name of the network view to associate with this + configured instance. + type: str + default: default + options: + description: + - Configures the set of DHCP options to be included as part of + the configured network instance. This argument accepts a list + of values (see suboptions). When configuring suboptions at + least one of C(name) or C(num) must be specified. + type: list + elements: dict + suboptions: + name: + description: + - The name of the DHCP option to configure + type: str + num: + description: + - The number of the DHCP option to configure + type: int + value: + description: + - The value of the DHCP option specified by C(name) + type: str + required: true + use_option: + description: + - Only applies to a subset of options (see NIOS API documentation) + type: bool + default: 'yes' + vendor_class: + description: + - The name of the space this DHCP option is associated to + type: str + default: DHCP + 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. + type: str + default: present + choices: + - present + - absent +''' + +EXAMPLES = ''' +- name: Configure an ipv4 dhcp fixed address + infoblox.nios_modules.nios_fixed_address: + name: ipv4_fixed + ipaddr: 192.168.10.1 + mac: 08:6d:41:e8:fd:e8 + network: 192.168.10.0/24 + network_view: default + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Configure an ipv4 dhcp fixed address reservation + infoblox.nios_modules.nios_fixed_address: + name: ipv4_fixed + ipaddr: 192.168.10.1 + mac: 00:00:00:00:00:00 + network: 192.168.10.0/24 + network_view: default + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Configure an ipv6 dhcp fixed address + infoblox.nios_modules.nios_fixed_address: + name: ipv6_fixed + ipaddr: fe80::1/10 + mac: 08:6d:41:e8:fd:e8 + network: fe80::/64 + network_view: default + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Set dhcp options for an ipv4 fixed address + infoblox.nios_modules.nios_fixed_address: + name: ipv4_fixed + ipaddr: 192.168.10.1 + mac: 08:6d:41:e8:fd:e8 + network: 192.168.10.0/24 + network_view: default + comment: this is a test comment + options: + - name: domain-name + value: ansible.com + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove an ipv4 dhcp fixed address + infoblox.nios_modules.nios_fixed_address: + name: ipv4_fixed + ipaddr: 192.168.10.1 + mac: 08:6d:41:e8:fd:e8 + network: 192.168.10.0/24 + network_view: default + 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 NIOS_IPV4_FIXED_ADDRESS, NIOS_IPV6_FIXED_ADDRESS +from ..module_utils.api import WapiModule +from ..module_utils.api import normalize_ib_spec +from ..module_utils.network import validate_ip_address, validate_ip_v6_address + + +def options(module): + ''' Transforms the module argument into a valid WAPI struct + This function will transform the options argument into a structure that + is a valid WAPI structure in the format of: + { + name: <value>, + num: <value>, + value: <value>, + use_option: <value>, + vendor_class: <value> + } + It will remove any options that are set to None since WAPI will error on + that condition. The use_option field only applies + to special options that are displayed separately from other options and + have a use flag. This function removes the use_option flag from all + other options. It will also verify that either `name` or `num` is + set in the structure but does not validate the values are equal. + The remainder of the value validation is performed by WAPI + ''' + special_options = ['routers', 'router-templates', 'domain-name-servers', + 'domain-name', 'broadcast-address', 'broadcast-address-offset', + 'dhcp-lease-time', 'dhcp6.name-servers'] + # options-router-templates, broadcast-address-offset, dhcp6.name-servers don't have any associated number + special_num = [3, 6, 15, 28, 51] + options = list() + for item in module.params['options']: + opt = dict([(k, v) for k, v in iteritems(item) if v is not None]) + if 'name' not in opt and 'num' not in opt: + module.fail_json(msg='one of `name` or `num` is required for option value') + if 'name' in opt and opt['name'] not in special_options: + del opt['use_option'] + if 'num' in opt and opt['num'] not in special_num: + del opt['use_option'] + options.append(opt) + return options + + +def validate_ip_addr_type(ip, arg_spec, module): + '''This function will check if the argument ip is type v4/v6 and return appropriate infoblox network type + ''' + check_ip = ip.split('/') + + if validate_ip_address(check_ip[0]) and 'ipaddr' in arg_spec: + arg_spec['ipv4addr'] = arg_spec.pop('ipaddr') + module.params['ipv4addr'] = module.params.pop('ipaddr') + del arg_spec['duid'] + del module.params['duid'] + if module.params["mac"] is None: + raise ValueError("the 'mac' address of the object must be specified") + module.params['mac'] = module.params['mac'].lower() + return NIOS_IPV4_FIXED_ADDRESS, arg_spec, module + elif validate_ip_v6_address(check_ip[0]) and 'ipaddr' in arg_spec: + arg_spec['ipv6addr'] = arg_spec.pop('ipaddr') + module.params['ipv6addr'] = module.params.pop('ipaddr') + del arg_spec['mac'] + del module.params['mac'] + if module.params["duid"] is None: + raise ValueError("the 'duid' of the object must be specified") + module.params['duid'] = module.params['duid'].lower() + return NIOS_IPV6_FIXED_ADDRESS, arg_spec, module + + +def main(): + ''' Main entry point for module execution + ''' + option_spec = dict( + # one of name or num is required; enforced by the function options() + name=dict(), + num=dict(type='int'), + + value=dict(required=True), + + use_option=dict(type='bool', default=True), + vendor_class=dict(default='DHCP') + ) + + ib_spec = dict( + name=dict(required=True), + ipaddr=dict(required=True, ib_req=True, type='str'), + mac=dict(ib_req=True, type='str'), + duid=dict(ib_req=True, type='str'), + network=dict(), + network_view=dict(default='default'), + + options=dict(type='list', elements='dict', options=option_spec, transform=options), + + extattrs=dict(type='dict'), + comment=dict(type='str') + ) + + 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) + + # to get the argument ipaddr + obj_filter = dict([(k, module.params[k]) for k, v in iteritems(ib_spec) if v.get('ib_req')]) + # to modify argument based on ipaddr type i.e. IPV4/IPV6 + fixed_address_ip_type, ib_spec, module = validate_ip_addr_type(obj_filter['ipaddr'], ib_spec, module) + + wapi = WapiModule(module) + + result = wapi.run(fixed_address_ip_type, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_host_record.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_host_record.py new file mode 100644 index 00000000..31f7f513 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_host_record.py @@ -0,0 +1,373 @@ +#!/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_host_record +author: "Peter Sprygada (@privateip)" +short_description: Configure Infoblox NIOS host records +version_added: "1.0.0" +description: + - Adds and/or removes instances of host record objects from + Infoblox NIOS servers. This module manages NIOS C(record:host) objects + using the Infoblox WAPI interface over REST. + - Updates instances of host record object from Infoblox NIOS servers. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + name: + description: + - Specifies the fully qualified hostname to add or remove from + the system. User can also update the hostname as it is possible + to pass a dict containing I(new_name), I(old_name). See examples. + type: str + required: true + view: + description: + - Sets the DNS view to associate this host record with. The DNS + view must already be configured on the system. + type: str + default: default + aliases: + - dns_view + configure_for_dns: + description: + - Sets the DNS to particular parent. If user needs to bypass DNS + user can make the value to false. + type: bool + default: true + aliases: + - dns + ipv4addrs: + description: + - Configures the IPv4 addresses for this host record. This argument + accepts a list of values (see suboptions). + type: list + elements: dict + aliases: + - ipv4 + suboptions: + ipv4addr: + description: + - Configures the IPv4 address for the host record. Users can dynamically + allocate ipv4 address to host record by passing dictionary containing, + I(nios_next_ip) and I(CIDR network range). If user wants to add or + remove the ipv4 address from existing record, I(add/remove) + params need to be used. See examples. + type: str + required: true + aliases: + - address + 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. + type: bool + required: false + aliases: + - dhcp + mac: + description: + - Configures the hardware MAC address for the host record. If user makes + DHCP to true, user need to mention MAC address. + type: str + required: false + aliases: + - mac + add: + version_added: "1.0.0" + description: + - If user wants to add the ipv4 address to an existing host record. + Note that with I(add) user will have to keep the I(state) as I(present), + as new IP address is allocated to existing host record. See examples. + type: bool + required: false + aliases: + - add + remove: + version_added: "1.0.0" + description: + - If user wants to remove the ipv4 address from an existing host record. + Note that with I(remove) user will have to change the I(state) to I(absent), + as IP address is de-allocated from an existing host record. See examples. + type: bool + required: false + aliases: + - remove + ipv6addrs: + description: + - Configures the IPv6 addresses for the host record. This argument + accepts a list of values (see options). + type: list + elements: dict + aliases: + - ipv6 + suboptions: + ipv6addr: + description: + - Configures the IPv6 address for the host record. + type: str + required: true + aliases: + - address + 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. + type: bool + required: false + mac: + description: + - Configures the hardware MAC address for the host record. If user makes + DHCP to true, user need to mention MAC address. + type: str + required: false + aliases: + - mac + aliases: + description: + - Configures an optional list of additional aliases to add to the host + record. These are equivalent to CNAMEs but held within a host + record. Must be in list format. + type: list + elements: str + ttl: + description: + - Configures the TTL to be associated with this host record. + type: int + 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. + type: str + default: present + choices: + - present + - absent +''' + +EXAMPLES = ''' +- name: Configure an ipv4 host record + infoblox.nios_modules.nios_host_record: + name: host.ansible.com + ipv4: + - address: 192.168.10.1 + aliases: + - cname.ansible.com + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- 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: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove a host record from the system + infoblox.nios_modules.nios_host_record: + name: host.ansible.com + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Update an ipv4 host record + infoblox.nios_modules.nios_host_record: + name: {new_name: host-new.ansible.com, old_name: host.ansible.com} + ipv4: + - address: 192.168.10.1 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Create an ipv4 host record bypassing DNS + infoblox.nios_modules.nios_host_record: + name: new_host + ipv4: + - address: 192.168.10.1 + dns: false + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Create an ipv4 host record over DHCP + 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 + 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 + ipv4: + - address: {nios_next_ip: 192.168.10.0/24} + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add ip to host record + infoblox.nios_modules.nios_host_record: + name: host.ansible.com + ipv4: + - address: 192.168.10.2 + add: true + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove ip from host record + infoblox.nios_modules.nios_host_record: + name: host.ansible.com + ipv4: + - address: 192.168.10.1 + remove: true + 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_HOST_RECORD +from ..module_utils.api import normalize_ib_spec + + +def ipaddr(module, key, filtered_keys=None): + ''' Transforms the input value into a struct supported by WAPI + This function will transform the input from the playbook into a struct + that is valid for WAPI in the form of: + { + ipv4addr: <value>, + mac: <value> + } + This function does not validate the values are properly formatted or in + the acceptable range, that is left to WAPI. + ''' + filtered_keys = filtered_keys or list() + objects = list() + for item in module.params[key]: + objects.append(dict([(k, v) for k, v in iteritems(item) if v is not None and k not in filtered_keys])) + return objects + + +def ipv4addrs(module): + return ipaddr(module, 'ipv4addrs', filtered_keys=['address', 'dhcp']) + + +def ipv6addrs(module): + return ipaddr(module, 'ipv6addrs', filtered_keys=['address', 'dhcp']) + + +def main(): + ''' Main entry point for module execution + ''' + ipv4addr_spec = dict( + ipv4addr=dict(required=True, aliases=['address']), + configure_for_dhcp=dict(type='bool', required=False, aliases=['dhcp']), + mac=dict(required=False), + add=dict(type='bool', required=False), + remove=dict(type='bool', required=False) + ) + + ipv6addr_spec = dict( + ipv6addr=dict(required=True, aliases=['address']), + configure_for_dhcp=dict(type='bool', required=False), + mac=dict(required=False) + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + view=dict(default='default', aliases=['dns_view'], ib_req=True), + + 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), + aliases=dict(type='list', elements='str'), + + ttl=dict(type='int'), + + 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_HOST_RECORD, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_member.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_member.py new file mode 100644 index 00000000..38a6899b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_member.py @@ -0,0 +1,575 @@ +#!/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_member +author: "Krishna Vasudevan (@krisvasudevan)" +short_description: Configure Infoblox NIOS members +version_added: "1.0.0" +description: + - Adds and/or removes Infoblox NIOS servers. This module manages NIOS C(member) 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: + host_name: + description: + - Specifies the host name of the member to either add or remove from + the NIOS instance. + required: true + aliases: + - name + type: str + vip_setting: + description: + - Configures the network settings for the grid member. + suboptions: + address: + description: + - The IPv4 Address of the Grid Member + type: str + subnet_mask: + description: + - The subnet mask for the Grid Member + type: str + gateway: + description: + - The default gateway for the Grid Member + type: str + type: list + elements: dict + ipv6_setting: + description: + - Configures the IPv6 settings for the grid member. + suboptions: + virtual_ip: + description: + - The IPv6 Address of the Grid Member + type: str + cidr_prefix: + description: + - The IPv6 CIDR prefix for the Grid Member + type: int + gateway: + description: + - The gateway address for the Grid Member + type: str + type: list + elements: dict + config_addr_type: + description: + - Address configuration type (IPV4/IPV6/BOTH). + default: IPV4 + type: str + comment: + description: + - A descriptive comment of the Grid member. + type: str + extattrs: + description: + - Extensible attributes associated with the object. + type: dict + enable_ha: + description: + - If set to True, the member has two physical nodes (HA pair). + default: False + type: bool + router_id: + description: + - Virtual router identifier. Provide this ID if "ha_enabled" is set to "true". This is a unique VRID number (from 1 to 255) for the local subnet. + type: int + lan2_enabled: + description: + - When set to "true", the LAN2 port is enabled as an independent port or as a port for failover purposes. + default: False + type: bool + lan2_port_setting: + description: + - Settings for the Grid member LAN2 port if 'lan2_enabled' is set to "true". + type: list + elements: dict + suboptions: + enabled: + description: + - If set to True, then it has its own IP settings. + type: bool + network_setting: + description: + - If the 'enable' field is set to True, this defines IPv4 network settings for LAN2. + suboptions: + address: + description: + - The IPv4 Address of LAN2 + type: str + subnet_mask: + description: + - The subnet mask of LAN2 + type: str + gateway: + description: + - The default gateway of LAN2 + type: str + type: list + elements: dict + v6_network_setting: + description: + - If the 'enable' field is set to True, this defines IPv6 network settings for LAN2. + type: list + elements: dict + suboptions: + virtual_ip: + description: + - The IPv6 Address of LAN2 + type: str + cidr_prefix: + description: + - The IPv6 CIDR prefix of LAN2 + type: int + gateway: + description: + - The gateway address of LAN2 + type: str + platform: + description: + - Configures the Hardware Platform. + default: INFOBLOX + type: str + node_info: + description: + - Configures the node information list with detailed status report on the operations of the Grid Member. + type: list + elements: dict + suboptions: + lan2_physical_setting: + description: + - Physical port settings for the LAN2 interface. + suboptions: + auto_port_setting_enabled: + description: + - Enable or disalbe the auto port setting. + type: bool + duplex: + description: + - The port duplex; if speed is 1000, duplex must be FULL. + type: str + speed: + description: + - The port speed; if speed is 1000, duplex is FULL. + type: str + type: list + elements: dict + lan_ha_port_setting: + description: + - LAN/HA port settings for the node. + type: list + elements: dict + suboptions: + ha_ip_address: + description: + - HA IP address. + type: str + ha_port_setting: + description: + - Physical port settings for the HA interface. + type: list + elements: dict + suboptions: + auto_port_setting_enabled: + description: + - Enable or disalbe the auto port setting. + type: bool + duplex: + description: + - The port duplex; if speed is 1000, duplex must be FULL. + type: str + speed: + description: + - The port speed; if speed is 1000, duplex is FULL. + type: str + lan_port_setting: + description: + - Physical port settings for the LAN interface. + type: list + elements: dict + suboptions: + auto_port_setting_enabled: + description: + - Enable or disalbe the auto port setting. + type: bool + duplex: + description: + - The port duplex; if speed is 1000, duplex must be FULL. + type: str + speed: + description: + - The port speed; if speed is 1000, duplex is FULL. + type: str + mgmt_ipv6addr: + description: + - Public IPv6 address for the LAN1 interface. + type: str + mgmt_lan: + description: + - Public IPv4 address for the LAN1 interface. + type: str + mgmt_network_setting: + description: + - Network settings for the MGMT port of the node. + type: list + elements: dict + suboptions: + address: + description: + - The IPv4 Address of MGMT + type: str + subnet_mask: + description: + - The subnet mask of MGMT + type: str + gateway: + description: + - The default gateway of MGMT + type: str + v6_mgmt_network_setting: + description: + - The network settings for the IPv6 MGMT port of the node. + type: list + elements: dict + suboptions: + virtual_ip: + description: + - The IPv6 Address of MGMT + type: str + cidr_prefix: + description: + - The IPv6 CIDR prefix of MGMT + type: int + gateway: + description: + - The gateway address of MGMT + type: str + mgmt_port_setting: + description: + - Settings for the member MGMT port. + type: list + elements: dict + suboptions: + enabled: + description: + - Determines if MGMT port settings should be enabled. + type: bool + security_access_enabled: + description: + - Determines if security access on the MGMT port is enabled or not. + type: bool + vpn_enabled: + description: + - Determines if VPN on the MGMT port is enabled or not. + type: bool + upgrade_group: + description: + - The name of the upgrade group to which this Grid member belongs. + default: Default + type: str + use_syslog_proxy_setting: + description: + - Use flag for external_syslog_server_enable , syslog_servers, syslog_proxy_setting, syslog_size. + type: bool + external_syslog_server_enable: + description: + - Determines if external syslog servers should be enabled. + type: bool + syslog_servers: + description: + - The list of external syslog servers. + type: list + elements: dict + suboptions: + address: + description: + - The server address. + type: str + category_list: + description: + - The list of all syslog logging categories. + type: list + elements: str + connection_type: + description: + - The connection type for communicating with this server.(STCP/TCP?UDP) + default: UDP + type: str + local_interface: + description: + - The local interface through which the appliance sends syslog messages to the syslog server.(ANY/LAN/MGMT) + default: ANY + type: str + message_node_id: + description: + - Identify the node in the syslog message. (HOSTNAME/IP_HOSTNAME/LAN/MGMT) + default: LAN + type: str + message_source: + description: + - The source of syslog messages to be sent to the external syslog server. + default: ANY + type: str + only_category_list: + description: + - The list of selected syslog logging categories. The appliance forwards syslog messages that belong to the selected categories. + type: bool + port: + description: + - The port this server listens on. + default: 514 + type: int + severity: + description: + - The severity filter. The appliance sends log messages of the specified severity and above to the external syslog server. + default: DEBUG + type: str + pre_provisioning: + description: + - Pre-provisioning information. + type: list + elements: dict + suboptions: + hardware_info: + description: + - An array of structures that describe the hardware being pre-provisioned. + type: list + elements: dict + suboptions: + hwmodel: + description: + - Hardware model + type: str + hwtype: + description: + - Hardware type. + type: str + licenses: + description: + - An array of license types. + type: list + elements: str + create_token: + description: + - Flag for initiating a create token request for pre-provisioned members. + type: bool + default: False + 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: Add a member to the grid with IPv4 address + infoblox.nios_modules.nios_member: + host_name: member01.localdomain + vip_setting: + - address: 192.168.1.100 + subnet_mask: 255.255.255.0 + gateway: 192.168.1.1 + config_addr_type: IPV4 + platform: VNIOS + comment: "Created by Ansible" + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a HA member to the grid + infoblox.nios_modules.nios_member: + host_name: memberha.localdomain + vip_setting: + - address: 192.168.1.100 + subnet_mask: 255.255.255.0 + gateway: 192.168.1.1 + config_addr_type: IPV4 + platform: VNIOS + enable_ha: true + router_id: 150 + node_info: + - lan_ha_port_setting: + - 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 + comment: "Created by Ansible" + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Update the member with pre-provisioning details specified + infoblox.nios_modules.nios_member: + name: member01.localdomain + pre_provisioning: + - hardware_info: + - hwmodel: IB-VM-820 + hwtype: IB-VNIOS + licenses: + - dns + - dhcp + - enterprise + - vnios + comment: "Updated by Ansible" + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove the member + infoblox.nios_modules.nios_member: + name: member01.localdomain + 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_MEMBER +from ..module_utils.api import normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + ipv4_spec = dict( + address=dict(), + subnet_mask=dict(), + gateway=dict(), + ) + + ipv6_spec = dict( + virtual_ip=dict(), + cidr_prefix=dict(type='int'), + gateway=dict(), + ) + + port_spec = dict( + auto_port_setting_enabled=dict(type='bool'), + duplex=dict(), + speed=dict(), + ) + + lan2_port_spec = dict( + enabled=dict(type='bool'), + network_setting=dict(type='list', elements='dict', options=ipv4_spec), + v6_network_setting=dict(type='list', elements='dict', options=ipv6_spec), + ) + + ha_port_spec = dict( + ha_ip_address=dict(), + ha_port_setting=dict(type='list', elements='dict', options=port_spec), + lan_port_setting=dict(type='list', elements='dict', options=port_spec), + mgmt_lan=dict(), + mgmt_ipv6addr=dict(), + ) + + node_spec = dict( + lan2_physical_setting=dict(type='list', elements='dict', options=port_spec), + lan_ha_port_setting=dict(type='list', elements='dict', options=ha_port_spec), + mgmt_network_setting=dict(type='list', elements='dict', options=ipv4_spec), + v6_mgmt_network_setting=dict(type='list', elements='dict', options=ipv6_spec), + ) + + mgmt_port_spec = dict( + enabled=dict(type='bool'), + security_access_enabled=dict(type='bool'), + vpn_enabled=dict(type='bool'), + ) + + syslog_spec = dict( + address=dict(), + category_list=dict(type='list', elements='str'), + connection_type=dict(default='UDP'), + local_interface=dict(default='ANY'), + message_node_id=dict(default='LAN'), + message_source=dict(default='ANY'), + only_category_list=dict(type='bool'), + port=dict(type='int', default=514), + severity=dict(default='DEBUG'), + ) + + hw_spec = dict( + hwmodel=dict(), + hwtype=dict(), + ) + + pre_prov_spec = dict( + hardware_info=dict(type='list', elements='dict', options=hw_spec), + licenses=dict(type='list', elements='str'), + ) + + ib_spec = dict( + host_name=dict(required=True, aliases=['name'], ib_req=True), + vip_setting=dict(type='list', elements='dict', options=ipv4_spec), + ipv6_setting=dict(type='list', elements='dict', options=ipv6_spec), + config_addr_type=dict(default='IPV4'), + comment=dict(), + enable_ha=dict(type='bool', default=False), + router_id=dict(type='int'), + lan2_enabled=dict(type='bool', default=False), + lan2_port_setting=dict(type='list', elements='dict', options=lan2_port_spec), + platform=dict(default='INFOBLOX'), + node_info=dict(type='list', elements='dict', options=node_spec), + mgmt_port_setting=dict(type='list', elements='dict', options=mgmt_port_spec), + upgrade_group=dict(default='Default'), + use_syslog_proxy_setting=dict(type='bool'), + external_syslog_server_enable=dict(type='bool'), + syslog_servers=dict(type='list', elements='dict', options=syslog_spec), + pre_provisioning=dict(type='list', elements='dict', options=pre_prov_spec), + extattrs=dict(type='dict'), + create_token=dict(type='bool', default=False), + ) + + 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_MEMBER, ib_spec) + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_mx_record.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_mx_record.py new file mode 100644 index 00000000..1ff3bc8a --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_mx_record.py @@ -0,0 +1,163 @@ +#!/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_mx_record +author: "Blair Rampling (@brampling)" +short_description: Configure Infoblox NIOS MX records +version_added: "1.0.0" +description: + - Adds and/or removes instances of MX record objects from + Infoblox NIOS servers. This module manages NIOS C(record:mx) 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 fully qualified hostname to add or remove from + the system. + type: str + required: true + view: + description: + - Sets the DNS view to associate this a record with. The DNS + view must already be configured on the system. + type: str + default: default + aliases: + - dns_view + mail_exchanger: + description: + - Configures the mail exchanger FQDN for this MX record. + type: str + required: true + aliases: + - mx + preference: + description: + - Configures the preference (0-65535) for this MX record. + type: int + required: true + ttl: + description: + - Configures the TTL to be associated with this host record. + type: int + 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. + type: str + default: present + choices: + - present + - absent +''' + +EXAMPLES = ''' +- name: Configure an MX record + infoblox.nios_modules.nios_mx_record: + name: ansible.com + mx: mailhost.ansible.com + preference: 0 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to an existing MX record + infoblox.nios_modules.nios_mx_record: + name: ansible.com + mx: mailhost.ansible.com + preference: 0 + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove an MX record from the system + infoblox.nios_modules.nios_mx_record: + name: ansible.com + mx: mailhost.ansible.com + preference: 0 + 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_MX_RECORD +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), + view=dict(default='default', aliases=['dns_view'], ib_req=True), + + mail_exchanger=dict(required=True, aliases=['mx'], ib_req=True), + preference=dict(required=True, type='int', ib_req=True), + + ttl=dict(type='int'), + + 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_MX_RECORD, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_naptr_record.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_naptr_record.py new file mode 100644 index 00000000..aa59921b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_naptr_record.py @@ -0,0 +1,195 @@ +#!/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_naptr_record +author: "Blair Rampling (@brampling)" +short_description: Configure Infoblox NIOS NAPTR records +version_added: "1.0.0" +description: + - Adds and/or removes instances of NAPTR record objects from + Infoblox NIOS servers. This module manages NIOS C(record:naptr) 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 fully qualified hostname to add or remove from + the system. + type: str + required: true + view: + description: + - Sets the DNS view to associate this a record with. The DNS + view must already be configured on the system. + type: str + default: default + aliases: + - dns_view + order: + description: + - Configures the order (0-65535) for this NAPTR record. This parameter + specifies the order in which the NAPTR rules are applied when + multiple rules are present. + type: int + preference: + description: + - Configures the preference (0-65535) for this NAPTR record. The + preference field determines the order NAPTR records are processed + when multiple records with the same order parameter are present. + type: int + replacement: + description: + - Configures the replacement field for this NAPTR record. + For nonterminal NAPTR records, this field specifies the + next domain name to look up. + type: str + services: + description: + - Configures the services field (128 characters maximum) for this + NAPTR record. The services field contains protocol and service + identifiers, such as "http+E2U" or "SIPS+D2T". + type: str + flags: + description: + - Configures the flags field for this NAPTR record. These control the + interpretation of the fields for an NAPTR record object. Supported + values for the flags field are "U", "S", "P" and "A". + type: str + regexp: + description: + - Configures the regexp field for this NAPTR record. This is the + regular expression-based rewriting rule of the NAPTR record. This + should be a POSIX compliant regular expression, including the + substitution rule and flags. Refer to RFC 2915 for the field syntax + details. + type: str + ttl: + description: + - Configures the TTL to be associated with this NAPTR record. + type: int + 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. + type: str + default: present + choices: + - present + - absent +''' + +EXAMPLES = ''' +- name: Configure an NAPTR record + infoblox.nios_modules.nios_naptr_record: + name: '*.subscriber-100.ansiblezone.com' + order: 1000 + preference: 10 + replacement: replacement1.network.ansiblezone.com + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- 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 + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove an 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 + 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 normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + + ib_spec = dict( + name=dict(required=True, ib_req=True), + view=dict(default='default', aliases=['dns_view'], ib_req=True), + + order=dict(type='int', ib_req=True), + preference=dict(type='int', ib_req=True), + replacement=dict(ib_req=True), + services=dict(), + flags=dict(), + regexp=dict(), + + ttl=dict(type='int'), + + 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('record:naptr', ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_network.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_network.py new file mode 100644 index 00000000..e53782dd --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_network.py @@ -0,0 +1,318 @@ +#!/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_network +author: "Peter Sprygada (@privateip)" +short_description: Configure Infoblox NIOS network object +version_added: "1.0.0" +description: + - Adds and/or removes instances of network objects from + Infoblox NIOS servers. This module manages NIOS C(network) objects + using the Infoblox WAPI interface over REST. + - Supports both IPV4 and IPV6 internet protocols. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + network: + description: + - Specifies the network to add or remove from the system. The value + should use CIDR notation. + type: str + required: true + aliases: + - name + - cidr + network_view: + description: + - Configures the name of the network view to associate with this + configured instance. + type: str + default: default + options: + description: + - Configures the set of DHCP options to be included as part of + the configured network instance. This argument accepts a list + of values (see suboptions). When configuring suboptions at + least one of C(name) or C(num) must be specified. + type: list + elements: dict + suboptions: + name: + description: + - The name of the DHCP option to configure. The standard options are + C(router), C(router-templates), C(domain-name-servers), C(domain-name), + C(broadcast-address), C(broadcast-address-offset), C(dhcp-lease-time), + and C(dhcp6.name-servers). + type: str + num: + description: + - The number of the DHCP option to configure + type: int + value: + description: + - The value of the DHCP option specified by C(name) + type: str + required: true + use_option: + description: + - Only applies to a subset of options (see NIOS API documentation) + type: bool + default: 'yes' + vendor_class: + description: + - The name of the space this DHCP option is associated to + type: str + default: DHCP + template: + description: + - If set on creation, the network is created according to the values + specified in the selected template. + 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. + 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 + container: + description: + - If set to true it'll create the network container to be added or removed + from the system. + type: bool + 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 a network ipv4 + infoblox.nios_modules.nios_network: + network: 192.168.10.0/24 + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Configure a network ipv6 + infoblox.nios_modules.nios_network: + network: fe80::/64 + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- 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: + - name: domain-name + value: ansible.com + 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 + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Configure an ipv4 network container + infoblox.nios_modules.nios_network: + network: 192.168.10.0/24 + container: true + comment: test network container + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Configure an ipv6 network container + infoblox.nios_modules.nios_network: + network: fe80::/64 + container: true + comment: test network container + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove an ipv4 network container + infoblox.nios_modules.nios_network: + networkr: 192.168.10.0/24 + container: true + comment: test network container + 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_IPV4_NETWORK, NIOS_IPV6_NETWORK +from ..module_utils.api import NIOS_IPV4_NETWORK_CONTAINER, NIOS_IPV6_NETWORK_CONTAINER +from ..module_utils.api import normalize_ib_spec +from ..module_utils.network import validate_ip_address, validate_ip_v6_address + + +def options(module): + ''' Transforms the module argument into a valid WAPI struct + This function will transform the options argument into a structure that + is a valid WAPI structure in the format of: + { + name: <value>, + num: <value>, + value: <value>, + use_option: <value>, + vendor_class: <value> + } + It will remove any options that are set to None since WAPI will error on + that condition. It will also verify that either `name` or `num` is + set in the structure but does not validate the values are equal. + The remainder of the value validation is performed by WAPI + ''' + options = list() + for item in module.params['options']: + opt = dict([(k, v) for k, v in iteritems(item) if v is not None]) + if 'name' not in opt and 'num' not in opt: + module.fail_json(msg='one of `name` or `num` is required for option value') + options.append(opt) + return options + + +def check_ip_addr_type(obj_filter, ib_spec): + '''This function will check if the argument ip is type v4/v6 and return appropriate infoblox + network/networkcontainer type + ''' + + ip = obj_filter['network'] + 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]): + return NIOS_IPV6_NETWORK_CONTAINER, ib_spec + else: + check_ip = ip.split('/') + del ib_spec['container'] # removing the container key from post arguments + if validate_ip_address(check_ip[0]): + return NIOS_IPV4_NETWORK, ib_spec + elif validate_ip_v6_address(check_ip[0]): + return NIOS_IPV6_NETWORK, ib_spec + + +def check_vendor_specific_dhcp_option(module, ib_spec): + '''This function will check if the argument dhcp option belongs to vendor-specific and if yes then will remove + use_options flag which is not supported with vendor-specific dhcp options. + ''' + for key, value in iteritems(ib_spec): + if isinstance(module.params[key], list): + for temp_dict in module.params[key]: + if 'num' in temp_dict: + if temp_dict['num'] in (43, 124, 125, 67, 60): + del temp_dict['use_option'] + return ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + option_spec = dict( + # one of name or num is required; enforced by the function options() + name=dict(), + num=dict(type='int'), + + value=dict(required=True), + + use_option=dict(type='bool', default=True), + vendor_class=dict(default='DHCP') + ) + + ib_spec = dict( + 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), + + template=dict(type='str'), + extattrs=dict(type='dict'), + comment=dict(), + container=dict(type='bool', ib_req=True) + ) + + 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) + + # to get the argument ipaddr + obj_filter = dict([(k, module.params[k]) for k, v in iteritems(ib_spec) if v.get('ib_req')]) + network_type, ib_spec = check_ip_addr_type(obj_filter, ib_spec) + + wapi = WapiModule(module) + # to check for vendor specific dhcp option + ib_spec = check_vendor_specific_dhcp_option(module, ib_spec) + + result = wapi.run(network_type, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_network_view.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_network_view.py new file mode 100644 index 00000000..3ebcb1f6 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_network_view.py @@ -0,0 +1,138 @@ +#!/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_network_view +author: "Peter Sprygada (@privateip)" +short_description: Configure Infoblox NIOS network views +version_added: "1.0.0" +description: + - Adds and/or removes instances of network view objects from + Infoblox NIOS servers. This module manages NIOS C(networkview) objects + using the Infoblox WAPI interface over REST. + - Updates instances of network view object from Infoblox NIOS servers. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + name: + description: + - Specifies the fully qualified hostname to add or remove from + the system. User can also update the hostname as it is possible + to pass a dict containing I(new_name), I(old_name). See examples. + type: str + required: true + aliases: + - network_view + 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. + type: str + default: present + choices: + - present + - absent +''' + +EXAMPLES = ''' +- name: Configure a new network view + infoblox.nios_modules.nios_network_view: + name: ansible + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Update the comment for network view + infoblox.nios_modules.nios_network_view: + name: ansible + comment: this is an example comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove the network view + infoblox.nios_modules.nios_network_view: + name: ansible + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Update an existing network view + infoblox.nios_modules.nios_network_view: + name: {new_name: ansible-new, old_name: ansible} + 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_NETWORK_VIEW +from ..module_utils.api import normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + ib_spec = dict( + name=dict(required=True, aliases=['network_view'], ib_req=True), + 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_NETWORK_VIEW, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_nsgroup.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_nsgroup.py new file mode 100644 index 00000000..948fe238 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_nsgroup.py @@ -0,0 +1,439 @@ +#!/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 +short_description: Configure InfoBlox DNS Nameserver 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. + This module manages NIOS C(nsgroup) objects using the Infoblox. WAPI interface over REST. +requirements: + - infoblox_client +notes: + - This module supports C(check_mode). +options: + name: + description: + - Specifies the name of the NIOS nameserver group to be managed. + required: true + type: str + grid_primary: + description: + - This host is to be used as primary server in this nameserver group. It must be a grid member. + This option is required when setting I(use_external_primaries) to C(false). + type: list + elements: dict + suboptions: + name: + description: + - Provide the name of the grid member to identify the host. + required: true + type: str + enable_preferred_primaries: + description: + - This flag represents whether the preferred_primaries field values of this member are used (see Infoblox WAPI docs). + default: false + type: bool + grid_replicate: + description: + - Use DNS zone transfers if set to C(True) or ID Grid Replication if set to C(False). + type: bool + default: false + lead: + description: + - This flag controls if the grid lead secondary nameserver performs zone transfers to non lead secondaries. + type: bool + default: false + stealth: + description: + - Configure the external nameserver as stealth server (without NS record) in the zones. + type: bool + default: false + preferred_primaries: + description: + - Provide a list of elements like in I(external_primaries) to set the precedence of preferred primary nameservers. + type: list + elements: dict + suboptions: + address: + description: + - Configures the IP address of the external nameserver + required: true + type: str + name: + description: + - Set a label for the external nameserver + required: true + type: str + stealth: + description: + - Configure the external nameserver as stealth server (without NS record) in the zones. + type: bool + default: false + tsig_key_name: + description: + - Sets a label for the I(tsig_key) value + required: true + type: str + tsig_key_alg: + description: + - Provides the algorithm used for the I(tsig_key) in use. + choices: ['HMAC-MD5', 'HMAC-SHA256'] + default: 'HMAC-MD5' + type: str + tsig_key: + description: + - Set a DNS TSIG key for the nameserver to secure zone transfers (AFXRs). + type: str + grid_secondaries: + description: + - Configures the list of grid member hosts that act as secondary nameservers. + This option is required when setting I(use_external_primaries) to C(true). + type: list + elements: dict + suboptions: + name: + description: + - Provide the name of the grid member to identify the host. + required: true + type: str + enable_preferred_primaries: + description: + - This flag represents whether the preferred_primaries field values of this member are used (see Infoblox WAPI docs). + default: false + type: bool + grid_replicate: + description: + - Use DNS zone transfers if set to C(True) or ID Grid Replication if set to C(False) + type: bool + default: false + lead: + description: + - This flag controls if the grid lead secondary nameserver performs zone transfers to non lead secondaries. + type: bool + default: false + stealth: + description: + - Configure the external nameserver as stealth server (without NS record) in the zones. + type: bool + default: false + preferred_primaries: + description: + - Provide a list of elements like in I(external_primaries) to set the precedence of preferred primary nameservers. + type: list + elements: dict + suboptions: + address: + description: + - Configures the IP address of the external nameserver + required: true + type: str + name: + description: + - Set a label for the external nameserver + required: true + type: str + stealth: + description: + - Configure the external nameserver as stealth server (without NS record) in the zones. + type: bool + default: false + tsig_key_name: + description: + - Sets a label for the I(tsig_key) value + required: true + type: str + tsig_key_alg: + description: + - Provides the algorithm used for the I(tsig_key) in use. + choices: ['HMAC-MD5', 'HMAC-SHA256'] + default: 'HMAC-MD5' + type: str + tsig_key: + description: + - Set a DNS TSIG key for the nameserver to secure zone transfers (AFXRs). + type: str + is_grid_default: + description: + - If set to C(True) this nsgroup will become the default nameserver group for new zones. + type: bool + default: false + use_external_primary: + description: + - This flag controls whether the group is using an external primary nameserver. + Note that modification of this field requires passing values for I(grid_secondaries) and I(external_primaries). + type: bool + default: false + external_primaries: + description: + - Configures a list of external nameservers (non-members of the grid). + This option is required when setting I(use_external_primaries) to C(true). + type: list + elements: dict + suboptions: + address: + description: + - Configures the IP address of the external nameserver + required: true + type: str + name: + description: + - Set a label for the external nameserver + required: true + type: str + stealth: + description: + - Configure the external nameserver as stealth server (without NS record) in the zones. + type: bool + default: false + tsig_key_name: + description: + - Sets a label for the I(tsig_key) value + required: true + type: str + tsig_key_alg: + description: + - Provides the algorithm used for the I(tsig_key) in use. + choices: ['HMAC-MD5', 'HMAC-SHA256'] + default: 'HMAC-MD5' + type: str + tsig_key: + description: + - Set a DNS TSIG key for the nameserver to secure zone transfers (AFXRs). + type: str + external_secondaries: + description: + - Allows to provide a list of external secondary nameservers, that are not members of the grid. + type: list + elements: dict + suboptions: + address: + description: + - Configures the IP address of the external nameserver + required: true + type: str + name: + description: + - Set a label for the external nameserver + required: true + type: str + stealth: + description: + - Configure the external nameserver as stealth server (without NS record) in the zones. + type: bool + default: false + tsig_key_name: + description: + - Sets a label for the I(tsig_key) value + required: true + type: str + tsig_key_alg: + description: + - Provides the algorithm used for the I(tsig_key) in use. + choices: ['HMAC-MD5', 'HMAC-SHA256'] + default: 'HMAC-MD5' + type: str + tsig_key: + description: + - Set a DNS TSIG key for the nameserver to secure zone transfers (AFXRs). + 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. + type: str + 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. + choices: [present, absent] + default: present + type: str +''' + +EXAMPLES = ''' +- name: Create simple infoblox nameserver group + infoblox.nios_modules.nios_nsgroup: + name: my-simple-group + comment: "this is a simple nameserver group" + grid_primary: + - name: infoblox-test.example.com + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Create infoblox nameserver group with external primaries + infoblox.nios_modules.nios_nsgroup: + name: my-example-group + use_external_primary: true + comment: "this is my example nameserver group" + external_primaries: "{{ ext_nameservers }}" + grid_secondaries: + - name: infoblox-test.example.com + lead: True + preferred_primaries: "{{ ext_nameservers }}" + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Delete infoblox nameserver group + infoblox.nios_modules.nios_nsgroup: + name: my-simple-group + comment: "this is a simple nameserver group" + grid_primary: + - name: infoblox-test.example.com + 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_NSGROUP +from ..module_utils.api import normalize_ib_spec + + +# from infoblox documentation +# Fields List +# Field Type Req R/O Base Search +# comment String N N Y : = ~ +# extattrs Extattr N N N ext +# external_primaries [struct] N N N N/A +# external_secondaries [struct] N N N N/A +# grid_primary [struct] N N N N/A +# grid_secondaries [struct] N N N N/A +# is_grid_default Bool N N N N/A +# is_multimaster Bool N Y N N/A +# name String Y N Y : = ~ +# use_external_primary Bool N N N N/A + + +def main(): + '''entrypoint for module execution.''' + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']), + ) + + # cleanup tsig fields + def clean_tsig(ext): + if 'tsig_key' in ext and not ext['tsig_key']: + del ext['tsig_key'] + if 'tsig_key' not in ext and 'tsig_key_name' in ext and not ext['tsig_key_name']: + del ext['tsig_key_name'] + if 'tsig_key' not in ext and 'tsig_key_alg' in ext: + del ext['tsig_key_alg'] + + def clean_grid_member(member): + if member['preferred_primaries']: + for ext in member['preferred_primaries']: + clean_tsig(ext) + if member['enable_preferred_primaries'] is False: + del member['enable_preferred_primaries'] + del member['preferred_primaries'] + if member['lead'] is False: + del member['lead'] + if member['grid_replicate'] is False: + del member['grid_replicate'] + + def ext_primaries_transform(module): + if module.params['external_primaries']: + for ext in module.params['external_primaries']: + clean_tsig(ext) + return module.params['external_primaries'] + + def ext_secondaries_transform(module): + if module.params['external_secondaries']: + for ext in module.params['external_secondaries']: + clean_tsig(ext) + return module.params['external_secondaries'] + + def grid_primary_preferred_transform(module): + for member in module.params['grid_primary']: + clean_grid_member(member) + return module.params['grid_primary'] + + def grid_secondaries_preferred_primaries_transform(module): + for member in module.params['grid_secondaries']: + clean_grid_member(member) + return module.params['grid_secondaries'] + + extserver_spec = dict( + address=dict(required=True), + name=dict(required=True), + stealth=dict(type='bool', default=False), + tsig_key=dict(no_log=True), + tsig_key_alg=dict(choices=['HMAC-MD5', 'HMAC-SHA256'], default='HMAC-MD5'), + tsig_key_name=dict(required=True) + ) + + memberserver_spec = dict( + name=dict(required=True), + enable_preferred_primaries=dict(type='bool', default=False), + grid_replicate=dict(type='bool', default=False), + lead=dict(type='bool', default=False), + preferred_primaries=dict(type='list', elements='dict', options=extserver_spec, default=None), + stealth=dict(type='bool', default=False), + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + grid_primary=dict(type='list', elements='dict', options=memberserver_spec, + transform=grid_primary_preferred_transform), + grid_secondaries=dict(type='list', elements='dict', options=memberserver_spec, + transform=grid_secondaries_preferred_primaries_transform), + external_primaries=dict(type='list', elements='dict', options=extserver_spec, transform=ext_primaries_transform), + external_secondaries=dict(type='list', elements='dict', options=extserver_spec, + transform=ext_secondaries_transform), + is_grid_default=dict(type='bool', default=False), + use_external_primary=dict(type='bool', default=False), + extattrs=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, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_ptr_record.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_ptr_record.py new file mode 100644 index 00000000..d649badc --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_ptr_record.py @@ -0,0 +1,164 @@ +#!/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_ptr_record +author: "Trebuchet Clement (@clementtrebuchet)" +short_description: Configure Infoblox NIOS PTR records +version_added: "1.0.0" +description: + - Adds and/or removes instances of PTR record objects from + Infoblox NIOS servers. This module manages NIOS C(record:ptr) 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: + - The name of the DNS PTR record in FQDN format to add or remove from + the system. + The field is required only for an PTR object in Forward Mapping Zone. + type: str + view: + description: + - Sets the DNS view to associate this a record with. The DNS + view must already be configured on the system. + type: str + default: default + aliases: + - dns_view + ipv4addr: + description: + - The IPv4 Address of the record. Mutually exclusive with the ipv6addr. + type: str + aliases: + - ipv4 + ipv6addr: + description: + - The IPv6 Address of the record. Mutually exclusive with the ipv4addr. + aliases: + - ipv6 + type: str + ptrdname: + description: + - The domain name of the DNS PTR record in FQDN format. + required: true + type: str + ttl: + description: + - Time To Live (TTL) value for the record. + A 32-bit unsigned integer that represents the duration, in seconds, that the record is valid (cached). + Zero indicates that the record should not be cached. + type: int + 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. Maximum 256 characters. + 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: Create a PTR Record + infoblox.nios_modules.nios_ptr_record: + ipv4: 192.168.10.1 + ptrdname: host.ansible.com + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Delete a PTR Record + infoblox.nios_modules.nios_ptr_record: + ipv4: 192.168.10.1 + ptrdname: host.ansible.com + 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_PTR_RECORD +from ..module_utils.api import normalize_ib_spec + + +def main(): + # Module entry point + ib_spec = dict( + name=dict(required=False), + view=dict(default='default', aliases=['dns_view'], ib_req=True), + ipv4addr=dict(aliases=['ipv4'], ib_req=True), + ipv6addr=dict(aliases=['ipv6'], ib_req=True), + ptrdname=dict(required=True, ib_req=True), + + ttl=dict(type='int'), + + 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) + + mutually_exclusive = [('ipv4addr', 'ipv6addr')] + required_one_of = [ + ['ipv4addr', 'ipv6addr'] + ] + + module = AnsibleModule(argument_spec=argument_spec, + mutually_exclusive=mutually_exclusive, + supports_check_mode=True, + required_one_of=required_one_of) + + if module.params['ipv4addr']: + del ib_spec['ipv6addr'] + elif module.params['ipv6addr']: + del ib_spec['ipv4addr'] + + wapi = WapiModule(module) + result = wapi.run(NIOS_PTR_RECORD, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_restartservices.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_restartservices.py new file mode 100644 index 00000000..b8f0bc49 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_restartservices.py @@ -0,0 +1,144 @@ +#!/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_restartservices +author: "Mauricio Teixeira (@badnetmask)" +short_description: Restart grid services. +version_added: "1.1.0" +description: + - Restart grid services. + - When invoked without any options, will restart ALL services on the + default restart group IF NEEDED. +requirements: + - infoblox-client +extends_documentation_fragment: infoblox.nios_modules.nios +notes: + - This module supports C(check_mode). +options: + groups: + description: + - The list of the Service Restart Groups to restart. + required: false + type: list + elements: str + members: + description: + - The list of the Grid Members to restart. + required: false + type: list + elements: str + mode: + description: + - The restart method in case of grid restart. + required: false + type: str + choices: + - GROUPED + - SEQUENTIAL + - SIMULTANEOUS + restart_option: + description: + - Controls whether services are restarted unconditionally or when needed + required: false + type: str + default: RESTART_IF_NEEDED + choices: + - RESTART_IF_NEEDED + - FORCE_RESTART + services: + description: + - The list of services the restart applicable to. + required: false + type: list + elements: str + default: ALL + choices: + - ALL + - DNS + - DHCP + - DHCPV4 + - DHCPV6 +''' + +EXAMPLES = ''' +- name: Restart all grid services if needed. + infoblox.nios_modules.nios_restartservices: + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Restart DNS service if needed. + infoblox.nios_modules.nios_restartservices: + services: + - DNS + 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 normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + + ib_spec = dict( + groups=dict(type='list', elements='str'), + members=dict(type='list', elements='str'), + mode=dict(type='str', choices=['GROUPED', 'SEQUENTIAL', + 'SIMULTANEOUS']), + restart_option=dict(type='str', default='RESTART_IF_NEEDED', + choices=['RESTART_IF_NEEDED', 'FORCE_RESTART']), + services=dict(type='list', elements='str', default=['ALL'], + choices=['ALL', 'DNS', 'DHCP', 'DHCPV4', 'DHCPV6']) + ) + + argument_spec = dict( + provider=dict(required=True) + ) + + 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) + + # restart is a grid function, so we need to properly format + # the arguments before sending the command + restart_params = module.params + del restart_params['provider'] + if restart_params['groups'] is None: + del restart_params['groups'] + if restart_params['members'] is None: + del restart_params['members'] + if restart_params['mode'] is None: + del restart_params['mode'] + grid_obj = wapi.get_object('grid') + if grid_obj is None: + module.fail_json(msg='Failed to get NIOS grid information.') + result = wapi.call_func('restartservices', grid_obj[0]['_ref'], restart_params) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_srv_record.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_srv_record.py new file mode 100644 index 00000000..9ac94577 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_srv_record.py @@ -0,0 +1,175 @@ +#!/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_srv_record +author: "Blair Rampling (@brampling)" +short_description: Configure Infoblox NIOS SRV records +version_added: "1.0.0" +description: + - Adds and/or removes instances of SRV record objects from + Infoblox NIOS servers. This module manages NIOS C(record:srv) 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 fully qualified hostname to add or remove from + the system. + required: true + type: str + view: + description: + - Sets the DNS view to associate this a record with. The DNS + view must already be configured on the system. + default: default + aliases: + - dns_view + type: str + port: + description: + - Configures the port (0-65535) of this SRV record. + type: int + priority: + description: + - Configures the priority (0-65535) for this SRV record. + type: int + target: + description: + - Configures the target FQDN for this SRV record. + type: str + weight: + description: + - Configures the weight (0-65535) for this SRV record. + type: int + ttl: + description: + - Configures the TTL to be associated with this host record. + type: int + 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 an SRV record + infoblox.nios_modules.nios_srv_record: + name: _sip._tcp.service.ansible.com + port: 5080 + priority: 10 + target: service1.ansible.com + weight: 10 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Add a comment to an existing SRV record + infoblox.nios_modules.nios_srv_record: + name: _sip._tcp.service.ansible.com + port: 5080 + priority: 10 + target: service1.ansible.com + weight: 10 + comment: this is a test comment + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove an SRV record from the system + infoblox.nios_modules.nios_srv_record: + name: _sip._tcp.service.ansible.com + port: 5080 + priority: 10 + target: service1.ansible.com + weight: 10 + 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_SRV_RECORD +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), + view=dict(default='default', aliases=['dns_view'], ib_req=True), + + port=dict(type='int', ib_req=True), + priority=dict(type='int', ib_req=True), + target=dict(ib_req=True), + weight=dict(type='int', ib_req=True), + + ttl=dict(type='int'), + + 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_SRV_RECORD, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_txt_record.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_txt_record.py new file mode 100644 index 00000000..51e4504c --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_txt_record.py @@ -0,0 +1,139 @@ +#!/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_txt_record +author: "Corey Wanless (@coreywan)" +short_description: Configure Infoblox NIOS txt records +version_added: "1.0.0" +description: + - Adds and/or removes instances of txt record objects from + Infoblox NIOS servers. This module manages NIOS C(record:txt) 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 fully qualified hostname to add or remove from + the system. + required: true + type: str + view: + description: + - Sets the DNS view to associate this tst record with. The DNS + view must already be configured on the system. + default: default + aliases: + - dns_view + type: str + text: + description: + - Text associated with the record. It can contain up to 255 bytes + per substring, up to a total of 512 bytes. To enter leading, + trailing, or embedded spaces in the text, add quotes around the + text to preserve the spaces. + required: true + type: str + ttl: + description: + - Configures the TTL to be associated with this txt record. + type: int + 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: 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: 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 = ''' # ''' + +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 normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + + ib_spec = dict( + name=dict(required=True, ib_req=True), + view=dict(default='default', aliases=['dns_view'], ib_req=True), + text=dict(required=True, type='str', ib_req=True), + ttl=dict(type='int'), + 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('record:txt', ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_zone.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_zone.py new file mode 100644 index 00000000..982c5e21 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_zone.py @@ -0,0 +1,244 @@ +#!/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_zone +author: "Peter Sprygada (@privateip)" +short_description: Configure Infoblox NIOS DNS zones +version_added: "1.0.0" +description: + - Adds and/or removes instances of DNS zone objects from + Infoblox NIOS servers. This module manages NIOS C(zone_auth) 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: + fqdn: + description: + - Specifies the qualified domain name to either add or remove from + the NIOS instance based on the configured C(state) value. + required: true + aliases: + - name + type: str + view: + description: + - Configures the DNS view name for the configured resource. The + specified DNS zone must already exist on the running NIOS instance + prior to configuring zones. + default: default + aliases: + - dns_view + type: str + grid_primary: + description: + - Configures the grid primary servers for this zone. + suboptions: + name: + description: + - The name of the grid primary server + required: true + type: str + type: list + elements: dict + grid_secondaries: + description: + - Configures the grid secondary servers for this zone. + suboptions: + name: + description: + - The name of the grid secondary server + required: true + type: str + type: list + elements: dict + ns_group: + description: + - Configures the name server group for this zone. Name server group is + mutually exclusive with grid primary and grid secondaries. + type: str + restart_if_needed: + description: + - If set to true, causes the NIOS DNS service to restart and load the + new zone configuration. + type: bool + zone_format: + description: + - Create an authorative Reverse-Mapping Zone which is an area of network + space for which one or more name servers-primary and secondary-have the + responsibility to respond to address-to-name queries. It supports + reverse-mapping zones for both IPv4 and IPv6 addresses. + default: FORWARD + 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. + 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 zone on the system using grid primary and secondaries + infoblox.nios_modules.nios_zone: + name: ansible.com + grid_primary: + - name: gridprimary.grid.com + grid_secondaries: + - name: gridsecondary1.grid.com + - name: gridsecondary2.grid.com + restart_if_needed: true + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Configure a zone on the system using a name server group + infoblox.nios_modules.nios_zone: + name: ansible.com + ns_group: examplensg + restart_if_needed: true + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Configure a reverse mapping zone on the system using IPV4 zone format + infoblox.nios_modules.nios_zone: + name: 10.10.10.0/24 + zone_format: IPV4 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Configure a reverse mapping zone on the system using IPV6 zone format + infoblox.nios_modules.nios_zone: + name: 100::1/128 + zone_format: IPV6 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Update the comment and ext attributes for an existing zone + infoblox.nios_modules.nios_zone: + name: ansible.com + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove the dns zone + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: Remove the reverse mapping dns zone from the system with IPV4 zone format + infoblox.nios_modules.nios_zone: + name: 10.10.10.0/24 + zone_format: IPV4 + 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_ZONE +from ..module_utils.api import normalize_ib_spec + + +def main(): + ''' Main entry point for module execution + ''' + grid_spec = dict( + name=dict(required=True), + ) + + ib_spec = dict( + fqdn=dict(required=True, aliases=['name'], ib_req=True, update=False), + zone_format=dict(default='FORWARD', ib_req=False), + view=dict(default='default', aliases=['dns_view'], ib_req=True), + + grid_primary=dict(type='list', elements='dict', options=grid_spec), + grid_secondaries=dict(type='list', elements='dict', options=grid_spec), + ns_group=dict(), + restart_if_needed=dict(type='bool'), + + 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, + mutually_exclusive=[ + ['ns_group', 'grid_primary'], + ['ns_group', 'grid_secondaries'] + ]) + + wapi = WapiModule(module) + result = wapi.run(NIOS_ZONE, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/infoblox/nios_modules/requirements.txt b/ansible_collections/infoblox/nios_modules/requirements.txt new file mode 100644 index 00000000..be611454 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/requirements.txt @@ -0,0 +1 @@ +infoblox-client diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/tasks/main.yml new file mode 100644 index 00000000..b3fa8014 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_a_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/tasks/nios_a_record_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/tasks/nios_a_record_idempotence.yml new file mode 100644 index 00000000..0bbf106c --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/tasks/nios_a_record_idempotence.yml @@ -0,0 +1,77 @@ +- name: cleanup the parent object + nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: create the parent object + nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: cleanup a_record + 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: 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: 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: a.ansible.com + ipv4: 192.168.10.1 + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: a_record_update1 + +- name: add a comment to an existing a_record + nios_a_record: + name: a.ansible.com + ipv4: 192.168.10.1 + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: a_record_update2 + +- name: remove a a_record from the system + 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: a.ansible.com + ipv4: 192.168.10.1 + state: absent + provider: "{{ nios_provider }}" + register: a_record_delete2 + +- 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" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/tasks/main.yml new file mode 100644 index 00000000..2fec2adb --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_aaaa_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/tasks/nios_aaaa_record_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/tasks/nios_aaaa_record_idempotence.yml new file mode 100644 index 00000000..2df01d34 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/tasks/nios_aaaa_record_idempotence.yml @@ -0,0 +1,77 @@ +- name: cleanup the parent object + nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: create the parent object + nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: cleanup aaaa record + 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: 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: 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: aaaa.ansible.com + ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: aaaa_record_update1 + +- name: add a comment to an existing aaaa record + nios_aaaa_record: + name: aaaa.ansible.com + ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: aaaa_record_update2 + +- name: remove a aaaa record from the system + 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: aaaa.ansible.com + ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 + state: absent + provider: "{{ nios_provider }}" + register: aaaa_record_delete2 + +- 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" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/tasks/main.yml new file mode 100644 index 00000000..b30f250a --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_cname_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/tasks/nios_cname_record_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/tasks/nios_cname_record_idempotence.yml new file mode 100644 index 00000000..f450c716 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/tasks/nios_cname_record_idempotence.yml @@ -0,0 +1,77 @@ +- name: cleanup the parent object + nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: create the parent object + nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: cleanup cname record + 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: 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: 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: cname.ansible.com + canonical: realhost.ansible.com + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: cname_record_update1 + +- name: add a comment to an existing cname record + nios_cname_record: + name: cname.ansible.com + canonical: realhost.ansible.com + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: cname_record_update2 + +- name: remove a cname record from the system + 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: cname.ansible.com + canonical: realhost.ansible.com + state: absent + provider: "{{ nios_provider }}" + register: cname_record_delete2 + +- 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" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: []
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/tasks/main.yml new file mode 100644 index 00000000..1eb9c07a --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_dns_view_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/tasks/nios_dns_view_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/tasks/nios_dns_view_idempotence.yml new file mode 100644 index 00000000..b9dc9fec --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/tasks/nios_dns_view_idempotence.yml @@ -0,0 +1,58 @@ +- name: delete dns view instance + nios_dns_view: + name: ansible-dns + state: absent + provider: "{{ nios_provider }}" + +- name: configure a new dns view instance + 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: ansible-dns + state: present + provider: "{{ nios_provider }}" + register: nios_dns_create2 + +- name: update the comment for dns view + 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: 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: ansible-dns + state: absent + provider: "{{ nios_provider }}" + register: nios_dns_delete1 + +- name: delete dns view instance + nios_dns_view: + name: ansible-dns + state: absent + provider: "{{ nios_provider }}" + register: nios_dns_delete2 + +- 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" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: []
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/tasks/main.yml new file mode 100644 index 00000000..2f1dcc55 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_host_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml new file mode 100644 index 00000000..636431ee --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/tasks/nios_host_record_idempotence.yml @@ -0,0 +1,126 @@ +- name: cleanup the parent object + nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: create the parent object + nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: cleanup ipv4 host record + 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: host.ansible.com + ipv4: + - address: 192.168.10.1 + state: present + provider: "{{ nios_provider }}" + register: ipv4_create1 + +- name: recreate an ipv4 host record + nios_host_record: + name: host.ansible.com + ipv4: + - address: 192.168.10.1 + state: present + provider: "{{ nios_provider }}" + register: ipv4_create2 + +- name: add a comment to an existing host record + 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_update1 + +- name: add a comment to an existing host record + 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 + 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: host.ansible.com + state: absent + provider: "{{ nios_provider }}" + register: ipv4_delete2 + +- name: create an ipv4 host record bypassing DNS + nios_host_record: + name: host + ipv4: + - address: 192.168.10.1 + dns: false + state: present + provider: "{{ nios_provider }}" + register: ipv4_create3 + +- name: recreate an ipv4 host record bypassing DNS + nios_host_record: + name: host + ipv4: + - address: 192.168.10.1 + dns: false + state: present + provider: "{{ nios_provider }}" + register: ipv4_create4 + +- name: create an ipv4 host record via DHCP and MAC + 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_create5 + +- name: recreate an ipv4 host record via DHCP and MAC + 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 + +- 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" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/tasks/main.yml new file mode 100644 index 00000000..fe687173 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_mx_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/tasks/nios_mx_record_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/tasks/nios_mx_record_idempotence.yml new file mode 100644 index 00000000..65b1e8f4 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/tasks/nios_mx_record_idempotence.yml @@ -0,0 +1,84 @@ +- name: cleanup the parent object + nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: create the parent object + nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: cleanup mx record + 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: ansible.com + mx: mailhost.ansible.com + preference: 0 + state: present + provider: "{{ nios_provider }}" + register: mx_record_create1 + +- name: recreate an mx record + nios_mx_record: + name: ansible.com + mx: mailhost.ansible.com + preference: 0 + state: present + provider: "{{ nios_provider }}" + register: mx_record_create2 + +- name: add a comment to an existing mx record + nios_mx_record: + name: ansible.com + mx: mailhost.ansible.com + preference: 0 + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: mx_record_update1 + +- name: add a comment to an existing mx record + nios_mx_record: + name: ansible.com + mx: mailhost.ansible.com + preference: 0 + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: mx_record_update2 + +- name: remove a mx record from the system + nios_mx_record: + name: ansible.com + mx: mailhost.ansible.com + preference: 0 + state: absent + provider: "{{ nios_provider }}" + register: mx_record_delete1 + +- name: remove a mx record from the system + nios_mx_record: + name: ansible.com + mx: mailhost.ansible.com + preference: 0 + state: absent + provider: "{{ nios_provider }}" + register: mx_record_delete2 + +- 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" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/tasks/main.yml new file mode 100644 index 00000000..a22a8018 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_naptr_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/tasks/nios_naptr_record_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/tasks/nios_naptr_record_idempotence.yml new file mode 100644 index 00000000..2303eff5 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/tasks/nios_naptr_record_idempotence.yml @@ -0,0 +1,91 @@ +- name: cleanup the parent object + nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: create the parent object + nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: cleanup naptr record + 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' + order: 1000 + preference: 10 + replacement: replacement1.network.ansiblezone.com + state: present + provider: "{{ nios_provider }}" + register: naptr_record_create1 + +- name: recreate an naptr record + nios_naptr_record: + name: '*.subscriber-100.ansiblezone.com' + order: 1000 + preference: 10 + replacement: replacement1.network.ansiblezone.com + state: present + provider: "{{ nios_provider }}" + register: naptr_record_create2 + +- name: add a comment to an existing naptr record + nios_naptr_record: + name: '*.subscriber-100.ansiblezone.com' + order: 1000 + preference: 10 + replacement: replacement1.network.ansiblezone.com + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: naptr_record_update1 + +- name: add a comment to an existing naptr record + nios_naptr_record: + name: '*.subscriber-100.ansiblezone.com' + order: 1000 + preference: 10 + replacement: replacement1.network.ansiblezone.com + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: naptr_record_update2 + +- name: remove a naptr record from the system + nios_naptr_record: + name: '*.subscriber-100.ansiblezone.com' + order: 1000 + preference: 10 + replacement: replacement1.network.ansiblezone.com + state: absent + provider: "{{ nios_provider }}" + register: naptr_record_delete1 + +- name: remove a naptr record from the system + nios_naptr_record: + name: '*.subscriber-100.ansiblezone.com' + order: 1000 + preference: 10 + replacement: replacement1.network.ansiblezone.com + state: absent + provider: "{{ nios_provider }}" + register: naptr_record_delete2 + +- 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" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/defaults/main.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/defaults/main.yaml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/tasks/main.yml new file mode 100644 index 00000000..c147af8f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_network_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml new file mode 100644 index 00000000..3b5dbc4b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/tasks/nios_network_idempotence.yml @@ -0,0 +1,80 @@ +- name: cleanup a network ipv4 + 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: + 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: + 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: + network: 192.168.10.0/24 + comment: this is a test comment + options: + - name: domain-name + value: ansible.com + state: present + provider: "{{ nios_provider }}" + register: nios_ipv4_update1 + +- name: set dhcp options for a network ipv4 + nios_network: + network: 192.168.10.0/24 + comment: this is a test comment + options: + - name: domain-name + value: ansible.com + state: present + provider: "{{ nios_provider }}" + register: nios_ipv4_update2 + +- name: remove a network ipv4 + nios_network: + network: 192.168.10.0/24 + state: absent + provider: "{{ nios_provider }}" + register: nios_ipv4_remove1 + +- name: remove a network ipv4 + nios_network: + network: 192.168.10.0/24 + state: absent + provider: "{{ nios_provider }}" + register: nios_ipv4_remove2 + +- name: configure a network ipv6 + nios_network: + network: fe80::/64 + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: nios_ipv6_create1 + +- 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" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: []
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/tasks/main.yml new file mode 100644 index 00000000..97e87148 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_network_view_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/tasks/nios_network_view_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/tasks/nios_network_view_idempotence.yml new file mode 100644 index 00000000..ad13e3a3 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/tasks/nios_network_view_idempotence.yml @@ -0,0 +1,58 @@ +- name: cleanup a new network view + nios_network_view: + name: ansible + state: absent + provider: "{{ nios_provider }}" + +- name: configure a new network view + 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: ansible + state: present + provider: "{{ nios_provider }}" + register: nios_network_view_create2 + +- name: update the comment for network view + 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: 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: ansible + state: absent + provider: "{{ nios_provider }}" + register: nios_network_view_delete1 + +- name: remove the network view + nios_network_view: + name: ansible + state: absent + provider: "{{ nios_provider }}" + register: nios_network_view_delete2 + +- 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" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/tasks/main.yml new file mode 100644 index 00000000..ec33e8f5 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_ptr_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/tasks/nios_ptr_record_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/tasks/nios_ptr_record_idempotence.yml new file mode 100644 index 00000000..a233d80f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/tasks/nios_ptr_record_idempotence.yml @@ -0,0 +1,83 @@ +--- + +- name: create an ipv4 ptr record + nios_ptr_record: + name: ptr.ansible.com + ptrdname: ptr.ansible.com + ipv4: 192.168.10.1 + state: present + provider: "{{ nios_provider }}" + view: default + register: ipv4_ptr_create1 + +- name: create the same ipv4 ptr record + nios_ptr_record: + name: ptr.ansible.com + ptrdname: ptr.ansible.com + ipv4: 192.168.10.1 + state: present + view: default + provider: "{{ nios_provider }}" + register: ipv4_ptr_create2 + +- name: add a comment to an existing ipv4 ptr record + nios_ptr_record: + name: ptr.ansible.com + ptrdname: ptr.ansible.com + ipv4: 192.168.10.1 + comment: this is a test comment + view: default + state: present + provider: "{{ nios_provider }}" + register: ipv4_ptr_update1 + +- name: add the same comment to the same ipv4 ptr host record + nios_ptr_record: + name: ptr.ansible.com + ptrdname: ptr.ansible.com + ipv4: 192.168.10.1 + comment: this is a test comment + view: default + state: present + provider: "{{ nios_provider }}" + register: ipv4_ptr_update2 + +- name: remove a ptr record from the system + nios_ptr_record: + name: ptr.ansible.com + ptrdname: ptr.ansible.com + ipv4: 192.168.10.1 + view: default + state: absent + provider: "{{ nios_provider }}" + register: ipv4_ptr_delete1 + +- name: remove the same ptr record from the system + nios_ptr_record: + ptrdname: ptr.ansible.com + name: ptr.ansible.com + ipv4: 192.168.10.1 + view: default + state: absent + provider: "{{ nios_provider }}" + register: ipv4_ptr_delete2 + +- name: create an ipv6 ptr record + nios_ptr_record: + ptrdname: ptr6.ansible.com + name: ptr6.ansible.com + ipv6: "2002:8ac3:802d:1242:20d:60ff:fe38:6d16" + view: default + state: present + provider: "{{ nios_provider }}" + register: ipv6_ptr_create1 + +- 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" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/meta/main.yaml new file mode 100644 index 00000000..1b01a972 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/tasks/main.yml new file mode 100644 index 00000000..1c847673 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_srv_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/tasks/nios_srv_record_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/tasks/nios_srv_record_idempotence.yml new file mode 100644 index 00000000..8f3dbfc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/tasks/nios_srv_record_idempotence.yml @@ -0,0 +1,98 @@ +- name: cleanup the parent object + nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: create the parent object + nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: cleanup srv record + nios_srv_record: + name: ansible.com + port: 5080 + priority: 10 + target: service1.ansible.com + weight: 10 + state: absent + provider: "{{ nios_provider }}" + +- name: create an srv record + nios_srv_record: + name: ansible.com + port: 5080 + priority: 10 + target: service1.ansible.com + weight: 10 + state: present + provider: "{{ nios_provider }}" + register: srv_record_create1 + +- name: recreate an srv record + nios_srv_record: + name: ansible.com + port: 5080 + priority: 10 + target: service1.ansible.com + weight: 10 + state: present + provider: "{{ nios_provider }}" + register: srv_record_create2 + +- name: add a comment to an existing srv record + nios_srv_record: + name: ansible.com + port: 5080 + priority: 10 + target: service1.ansible.com + weight: 10 + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: srv_record_update1 + +- name: add a comment to an existing srv record + nios_srv_record: + name: ansible.com + port: 5080 + priority: 10 + target: service1.ansible.com + weight: 10 + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: srv_record_update2 + +- name: remove a srv record from the system + nios_srv_record: + name: ansible.com + port: 5080 + priority: 10 + target: service1.ansible.com + weight: 10 + state: absent + provider: "{{ nios_provider }}" + register: srv_record_delete1 + +- name: remove a srv record from the system + nios_srv_record: + name: ansible.com + port: 5080 + priority: 10 + target: service1.ansible.com + weight: 10 + state: absent + provider: "{{ nios_provider }}" + register: srv_record_delete2 + +- 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" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: []
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/tasks/main.yml new file mode 100644 index 00000000..e15b4c55 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_txt_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/tasks/nios_txt_record_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/tasks/nios_txt_record_idempotence.yml new file mode 100644 index 00000000..37638d85 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/tasks/nios_txt_record_idempotence.yml @@ -0,0 +1,82 @@ +- name: cleanup the parent object + nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: create the parent object + nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: cleanup txt record + nios_txt_record: + name: txt.ansible.com + text: mytext + state: absent + provider: "{{ nios_provider }}" + +- name: create txt record + 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: txt.ansible.com + text: mytext + state: present + provider: "{{ nios_provider }}" + register: txt_create2 + +- assert: + that: + - "txt_create1.changed" + - "not txt_create2.changed" + +- name: add a comment to an existing txt record + nios_txt_record: + name: txt.ansible.com + text: mytext + state: present + comment: mycomment + provider: "{{ nios_provider }}" + register: txt_update1 + +- name: add a comment to an existing txt record + nios_txt_record: + name: txt.ansible.com + text: mytext + state: present + comment: mycomment + provider: "{{ nios_provider }}" + register: txt_update2 + +- name: remove a txt record from the system + 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: txt.ansible.com + text: mytext + state: absent + provider: "{{ nios_provider }}" + register: txt_delete2 + +- assert: + that: + - "txt_create1.changed" + - "not txt_create2.changed" + - "txt_update1.changed" + - "not txt_update2.changed" + - "txt_delete1.changed" + - "not txt_delete2.changed" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: []
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests
\ No newline at end of file diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/tasks/main.yml new file mode 100644 index 00000000..f066edcd --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/tasks/main.yml @@ -0,0 +1 @@ +- include: nios_zone_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/tasks/nios_zone_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/tasks/nios_zone_idempotence.yml new file mode 100644 index 00000000..03d40aaf --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/tasks/nios_zone_idempotence.yml @@ -0,0 +1,68 @@ +- name: cleanup dns view instance + nios_dns_view: + name: ansible-dns + state: absent + provider: "{{ nios_provider }}" + +- name: cleanup test zone + nios_zone: + name: ansible-dns + state: absent + provider: "{{ nios_provider }}" + +- name: configure a zone on the system + nios_zone: + name: ansible-dns + state: present + provider: "{{ nios_provider }}" + register: zone_create1 + +- name: configure a zone on the system + 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: ansible-dns + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + register: zone_update1 + +- name: update the comment and ext attributes for an existing zone + nios_zone: + name: ansible-dns + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + register: zone_update2 + +- name: remove the dns zone + nios_zone: + name: ansible-dns + state: absent + provider: "{{ nios_provider }}" + register: zone_delete1 + +- name: remove the dns zone + nios_zone: + name: ansible-dns + state: absent + provider: "{{ nios_provider }}" + register: zone_delete2 + +- assert: + that: + - "zone_create1.changed" + - "not zone_create2.changed" + - "zone_update1.changed" + - "not zone_update2.changed" + - "zone_delete1.changed" + - "not zone_delete2.changed" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/prepare_nios_tests/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/prepare_nios_tests/tasks/main.yml new file mode 100644 index 00000000..2a3092f3 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/prepare_nios_tests/tasks/main.yml @@ -0,0 +1 @@ +- include: prepare_nios_tests_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/prepare_nios_tests/tasks/prepare_nios_tests_idempotence.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/prepare_nios_tests/tasks/prepare_nios_tests_idempotence.yml new file mode 100644 index 00000000..749faa20 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/prepare_nios_tests/tasks/prepare_nios_tests_idempotence.yml @@ -0,0 +1,2 @@ +- pip: + name: infoblox-client diff --git a/ansible_collections/infoblox/nios_modules/tests/requirements.txt b/ansible_collections/infoblox/nios_modules/tests/requirements.txt new file mode 100644 index 00000000..7f835e9f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/requirements.txt @@ -0,0 +1,9 @@ +infoblox-client +pytest +pytest-xdist +mock +pytest-mock +pytest-cov==2.8.0 +coverage +pygobject +launchpadlib diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/__init__.py b/ansible_collections/infoblox/nios_modules/tests/unit/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/__init__.py diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/compat/__init__.py b/ansible_collections/infoblox/nios_modules/tests/unit/compat/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/compat/__init__.py diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/compat/mock.py b/ansible_collections/infoblox/nios_modules/tests/unit/compat/mock.py new file mode 100644 index 00000000..ba8455bf --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/compat/mock.py @@ -0,0 +1,120 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# 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 <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +''' +Compat module for Python3.x's unittest.mock module +''' +import sys + +# Python 2.7 + +# Note: Could use the pypi mock library on python3.x as well as python2.x. It +# is the same as the python3 stdlib mock library + +try: + # Allow wildcard import because we really do want to import all of mock's + # symbols into this compat shim + # pylint: disable=wildcard-import,unused-wildcard-import + from unittest.mock import * +except ImportError: + # Python 2 + # pylint: disable=wildcard-import,unused-wildcard-import + try: + from mock import * + except ImportError: + print('You need the mock library installed on python2.x to run tests') + + +# Prior to 3.4.4, mock_open cannot handle binary read_data +if sys.version_info >= (3,) and sys.version_info < (3, 4, 4): + file_spec = None + + def _iterate_read_data(read_data): + # Helper for mock_open: + # Retrieve lines from read_data via a generator so that separate calls to + # readline, read, and readlines are properly interleaved + sep = b'\n' if isinstance(read_data, bytes) else '\n' + data_as_list = [l + sep for l in read_data.split(sep)] + + if data_as_list[-1] == sep: + # If the last line ended in a newline, the list comprehension will have an + # extra entry that's just a newline. Remove this. + data_as_list = data_as_list[:-1] + else: + # If there wasn't an extra newline by itself, then the file being + # emulated doesn't have a newline to end the last line remove the + # newline that our naive format() added + data_as_list[-1] = data_as_list[-1][:-1] + + for line in data_as_list: + yield line + + def mock_open(mock=None, read_data=''): + """ + A helper function to create a mock to replace the use of `open`. It works + for `open` called directly or used as a context manager. + The `mock` argument is the mock object to configure. If `None` (the + default) then a `MagicMock` will be created for you, with the API limited + to methods or attributes available on standard file handles. + `read_data` is a string for the `read` methoddline`, and `readlines` of the + file handle to return. This is an empty string by default. + """ + def _readlines_side_effect(*args, **kwargs): + if handle.readlines.return_value is not None: + return handle.readlines.return_value + return list(_data) + + def _read_side_effect(*args, **kwargs): + if handle.read.return_value is not None: + return handle.read.return_value + return type(read_data)().join(_data) + + 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 + + global file_spec + if file_spec is None: + import _io + file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))) + + if mock is None: + mock = MagicMock(name='open', spec=open) + + handle = MagicMock(spec=file_spec) + handle.__enter__.return_value = handle + + _data = _iterate_read_data(read_data) + + handle.write.return_value = None + handle.read.return_value = None + handle.readline.return_value = None + handle.readlines.return_value = None + + handle.read.side_effect = _read_side_effect + handle.readline.side_effect = _readline_side_effect() + handle.readlines.side_effect = _readlines_side_effect + + mock.return_value = handle + return mock diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/__init__.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/__init__.py diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/module_utils/__init__.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/module_utils/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/module_utils/__init__.py diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/module_utils/test_api.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/module_utils/test_api.py new file mode 100644 index 00000000..550d1bd7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/module_utils/test_api.py @@ -0,0 +1,255 @@ +# (c) 2018 Red Hat, 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 + +import copy + +from ansible_collections.infoblox.nios_modules.tests.unit.compat import unittest +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from ansible.module_utils.common.validation import check_type_dict +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api + + +class TestNiosApi(unittest.TestCase): + + def setUp(self): + super(TestNiosApi, self).setUp() + + self.module = MagicMock(name='AnsibleModule') + self.module.check_mode = False + self.module.params = {'provider': None} + + self.mock_connector = patch('ansible_collections.infoblox.nios_modules.plugins.module_utils.api.get_connector') + self.mock_connector.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(TestNiosApi, self).tearDown() + + self.mock_connector.stop() + self.mock_check_type_dict.stop() + + def test_get_provider_spec(self): + provider_options = ['host', 'username', 'password', 'cert', 'key', 'validate_certs', 'silent_ssl_warnings', + 'http_request_timeout', 'http_pool_connections', + 'http_pool_maxsize', 'max_retries', 'wapi_version', 'max_results'] + res = api.WapiBase.provider_spec + self.assertIsNotNone(res) + self.assertIn('provider', res) + self.assertIn('options', res['provider']) + returned_options = res['provider']['options'] + self.assertEqual(sorted(provider_options), sorted(returned_options.keys())) + + 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 test_wapi_no_change(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'default', + 'comment': 'test comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": 'default', + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertFalse(res['changed']) + + def test_wapi_change(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'default', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "default", + "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.update_object.called_once_with(test_object) + + def test_wapi_change_false(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'default', + 'comment': 'updated comment', 'extattrs': None, 'fqdn': 'foo'} + + test_object = [ + { + "comment": "test comment", + "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "default", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "fqdn": {"ib_req": True, 'update': False}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.update_object.called_once_with(test_object) + + def test_wapi_extattrs_change(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'default', + 'comment': 'test comment', 'extattrs': {'Site': 'update'}} + + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "name": "default", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + kwargs = copy.deepcopy(test_object[0]) + kwargs['extattrs']['Site']['value'] = 'update' + kwargs['name'] = 'default' + del kwargs['_ref'] + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, kwargs) + + def test_wapi_extattrs_nochange(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'default', + 'comment': 'test comment', 'extattrs': {'Site': 'test'}} + + test_object = [{ + "comment": "test comment", + "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "default", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertFalse(res['changed']) + + def test_wapi_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible', + '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': 'ansible'}) + + def test_wapi_delete(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible', + 'comment': None, 'extattrs': None} + + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "name": "ansible", + "extattrs": {'Site': {'value': 'test'}} + }] + + 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) + + def test_wapi_strip_network_view(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible', + 'comment': 'updated comment', 'extattrs': None, + 'network_view': 'default'} + + test_object = [{ + "comment": "test comment", + "_ref": "view/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/true", + "name": "ansible", + "extattrs": {}, + "network_view": "default" + }] + + test_spec = { + "name": {"ib_req": True}, + "network_view": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + kwargs = test_object[0].copy() + ref = kwargs.pop('_ref') + kwargs['comment'] = 'updated comment' + kwargs['name'] = 'ansible' + del kwargs['network_view'] + del kwargs['extattrs'] + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, kwargs) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/__init__.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/__init__.py diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/fixtures/nios_result.txt b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/fixtures/nios_result.txt new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/fixtures/nios_result.txt diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_a_record.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_a_record.py new file mode 100644 index 00000000..b8722011 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_a_record.py @@ -0,0 +1,163 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_a_record +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 ansible.module_utils.common.validation import check_type_dict +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosARecordModule(TestNiosModule): + + module = nios_a_record + + def setUp(self): + super(TestNiosARecordModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_a_record.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_a_record.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_a_record.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(TestNiosARecordModule, 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_a_record_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'a.ansible.com', + 'ipv4': '192.168.10.1', 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "ipv4": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi.__dict__) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'a.ansible.com', + 'ipv4': '192.168.10.1'}) + + 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} + + test_object = [ + { + "comment": "test comment", + "_ref": "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "a.ansible.com", + "ipv4": "192.168.10.1", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "ipv4": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_a_record_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'a.ansible.com', 'ipv4': '192.168.10.1', + 'comment': None, 'extattrs': None} + + ref = "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "name": "a.ansible.com", + "ipv4": "192.168.10.1", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "name": {"ib_req": True}, + "ipv4": {"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) + + 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} + + test_object = [ + { + "comment": "test comment", + "_ref": "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "a_new.ansible.com", + "old_name": "a.ansible.com", + "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.update_object.called_once_with(test_object) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_aaaa_record.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_aaaa_record.py new file mode 100644 index 00000000..9bfa1c5f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_aaaa_record.py @@ -0,0 +1,163 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_aaaa_record +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 ansible.module_utils.common.validation import check_type_dict +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosAAAARecordModule(TestNiosModule): + + module = nios_aaaa_record + + def setUp(self): + super(TestNiosAAAARecordModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_aaaa_record.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_aaaa_record.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_aaaa_record.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(TestNiosAAAARecordModule, 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_aaaa_record_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'aaaa.ansible.com', + 'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "ipv6": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi.__dict__) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'aaaa.ansible.com', + 'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334'}) + + 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} + + test_object = [ + { + "comment": "test comment", + "_ref": "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "aaaa.ansible.com", + "ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "ipv6": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_aaaa_record_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'aaaa.ansible.com', + 'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'comment': None, 'extattrs': None} + + ref = "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "name": "aaaa.ansible.com", + "ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "name": {"ib_req": True}, + "ipv6": {"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) + + 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} + + test_object = [ + { + "comment": "test comment", + "_ref": "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "aaaa_new.ansible.com", + "old_name": "aaaa.ansible.com", + "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.update_object.called_once_with(test_object) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_cname_record.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_cname_record.py new file mode 100644 index 00000000..3df06300 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_cname_record.py @@ -0,0 +1,137 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_cname_record +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 ansible.module_utils.common.validation import check_type_dict +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosCNameRecordModule(TestNiosModule): + + module = nios_cname_record + + def setUp(self): + super(TestNiosCNameRecordModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_cname_record.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_cname_record.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_cname_record.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(TestNiosCNameRecordModule, 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_cname_record_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'cname.ansible.com', + 'canonical': 'realhost.ansible.com', 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "canonical": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi.__dict__) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'cname.ansible.com', + 'canonical': 'realhost.ansible.com'}) + + 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} + + test_object = [ + { + "comment": "test comment", + "_ref": "cnamerecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "cname.ansible.com", + "canonical": "realhost.ansible.com", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "canonical": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_cname_record_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'cname.ansible.com', + 'canonical': 'realhost.ansible.com', 'comment': None, 'extattrs': None} + + ref = "cnamerecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "name": "cname.ansible.com", + "canonical": "realhost.ansible.com", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "name": {"ib_req": True}, + "canonical": {"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/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dns_view.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dns_view.py new file mode 100644 index 00000000..a59f50f5 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dns_view.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 <http://www.gnu.org/licenses/>. + +# 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_dns_view +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 ansible.module_utils.common.validation import check_type_dict +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDnsViewModule(TestNiosModule): + + module = nios_dns_view + + def setUp(self): + super(TestNiosDnsViewModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dns_view.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dns_view.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dns_view.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(TestNiosDnsViewModule, 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_dns_view_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible-dns', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'ansible-dns'}) + + def test_nios_dns_view_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible-dns', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dnsview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "ansible-dns", + "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_dns_view_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible-dns', + 'comment': None, 'extattrs': None} + + ref = "dnsview/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "name": "ansible-dns", + "extattrs": {'Site': {'value': 'test'}} + }] + + 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/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_fixed_address.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_fixed_address.py new file mode 100644 index 00000000..ae373fd3 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_fixed_address.py @@ -0,0 +1,201 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_fixed_address +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 TestNiosFixedAddressModule(TestNiosModule): + + module = nios_fixed_address + + def setUp(self): + super(TestNiosFixedAddressModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_fixed_address.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_fixed_address.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_fixed_address.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + + def tearDown(self): + super(TestNiosFixedAddressModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + + 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 _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 test_nios_fixed_address_ipv4_create(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': None, 'extattrs': None} + + test_object = None + test_spec = { + "name": {}, + "ipaddr": {"ib_req": True}, + "mac": {"ib_req": True}, + "network": {"ib_req": True}, + "network_view": {}, + "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': 'test_fa', 'ipaddr': '192.168.10.1', 'mac': '08:6d:41:e8:fd:e8', + 'network': '192.168.10.0/24', 'network_view': 'default'}) + + 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} + + test_object = [ + { + "comment": "test comment", + "name": "test_fa", + "_ref": "network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "ipaddr": "192.168.10.1", + "mac": "08:6d:41:e8:fd:e8", + "network": "192.168.10.0/24", + "network_view": "default", + "extattrs": {'options': {'name': 'test', 'value': 'ansible.com'}} + } + ] + + test_spec = { + "name": {}, + "ipaddr": {"ib_req": True}, + "mac": {"ib_req": True}, + "network": {"ib_req": True}, + "network_view": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + 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', + 'network': '192.168.10.0/24', 'network_view': 'default', 'comment': None, 'extattrs': None} + + ref = "fixedaddress/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "name": "test_fa", + "_ref": ref, + "ipaddr": "192.168.10.1", + "mac": "08:6d:41:e8:fd:e8", + "network": "192.168.10.0/24", + "network_view": "default", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "name": {}, + "ipaddr": {"ib_req": True}, + "mac": {"ib_req": True}, + "network": {"ib_req": True}, + "network_view": {}, + "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) + + def test_nios_fixed_address_ipv6_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'test_fa', 'ipaddr': 'fe80::1/10', 'mac': '08:6d:41:e8:fd:e8', + 'network': 'fe80::/64', 'network_view': 'default', 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {}, + "ipaddr": {"ib_req": True}, + "mac": {"ib_req": True}, + "network": {"ib_req": True}, + "network_view": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'test_fa', 'ipaddr': 'fe80::1/10', 'mac': '08:6d:41:e8:fd:e8', + 'network': 'fe80::/64', 'network_view': 'default'}) + + def test_nios_fixed_address_ipv6_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'test_fa', 'ipaddr': 'fe80::1/10', 'mac': '08:6d:41:e8:fd:e8', + 'network': 'fe80::/64', 'network_view': 'default', 'comment': None, 'extattrs': None} + + ref = "ipv6fixedaddress/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "name": "test_fa", + "_ref": ref, + "ipaddr": "fe80::1/10", + "mac": "08:6d:41:e8:fd:e8", + "network": "fe80::/64", + "network_view": "default", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "name": {}, + "ipaddr": {"ib_req": True}, + "mac": {"ib_req": True}, + "network": {"ib_req": True}, + "network_view": {}, + "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/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_host_record.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_host_record.py new file mode 100644 index 00000000..11489960 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_host_record.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 <http://www.gnu.org/licenses/>. + +# 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_host_record +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 ansible.module_utils.common.validation import check_type_dict +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosHostRecordModule(TestNiosModule): + + module = nios_host_record + + def setUp(self): + + super(TestNiosHostRecordModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_host_record.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_host_record.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_host_record.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(TestNiosHostRecordModule, self).tearDown() + self.mock_wapi.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_host_record_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible', + 'comment': None, 'extattrs': None} + + test_object = None + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'ansible'}) + + def test_nios_host_record_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible', + 'comment': None, 'extattrs': None} + + ref = "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "name": "ansible", + "extattrs": {'Site': {'value': 'test'}} + }] + + 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) + + def test_nios_host_record_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'default', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "default", + "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.update_object.called_once_with(test_object) + + 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} + + test_object = [ + { + "comment": "test comment", + "_ref": "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "default", + "old_name": "old_default", + "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.update_object.called_once_with(test_object) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_member.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_member.py new file mode 100644 index 00000000..a65b5df1 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_member.py @@ -0,0 +1,162 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_member +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 TestNiosMemberModule(TestNiosModule): + + module = nios_member + + def setUp(self): + super(TestNiosMemberModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_member.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_member.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_member.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + + def tearDown(self): + super(TestNiosMemberModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + + 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 _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 test_nios_member_create(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': None, 'extattrs': None} + + test_object = None + test_spec = { + "host_name": {"ib_req": True}, + "vip_setting": {}, + "config_addr_type": {}, + "platform": {}, + "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', {'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_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} + + test_object = [ + { + "comment": "Created with Ansible", + "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQ3:member01.ansible-dev.com", + "config_addr_type": "IPV4", + "host_name": "member01.ansible-dev.com", + "platform": "VNIOS", + "service_type_configuration": "ALL_V4", + "vip_setting": + { + "address": "192.168.1.100", + "dscp": 0, + "gateway": "192.168.1.1", + "primary": True, + "subnet_mask": "255.255.255.0", + "use_dscp": False + } + } + ] + + test_spec = { + "host_name": {"ib_req": True}, + "vip_setting": {}, + "config_addr_type": {}, + "platform": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_member_remove(self): + self.module.params = {'provider': None, 'state': 'absent', '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", + "config_addr_type": "IPV4", + "host_name": "member01.ansible-dev.com", + "platform": "VNIOS", + "service_type_configuration": "ALL_V4", + "vip_setting": + { + "address": "192.168.1.100", + "dscp": 0, + "gateway": "192.168.1.1", + "primary": True, + "subnet_mask": "255.255.255.0", + "use_dscp": False + } + } + ] + + test_spec = { + "host_name": {"ib_req": True}, + "vip_setting": {}, + "config_addr_type": {}, + "platform": {}, + "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/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_module.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_module.py new file mode 100644 index 00000000..6ffaa1f7 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_module.py @@ -0,0 +1,88 @@ +# (c) 2018 Red Hat Inc. +# +# 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 <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json + +from ansible_collections.infoblox.nios_modules.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase + + +fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') +fixture_data = {} + + +def load_fixture(name): + path = os.path.join(fixture_path, name) + + if path in fixture_data: + return fixture_data[path] + + with open(path) as f: + data = f.read() + + try: + data = json.loads(data) + except Exception: + pass + + fixture_data[path] = data + return data + + +class TestNiosModule(ModuleTestCase): + + def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False): + + self.load_fixtures(commands) + + if failed: + result = self.failed() + self.assertTrue(result['failed'], result) + else: + result = self.changed(changed) + self.assertEqual(result['changed'], changed, result) + + if commands is not None: + if sort: + self.assertEqual(sorted(commands), sorted(result['commands']), result['commands']) + else: + self.assertEqual(commands, result['commands'], result['commands']) + + return result + + def failed(self): + with self.assertRaises(AnsibleFailJson) as exc: + self.module.main() + + result = exc.exception.args[0] + self.assertTrue(result['failed'], result) + return result + + def changed(self, changed=False): + with self.assertRaises(AnsibleExitJson) as exc: + self.module.main() + + result = exc.exception.args[0] + self.assertEqual(result['changed'], changed, result) + return result + + def load_fixtures(self, commands=None): + pass diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_mx_record.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_mx_record.py new file mode 100644 index 00000000..e28cd0e1 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_mx_record.py @@ -0,0 +1,141 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_mx_record +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 ansible.module_utils.common.validation import check_type_dict +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosMXRecordModule(TestNiosModule): + + module = nios_mx_record + + def setUp(self): + super(TestNiosMXRecordModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_mx_record.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_mx_record.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_mx_record.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(TestNiosMXRecordModule, 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_mx_record_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible.com', + 'mx': 'mailhost.ansible.com', 'preference': 0, 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "mx": {"ib_req": True}, + "preference": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'ansible.com', + 'mx': 'mailhost.ansible.com', 'preference': 0}) + + 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} + + test_object = [ + { + "comment": "test comment", + "_ref": "mxrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "ansible.com", + "mx": "mailhost.ansible.com", + "preference": 0, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "mx": {"ib_req": True}, + "preference": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_mx_record_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible.com', 'mx': 'mailhost.ansible.com', + 'preference': 0, 'comment': None, 'extattrs': None} + + ref = "mxrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "name": "ansible.com", + "mx": "mailhost.ansible.com", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "name": {"ib_req": True}, + "mx": {"ib_req": True}, + "preference": {"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/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_naptr_record.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_naptr_record.py new file mode 100644 index 00000000..a546a90a --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_naptr_record.py @@ -0,0 +1,151 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_naptr_record +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 ansible.module_utils.common.validation import check_type_dict +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosNAPTRRecordModule(TestNiosModule): + + module = nios_naptr_record + + def setUp(self): + super(TestNiosNAPTRRecordModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_naptr_record.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_naptr_record.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_naptr_record.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(TestNiosNAPTRRecordModule, 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_naptr_record_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': '*.subscriber-100.ansiblezone.com', + 'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "order": {"ib_req": True}, + "preference": {"ib_req": True}, + "replacement": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi.__dict__) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': '*.subscriber-100.ansiblezone.com', + 'order': '1000', 'preference': '10', + 'replacement': 'replacement1.network.ansiblezone.com'}) + + def test_nios_naptr_record_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': '*.subscriber-100.ansiblezone.com', + 'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "naptrrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "*.subscriber-100.ansiblezone.com", + "order": "1000", + "preference": "10", + "replacement": "replacement1.network.ansiblezone.com", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "order": {"ib_req": True}, + "preference": {"ib_req": True}, + "replacement": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_naptr_record_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': '*.subscriber-100.ansiblezone.com', + 'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com', + 'comment': None, 'extattrs': None} + + ref = "naptrrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "name": "*.subscriber-100.ansiblezone.com", + "order": "1000", + "preference": "10", + "replacement": "replacement1.network.ansiblezone.com", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "name": {"ib_req": True}, + "order": {"ib_req": True}, + "preference": {"ib_req": True}, + "replacement": {"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/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_network.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_network.py new file mode 100644 index 00000000..0fad5aaa --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_network.py @@ -0,0 +1,248 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_network +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 TestNiosNetworkModule(TestNiosModule): + + module = nios_network + + def setUp(self): + super(TestNiosNetworkModule, self).setUp() + 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.start() + self.load_config = self.mock_wapi_run.start() + + def tearDown(self): + super(TestNiosNetworkModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + + 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 _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 test_nios_network_ipv4_create(self): + self.module.params = {'provider': None, 'state': 'present', 'network': '192.168.10.0/24', + 'comment': None, 'extattrs': None} + + test_object = None + test_spec = { + "network": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'network': '192.168.10.0/24'}) + + 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} + + test_object = [ + { + "comment": "test comment", + "_ref": "network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "network": "192.168.10.0/24", + "extattrs": {'options': {'name': 'test', 'value': 'ansible.com'}} + } + ] + + test_spec = { + "network": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_network_ipv6_dhcp_update(self): + self.module.params = {'provider': None, 'state': 'present', 'ipv6network': 'fe80::/64', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "ipv6network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "ipv6network": "fe80::/64", + "extattrs": {'options': {'name': 'test', 'value': 'ansible.com'}} + } + ] + + test_spec = { + "ipv6network": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + self.assertTrue(res['changed']) + + def test_nios_network_ipv4_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'network': '192.168.10.0/24', + 'comment': None, 'extattrs': None} + + ref = "network/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "network": "192.168.10.0/24", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "network": {"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) + + def test_nios_network_ipv6_create(self): + self.module.params = {'provider': None, 'state': 'present', 'ipv6network': 'fe80::/64', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "ipv6network": {"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', {'ipv6network': 'fe80::/64'}) + + def test_nios_network_ipv6_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'ipv6network': 'fe80::/64', + 'comment': None, 'extattrs': None} + + ref = "ipv6network/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "ipv6network": "fe80::/64", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "ipv6network": {"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) + + def test_nios_networkcontainer_ipv4_create(self): + self.module.params = {'provider': None, 'state': 'present', 'networkcontainer': '192.168.10.0/24', + 'comment': None, 'extattrs': None} + + test_object = None + test_spec = { + "networkcontainer": {"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', {'networkcontainer': '192.168.10.0/24'}) + + def test_nios_networkcontainer_ipv4_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'networkcontainer': '192.168.10.0/24', + 'comment': None, 'extattrs': None} + + ref = "networkcontainer/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "networkcontainer": "192.168.10.0/24" + }] + + test_spec = { + "networkcontainer": {"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) + + def test_nios_networkcontainer_ipv6_create(self): + self.module.params = {'provider': None, 'state': 'present', 'ipv6networkcontainer': 'fe80::/64', + 'comment': None, 'extattrs': None} + + test_object = None + test_spec = { + "ipv6networkcontainer": {"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', {'ipv6networkcontainer': 'fe80::/64'}) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_network_view.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_network_view.py new file mode 100644 index 00000000..4756127c --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_network_view.py @@ -0,0 +1,160 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_network_view +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 ansible.module_utils.common.validation import check_type_dict +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosNetworkViewModule(TestNiosModule): + + module = nios_network_view + + def setUp(self): + super(TestNiosNetworkViewModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_network_view.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_network_view.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_network_view.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(TestNiosNetworkViewModule, 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_network_view_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible', + 'comment': None, 'extattrs': None} + + test_object = None + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {}, + + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'ansible'}) + + 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'} + + test_object = [ + { + "comment": "test comment", + "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "default", + "extattrs": {}, + "network_view": "default" + } + ] + + 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.update_object.called_once_with(test_object) + + 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'} + + test_object = [ + { + "comment": "test comment", + "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "default", + "old_name": "old_default", + "extattrs": {}, + "network_view": "default" + } + ] + + 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.update_object.called_once_with(test_object) + + def test_nios_network_view_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible', + 'comment': None, 'extattrs': None} + + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "name": "ansible", + "extattrs": {'Site': {'value': 'test'}} + }] + + 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/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_nsgroup.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_nsgroup.py new file mode 100644 index 00000000..d8ca9667 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_nsgroup.py @@ -0,0 +1,130 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_nsgroup +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 ansible.module_utils.common.validation import check_type_dict +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosNSGroupModule(TestNiosModule): + + module = nios_nsgroup + + def setUp(self): + + super(TestNiosNSGroupModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_nsgroup.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_nsgroup.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_nsgroup.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(TestNiosNSGroupModule, self).tearDown() + self.mock_wapi.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_nsgroup_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'my-simple-group', + 'comment': None, 'grid_primary': None} + + test_object = None + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "grid_primary": {} + } + + 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': 'my-simple-group'}) + + def test_nios_nsgroup_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'my-simple-group', + 'comment': None, 'grid_primary': None} + + ref = "nsgroup/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "name": "my-simple-group", + "grid_primary": {'name': 'infoblox-test.example.com'} + }] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "grid_primary": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) + + def test_nios_nsgroup_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'default', + 'comment': 'updated comment', 'grid_primary': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "nsgroup/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "default", + "grid_primary": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "grid_primary": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.update_object.called_once_with(test_object) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_ptr_record.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_ptr_record.py new file mode 100644 index 00000000..5ffd6487 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_ptr_record.py @@ -0,0 +1,184 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_ptr_record +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 TestNiosPTRRecordModule(TestNiosModule): + + module = nios_ptr_record + + def setUp(self): + + super(TestNiosPTRRecordModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_ptr_record.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_ptr_record.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_ptr_record.WapiModule.run') + self.mock_wapi_run.start() + + self.load_config = self.mock_wapi_run.start() + + def tearDown(self): + super(TestNiosPTRRecordModule, self).tearDown() + self.mock_wapi.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_ptr_record_create(self): + self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.com', + 'ipv4addr': '10.36.241.14', 'comment': None, 'extattrs': None, 'view': 'default'} + + test_object = None + test_spec = { + "ipv4addr": {"ib_req": True}, + "ptrdname": {"ib_req": True}, + "comment": {}, + "extattrs": {}, + "view": {"ib_req": True} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'ipv4addr': '10.36.241.14', 'ptrdname': 'ansible.test.com', 'view': 'default'}) + + def test_nios_ptr_record_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'ptrdname': 'ansible.test.com', + 'ipv4addr': '10.36.241.14', 'comment': None, 'extattrs': None, 'view': 'default'} + + ref = "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "ptrdname": "ansible.test.com", + "ipv4addr": "10.36.241.14", + "view": "default", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "ipv4addr": {"ib_req": True}, + "ptrdname": {"ib_req": True}, + "comment": {}, + "extattrs": {}, + "view": {"ib_req": True} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) + + 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'} + + test_object = [ + { + "comment": "test comment", + "_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default", + "ptrdname": "ansible.test.com", + "ipv4addr": "10.36.241.14", + "extattrs": {}, + "view": "default" + } + ] + + test_spec = { + "ipv4addr": {"ib_req": True}, + "ptrdname": {"ib_req": True}, + "comment": {}, + "extattrs": {}, + "view": {"ib_req": True} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.update_object.called_once_with(test_object) + + 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'} + + test_object = [ + { + "comment": "test comment", + "_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default", + "ptrdname": "ansible.test.com", + "ipv4addr": "10.36.241.14", + "extattrs": {}, + "view": "default" + } + ] + + test_spec = { + "ipv4addr": {"ib_req": True}, + "ptrdname": {"ib_req": True}, + "comment": {}, + "extattrs": {}, + "view": {"ib_req": True} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.update_object.called_once_with(test_object) + + def test_nios_ptr6_record_create(self): + self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible6.test.com', + 'ipv6addr': '2002:8ac3:802d:1242:20d:60ff:fe38:6d16', 'comment': None, 'extattrs': None, 'view': 'default'} + + test_object = None + test_spec = {"ipv6addr": {"ib_req": True}, + "ptrdname": {"ib_req": True}, + "comment": {}, + "extattrs": {}, + "view": {"ib_req": True}} + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'ipv6addr': '2002:8ac3:802d:1242:20d:60ff:fe38:6d16', + 'ptrdname': 'ansible6.test.com', 'view': 'default'}) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_srv_record.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_srv_record.py new file mode 100644 index 00000000..3d7e6c98 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_srv_record.py @@ -0,0 +1,157 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_srv_record +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 ansible.module_utils.common.validation import check_type_dict +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosSRVRecordModule(TestNiosModule): + + module = nios_srv_record + + def setUp(self): + super(TestNiosSRVRecordModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_srv_record.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_srv_record.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_srv_record.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(TestNiosSRVRecordModule, 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_srv_record_create(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} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "port": {"ib_req": True}, + "target": {"ib_req": True}, + "priority": {"ib_req": True}, + "weight": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': '_sip._tcp.service.ansible.com', + 'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10}) + + 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} + + test_object = [ + { + "comment": "test comment", + "_ref": "srvrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "_sip._tcp.service.ansible.com", + 'port': 5080, + "target": "mailhost.ansible.com", + "priority": 10, + 'weight': 10, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "port": {"ib_req": True}, + "target": {"ib_req": True}, + "priority": {"ib_req": True}, + "weight": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_srv_record_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': '_sip._tcp.service.ansible.com', + 'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10, + 'comment': None, 'extattrs': None} + + ref = "srvrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "_sip._tcp.service.ansible.com", + "port": 5080, + "target": "mailhost.ansible.com", + "priority": 10, + "weight": 10, + "extattrs": {'Site': {'value': 'test'}} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "port": {"ib_req": True}, + "target": {"ib_req": True}, + "priority": {"ib_req": True}, + "weight": {"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/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_zone.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_zone.py new file mode 100644 index 00000000..693ab060 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_zone.py @@ -0,0 +1,287 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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_zone +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 TestNiosZoneModule(TestNiosModule): + + module = nios_zone + + def setUp(self): + super(TestNiosZoneModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_zone.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_zone.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_zone.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + + def tearDown(self): + super(TestNiosZoneModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.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_zone_create(self): + self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "fqdn": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'fqdn': 'ansible.com'}) + + def test_nios_zone_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'fqdn': 'ansible.com', + 'comment': None, 'extattrs': None} + + ref = "zone/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "fqdn": "ansible.com", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "fqdn": {"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) + + def test_nios_zone_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "zone/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "fqdn": "ansible.com", + "extattrs": {'Site': {'value': 'test'}} + } + ] + + test_spec = { + "fqdn": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_zone_create_using_grid_primary_secondaries(self): + self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com', + 'grid_primary': [{"name": "gridprimary.grid.com"}], + 'grid_secondaries': [{"name": "gridsecondary1.grid.com"}, + {"name": "gridsecondary2.grid.com"}], + 'restart_if_needed': True, + 'comment': None, 'extattrs': None} + + test_object = None + grid_spec = dict( + name=dict(required=True), + ) + test_spec = { + "fqdn": {"ib_req": True}, + "grid_primary": {}, + "grid_secondaries": {}, + "restart_if_needed": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'fqdn': 'ansible.com', + "grid_primary": [{"name": "gridprimary.grid.com"}], + "grid_secondaries": [{"name": "gridsecondary1.grid.com"}, + {"name": "gridsecondary2.grid.com"}], + "restart_if_needed": True + }) + + def test_nios_zone_remove_using_grid_primary_secondaries(self): + self.module.params = {'provider': None, 'state': 'absent', 'fqdn': 'ansible.com', + 'grid_primary': [{"name": "gridprimary.grid.com"}], + 'grid_secondaries': [{"name": "gridsecondary1.grid.com"}, + {"name": "gridsecondary2.grid.com"}], + 'restart_if_needed': True, + 'comment': None, 'extattrs': None} + + ref = "zone/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "fqdn": "ansible.com", + "grid_primary": [{"name": "gridprimary.grid.com"}], + "grid_secondaries": [{"name": "gridsecondary1.grid.com"}, {"name": "gridsecondary2.grid.com"}], + "restart_if_needed": True, + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "fqdn": {"ib_req": True}, + "grid_primary": {}, + "grid_secondaries": {}, + "restart_if_needed": {}, + "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) + + def test_nios_zone_create_using_name_server_group(self): + self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com', + 'ns_group': 'examplensg', 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "fqdn": {"ib_req": True}, + "ns_group": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'fqdn': 'ansible.com', + 'ns_group': 'examplensg'}) + + def test_nios_zone_remove_using_name_server_group(self): + self.module.params = {'provider': None, 'state': 'absent', 'fqdn': 'ansible.com', + 'ns_group': 'examplensg', 'comment': None, 'extattrs': None} + + ref = "zone/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "fqdn": "ansible.com", + "ns_group": "examplensg", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "fqdn": {"ib_req": True}, + "ns_group": {}, + "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) + + def test_nios_zone_create_using_zone_format(self): + self.module.params = {'provider': None, 'state': 'present', 'fqdn': '10.10.10.in-addr.arpa', + 'zone_format': 'IPV4', 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "fqdn": {"ib_req": True}, + "zone_format": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + print("WAPI: ", wapi) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'fqdn': '10.10.10.in-addr.arpa', + 'zone_format': 'IPV4'}) + + def test_nios_zone_remove_using_using_zone_format(self): + self.module.params = {'provider': None, 'state': 'absent', 'fqdn': 'ansible.com', + 'zone_format': 'IPV4', 'comment': None, 'extattrs': None} + + ref = "zone/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false" + + test_object = [{ + "comment": "test comment", + "_ref": ref, + "fqdn": "ansible.com", + "zone_format": "IPV4", + "extattrs": {'Site': {'value': 'test'}} + }] + + test_spec = { + "fqdn": {"ib_req": True}, + "zone_format": {}, + "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/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py new file mode 100644 index 00000000..6a00fd25 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py @@ -0,0 +1,52 @@ +# 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 + +import json + +from ansible_collections.community.general.tests.unit.compat 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 + + +def set_module_args(args): + if '_ansible_remote_tmp' not in args: + args['_ansible_remote_tmp'] = '/tmp' + if '_ansible_keep_remote_files' not in args: + args['_ansible_keep_remote_files'] = False + + args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) + basic._ANSIBLE_ARGS = to_bytes(args) + + +class AnsibleExitJson(Exception): + pass + + +class AnsibleFailJson(Exception): + pass + + +def exit_json(*args, **kwargs): + if 'changed' not in kwargs: + kwargs['changed'] = False + raise AnsibleExitJson(kwargs) + + +def fail_json(*args, **kwargs): + kwargs['failed'] = True + raise AnsibleFailJson(kwargs) + + +class ModuleTestCase(unittest.TestCase): + + def setUp(self): + self.mock_module = patch.multiple(basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json) + self.mock_module.start() + self.mock_sleep = patch('time.sleep') + self.mock_sleep.start() + set_module_args({}) + self.addCleanup(self.mock_module.stop) + self.addCleanup(self.mock_sleep.stop) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt b/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt new file mode 100644 index 00000000..a0a2eb7e --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt @@ -0,0 +1,8 @@ +infoblox-client +pytest +pytest-forked +pytest-xdist +mock +pytest-mock +pytest-cov +coverage==4.5.4 |