Skip to content

Commit

Permalink
Additional DNS Records Support for Bloxone Ansible v2 (infobloxopen#65)
Browse files Browse the repository at this point in the history
* Modules for DNS data

* DNS A Record Support for Bloxone Ansible

* deleted main.yml.bckp file

* Removed dns_record and dns_record_info, added dns_a_record and dns_a_record_info

* added A record changelog and setup_auth_zone_rmz; updated  dns_record, and dns_record_info modules

* Deleted unused file

* Restore setup_view file

* Restored setup_view

* Modified tasks in dns_a_record and dns_a_record_info

* Removed extra lines

* addressed review comments

Co-authored-by: Ujjwal Nasra <[email protected]>

* addressed review comments

* fixed indentation

* Modified find and update functions

* Removed HTML tags

* added cleanup.yml for setup_auth_zone_rmz

* Removed setup_view directory from PR

* Addressed PR comments

* addressed PR comments

* Addressed PR comments

* Fixed Documentation

* addressed PR comments

* Addressed PR Comments

* Initial commit for DNS resource records

* Examples included in modules

* included setup file for IPv6 rmz

* fixed lint issues

* added deprecation notice

* addresses review comments

* minor changes

* switch from Bloxone-Python-Client to Universal-Python-Client

* addressed review comments

* addressed review comments

---------

Co-authored-by: Ujjwal Nasra <[email protected]>
Co-authored-by: Ashish Mathew <[email protected]>
  • Loading branch information
3 people authored Feb 3, 2025
1 parent e18ca69 commit a6ebe65
Show file tree
Hide file tree
Showing 56 changed files with 4,947 additions and 47 deletions.
36 changes: 36 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,39 @@ plugin_routing:
deprecation:
removal_version: 3.0.0
warning_text: Use infoblox.bloxone.ipam_address_info instead.

b1_a_record:
deprecation:
removal_version: 3.0.0
warning_text: Use infoblox.bloxone.dns_record instead.
b1_a_record_gather:
deprecation:
removal_version: 3.0.0
warning_text: Use infoblox.bloxone.dns_record_info instead.

b1_cname_record:
deprecation:
removal_version: 3.0.0
warning_text: Use infoblox.bloxone.dns_record instead.
b1_cname_record_gather:
deprecation:
removal_version: 3.0.0
warning_text: Use infoblox.bloxone.dns_record_info instead.

b1_ns_record:
deprecation:
removal_version: 3.0.0
warning_text: Use infoblox.bloxone.dns_record instead.
b1_ns_record_gather:
deprecation:
removal_version: 3.0.0
warning_text: Use infoblox.bloxone.dns_record_info instead.

b1_ptr_record:
deprecation:
removal_version: 3.0.0
warning_text: Use infoblox.bloxone.dns_record instead.
b1_ptr_record_gather:
deprecation:
removal_version: 3.0.0
warning_text: Use infoblox.bloxone.dns_record_info instead.
132 changes: 121 additions & 11 deletions plugins/modules/dns_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,45 +325,155 @@
state: present
register: _view
- name: Create an Auth Zone (required as parent)
- name: Create an Auth Zone in the View (required as parent)
infoblox.bloxone.dns_auth_zone:
fqdn: "example_zone"
primary_type: "cloud"
view: "{{ _view.id }}"
state: "present"
register: _auth_zone
- name: Create an A Record in an Auth Zone
- name: Create an A Record in the Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
comment: "Example A Record"
rdata:
address: "192.168.10.10"
type: "A"
state: "present"
- name: Create an A Record with Name in Zone and Zone
state: "present"
- name: Create an A Record with Additional Fields
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
name_in_zone: "example_a_record"
comment: "Example A Record"
ttl: 3600
disabled: true
rdata:
address: "192.168.10.10"
type: "A"
comment: "This is an example A Record"
ttl: 3600
disabled: true
inheritance_sources:
ttl:
action: "inherit"
tags:
location: "site-1"
state: "present"
- name: Create an AAAA Record in an Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
type: "AAAA"
state: "present"
- name: Create a CAA Record in an Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
tag: "issue"
value: "ca.example.com"
type: "CAA"
state: "present"
- name: Create a CNAME Record in an Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
name_in_zone: "example_cname_record"
rdata:
cname: "example.com"
type: "CNAME"
state: "present"
- name: Create a DNAME Record in an Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
target: "google.com."
type: "DNAME"
state: "present"
- name: Create a Generic Record in an Auth Zone (e.g, TYPE256)
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
subfields:
- type: "PRESENTATION"
value: "10 1 \"https://example.com\""
type: "TYPE256"
state: "present"
- name: Create a MX Record in an Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
preference: 10
exchange: "mail.example.com."
type: "MX"
state: "present"
- name: Create a NAPTR Record in an Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
order: 100
preference: 10
replacement: "."
services: "SIP+D2U"
type: "NAPTR"
state: "present"
- name: Create a NS Record in an Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
name_in_zone: "example_ns_record"
rdata:
dname: "ns.example.com."
type: "NS"
state: "present"
- name: Create a PTR Record in an Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ rmz.id }}"
name_in_zone: "1.0.0" # Note: 10.in-addr.arpa is the reverse mapping zone
rdata:
dname: "ptr.example.com."
type: "PTR"
state: "present"
- name: Create a SRV Record in an Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
priority: 10
port: 5060
target: "srv.example.com."
type: "SRV"
state: "present"
- name: Create a SVCB Record in an Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
target_name: "svc.example.com."
type: "SVCB"
state: "present"
- name: Create a TXT Record in an Auth Zone
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
text: "sample text"
type: "TXT"
state: "present"
- name: Delete the A Record
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
name_in_zone: "example_a_record"
rdata:
address: "192.168.10.10"
address: "192.168.10.10"
type: "A"
state: "absent"
state: "absent"
""" # noqa: E501

RETURN = r"""
Expand Down
29 changes: 10 additions & 19 deletions plugins/modules/dns_record_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,25 @@
""" # noqa: E501

EXAMPLES = r"""
- name: Get A Record information by ID
infoblox.bloxone.a_record_info:
- name: Get Record information by ID
infoblox.bloxone.dns_record_info:
id: "{{ a_record_id }}"
- name: Get A Record information by filters (e.g., name_in_zone)
infoblox.bloxone.a_record_info:
- name: Get Record information by filters
infoblox.bloxone.dns_record_info:
filters:
name_in_zone: "example_a_record"
type: "A"
- name: Get A Record information by raw filter query
infoblox.bloxone.a_record_info:
filter_query: "name_in_zone=='example_a_record' and type=='A'"
- name: Get A Record information by filters (zone)
infoblox.bloxone.a_record_info:
filters:
zone: "example_zone_id"
type: "A"
- name: Get A Record information by raw filter query
infoblox.bloxone.a_record_info:
filter_query: "zone=='example_zone_id' and type=='A'"
- name: Get Record information by raw filter query
infoblox.bloxone.dns_record_info:
filter_query: "name_in_zone=='example_a_record' and zone=='example_zone_id' and type=='A'"
- name: Get A Record information by tag filters
infoblox.bloxone.a_record_info:
- name: Get Record information by tag filters
infoblox.bloxone.dns_record_info:
tag_filters:
location: "site-1"
location: "site-1"
""" # noqa: E501

RETURN = r"""
Expand Down
63 changes: 61 additions & 2 deletions tests/integration/targets/dns_a_record/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@
- 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
- name: Create an A Record with Options (create_ptr and check_rmz are true)
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "40.0.0.0"
address: "40.0.0.1"
type: "A"
options:
create_ptr: true
Expand Down Expand Up @@ -271,6 +271,65 @@
- ptr_record_info is not failed
- ptr_record_info.objects | length == 1
- ptr_record_info.objects[0].zone == rmz.id
- ptr_record_info.objects[0].name_in_zone == "1"

