Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

DNS Record Support for Bloxone Ansible v2 #46

Merged
merged 33 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9fcc451
Modules for DNS data
Tejashree-RS Nov 13, 2024
413ab0d
DNS A Record Support for Bloxone Ansible
Tejashree-RS Dec 2, 2024
462f0d4
deleted main.yml.bckp file
Tejashree-RS Dec 2, 2024
6a57e23
Merge branch 'v2' of github.com:infobloxopen/bloxone-ansible into dns…
Tejashree-RS Dec 17, 2024
63a4aa6
Removed dns_record and dns_record_info, added dns_a_record and dns_a_…
Tejashree-RS Dec 18, 2024
f4e7180
added A record changelog and setup_auth_zone_rmz; updated dns_record…
Tejashree-RS Dec 18, 2024
6837162
Deleted unused file
Tejashree-RS Dec 18, 2024
367a0dc
Restore setup_view file
Tejashree-RS Dec 18, 2024
d27ab24
Restored setup_view
Tejashree-RS Dec 18, 2024
21f18ce
Modified tasks in dns_a_record and dns_a_record_info
Tejashree-RS Dec 18, 2024
5789ea1
Removed extra lines
Tejashree-RS Dec 23, 2024
5da4699
Merge branch 'v2' of github.com:infobloxopen/bloxone-ansible into dns…
Tejashree-RS Dec 23, 2024
4377b79
addressed review comments
Tejashree-RS Jan 6, 2025
b3d8bae
addressed review comments
Tejashree-RS Jan 6, 2025
f248c12
Merge branch 'dns_records' of github.com:Tejashree-RS/bloxone-ansible…
Tejashree-RS Jan 6, 2025
0dfb09a
fixed indentation
Tejashree-RS Jan 6, 2025
2cd46d0
Modified find and update functions
Tejashree-RS Jan 9, 2025
939e08d
Removed HTML tags
Tejashree-RS Jan 9, 2025
1476303
added cleanup.yml for setup_auth_zone_rmz
Tejashree-RS Jan 10, 2025
d557e8e
Resolved merge conflicts
Tejashree-RS Jan 10, 2025
9abeae8
Removed setup_view directory from PR
Tejashree-RS Jan 10, 2025
e1c8dda
Addressed PR comments
Tejashree-RS Jan 10, 2025
a00709a
addressed PR comments
Tejashree-RS Jan 13, 2025
02bd9b3
Addressed PR comments
Tejashree-RS Jan 16, 2025
fcc9b4b
Merge branch 'v2' of github.com:infobloxopen/bloxone-ansible into dns…
Tejashree-RS Jan 16, 2025
6bde072
Fixed Documentation
Tejashree-RS Jan 20, 2025
05643e6
addressed PR comments
Tejashree-RS Jan 22, 2025
29ade6d
Merge branch 'v2' of github.com:infobloxopen/bloxone-ansible into dns…
Tejashree-RS Jan 22, 2025
2bee3b3
Merge branch 'v2' of github.com:infobloxopen/bloxone-ansible into dns…
Tejashree-RS Jan 23, 2025
d89ddbc
Addressed PR Comments
Tejashree-RS Jan 23, 2025
9af4b25
implemented minor correction
Tejashree-RS Jan 27, 2025
d8a620a
added conditional check for CNAME,NS and PTR records
Tejashree-RS Jan 27, 2025
41529b3
Merge branch 'v2' into dns_records
mathewab Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/46-a-record.yml
mathewab marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
deprecated_features:
- b1_a_record - is deprecated in favor of 'dns_record'.
- b1_a_record_gather - is deprecated in favor of 'dns_record_info'.
mathewab marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ action_groups:
- dns_auth_nsg_info
- dns_delegation
- dns_delegation_info
- dns_record
- dns_record_info

ipam:
- ipam_ip_space
Expand Down
599 changes: 599 additions & 0 deletions plugins/modules/dns_record.py

Large diffs are not rendered by default.

406 changes: 406 additions & 0 deletions plugins/modules/dns_record_info.py

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions tests/integration/targets/dns_a_record/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
dependencies: [setup_auth_zone, setup_auth_zone_rmz]
349 changes: 349 additions & 0 deletions tests/integration/targets/dns_a_record/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,349 @@
---
- module_defaults:
group/infoblox.bloxone.all:
csp_url: "{{ csp_url }}"
api_key: "{{ api_key }}"

block:
# Create an A record with a random name to avoid conflicts
- ansible.builtin.set_fact:
record_name: "test-a-record-{{ 999999 | random | string }}"
record_2_name: "test-a-record-2-{{ 999999 | random | string }}"

- ansible.builtin.set_fact:
absolute_name_spec: "{{ record_2_name }}.{{ _fqdn_auth_zone }}"

- name: Create an A Record (check mode)
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "192.168.10.0"
type: "A"
state: present
check_mode: true
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
zone: "{{ _auth_zone.id }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record is changed
- a_record_info is not failed
- a_record_info.objects | length == 0

- name: Create an A Record
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
type: "A"
rdata:
address: "192.168.10.0"
state: present
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
zone: "{{ _auth_zone.id }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record is changed
- a_record_info is not failed
- a_record_info.objects | length == 1
- a_record_info.objects[0].id == a_record.id
- a_record_info.objects[0].rdata.address == "192.168.10.0"
- a_record_info.objects[0].type == "A"
- a_record_info.objects[0].zone == a_record.object.zone

- name: Create an A Record (idempotent)
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
type: "A"
rdata:
address: "192.168.10.0"
state: present
register: a_record
- assert:
that:
- a_record is not changed
- a_record is not failed

