This project is in active development.
This role is the home for all NS1 specific modules. It will serve as a preview for the modules submitted to ansible-core.
NS1 is an authoritative DNS platform providing data-driven global traffic routing and a fully featured REST API. This module unlocks some of the functionality NS1 can offer for ansible. For more information about what is possible check out ns1.com and api docs.
Completed Modules:
- ns1_zone
- ns1_record
- ns1_data_source_info
-
Install this role from ansible-galaxy.
ansible-galaxy install ns1.ns1
-
Install NS1 Python SDK version 0.9.19 or greater. Additional information can be found here ns1-python.
pip install ns1-python
Previous versions of these modules can be installed from ansible-galaxy by including the desired version tag after the role name (i.e. ansible-galaxy install ns1.ns1,v2.1.0
).
Unit tests use pytest (pip install pytest
). Python 2.7 also requires mock to be installed (pip install mock
).
git clone https://github.com/ns1/ns1-ansible-modules.git
cd ns1-ansible-module
pytest -v
Integration tests can be executed by using ansible directly.
git clone https://github.com/ns1/ns1-ansible-modules.git
cd ns1-ansible-module
ansible-playbook -i local tests/<name of module to test>.yaml --extra-vars ns1_token=<your NS1 API key> --extra-vars test_zone=<a zone you have at ns1>
You can use any test zone to get started, the only requirement is that it's not yet defined on the NS1 platform. That is, you do not need to make the zone authoritative through your registrar for the ansible module to work correctly.
The current version of the module has been tested with Ansible 2.9.4 and both Python 3.7.2 and 2.7.17.
Check out the integration tests in tests/
, which is all working ansible code. All of the resources try to model the api objects as closely as possible.
Contributions, ideas and criticisms are all welcome. Please keep the integration tests up to date or add new ones if you do wind up hacking on the project.
When creating filters on records you have to use the full syntax required by the REST API to prevent ansible from updating the resources each time. For example the filters field should look like
filters:
- filter: "up"
config: {}
Not
filters:
- filter: {}
Even though it still creates the correct resources. It calls out to the api to update each time.
Pull Requests and issues are welcome. See the NS1 Contribution Guidelines for more information.