- name: Create an A Record with Options (create_ptr is true and check_rmz is false)
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "40.0.0.2"
type: "A"
options:
create_ptr: true
check_rmz: false
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
- name: Get Information about the PTR Record created in the Reverse Mapping Zone
infoblox.bloxone.dns_record_info:
filters:
zone: "{{ rmz.id }}"
type: "PTR"
register: ptr_record_info
- assert:
that:
- ptr_record_info is not failed
- ptr_record_info.objects | length == 1
- ptr_record_info.objects[0].zone == rmz.id
- ptr_record_info.objects[0].name_in_zone == "2"

- name: Create an A Record with Options (create_ptr and check_rmz are false)
infoblox.bloxone.dns_record:
zone: "{{ _auth_zone.id }}"
rdata:
address: "50.0.0.0"
type: "A"
options:
create_ptr: false
check_rmz: false
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

- name: Create an A Record with Name in Zone and Zone
infoblox.bloxone.dns_record:
Expand Down
21 changes: 6 additions & 15 deletions tests/integration/targets/dns_a_record_info/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
group/infoblox.bloxone.all:
portal_url: "{{ portal_url }}"
portal_key: "{{ portal_key }}"

block:
# Create a random A record name to avoid conflicts
- ansible.builtin.set_fact:
Expand All @@ -22,28 +23,18 @@
state: present
register: a_record

- name: Get A Record information by filters (name_in_zone)
- name: Get A Record information by ID
infoblox.bloxone.dns_record_info:
filters:
name_in_zone: "{{ record_name }}"
type: "A"
id: "{{ a_record.id }}"
register: a_record_info
- assert:
that:
- a_record_info.objects | length == 1
- a_record_info.objects[0].id == a_record.id

- name: Get A Record information by raw filter query
infoblox.bloxone.dns_record_info:
filter_query: "name_in_zone=='{{ record_name }}' and type=='A'"
- assert:
that:
- a_record_info.objects | length == 1
- a_record_info.objects[0].id == a_record.id

- name: Get A Record information by filters (zone)
- name: Get A Record information by filters
infoblox.bloxone.dns_record_info:
filters:
name_in_zone: "{{ record_name }}"
zone: "{{ _auth_zone.id }}"
type: "A"
register: a_record_info
Expand All @@ -54,7 +45,7 @@

- name: Get A Record information by raw filter query
infoblox.bloxone.dns_record_info:
filter_query: "zone=='{{ _auth_zone.id }}' and type=='A'"
filter_query: "name_in_zone=='{{ record_name }}' and zone=='{{ _auth_zone.id }}' and type=='A'"
register: a_record_info
- assert:
that:
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/targets/dns_aaaa_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_ipv6]
Loading

0 comments on commit a6ebe65

Please sign in to comment.