- name: Delete the A Record (check mode)
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "192.168.10.20"
type: "A"
state: absent
check_mode: true
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
zone: "{{ _auth_zone.id }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record is changed
- a_record_info is not failed
- a_record_info.objects | length == 1

- name: Delete the A Record
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "192.168.10.20"
type: "A"
state: absent
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
zone: "{{ _auth_zone.id }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record is changed
- a_record_info is not failed
- a_record_info.objects | length == 0

- name: Delete the A Record (idempotent)
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "192.168.10.20"
type: "A"
state: absent
register: a_record
- assert:
that:
- a_record is not changed
- a_record is not failed

- name: Create an A Record with comment
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "10.0.0.0"
type: "A"
comment: "This is a test A Record"
state: present
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
zone: "{{ _auth_zone.id }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record_info is not failed
- a_record_info.objects | length == 1
- a_record_info.objects[0].id == a_record.id
- a_record_info.objects[0].comment == "This is a test A Record"

- name: Create an A Record with TTL
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "10.0.0.0"
type: "A"
ttl: 3600
state: present
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
zone: "{{ _auth_zone.id }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record_info is not failed
- a_record_info.objects | length == 1
- a_record_info.objects[0].id == a_record.id
- a_record_info.objects[0].ttl == 3600

- name: Create an A Record with Disabled
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "10.0.0.0"
type: "A"
disabled: true
state: present
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
zone: "{{ _auth_zone.id }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record_info is not failed
- a_record_info.objects | length == 1
- a_record_info.objects[0].id == a_record.id
- a_record_info.objects[0].disabled == true

- name: Create an A Record with Tags
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "10.0.0.0"
type: "A"
tags:
location: "site-1"
state: present
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
zone: "{{ _auth_zone.id }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record_info is not failed
- a_record_info.objects | length == 1
- a_record_info.objects[0].id == a_record.id
- a_record_info.objects[0].tags.location == "site-1"

- name: Create an A Record with Inheritance Sources
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "10.0.0.0"
type: "A"
inheritance_sources:
ttl:
action: "inherit"
state: present
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
zone: "{{ _auth_zone.id }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record_info is not failed
- a_record_info.objects | length == 1
- a_record_info.objects[0].id == a_record.id
- a_record_info.objects[0].inheritance_sources.ttl.action == "inherit"

- name: Create an A Record with Options
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "40.0.0.0"
type: "A"
options:
create_ptr: true
check_rmz: true
state: present
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
zone: "{{ _auth_zone.id }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record_info is not failed
- a_record_info.objects | length == 1
- a_record_info.objects[0].id == a_record.id
mathewab marked this conversation as resolved.
Show resolved Hide resolved
# create_ptr and check_rmz cannot be asserted here because the flags are not returned in the response of the call

- name: Create an A Record with Name in Zone and Zone
infoblox.bloxone.dns_record:
name_in_zone: "{{ record_name }}"
zone: "{{ _auth_zone.id }}"
rdata:
address: "10.0.0.0"
type: "A"
state: present
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
name_in_zone: "{{ record_name }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record_info is not failed
- a_record_info.objects | length == 1
- a_record_info.objects[0].id == a_record.id
- a_record_info.objects[0].name_in_zone == a_record.object.name_in_zone
- a_record_info.objects[0].zone == a_record.object.zone

- name: Create an A Record using Absolute Name Spec and View
infoblox.bloxone.dns_record:
absolute_name_spec: "{{ absolute_name_spec }}"
view: "{{ _view.id }}"
comment: "This is a test A Record created using ANS and View"
rdata:
address: "15.0.0.0"
type: "A"
state: present
register: a_record
- name: Get Information about the A Record
infoblox.bloxone.dns_record_info:
filters:
absolute_name_spec: "{{ absolute_name_spec }}"
type: "A"
register: a_record_info
- assert:
that:
- a_record_info is not failed
- a_record_info.objects | length == 1
- a_record_info.objects[0].id == a_record.id
- a_record_info.objects[0].absolute_name_spec == a_record.object.absolute_name_spec
- a_record_info.objects[0].view == a_record.object.view
- a_record_info.objects[0].rdata.address == "15.0.0.0"
- a_record_info.objects[0].comment == "This is a test A Record created using ANS and View"
- a_record_info.objects[0].type == "A"
- a_record_info.objects[0].name_in_zone == a_record.object.name_in_zone
- a_record_info.objects[0].zone == a_record.object.zone

always:
- name: "Delete the A Record created with Absolute Name Spec and View"
infoblox.bloxone.dns_record:
absolute_name_spec: "{{ absolute_name_spec }}"
view: "{{ _view.id }}"
rdata:
address: "15.0.0.0"
type: "A"
state: absent

- name: "Delete the A Record"
infoblox.bloxone.dns_record:
name_in_zone: "{{ record_name }}"
zone: "{{ _auth_zone.id }}"
rdata:
address: "10.0.0.0"
type: "A"
state: absent

- name: "Delete the Auth Zone"
ansible.builtin.include_role:
name: setup_auth_zone
tasks_from: cleanup.yml

- name: "Delete the Reverse Mapping Zone"
ansible.builtin.include_role:
name: setup_auth_zone_rmz
tasks_from: cleanup.yml

- name: "Delete the View"
ansible.builtin.include_role:
name: setup_view
tasks_from: cleanup.yml
2 changes: 2 additions & 0 deletions tests/integration/targets/dns_a_record_info/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
dependencies: [setup_auth_zone]
Loading
Loading